Saturday, May 23, 2009

JetBrains ReSharper 4.5

JetBrains is providing the “best” productivity add-on around. Visual Studio is simply not the same without R#. There is a small penalty in performance of-course but it’s absolutely worth it. Bare in mind that the solution wide analysis feature should not be turned on all the time for large solutions (50+ projects) because it slows down studio a lot.

The is a 30 day fully functional trial available: http://www.jetbrains.com/resharper/download/index.html

Features: http://www.jetbrains.com/resharper/features/

Code Analysis
On-the-fly Error Detection
Multilevel Code Inspection
Quick-Fixes
Navigating Between Code Highlights
Solution-Wide Error Analysis
Value Analysis
Annotated Framework
Navigation & Search
Navigate from Here
'Go to' Features
Usage Search
CamelHumps
Type Hierarchy
File Structure
Find Referenced/Dependent Code
Collapse All in Solution Explorer
Locate in Solution Explorer
View Recent Items
Stack Trace Explorer
To-do Explorer
Refactorings
Using Code Refactorings
Change Signature
'Convert' Refactorings
Copy Type
Encapsulate Field
'Extract' Refactorings
'Inline' Refactorings
'Introduce' Refactorings
Make Method Static/Non-Static
'Move' Refactorings
Pull/Push Members Up/Down
Rename
Replace Constructor with Factory Method
Safe Delete
Use Base Type where Possible
Code Generation
Create from Usage
Generate Type Members
Implement/Override Methods
Configure Generation Options
Coding Assistance
Syntax Highlighting
Context Actions
Code Completion
Complete Statement
Extended Naming Style Configuration
Parameter Info
Highlight Matching Delimiters
Importing Namespaces
Auto-insertion of Delimiters
Code Reordering
Quick Documentation
Comment/Uncomment Code
Highlight Current Line
Extend/Shrink Selection
Duplicate Line or Selection
Multiple Entries Clipboard
Code Cleanup
Using Code Cleanup
Code Formatting
Optimizing Namespace Import Directives
Removing Code Redundancies
Migrating to C# 3.0
Reordering Type Members
Code Style Configuration and Sharing
Code Templates
Live Templates, Surround Templates, File Templates
Customizing, Configuring and Sharing Templates
Unit Testing
Running and Debugging Tests
Unit Test Explorer
Unit Test Sessions
Profiling Unit Tests with dotTrace Profiler
Cross-Language Functionality
Build Scripts

Visual Studio 2010 Beta 1 (MSDN Subscriptions)

Visual Studio 2010 Professional Beta 1 (x86) - DVD (English)
Includes: Professional; 05-18-2009
File Name: en_visual_studio_2010_professional_edition_beta_1_x86_dvd.iso
Date Posted (UTC): 5/18/2009 10:03:17 AM
SHA1: A89E7C40FEA61F5371F6C80571870FC2EC43CBDB
ISO/CRC: 01AAB7A1
Available to Levels: MSDN OS (VL); VS Pro with MSDN Pro (VL); VS Pro with MSDN Premium (Empower); MSDN OS (Retail); Developer AA; VS Pro with MSDN Pro (Retail); MSDN Enterprise; MSDN Universal (Retail); VSTS Team Suite (VL); VSTS Architecture (VL); VSTS Development (VL); VSTS Test (VL); VS Pro with MSDN Premium (VL); MSDN Universal (VL); VSTS Database (VL); VS Pro with MSDN Premium (Retail); VSTS Test (Retail); VSTS Development (Retail); VSTS Architecture (Retail); VSTS Team Suite (Retail); VSTS Database (Retail); BizSpark Admin; BizSpark;

Visual Studio Team Foundation Server 2010 Beta 1 (x86 and x64) - DVD (English)
Includes: Team Foundation Server; 05-18-2009
File Name: en_visual_studio_team_foundation_server_2010_beta_1_x86_x64_dvd.iso
Date Posted (UTC): 5/18/2009 10:02:33 AM
SHA1: 9BFD2776D031508D136FE8E5872915D289EFC239
ISO/CRC: 27D0FE12
Available to Levels: MSDN OS (VL); VS Pro with MSDN Pro (VL); VS Pro with MSDN Premium (Empower); MSDN OS (Retail); Developer AA; VS Pro with MSDN Pro (Retail); MSDN Enterprise; MSDN Universal (Retail); VSTS Team Suite (VL); VSTS Architecture (VL); VSTS Development (VL); VSTS Test (VL); VS Pro with MSDN Premium (VL); MSDN Universal (VL); VSTS Database (VL); VS Pro with MSDN Premium (Retail); VSTS Test (Retail); VSTS Development (Retail); VSTS Architecture (Retail); VSTS Team Suite (Retail); VSTS Database (Retail); BizSpark Admin; BizSpark;

Visual Studio Team System 2010 Team Suite Beta 1 (x86) - DVD (English)
Includes: Team System; 05-18-2009
File Name: en_visual_studio_team_system_2010_team_suite_beta_1_x86_dvd.iso
Date Posted (UTC): 5/18/2009 10:02:03 AM
SHA1: 01A3E649F86EE726E6422F0CC53E96BE27FB9CA3
ISO/CRC: CBD6B829
Available to Levels: MSDN OS (VL); VS Pro with MSDN Pro (VL); VS Pro with MSDN Premium (Empower); MSDN OS (Retail); Developer AA; VS Pro with MSDN Pro (Retail); MSDN Enterprise; MSDN Universal (Retail); VSTS Team Suite (VL); VSTS Architecture (VL); VSTS Development (VL); VSTS Test (VL); VS Pro with MSDN Premium (VL); MSDN Universal (VL); VSTS Database (VL); VS Pro with MSDN Premium (Retail); VSTS Test (Retail); VSTS Development (Retail); VSTS Architecture (Retail); VSTS Team Suite (Retail); VSTS Database (Retail); BizSpark Admin; BizSpark;

Friday, May 22, 2009

ASP.NET Portal Starter Kit

The ASP.NET Portal Starter Kit demonstrates how you can use ASP.NET and the .NET Framework to build a dynamic portal application. The ASP.NET Portal Starter Kit offers all the functionality of typical portal applications.
It's developed in c# 3.0 \ .NET 3.5.
Portal_Big.bmp Logoneg.gif
http://www.codeplex.com/ASPNETPortal

Project Scope

Re-engineering the original project using up-to-date technologies

Features

  • Dynamic Portal Infrastructure
  • 10 basic portal modules for common types of content
  • 2 extra portal modules: RSS Feed and Wiki (postponed)
  • A "pluggable" framework that is simple to extend with custom portal modules
  • Online administration of portal layout, content and security
  • XML based definition of portal layout
  • Database based definition of portal layout new.jpg
  • Roles-based security for viewing content, editing content, and administering the portal
  • Full mobile support using the ASP.NET Mobile Controls
  • Multiple database support easily extensible to support more databases new.jpg
  • Web service layer ASMX and WCF new.jpg
  • Smart Client to support Admins and power users new.jpg

Technologies and Design Approaches Demonstrated

  • .NET 2.0 \ .NET 3.5 new.jpg
  • Web Client Software Factory new.jpg
  • Object Builder new.jpg
  • Smart Client Software Factory new.jpg
  • ASP.NET Mobile Controls
  • Three-tier architecture with ASP.NET
  • Role Based Security
  • Layered architecture new.jpg
    • Vertical: Data\Business\Presentation
    • Horizontal: Services, Framework
  • Design Patterns new.jpg
  • NUnit Tests new.jpg
  • Master Pages, SiteMaps & Themes new.jpg

Thursday, May 21, 2009

Design Pattern: Factory Method

The factory method pattern deals with the problem of creating objects without specifying the exact class of object that will be created. The factory method design pattern handles this problem by defining a separate method for creating the objects, whose subclasses can then override to specify the derived type of object that will be created.
More generally, the term factory method is often used to refer to any method whose main purpose is creation of objects.

This sample requires the following to be installed: Visual Studio 2008. You can checkout a read-only copy of this sample using tortoise from:
http://bakopanos.googlecode.com/svn/trunk/designpatterns/GangOfFour.FactoryMethod

A very simple example: we’ll create a DataFactory class that will be able to map a IDataReader to an Object. The DataFactory is abstract since the subclasses will override the Map method implementation.   
    

public abstract class DataFactory<T>
where T : class, new()
{
public abstract List<T> List();

protected List<T> List(string cmd)
{
var items = new List<T>();

using (var conn = new SqlCeConnection(@"Data Source=Database1.sdf"))
{
conn.Open();
using (var command = new SqlCeCommand(cmd, conn))
{
var reader=command.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
items.Add(Map(reader));
}
}
}
return items;
}

public abstract T Map(IDataRecord reader);
}


We need to map the database Table Titles to the object Title.



 
public classTitle
{
    public int Id { get; set; }
    public stringName { get; set; }
}
The TitleDataFactory class subclasses the DataFactory and overrides the Map method.


public class TitleDataFactory : DataFactory<Title>
{
public override List<Title> List()
{
return List("select * from titles");
}

public override Title Map(IDataRecord reader)
{
int id = (int) reader["id"];
string name = reader["name"] as string;
var item = new Title {Id = id, Name = name};

return item;
}
}



Although the sample is far from a proper ORM implementation it demonstrates well the Factory Method design pattern. 
If you are looking for your next ORM tool then this is the wrong place, consider:
EntLib, Spring, ActiveRecord, NHibernate
LinqToSql, EntityFramework, DataSet
any of the many commercial frameworks such as IdeaBlade, DevExpress XPO and so on…
Some sample client code to demonstrate how to use the DataFactory


/// <summary>
///
Entry point into console application.
/// </summary>
static void Main()
{
List<Title> list = new TitleDataFactory().List();

foreach (var title in list)
{
Console.WriteLine(title.Name);
}

// Wait for user
Console.ReadKey();
}

Wednesday, May 20, 2009

C# Generics and Extension methods to build a simple iterator

In this example we focus on the type safe collection classes and show how to build a simple iterator.

This sample requires the following to be installed: Visual Studio 2008. You can checkout a read-only copy of this sample using tortoise from:
http://bakopanos.googlecode.com/svn/trunk/csharpsamples/GenericSamples/ForEachIteratoren
using System;

namespace ForEachIterators
{
interface IAction
{
void Action();
}

static class Program
{
public static void ForEachI<T>(this T[] array) where T : IAction
{
foreach (T elem in array)
{
elem.Action();
}
}

public class MyString : IAction
{
readonly string _s;
public MyString(string s) { _s = s; }

public void Action()
{
Console.WriteLine("I'm a string with {0}", _s);
}
}

public delegate void Action<T>(T obj);

public static void ForEach<T>(this T[] array, Action<T> action)
{
if (action != null)
foreach (T elem in array)
{
action(elem);
}
}
//leave private
static void StringAction(this string s)
{
Console.WriteLine("a String {0}", s);
}
//leave private
static void IntAction(this int i)
{
Console.WriteLine("an Integer {0}", i);
}

static void Main()
{
var arr0 = new MyString[2];
arr0[0] = new MyString("Hallo");
arr0[1] = new MyString("value");
arr0.ForEachI();

var arr1 = new [] { "Hello", "World" };
arr1.ForEach(StringAction);
var arr2 = new [] { 2, 6, 3, 9 };
arr2.ForEach(IntAction);
arr2.ForEach(IntAction); //Delegate inference
arr2.ForEach(i => Console.WriteLine("lambda: {0}", i));

Console.ReadLine();
}
}
}

C# Generics Sample

Generics provide the tool to create flexible reusable code by allowing classes, structures, interfaces, methods and delegates to be declared as a generic type instead of an actual type; the actual type is specified later. The System.Collections.Generic namespace provides generic collection classes that make creating type safe collections very easy.

In this example we focus on the type safe collection classes and show how their type safety works and what the speed benefit is of using a generic collection over a standard collection.

This sample requires the following to be installed: Visual Studio 2008. You can checkout a read-only copy of this sample using tortoise from:
http://bakopanos.googlecode.com/svn/trunk/csharpsamples/GenericSamples/ComparableConstraint

using System;
using System.Collections.Generic;

namespace ComparableConstraint
{
interface IPriorityQueue<TE, TP> where TP : IComparable<TP>
{
//
void Put(TE element, TP priority);
//
TE Get();
//
int Count { get;}
}

class PriorityQueue<TE, TP> : IPriorityQueue<TE, TP>
where TP : IComparable<TP>
{
struct KeyValuePair<TK, TV>
{
public readonly TK Key;
public readonly TV Value;

public KeyValuePair(TK key, TV value)
{
Key = key;
Value = value;
}
}

readonly List<KeyValuePair<TP, TE>> _list = new List<KeyValuePair<TP, TE>>();

public void Put(TE element, TP priority) {
_list.Add(new KeyValuePair<TP,TE>(priority, element));
}

public TE Get()
{
int maxInd = 0;
for (int i = 0; i < _list.Count; i++)
{
if (_list[i].Key.CompareTo(_list[maxInd].Key) > 0)
maxInd = i;
}
TE val = _list[maxInd].Value;
_list.RemoveAt(maxInd);
return val ;
}

public int Count { get { return _list.Count; }}
}

class Program
{
static void Main()
{
IPriorityQueue<String, int> pq1 = new PriorityQueue<String, int>(); //ok
pq1.Put("String 1 mit Prio 7", 7);
pq1.Put("String 2 mit Prio 4", 4);
pq1.Put("String 3 mit Prio 1", 1);
pq1.Put("String 4 mit Prio 5", 5);

while (pq1.Count > 0)
{
string s = pq1.Get();
Console.WriteLine(s);
}
Console.ReadLine();
}
}
}

Monday, October 13, 2008

MSBuild Community Tasks Project

http://msbuildtasks.tigris.org/ an open source project providing MSBuild tasks for almost any tool you need to integrate.

Current Community Tasks

Add Add numbers
AddTnsName Defines a database host within the Oracle TNSNAMES.ORA file.
AppPoolController Allows control for an application pool on a local or remote machine with IIS installed. The default is to control the application pool on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.
AppPoolCreate Creates a new application pool on a local or remote machine with IIS installed. The default is to create the new application pool on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.
AppPoolDelete Deletes an existing application pool on a local or remote machine with IIS installed. The default is to delete an existing application pool on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.
AssemblyInfo Generates an AssemblyInfo files
Attrib Changes the attributes of files and/or directories
Beep A task to play the sound of a beep through the console speaker.
BuildAssembler BuildAssembler task for Sandcastle.
ChmBuilder ChmBuilder task for Sandcastle.
ChmCompiler Html Help 1x compiler task.
Computer Provides information about the build computer.
DBCSFix DBCSFix task for Sandcastle.
Divide Divide numbers
ExecuteDDL MSBuild task to execute DDL and SQL statements.
FileUpdate Replace text in file(s) using a Regular Expression.
FtpCreateRemoteDirectory Creates a full remote directory on the remote server if not exists using the File Transfer Protocol (FTP). This can be one directory or a full path to create.
FtpDirectoryExists Determ if a remote directory exists on a FTP server or not.
FtpUpload Uploads a group of files using File Transfer Protocol (FTP).
FtpUploadDirectoryContent Uploads a full directory content to a remote directory.
FxCop Uses FxCop to analyse managed code assemblies and reports on their design best-practice compliance.
GacUtil MSBuild task to install and uninstall asseblies into the GAC
GetSolutionProjects Retrieves the list of Projects contained within a Visual Studio Solution (.sln) file
HxCompiler A Html Help 2.0 compiler task.
ILMerge A wrapper for the ILMerge tool.
InstallAspNet Installs and register script mappings for ASP.NET
InstallAssembly Installs assemblies.
JSCompress Compresses JavaScript source by removing comments and unnecessary whitespace. It typically reduces the size of the script by half, resulting in faster downloads and code that is harder to read.
Mail Sends an email message
Merge Merge files into the destination file.
Modulo Performs the modulo operation on numbers.
Move Moves files on the filesystem to a new location.
MRefBuilder MRefBuilder task for Sandcastle.
Multiple Multiple numbers
NDoc Runs the NDoc application.
NUnit Run NUnit 2.4 on a group of assemblies.
Prompt Displays a message on the console and waits for user input.
RegexMatch Task to filter an Input list with a Regex expression. Output list contains items from Input list that matched given expression
RegexReplace Task to replace portions of strings within the Input list Output list contains all the elements of the Input list after performing the Regex Replace.
RegistryRead Reads a value from the Registry
RegistryWrite Writes a value to the Registry
RoboCopy Task wrapping the Window Resource Kit Robocopy.exe command.
Sandcastle The Sandcastle task.
Script Executes code contained within the task.
ServiceController Task that can control a Windows service.
ServiceQuery Task that can determine the status of a specified service on a target server.
Sleep A task for sleeping for a specified period of time.
Sound A task to play a sound from a .wav file path or URL.
SqlExecute Executes a SQL command.
SqlPubWiz The Database Publishing Wizard enables the deployment of SQL Server databases (both schema and data) into a shared hosting environment.
Subtract Subtract numbers
SvnCheckout Checkout a local working copy of a Subversion repository.
SvnClient Subversion client base class
SvnCommit Subversion Commit command
SvnCopy Copy a file or folder in Subversion
SvnExport Export a folder from a Subversion repository
SvnInfo Run the "svn info" command and parse the output
SvnUpdate Subversion Update command
SvnVersion Summarize the local revision(s) of a working copy.
TaskSchema A Task that generates a XSD schema of the tasks in an assembly.
TemplateFile MSBuild task that replaces tokens in a template file and writes out a new file.
TfsVersion Determines the changeset in a local Team Foundation Server workspace
Time Gets the current date and time.
UninstallAssembly Uninstalls assemblies.
Unzip Unzip a file to a target directory.
User Provides information about the build user.
Version Generates version information based on various algorithms
VssAdd Task that adds files to a Visual SourceSafe database.
VssCheckin Task that executes a checkin against a VSS Database.
VssCheckout Task that executes a checkout of files or projects against a Visual SourceSafe database.
VssClean Task that can strip the source control information from a Visual Studio Solution and subprojects.
VssDiff Task that records differences between the latest version of all the items in a Visual SourceSafe project and another version or label to a file.
VssGet Task that retireves an item or project from a Visual SourceSafe database.
VssHistory Generates an XML file containing details of all changes made to a Visual SourceSafe project or file between specified labels or dates.
VssLabel Task that applies a label to a Visual SourceSafe item.
VssUndoCheckout Task that undoes a checkout of files or projects against a Visual SourceSafe database.
WebDirectoryCreate Creates a new web directory on a local or remote machine with IIS installed. The default is to create the new web directory on the local machine. The physical path is required to already exist on the target machine. If connecting to a remote machine, you can specify the and for the task to run under.
WebDirectoryDelete Deletes a web directory on a local or remote machine with IIS installed. The default is to delete the web directory on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.
WebDirectoryScriptMap Sets an application mapping for a filename extension on an existing web directory.
WebDirectorySetting Reads and modifies a web directory configuration setting.
WebDownload Downloads a resource with the specified URI to a local file.
XmlMassUpdate Performs multiple updates on an XML file
XmlQuery Reads a value or values from lines of XML
XmlRead Reads a value from a XML document using a XPath.
XmlUpdate Updates a XML document using a XPath.
Xslt A task to merge and transform a set of xml files.
XslTransform XslTransform task for Sandcastle.
Zip Create a zip file with the files specified.

* Items not complete or have not been released.