<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Christian Nagel's OneNotes : Technology</title><link>http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx</link><description>Tags: Technology</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>77 Days</title><link>http://weblogs.asp.net/cnagel/archive/2005/08/22/423335.aspx</link><pubDate>Mon, 22 Aug 2005 19:08:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:423335</guid><dc:creator>CNagel</dc:creator><author>CNagel</author><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/cnagel/rsscomments.aspx?PostID=423335</wfw:commentRss><comments>http://weblogs.asp.net/cnagel/archive/2005/08/22/423335.aspx#comments</comments><description>&lt;p&gt;77 days to the launch of Visual Studio 2005. &lt;a href="http://blogs.msdn.com/somasegar/"&gt;Somasgear&lt;/a&gt;&amp;nbsp;blogs about &lt;a href="http://blogs.msdn.com/somasegar/archive/2005/08/22/451026.aspx"&gt;upates for Visual Studio 2005&lt;/a&gt;:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;August: new CTP for Visual Studio 2005&lt;/li&gt; &lt;li&gt;September: Visual Studio 2005 RC1 &amp;amp; Team Foundation Server Beta 3&lt;/li&gt; &lt;li&gt;TFS will ship in Q1 2006&lt;/li&gt; &lt;li&gt;TFS Beta 3 will have a Go Live license!&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Christian&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=423335" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx">Technology</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Whidbey+_2600_amp_3B00_+Longhorn/default.aspx">Whidbey &amp;amp; Longhorn</category></item><item><title>Faster Transactions with Enterprise Services...</title><link>http://weblogs.asp.net/cnagel/archive/2005/07/22/420284.aspx</link><pubDate>Fri, 22 Jul 2005 21:53:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:420284</guid><dc:creator>CNagel</dc:creator><author>CNagel</author><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/cnagel/rsscomments.aspx?PostID=420284</wfw:commentRss><comments>http://weblogs.asp.net/cnagel/archive/2005/07/22/420284.aspx#comments</comments><description>&lt;p&gt;...if a single database (SQL Server 2005) is used - &lt;em&gt;no DTC needed!&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Transaction Promotion and Delegation will be supported by Enterprise Services!&lt;/p&gt; &lt;p&gt;More information in &lt;a href="http://www.paulfallon.com"&gt;Paul Fallon's Blog&lt;/a&gt; &lt;a href="http://www.paulfallon.com/Transaction+Promotion+And+Delegation+Coming+Soon+To+ES+Transactions+In+Whidbey.aspx"&gt;Transaction Promotion and Delegation coming soon to ES Transactions in Whidbey&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Christian&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.ftponline.com/books/chapters/default.asp?isbn=032124673X"&gt;Sample chapter about ES Transaction Services at ftponline&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=420284" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx">Technology</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Communication/default.aspx">Communication</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Framework/default.aspx">Framework</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Data+_2600_amp_3B00_+XML/default.aspx">Data &amp;amp; XML</category></item><item><title>Friend Assemblies</title><link>http://weblogs.asp.net/cnagel/archive/2005/04/17/402267.aspx</link><pubDate>Sun, 17 Apr 2005 19:29:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:402267</guid><dc:creator>CNagel</dc:creator><author>CNagel</author><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/cnagel/rsscomments.aspx?PostID=402267</wfw:commentRss><comments>http://weblogs.asp.net/cnagel/archive/2005/04/17/402267.aspx#comments</comments><description>&lt;p&gt;The C# access modifier internal defines access is only allowed within the assembly. This is what .NET 1.0 defined. With .NET 2.0 friend assemblies are allowed to access these members, too. Friend assemblies are defined with the attribute class InternalsVisibleToAttribute:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;[assembly:InternalsVisibleTo ("AssemblyB, PublicKeyToken=32ab4ba45e0a69a1")]&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Christian&lt;br /&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=402267" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx">Technology</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Framework/default.aspx">Framework</category></item><item><title>ASP.NET 2.0 and SharePoint WebParts</title><link>http://weblogs.asp.net/cnagel/archive/2005/03/17/395024.aspx</link><pubDate>Thu, 17 Mar 2005 17:21:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:395024</guid><dc:creator>CNagel</dc:creator><author>CNagel</author><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/cnagel/rsscomments.aspx?PostID=395024</wfw:commentRss><comments>http://weblogs.asp.net/cnagel/archive/2005/03/17/395024.aspx#comments</comments><description>&lt;p&gt;ASP.NET 2.0 has great features for WebParts built in.&amp;nbsp;The next version of SharePoint&amp;nbsp;will be based on ASP.NET 2.0 WebParts.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/mikefitz"&gt;Mike Fitzmaurice&lt;/a&gt; has&amp;nbsp;the &lt;a href="http://blogs.msdn.com/mikefitz/archive/2005/03/17/397775.aspx"&gt;roadmap for SharePoint and ASP.NET 2.0 WebParts, and what can be&amp;nbsp;done now&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;A short summary about what can be done now:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;don't install ASP.NET 2.0 on a WSS/SPS site before SP2 (WSS/SPS breaks!)&lt;/li&gt; &lt;li&gt;ASP.NET 1.1 user controls can be SharePoint WebParts with &lt;a href="http://workspaces.gotdotnet.com/smartpart"&gt;SmartPart&lt;/a&gt;&lt;/li&gt; &lt;li&gt;SharePoint WebParts written today will work in WSS v3 (together with ASP.NET 2.0 WebParts)&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Christian&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=395024" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx">Technology</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>C++/CLI: Pointer Arithmetic with Embedded Value Types</title><link>http://weblogs.asp.net/cnagel/archive/2005/03/15/394638.aspx</link><pubDate>Tue, 15 Mar 2005 08:22:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:394638</guid><dc:creator>CNagel</dc:creator><author>CNagel</author><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/cnagel/rsscomments.aspx?PostID=394638</wfw:commentRss><comments>http://weblogs.asp.net/cnagel/archive/2005/03/15/394638.aspx#comments</comments><description>&lt;p&gt;With C++/CLI it is possible to use the interior_ptr&amp;lt;&amp;gt; keyword&amp;nbsp;for using pointer arithmetic with value types that are embedded in a managed class.&lt;/p&gt; &lt;p&gt;The array keyword is used to create .NET arrays. Here the array consists of 8 int values.&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;array&amp;lt;int&amp;gt;^ numbers = gcnew array&amp;lt;int&amp;gt;(8) {1, 1, 2, 3, 5, 8, 13, 21};&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Now it would be interesting to iterate through all the elements in the array by using&amp;nbsp;a pointer that references&amp;nbsp;the first element, a pointer that&amp;nbsp;points after the&amp;nbsp;last element, and to use pointer arithmetic to step through all ements:&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;int sum(array&amp;lt;int&amp;gt;^ arr)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; int* begin = &amp;amp;arr[0];&lt;br /&gt;&amp;nbsp;&amp;nbsp; int* end = &amp;amp;arr[arr-&amp;gt;Length];&lt;br /&gt;&amp;nbsp;&amp;nbsp; int sum = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp; for (; beging != end; begin++)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum += *begin;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; return sum;&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;However, because the value types are contained in a managed reference type, the garbage collector may move the array including its contained members to a different memory location. A native pointer cannot be aware of this fact. This is the reason for the new C++/CLI language construct interior_ptr&amp;lt;&amp;gt;. Instead of using a native pointer, an interior_ptr&amp;lt;&amp;gt; can be used to deal with pointer arithmetic with embedded value types:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Courier New" size="2"&gt;int sum(array&amp;lt;int&amp;gt;^ arr)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; interior_ptr&amp;lt;int&amp;gt; begin = &amp;amp;arr[0];&lt;br /&gt;&amp;nbsp;&amp;nbsp; interior_ptr&amp;lt;int&amp;gt; end = &amp;amp;arr[arr-&amp;gt;Length - 1] + 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp; int sum = 0;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; for (; begin != end; begin++)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console::WriteLine(*begin);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum += *begin;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; return sum;&lt;br /&gt;}&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;A closer look to the declaration of the end variable:&lt;/p&gt; &lt;p&gt;end should point after the last element, such as:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;interior_ptr&amp;lt;int&amp;gt; end = &amp;amp;arr[arr-&amp;gt;Length];&lt;/font&gt;&lt;/p&gt; &lt;p&gt;However, with&amp;nbsp;.NET&amp;nbsp;the bounds of arrays is checked. arr[arr-&amp;gt;Length]&amp;nbsp;clearly is out of bounds.&lt;/p&gt; &lt;p&gt;So the last element of the array is referenced with arr-&amp;gt;Length - 1, and then pointer arithmetic +1 is used to point to the address after the last element.&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;interior_ptr&amp;lt;int&amp;gt; end = &amp;amp;arr[arr-&amp;gt;Length -1] + 1;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;A language construct that makes it easier moving C++ class libraries to .NET.&lt;/p&gt; &lt;p&gt;Christian&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=394638" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx">Technology</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Language/default.aspx">Language</category></item><item><title>Predicates with .NET 2.0</title><link>http://weblogs.asp.net/cnagel/archive/2005/03/10/391616.aspx</link><pubDate>Thu, 10 Mar 2005 09:06:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:391616</guid><dc:creator>CNagel</dc:creator><author>CNagel</author><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/cnagel/rsscomments.aspx?PostID=391616</wfw:commentRss><comments>http://weblogs.asp.net/cnagel/archive/2005/03/10/391616.aspx#comments</comments><description>&lt;p&gt;In a &lt;A href="http://weblogs.asp.net/cnagel/archive/2005/03/06/386147.aspx"&gt;previous blog entry&lt;/a&gt; I've shown the transformation of the Accumulate method from a traditional implementation to a generic implementation where the action is passed. This was the result of the last version that does something to every object in a collection:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;public static TSum Accumulate&amp;lt;TObj, TSum&amp;gt;(&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;/strong&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;IEnumerable&amp;lt;TObj&amp;gt; coll, Action&amp;lt;TObj, TSum&amp;gt; action)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; TSum sum = default(TSum);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/strong&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;foreach (TObj obj in coll)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum = action(obj, sum);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return sum;&lt;br /&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;And this is how this method can be invoked with an anonymous delegate:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Courier New" size="2"&gt;decimal amount = Algorithm.Accumulate&amp;lt;Account, decimal&amp;gt;(&lt;br /&gt;&amp;nbsp;&amp;nbsp; accounts,&lt;br /&gt;&amp;nbsp;&amp;nbsp; delegate(Account a, decimal sum)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return a.Balance + sum;&lt;br /&gt;&amp;nbsp;&amp;nbsp; });&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Now I'm extending the implementation of the Accumulate method by using a predicate. A predicate is a method that returns a boolean value. .NET 2.0 defines this generic predicate delegate:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Courier New" size="2"&gt;public delegate bool Predicate&amp;lt;T&amp;gt;(T obj);&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Such a predicate can be used with the AccumulateIf method to only work with&amp;nbsp;these objects of a collection where the predicate returns true:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;public static TSum AccumulateIf&amp;lt;TObj, TSum&amp;gt;(&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;IEnumerable&amp;lt;TObj&amp;gt; coll, &lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;Action&amp;lt;TObj, TSum&amp;gt; action&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; Predicate&amp;lt;TObj&amp;gt; filter)&lt;br /&gt;&lt;/strong&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; TSum sum = default(TSum);&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;foreach (TObj obj in coll)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (filter(obj))&lt;/strong&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum = action(obj, sum);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return sum;&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Now the predicate implementation&amp;nbsp;- the algorithm when the accumulation should happen - can be passed with the method AccumulateIf as anonymous method. In the example&amp;nbsp;the action only happens if the balance has a value greater than 2500.&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;decimal amount = Algorithm.AccumulateIf&amp;lt;Account, decimal&amp;gt;(&lt;br /&gt;&amp;nbsp;&amp;nbsp; accounts,&lt;br /&gt;&amp;nbsp;&amp;nbsp; delegate(Account a, decimal sum)&amp;nbsp;// Action&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return a.Balance + sum;&lt;br /&gt;&amp;nbsp;&amp;nbsp; },&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; delegate (Account a)&amp;nbsp; //&amp;nbsp;Predicate&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return a.Balance &amp;gt; 2500;&lt;/strong&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;/strong&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;);&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Christian&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=391616" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx">Technology</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Language/default.aspx">Language</category></item><item><title>Longhorn Milestone Dates</title><link>http://weblogs.asp.net/cnagel/archive/2005/03/08/389707.aspx</link><pubDate>Tue, 08 Mar 2005 18:26:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:389707</guid><dc:creator>CNagel</dc:creator><author>CNagel</author><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/cnagel/rsscomments.aspx?PostID=389707</wfw:commentRss><comments>http://weblogs.asp.net/cnagel/archive/2005/03/08/389707.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://blogs.bartdesmet.net/bart"&gt;Bart De Smet&lt;/a&gt; has some &lt;a href="http://blogs.bartdesmet.net/bart/archive/2005/03/07/678.aspx"&gt;Longhorn milestone dates&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Christian&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=389707" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx">Technology</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Whidbey+_2600_amp_3B00_+Longhorn/default.aspx">Whidbey &amp;amp; Longhorn</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Framework/default.aspx">Framework</category></item><item><title>Project Green Roadmap</title><link>http://weblogs.asp.net/cnagel/archive/2005/03/08/389515.aspx</link><pubDate>Tue, 08 Mar 2005 14:40:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:389515</guid><dc:creator>CNagel</dc:creator><author>CNagel</author><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/cnagel/rsscomments.aspx?PostID=389515</wfw:commentRss><comments>http://weblogs.asp.net/cnagel/archive/2005/03/08/389515.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.microsoft.com/presspass/press/2005/mar05/03-07Convergence05UmbrellaPR.asp"&gt;Microsoft outlined the roadmap for Project Green&lt;/a&gt;:&lt;/p&gt; &lt;p&gt;Wave 1: 2005-2007&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Common role-based shared user interface with Office integration &lt;li&gt;Interoperability with service-oriented applications &lt;li&gt;SQL Server Reporting Services as the default reporting environment &lt;li&gt;SharePoint Portal Server as intranet or extranet environment &lt;li&gt;The next version of Microsoft CRM is planned for Q4 2005 &lt;li&gt;&lt;a href="http://www.microsoft.com/presspass/press/2005/mar05/03-07Convergence05UmbrellaPR.asp"&gt;More information about Axapta, Great Plains, Navision...&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Wave 2: starts 2008&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The second wave will build on the innovations of the first wave and bring us a model-driven approach to business processes based on Visual Studio and WinFX.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/timbrookins"&gt;Tim Brookins&lt;/a&gt; was quiet with his blog lately. His &lt;a href="http://blogs.msdn.com/timbrookins/archive/2004/09/20/231819.aspx"&gt;latest blog entry from Sep-2004 &lt;/a&gt;very good explains the&amp;nbsp;roads of MBF.&lt;/p&gt; &lt;p&gt;Christian&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=389515" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx">Technology</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Whidbey+_2600_amp_3B00_+Longhorn/default.aspx">Whidbey &amp;amp; Longhorn</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Framework/default.aspx">Framework</category></item><item><title>Generic Methods</title><link>http://weblogs.asp.net/cnagel/archive/2005/03/06/386147.aspx</link><pubDate>Sun, 06 Mar 2005 15:16:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:386147</guid><dc:creator>CNagel</dc:creator><author>CNagel</author><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/cnagel/rsscomments.aspx?PostID=386147</wfw:commentRss><comments>http://weblogs.asp.net/cnagel/archive/2005/03/06/386147.aspx#comments</comments><description>&lt;p&gt;Following my blog about &lt;A href="http://weblogs.asp.net/cnagel/archive/2005/03/04/385077.aspx"&gt;Generic Delegates and Anonymous Methods&lt;/a&gt;, here is more:&lt;/p&gt; &lt;p&gt;Generics and anonymous methods can make code a lot more flexible. &lt;/p&gt; &lt;p&gt;Following I show different ways to accumulate the balance of Account objects. The Account class is a simple class that has a Balance property to access the balance of the class.&lt;/p&gt; &lt;p&gt;1. Summarizing the balance of Account objects in a collection can be done with the Accumulate method:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;public static decimal Accumulate(IEnumerable e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; decimal sum = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp; foreach (Account a in e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum += a.Balance;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; return sum;&lt;br /&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Invoking the method, the Account collection is passed:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Courier New" size="2"&gt;decimal amount = Algorithm.Accumulate(accounts);&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;2. Making this method generic that it is possible to use other than Account objects, a generic method Accumulate can be implemented. However, because the Balance property is accessed for the accumulation, all generic TAccount&amp;nbsp;classes must offer this property as is defined with the constraint IAccount.&amp;nbsp;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;public static decimal Accumulate&amp;lt;TAccount&amp;gt;(IEnumerable&amp;lt;TAccount&amp;gt; coll)&lt;br /&gt;&amp;nbsp;&amp;nbsp; where TAccount : IAccount&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; decimal sum = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp; foreach (TAccount obj in coll)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum += obj.Balance;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; return sum;&lt;br /&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Invoking the method is not different to before:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Courier New" size="2"&gt;decimal amount = Algorithm.Accumulate(accounts);&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;3. The second version has the requirement that all objects that are accumulated implement the Balance property. This can be more flexible by defining a generic delegate that defines the action.&lt;/p&gt; &lt;p&gt;Now the Accumulate mehtod can do anything to any object of a collection. What is done to the objects is defined with the delegate Action&amp;lt;&amp;gt;(). This Action delegate defines two parameters and a return type.&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;public delegate TSum Action&amp;lt;TObj, TSum&amp;gt;(TObj obj, TSum sum);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;public static TSum Accumulate&amp;lt;TObj, TSum&amp;gt;(&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;/strong&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;IEnumerable&amp;lt;TObj&amp;gt; coll, Action&amp;lt;TObj, TSum&amp;gt; action)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; TSum sum = default(TSum);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/strong&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;foreach (TObj obj in coll)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum = action(obj, sum);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return sum;&lt;br /&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;To do the same as before - adding all balances - the implementation of the Action can be defined as anonymous method calling the Accumulate method.&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;decimal amount = Algorithm.Accumulate&amp;lt;Account, decimal&amp;gt;(&lt;br /&gt;&amp;nbsp;&amp;nbsp; accounts,&lt;br /&gt;&amp;nbsp;&amp;nbsp; delegate(Account a, decimal sum)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return a.Balance + sum;&lt;br /&gt;&amp;nbsp;&amp;nbsp; });&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;This is really flexible as it is not only possible to use Account objects, but any object. Instead of accumulating some values anything else can be done, too.&lt;/p&gt; &lt;p&gt;Of course anonymous methods should only be used with very simple implementations that are not needed somewhere else. Instead of anonymous methods a normal method can be used, too.&lt;/p&gt; &lt;p&gt;Christian&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=386147" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx">Technology</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Whidbey+_2600_amp_3B00_+Longhorn/default.aspx">Whidbey &amp;amp; Longhorn</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Code+Snippets/default.aspx">Code Snippets</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Language/default.aspx">Language</category></item><item><title>Generic Delegates and Anonymous Methods</title><link>http://weblogs.asp.net/cnagel/archive/2005/03/04/385077.aspx</link><pubDate>Fri, 04 Mar 2005 14:16:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:385077</guid><dc:creator>CNagel</dc:creator><author>CNagel</author><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/cnagel/rsscomments.aspx?PostID=385077</wfw:commentRss><comments>http://weblogs.asp.net/cnagel/archive/2005/03/04/385077.aspx#comments</comments><description>&lt;p&gt;Generics and anonymous methods are great improvements of C#.&lt;/p&gt; &lt;p&gt;Having a generic collection persons of type List&amp;lt;Person&amp;gt;, the objects of the collection can be accessed with a simple foreach statement:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;foreach (Person p in persons)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; Console.WriteLine(p);&lt;br /&gt;}&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;The collection class also has a ForEach method that can be used instead of a foreach statement. The ForEach method has the parameter Action&amp;lt;T&amp;gt; action. Action is a generic delegate: &lt;br /&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;public delegate void Action&amp;lt;T&amp;gt;(T obj);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Using Person objects in the collection, the method that can be invoked by the delegate looks like this:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;void DisplayPerson(Person p)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; Console.WriteLine(p);&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Now this method can be passed to the ForEach method:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;persons.ForEach(new Action&amp;lt;Person&amp;gt;(DisplayPerson));&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;The same can be done with fewer characters as the delegate type is inferred if possible:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;persons.ForEach(DisplayPerson);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;If the method that is invoked by ForEach is not used on other places, it can be implemented as an anonymous method:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;strong&gt;persons.ForEach(delegate(Person p)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; Console.WriteLine(p);&lt;br /&gt;});&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Christian&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=385077" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/cnagel/archive/tags/Technology/default.aspx">Technology</category><category domain="http://weblogs.asp.net/cnagel/archive/tags/Language/default.aspx">Language</category></item></channel></rss>