<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fresh Click Media &#187; Visual Studio</title>
	<atom:link href="http://www.freshclickmedia.com/blog/category/visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.freshclickmedia.com</link>
	<description></description>
	<lastBuildDate>Mon, 23 Aug 2010 20:00:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Getting started with googletest &#8211; the Google C++ Testing Framework</title>
		<link>http://www.freshclickmedia.com/blog/2009/10/getting-started-with-googletest-the-google-c-testing-framework/</link>
		<comments>http://www.freshclickmedia.com/blog/2009/10/getting-started-with-googletest-the-google-c-testing-framework/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 18:54:30 +0000</pubDate>
		<dc:creator>Shane</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.freshclickmedia.com/?p=193</guid>
		<description><![CDATA[So, I've just recorded a second screencast at <a href="http://screenr.com">screenr</a>, this time about googletest - the Google C++ Testing Framework.  I had a couple of issues getting things up and running so I thought it might be beneficial to show I got going.

I've been more used to unit testing in a C# environment, particularly NUnit and MS Unit, so googletest was a fresh look at unit testing for C++.  Note that the screenr title is incorrect, it should read 'Getting started with googletest - the Google C<strong>++</strong> Testing Framework :)

<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_0817090731.swf' ></param><param name='flashvars' value='i=21294' ></param><param name='allowFullScreen' value='true' ></param><embed src='http://screenr.com/Content/assets/screenr_0817090731.swf' flashvars='i=21294' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer' ></embed></object>]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;ve just recorded a second screencast at <a href="http://screenr.com">screenr</a>, this time about googletest &#8211; the Google C++ Testing Framework.  I had a couple of issues getting things up and running so I thought it might be beneficial to show I got going.</p>
<p>I&#8217;ve been more used to unit testing in a C# environment, particularly NUnit and MS Unit, so googletest was a fresh look at unit testing for C++.  Note that the screenr title is incorrect, it should read &#8216;Getting started with googletest &#8211; the Google C<strong>++</strong> Testing Framework :)</p>
<p><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_0817090731.swf' ></param><param name='flashvars' value='i=21294' ></param><param name='allowFullScreen' value='true' ></param><embed src='http://screenr.com/Content/assets/screenr_0817090731.swf' flashvars='i=21294' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer' ></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.freshclickmedia.com/blog/2009/10/getting-started-with-googletest-the-google-c-testing-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>5 things you may not know about ASP.NET</title>
		<link>http://www.freshclickmedia.com/blog/2009/03/5-things-you-may-not-know-about-aspnet/</link>
		<comments>http://www.freshclickmedia.com/blog/2009/03/5-things-you-may-not-know-about-aspnet/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 12:17:55 +0000</pubDate>
		<dc:creator>Shane</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.freshclickmedia.com/?p=138</guid>
		<description><![CDATA[Since its release in early 2002, Microsoft's ASP.NET platform has gone from strength to strength.  Despite its strong uptake from Microsoft-centric software houses, there may be a few people who have hesitated in adopting ASP.NET for their web development platform.  Here I present some things you might not know about ASP.NET.  Perhaps it'll encourage you to take a look at it.

<h3>Cost</h3>
There once was a time when the standard IDE for developing ASP.NET apps, Visual Studio, was prohibitively expensive for the average Joe.  In late 2007, Microsoft released its first versions of 'Express' software, aimed at students and hobbyists.  Though Express incarnations have fewer features than their full version cousins, they do offer the possibility of exploring ASP.NET.  The Microsoft website offers a <a href="http://www.microsoft.com/express/vwd/">download page for Visual Web Developer 2008 Express Edition</a>. An express version of SQL Server is also available, and can be downloaded from the <a href="http://www.microsoft.com/express/sql/">SQL Server 2008 download page</a>.

<h3><abbr title="Model View Controller">MVC</abbr> Support</h3>
The MVC pattern is an established and well-recognised way of building web applications, and is familiar to <abbr title="Ruby on Rails">RoR</abbr>, Java and PHP developers.  For many years, MVC was not available as a standard approach to developing ASP.NET websites, but Microsoft has recognised the deficiency and have (at the time of writing) released version 1.0 Release Candidate of ASP.NET MVC.  The release has had a mixed response from the ASP.NET community, many of whom are used to the traditional code-behind model.  Despite the inevitable squabbles as to which way is best, many have welcomed the MVC approach for its separation of concerns and finer control over JavaScript and markup.  To find out more about the release candidate, head over to <a href="http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx">Scott Guthrie's blog post</a>.

<h3>Learning Resources</h3>  
A big advantage for anybody learning a new technology is the wealth of learning material that is available.  Although you can rely on a large number of books, the <a href="http://www.asp.net/learn">ASP.NET learn</a> website contains many videos on both traditional and MVC ASP.NET as well as data access.

<h3>Intrinsic jQuery Support</h3>
The lightweight open source JavaScript library that's taken the web by storm is now fully supported by Microsoft.  As well as <a href="http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx">full intellisense support in Visual Studio</a>, Microsoft will be using the library as-is, without forking or changing the code from the main jQuery branch.  What's more, Microsoft will be using jQuery as a basis for future ASP.NET and ASP.NET AJAX features.  I feel this counters the argument of Microsoft not supporting open-source software.

<h3>Career Prospects</h3>
Microsoft's ubiquity means that learning ASP.NET and supporting technologies will do no harm to your career prospects.  <a href="http://www.cwjobs.co.uk/Content/PermanentDeveloperDemand.html">.NET skills are ranked as some of the most in-demand in the UK</a>.  ]]></description>
			<content:encoded><![CDATA[<p>Since its release in early 2002, Microsoft&#8217;s ASP.NET platform has gone from strength to strength.  Despite its strong uptake from Microsoft-centric software houses, there may be a few people who have hesitated in adopting ASP.NET for their web development platform.  Here I present some things you might not know about ASP.NET.  Perhaps it&#8217;ll encourage you to take a look at it.</p>
<h3>Cost</h3>
<p>There once was a time when the standard IDE for developing ASP.NET apps, Visual Studio, was prohibitively expensive for the average Joe.  In late 2007, Microsoft released its first versions of &#8216;Express&#8217; software, aimed at students and hobbyists.  Though Express incarnations have fewer features than their full version cousins, they do offer the possibility of exploring ASP.NET.  The Microsoft website offers a <a href="http://www.microsoft.com/express/vwd/">download page for Visual Web Developer 2008 Express Edition</a>. An express version of SQL Server is also available, and can be downloaded from the <a href="http://www.microsoft.com/express/sql/">SQL Server 2008 download page</a>.</p>
<h3><abbr title="Model View Controller">MVC</abbr> Support</h3>
<p>The MVC pattern is an established and well-recognised way of building web applications, and is familiar to <abbr title="Ruby on Rails">RoR</abbr>, Java and PHP developers.  For many years, MVC was not available as a standard approach to developing ASP.NET websites, but Microsoft has recognised the deficiency and have (at the time of writing) released version 1.0 Release Candidate of ASP.NET MVC.  The release has had a mixed response from the ASP.NET community, many of whom are used to the traditional code-behind model.  Despite the inevitable squabbles as to which way is best, many have welcomed the MVC approach for its separation of concerns and finer control over JavaScript and markup.  To find out more about the release candidate, head over to <a href="http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx">Scott Guthrie&#8217;s blog post</a>.</p>
<h3>Learning Resources</h3>
<p>A big advantage for anybody learning a new technology is the wealth of learning material that is available.  Although you can rely on a large number of books, the <a href="http://www.asp.net/learn">ASP.NET learn</a> website contains many videos on both traditional and MVC ASP.NET as well as data access.</p>
<h3>Intrinsic jQuery Support</h3>
<p>The lightweight open source JavaScript library that&#8217;s taken the web by storm is now fully supported by Microsoft.  As well as <a href="http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx">full intellisense support in Visual Studio</a>, Microsoft will be using the library as-is, without forking or changing the code from the main jQuery branch.  What&#8217;s more, Microsoft will be using jQuery as a basis for future ASP.NET and ASP.NET AJAX features.  I feel this counters the argument of Microsoft not supporting open-source software.</p>
<h3>Career Prospects</h3>
<p>Microsoft&#8217;s ubiquity means that learning ASP.NET and supporting technologies will do no harm to your career prospects.  <a href="http://www.cwjobs.co.uk/Content/PermanentDeveloperDemand.html">.NET skills are ranked as some of the most in-demand in the UK</a>.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.freshclickmedia.com/blog/2009/03/5-things-you-may-not-know-about-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>October web round-up</title>
		<link>http://www.freshclickmedia.com/blog/2008/10/october-web-round-up/</link>
		<comments>http://www.freshclickmedia.com/blog/2008/10/october-web-round-up/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 21:26:24 +0000</pubDate>
		<dc:creator>Shane</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.freshclickmedia.com/?p=98</guid>
		<description><![CDATA[<img src="http://farm4.static.flickr.com/3277/2989416849_fe142a6703_o.jpg" alt="October Web Roundup" />

It's been a busy old month, and with so much time working, I'm going to share some of the things that have interested me during October.]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm4.static.flickr.com/3171/2989434207_fd9a08c265_o.jpg" alt="October Web Roundup" /></p>
<p>It&#8217;s been a busy old month, and with so much time working, I&#8217;m going to share some of the things that have interested me during October.</p>
<h3>Windows 7 Desktop Improvements</h3>
<p>With hardware compatability issues and a reluctance from users and computer manufacturers to adopt it, Vista hasn&#8217;t perhaps been the success that Microsoft had hoped.  <a href="http://channel9.msdn.com/pdc2008/PC24/">The next version of Windows gets a preview over at channel9</a>.  There&#8217;s quite a lot of verbal fluff at the beginning, but forward through and you&#8217;ll get an idea of some of the features that&#8217;ll be present in the next version.  </p>
<h3>ASP.NET MVC Beta</h3>
<p>Many of the great frameworks, such as CodeIgniter and Ruby on Rails use a MVC architecture, and it&#8217;s a concept that many web developers are familiar with.  Maybe not so developers who have exclusively used ASP.NET for their development.  Since the introduction of <a href="http://www.microsoft.com/express/webdevelopment/Default.aspx">Visual Web Developer Express</a>, developing has become very attractive for hobby developers wishing to get to grips with ASP.NET.  I think the development of ASP.NET MVC will encourage those familiar with the pattern to give it a go.  <a href="http://weblogs.asp.net/scottgu/archive/2008/10/16/asp-net-mvc-beta-released.aspx">Scott Guthrie describes the beta release on his blog</a>.</p>
<h3>Microsoft to ship jQuery with future versions of Visual Studio</h3>
<p>I&#8217;ve been using jQuery alongside ASP.NET for several months now, and find it to be an excellent JavaScript library.  I was quite shocked that Microsoft will be <a href="http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx">distributing it with future versions</a> of Visual Studio (including express versions), providing support for it, and providing intellisense support for it.  Good on &#8216;em!</p>
<h3>Google releases Google Earth for iPhone/iPod Touch</h3>
<p>I&#8217;d definitely recommend a download of free app Google Earth &#8211; well worth taking a look.  </p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/v6BPuKaLel4"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/v6BPuKaLel4" type="application/x-shockwave-flash" wmode="transparent" width="425" height="344"></embed></object></p>
<p>For more information, head over to the <a href="http://www.google.com/mobile/apple/earth.html">Google Earth on the iPhone</a> page.</p>
<h3>Google Android Phone</h3>
<p>Following the launch of <a href="http://www.freshclickmedia.com/blog/2008/09/google-chrome-a-first-impression-or-two/">Chrome</a> , Google is pressing ahead with Mobile Device Platform <a href="http://www.android.com/">Android</a>.  Now the first handset, the <a href="http://www.google.co.uk/mobile/android/hpp.html">T-Mobile G1</a> has hit the market.  It&#8217;s certainly no looker, but Google is a company that has the expertise to change the mobile market, and I&#8217;ll be keeping an eye on things, that&#8217;s for sure.  For now though, I&#8217;ll keep my iPhone.</p>
<h3>No opera for iPhone</h3>
<p>Well well, a version of Opera has been developed for the iPhone, but Apple has refused to add it to their App Store, stating that it is too similar to Safari.  So, I won&#8217;t be holding my breath for a version of Firefox, either.  <a href="http://daringfireball.net/linked/2008/10/30/opera-iphone">John Gruber offers his opinion over at Daring Fireball</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freshclickmedia.com/blog/2008/10/october-web-round-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A quick tour of C# 3.0&#8242;s new language features</title>
		<link>http://www.freshclickmedia.com/blog/2007/12/a-quick-tour-of-c-30s-new-language-features/</link>
		<comments>http://www.freshclickmedia.com/blog/2007/12/a-quick-tour-of-c-30s-new-language-features/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 13:37:41 +0000</pubDate>
		<dc:creator>Shane</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.freshclickmedia.com/blog/2007/12/a-quick-tour-of-c-30s-new-language-features/</guid>
		<description><![CDATA[With Visual Studio 2008 now fully released, I take a quick look at some of the new language features in C# 3.0. I&#8217;ll start the overview with the introduction of two classes, Person, and MyExtensions. public partial class Person { public Person() { LogCreation(); } // automatic properties: public int Age { get; set; } [...]]]></description>
			<content:encoded><![CDATA[<p>With Visual Studio 2008 now <a href="http://weblogs.asp.net/scottgu/archive/2007/11/19/visual-studio-2008-and-net-3-5-released.aspx">fully released</a>, I take a quick look at some of the new language features in C# 3.0.</p>
<p><span id="more-73"></span><br />
I&#8217;ll start the overview with the introduction of two classes, Person, and MyExtensions.</p>
<pre class="code">
    public partial class Person
    {
        public Person()
        {
            LogCreation();
        }

        // automatic properties:
        public int Age { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public short NumberOfChildren { get; set; }

        // partial method:
        partial void LogCreation();
    }

    // this could (and probably would) be in a different file:
    public partial class Person
    {
        // partial method implementation:
        partial void LogCreation()
        {
            Console.WriteLine("Person created");
        }
    }
</pre>
<p>The Person class introduces two new language features.</p>
<h3>Partial Methods</h3>
<p>The LogCreation method in the Person class has been decorated with the &#8216;partial&#8217; keyword, meaning that it is a &#8216;partial method&#8217;.  </p>
<p>Partial methods add a lightweight event handling mechanism to C#.  They&#8217;re basically methods where the declaration or prototype is specified in the declaration of a partial class, but the implementation can only be provided in another declaration for that partial class.  In other words, a partial method will only compile if it is specified in one partial class definition and is the implementation is provided in another partial class definition, as shown above.</p>
<p>The &#8216;clever&#8217; thing is that because no definition for the method is provided, no IL code is produced for that method, so the resulting assembly is no bigger or slower than if the partial method wasn&#8217;t there in the first place.  This then begs the question &#8211; if an implementation isn&#8217;t provided, why have the prototype at all?  Well, you could set up some &#8216;hooks&#8217; into your code for specific methods, that may or may not be implemented by a developer.</p>
<p>The Person class invokes the partial method LogCreation, and because an implementation is provided, the code is executed.  If the second partial class definition didn&#8217;t exist, or the method wasn&#8217;t implemented, the code would not be executed.  In practice, they are used by some new LINQ (more on that shortly) SQL entity classes as a hook for property value change notification.  A partial method is called before a property value changes, and a partial method is called after the property value has changed.  If you wish to hook into these, you can implement the methods in your partial class and be notified.  If not, the partial methods are &#8216;removed&#8217; from the assembly&#8217;s output.  </p>
<p>Syntactically, there are a few rules for partial methods:</p>
<ol>
<li>Can only be defined and implemented in partial classes</li>
<li>Must specify the partial modifer</li>
<li>Must not specify an access modifier, but are private.  If an access modifier (even if it&#8217;s private) is specified, you&#8217;ll get a compiler error</li>
<li>They must return void</li>
</ol>
<p>A little less strict in some other areas:</p>
<ol>
<li>They can have arguments</li>
<li>The don&#8217;t have to be implemented</li>
<li>They can be static</li>
</ol>
<p>The second class, MyExtensions, is shown below:</p>
<pre class="code">
    public static class MyExtensions
    {
        // extension method
        public static bool IsEven(this int number)
        {
            return number % 2 == 0;
        }
    }
</pre>
<p>The MyExtensions class shown above may look familiar at first glance, but the this keyword in the method arguments makes it stand out as an extension method.</p>
<h3>Extension Methods</h3>
<p>Basically, extension methods are a way of &#8216;extending&#8217; a .NET type with a method so that it may be called on an instance of that method.</p>
<p>The example shown illustrates the rules that an extension method must be defined as static, in a static class, and contain the this keyword in the method arguments list.  The type of argument is the .NET type that is being extended.</p>
<p>The nice thing is that when you have an extension method, you can do something like this:</p>
<p><img src="http://farm3.static.flickr.com/2286/2088223227_ab2e224bb1_o.png" alt="Extension methods in the Visual Studio 2008 IDE" /></p>
<p>Our example extends int, and the Visual Studio 2008 IDE indicates our extension method with a little icon and associated text.  Perhaps I need to get out a little more, but I find extension methods quite exciting.</p>
<h3>Collection and Object initialization</h3>
<pre class="code">
// collection initializer:
List<Person> people = new List< Person>
{
    // object initializer:
    new Person { Age = 6, FirstName = "Andy", LastName = "Andrews", NumberOfChildren = 0 },
    new Person { Age = 46, FirstName = "Bob", LastName = "Bobbins", NumberOfChildren = 3 },
    new Person { Age = 19, FirstName = "Charlie", LastName = "Charles", NumberOfChildren = 0 }
};
</pre>
<p>Collection initialization is a shorter way of creating a collection and initialising it.  Whereas before, the list would have to be created, and each item added separately, the whole thing can be done in one swoop.</p>
<p>Object initialization is very similar, and makes it easier to create an object and set property values at the same time.</p>
<h3>Lambda Expressions</h3>
<p>For the three Person instances added to the list, you could specify an anonymous method in C# 2.0 to extract items (in our case items of type Person) from the list based on a set of &#8216;matching criteria&#8217;:</p>
<pre class="code">
List< Person> children = people.FindAll( delegate( Person p) { return p.Age < 18; } );
</pre>
<p>This is all well and good, but the problem with anonymous methods is that they're a little bit, well, clunky.  </p>
<p>With lambda expressions, we can rewrite the above 'query' as follows:</p>
<pre class="code">
    IEnumerable&lt;Person&gt; children =
                people.Select(p =&gt; p).Where(p =&gt; p.Age &lt; 18);
</pre>
<p>Basically, we're referring to an item in the list as 'p', selecting 'p', and filtering using the Where method where the Age of the item is less than 18.  At first, I found them a little strange syntactically, but I've got used to them now, and don't typically use the old style anonymous methods.</p>
<h3>LINQ, var and anonymous type projection</h3>
<p><a href="http://msdn2.microsoft.com/netframework/aa904594.aspx">LINQ</a> is part of C# 3.0 and it's going to revolutionise the way that .NET developers access and manipulate data.  The previous example showed how the Select and Where methods seem familiar to a SQL way of dealing with data.</p>
<p>I attended a <a href="http://www.developerday.co.uk/ddd/default.asp">DDD</a> event last year, and was introduced to the 'var' keyword during a presentation.  I'm guessing that it was new to my fellow developers present because there were several loud gasps from the attendees.  </p>
<p>Aaaggggh!  It's like the old days of variants!</p>
<pre class="code">
var myName = "Shane";
</pre>
<p>The thing to really shout about here is that it is not a variant!  The compiler simply infers the type from the data on the right side of the assignment, in this case, a string.  It is a string!  It is not a variant!</p>
<p>The reason that this keyword is introduced is for anonymous types, and the following example, with some new LINQ syntax thrown in for good measure, will illustrate:</p>
<pre class="code">
var adults =
    from p in people
    where p.Age &gt;= 18
    select new { Name = p.FirstName + " " + p.LastName, Age = p.Age }; // anonymous type projection
</pre>
<p>The first thing to note is that from, where and select keywords are exactly as in a SQL query, but that the from occurs first.  This is mandatory, and it's unusual position is because Visual Studio's intellisense can only offer member information based on the data that is being queried.  Because this is first, Visual Studio can offer help for the where clause and the select clause (which appears last.)  There are a <a href="http://msdn2.microsoft.com/netframework/aa904594.aspx">number of other methods and keywords</a>, but I'll keep things brief here.</p>
<p>You'll notice that we're referring to an item in the list as 'p', referencing 'p' in the where clause with the Age property of the Person class, and then doing a select.</p>
<p>This select is doing something more interesting than the earlier example (which was just selecting people from the list).  It is using anonymous type projection, whereby an anonymous type is created as a result of a select on the data.</p>
<p>The type doesn't have a name (therefore it's anonymous), and its properties can be specified 'on the fly'.  Here, we're creating a new type to merge the first name and last name as 'Name', and creating an 'Age' property for the Person 'Age' property.</p>
<p>Because this type is anonymous, we need to specify the var keyword, and let the compiler work things out by inferring the type.</p>
<pre class="code">
// local variable type inference:
foreach (var currentAdult in adults)
{
    Console.WriteLine(currentAdult.Name + ".  Their age is " +
          (currentAdult.Age.IsEven() ? "" : "not ") + "even");
}
</pre>
<p>Once again, type inference comes into play, and we loop through the selected adults.  Note that the previously demonstrated int extension method is used (IsEven).</p>
<p>Remember that the Person class had a LogCreation partial method that was implemented?  Well, that is called every time a Person is constructed, so for our collection, object initialization and output, we get the following:</p>
<p><img src="http://farm3.static.flickr.com/2398/2089056994_f4af8efd4b_o.png" alt="Program output with partial method implementation" /></p>
<p>If the partial method implementation is taken out of the Person class, everything still compiles, but we get the following:</p>
<p><img src="http://farm3.static.flickr.com/2086/2089056998_48705d82e0_o.png" alt="Program output with partial method implementation removed" /></p>
<p>So, that concludes my brief overview of new language features.  Without doubt, the var keyword is likely to cause some controversy, but it really isn't bad, and is in fact required for anonymous types (which I believe to be a very handy addition to the language.)</p>
<p>I'm certainly looking forward to using the new language features, and I hope you do too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freshclickmedia.com/blog/2007/12/a-quick-tour-of-c-30s-new-language-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write your own Visual Studio .NET Snippets to improve your coding productivity</title>
		<link>http://www.freshclickmedia.com/blog/2007/11/write-your-own-visual-studio-net-snippets-to-improve-your-coding-productivity/</link>
		<comments>http://www.freshclickmedia.com/blog/2007/11/write-your-own-visual-studio-net-snippets-to-improve-your-coding-productivity/#comments</comments>
		<pubDate>Wed, 07 Nov 2007 21:03:37 +0000</pubDate>
		<dc:creator>Shane</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.freshclickmedia.com/blog/2007/11/write-your-own-visual-studio-net-snippets-to-improve-your-coding-productivity/</guid>
		<description><![CDATA[Chances are that if you&#8217;ve been using Visual Studio .NET, you&#8217;ll have come across the concept of snippets &#8211; useful reusable chunks of code that are inserted after typing in a small textual identifier for that snippet. This tutorial describes Visual Studio .NET snippets and describes how you can create your own. A snippet that [...]]]></description>
			<content:encoded><![CDATA[<p>Chances are that if you&#8217;ve been using Visual Studio .NET, you&#8217;ll have come across the concept of snippets &#8211; useful reusable chunks of code that are inserted after typing in a small textual identifier for that snippet.   This tutorial describes Visual Studio .NET snippets and describes how you can create your own.</p>
<p><span id="more-20"></span></p>
<p>A snippet that I use probably the most is the &#8216;prop&#8217; snippet.  To activate it, type &#8216;prop&#8217; at class scope in a Visual C# project.</p>
<p><img src="http://farm3.static.flickr.com/2335/1907228239_f5d7adb12e_o.gif" width="521" height="325" alt="The ‘prop’ snippet for quickly inserting a property at class scope" /></p>
<p>Selecting &#8216;prop&#8217; from the list, or tabbing twice will then produce the following code:</p>
<p><img src="hhttp://farm3.static.flickr.com/2008/1907228245_676e149ef3_o.gif" width="250" height="191" alt="The initial code produced by the ‘prop’ snippet" /></p>
<p>The focus is initially over the private member&#8217;s data type &#8216;int&#8217;.  This, and all the other text highlighted in green can be typed over.  Each piece of text can be cycled through by pressing the tab key.</p>
<p>You&#8217;ll also notice that the property&#8217;s type is outlined with a dotted line.  This means that once something has been typed in the active selection, tabbing out will change the dotted selection&#8217;s text to be the same.  This makes sense, since a property and the member that it relates to must be the same type.</p>
<p>In this quick scenario, we&#8217;ll change the data type to be of type string, the member to be _name, and property to be Name.  Note that tabbing through will cycle through the highlighted text.  When you&#8217;re happy, press enter, and you have a property.  Once the method for using snippets becomes familiar, their use becomes second nature and you&#8217;ll wonder how you ever worked without them.</p>
<p>The &#8216;prop&#8217; example is just one of many that can be managed through the &#8216;Code Snippets Manager&#8217;, accessed from the Visual Studio Tools menu.</p>
<p><img src="http://farm3.static.flickr.com/2030/1907228231_7bbe0e30a7_o.gif" width="472" height="350" alt="The code snippets manager" /></p>
<p>The real fun with snippets (real fun? perhaps I need to get out more) comes with developing your own.  The rest of the tutorial will create a simple property snippet to write/read information to/from the ViewState on an ASP.NET page.</p>
<p>A snippet is just an XML file, and the default Visual Studio snippets can be found in C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Visual C# by default.</p>
<p><img src="http://farm3.static.flickr.com/2269/1907228297_2caed5d003_o.gif" width="472" height="320" alt="The default Visual Studio snippets folder" /></p>
<p>If we open the prop.snippet file, we get this:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&gt;
  &lt;CodeSnippet Format="1.0.0"&gt;
    &lt;Header&gt;
      &lt;Title&gt;prop&lt;/Title&gt;
      &lt;Shortcut&gt;prop&lt;/Shortcut&gt;
      &lt;Description&gt;Code snippet for property and backing field&lt;/Description&gt;
      &lt;Author&gt;Microsoft Corporation&lt;/Author&gt;
      &lt;SnippetTypes&gt;
      &lt;SnippetType&gt;Expansion&lt;/SnippetType&gt;
      &lt;/SnippetTypes&gt;
   &lt;/Header&gt;
   &lt;Snippet&gt;
     &lt;Declarations&gt;
        &lt;Literal&gt;
          &lt;ID&gt;type&lt;/ID&gt;
          &lt;ToolTip&gt;Property type&lt;/ToolTip&gt;
          &lt;Default&gt;int&lt;/Default&gt;
        &lt;/Literal&gt;
        &lt;Literal&gt;
          &lt;ID&gt;property&lt;/ID&gt;
          &lt;ToolTip&gt;Property name&lt;/ToolTip&gt;
          &lt;Default&gt;MyProperty&lt;/Default&gt;
        &lt;/Literal&gt;
        &lt;Literal&gt;
          &lt;ID&gt;field&lt;/ID&gt;
          &lt;ToolTip&gt;The variable backing this property&lt;/ToolTip&gt;
          &lt;Default&gt;myVar&lt;/Default&gt;
        &lt;/Literal&gt;
      &lt;/Declarations&gt;
      &lt;Code Language="csharp"&gt;&lt;![CDATA[private $type$ $field$;
	public $type$ $property$
	{
          get { return $field$;}
          set { $field$ = value;}
	}
	$end$]]&gt;
      &lt;/Code&gt;
    &lt;/Snippet&gt;
  &lt;/CodeSnippet&gt;
&lt;/CodeSnippets&gt;</pre>
<p>The two main areas are the Header and the Snippet elements, underneath the main CodeSnippet element.  The Header contains the snippet title, shortcut (what you type in the editor to invoke the snippet), the description, author, and the snippet types.  In our case, it&#8217;ll be an Expansion type, meaning it will expand to generate a piece of code.</p>
<p>The Snippet element contains a declarations section.  This section contains 0 or more (in this case 3) items, 1 for each item that can be customised.  Each of these items has a unique identifier, ID, a tooltip and a default value.  The Snippet element also contains a Code section.  Wrapped in a CDATA section (since it&#8217;s quite likely we&#8217;ll be using reserved xml characters in here), it contains the injected code.  The variables declared in the Declarations are referenced in $s.  The $end$ defines where the cursor will be when the user types enter.</p>
<p>When I develop my own snippets, I often find it useful to start with an example of the type of code that the snippet will produce, before developing the snippet and removing &#8216;configurable&#8217; items.</p>
<pre class="code">public string SelectedValue
{
  get { return ViewState["SelectedValue"] == null ? 15 : (int)ViewState["SelectedValue"]; }
  set { ViewState["SelectedValue"] = value; }
}</pre>
<p>So, thinking about a snippet, it would be good to define the type of the property (string), the property name (SelectedValue), which is also used as the ViewStateIdentifier, and the default value (15).</p>
<p>Translating that into the snippet code gives us:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&gt;
  &lt;CodeSnippet Format="1.0.0"&gt;
    &lt;Header&gt;
      &lt;Title&gt;propvs&lt;/Title&gt;
      &lt;Shortcut&gt;propvs&lt;/Shortcut&gt;
      &lt;Description&gt;Code snippet for property and ViewState backing&lt;/Description&gt;
      &lt;Author&gt;Shane Porter&lt;/Author&gt;
      &lt;SnippetTypes&gt;
        &lt;SnippetType&gt;Expansion&lt;/SnippetType&gt;
      &lt;/SnippetTypes&gt;
    &lt;/Header&gt;
    &lt;Snippet&gt;
      &lt;Declarations&gt;
        &lt;Literal&gt;
          &lt;ID&gt;type&lt;/ID&gt;
          &lt;ToolTip&gt;Property type&lt;/ToolTip&gt;
          &lt;Default&gt;string&lt;/Default&gt;
        &lt;/Literal&gt;
        &lt;Literal&gt;
          &lt;ID&gt;property&lt;/ID&gt;
          &lt;ToolTip&gt;Property name&lt;/ToolTip&gt;
          &lt;Default&gt;MyProperty&lt;/Default&gt;
        &lt;/Literal&gt;
        &lt;Literal&gt;
          &lt;ID&gt;default&lt;/ID&gt;
          &lt;ToolTip&gt;The default value, if the ViewState value is null&lt;/ToolTip&gt;
          &lt;Default&gt;string.Empty&lt;/Default&gt;
        &lt;/Literal&gt;
      &lt;/Declarations&gt;
      &lt;Code Language="csharp"&gt;&lt;![CDATA[public $type$ $property$
        {
          get { return ViewState["$property$"] == null ? $default$ : (int)ViewState["$property$"]; }
          set { ViewState["$property$"] = value; }
        }
	$end$]]&gt;
      &lt;/Code&gt;
    &lt;/Snippet&gt;
  &lt;/CodeSnippet&gt;
&lt;/CodeSnippets&gt;</pre>
<p>Things are pretty simple.  I took the code that I wanted, thought about what I needed, created a variable (Literal element) for each thing, and replaced the hard-coded values in the pasted C# code to the $variable$ syntax.  I called the snippet &#8216;propvs&#8217;, since it uses the View State, and doesn&#8217;t clash with the default &#8216;prop&#8217; snippet.  You can have multiple snippets with the same name, but it becomes a little harder to distinguish them at usage-time since the Visual Studio IDE simply presents the two in a menu.</p>
<p>To use the snippet, you&#8217;ll need to import it using the Visual Studio Tools -&gt; Code Snippets Manager menu item.  On the resulting dialog, click the &#8216;Import&#8217; button and browse for the snippet.  You will then see this dialog:</p>
<p><img src="http://farm3.static.flickr.com/2228/1907249717_4ee521a2c0_o.gif" width="472" height="384" alt="Importing the snippet" /></p>
<p>Once Finish is clicked, click OK on the previous dialog to return to the editor.  Then, we can use our newly developed snippet by typing propvs and tabbing, or by selecting from the menu.</p>
<p><img src="http://farm3.static.flickr.com/2224/1907228251_2ff0f7446e_o.gif" width="284" height="295" alt="Selecting ‘propvs’ from the intellisense menu" /></p>
<p>Once this has been selected, you will get the injected code:</p>
<p><a href="http://farm3.static.flickr.com/2014/1907228263_f3457083c9_o.gif" title="View full size image"><img src="http://farm3.static.flickr.com/2014/1907228263_86b1b709e6.jpg" width="500" height="62" alt="The ‘propvs’ injected code" /></a></p>
<p>Tabbing through, typing what we need, will give us a very quick and easy way to insert the viewstate property pattern into our code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freshclickmedia.com/blog/2007/11/write-your-own-visual-studio-net-snippets-to-improve-your-coding-productivity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
