<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2366485263164379453</id><updated>2025-07-06T08:53:16.554+05:30</updated><category term="C#"/><category term="CodeProject"/><category term=".NET"/><category term="WPF"/><category term=".NET 4.0"/><category term=".NET 3.5"/><category term="internals"/><category term="beyondrelational"/><category term="dotnetfunda.com"/><category term="architecture"/><category term=".NET Memory Management"/><category term="XAML"/><category term="WinForms"/><category term="Online Session"/><category term="design pattern"/><category term="ASP.NET 4.0"/><category term="windowsclient.net"/><category term="Memory Allocation"/><category term="Finalize"/><category term="async"/><category term="C#5.0"/><category term="IDisposable"/><category term="MVVM"/><category term="Patterns"/><category term="Reflection"/><category term="Windows Phone7"/><category term=".NET 4.5"/><category term="DLR"/><category term="MEF"/><category term="MVP"/><category term="WCF"/><category term="Windows8"/><category term="silverlight"/><category term="tips"/><category term="ADO.NET"/><category term="Database"/><category term="IObservable. Rx"/><category term="Metro"/><category term="PDC10"/><category term="blogger tips"/><category term="book"/><category term="cookbook"/><category term="Azure"/><category term="C# 6.0"/><category term="IsolatedStorage"/><category term="LOH"/><category term="SOH"/><category term="Threading"/><category term="WinRT"/><category term="debugging"/><category term=".NET infrastructure"/><category term="ALM"/><category term="Auto property initialization"/><category term="Configuration"/><category term="Custom Control"/><category term="Developer Conference"/><category term="Extention"/><category term="GC"/><category term="Geolocator"/><category term="Prism"/><category term="Regex"/><category term="TFS"/><category term="TPL"/><category term="TPL Data Flows"/><category term="Teched"/><category term="Testing"/><category term="Unity"/><category term="VS2012"/><category term="Visual Studio"/><category term="WeakReference"/><category term="Windows Phone"/><category term="asp.net4.5"/><category term="await"/><category term="exception filters"/><category term="expression bodies functions"/><category term="free"/><category term="gesture"/><category term="gift"/><category term="giveaways"/><category term="html5"/><category term="jquery"/><category term="kinect"/><category term="multithreading"/><category term="nameof"/><category term="null condition"/><category term="push technology"/><category term="scripting"/><category term="static class"/><category term="string interpolation"/><category term="struct"/><title type='text'>DOT NET TRICKS</title><subtitle type='html'>Handy Tricks and Tips to do your .NET code Fast, Efficient and Simple. Some common questions that comes into mind. Please check if you could find them listed or not.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>173</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-4153914545952808387</id><published>2024-11-04T10:16:00.003+05:30</published><updated>2024-11-04T10:16:13.094+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="design pattern"/><title type='text'>Enterprise Architectural Patterns</title><content type='html'>&lt;p&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;span style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px;&quot;&gt;An architectural pattern is a common standard for an architecture and solution to a problem. Unlike&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://www.abhisheksur.com/2024/11/software-patterns-practices.html&quot; target=&quot;_blank&quot;&gt;Design Patterns&lt;/a&gt;&lt;span style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px;&quot;&gt;, an architectural pattern has a broader scope and can address big problems. &amp;nbsp;The architectural pattern address various issues of software engineering, such as computer hardware performance limitations, high availability and minimizing business risk.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;According to Martin Fowler, there Enterprise Architectural Patterns are broadly categorized into&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;ol style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: decimal; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Domain Logic Patterns&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Transaction Script&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Domain Model&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Table Module&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Service Layer&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;2. Data Source Architectural Patterns&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Table Data Gateway&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Row Data Gateway&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Active Record&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Data Mapper&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;3. Object Relational Behavioral Patterns&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Unit of Work&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Identity Map&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Lazy Load&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;4. Object Relational Structural Patterns&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Identity Field&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Foreign Key Mapping&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Association Table Mapping&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Dependent Mapping&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Embedded Value&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Serialized LOB&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Single Table Inheritance&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Class Table Inheritance&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Concrete Table Inheritance&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Inheritance Mappers&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;5. Object Relational Metadata Mapping Patterns&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Metadata Mapping&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Query Object&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Repository&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;6. Web Presentation Patterns&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Model View Controller&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Page Controller&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Front Controller&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Template View&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Transform View&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Two-step View&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Application Controller&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;7. Distribution Patterns&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Remote Facade&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Data Transfer Object&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;8. Offline Concurrency Patterns&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Optimistic Offline Lock&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Pessimistic Offline Lock&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Coarse Grained Lock&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Implicit Lock&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;9. Session State Patterns&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Client Session State&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Server Session State&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Database session State&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;10. Base Patterns&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Geteway&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Mapper&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Layer Supertype&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Separated Interface&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Registry&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Value Object&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Money&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Special Case&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Plugin&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Service Stub&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Record Set&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;I would edit this article with all the links when I am complete in writing implementation of each of those. If you have contributed anyone of these patterns, please go ahead and put the links.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/4153914545952808387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2024/11/enterprise-architectural-patterns.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/4153914545952808387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/4153914545952808387'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2024/11/enterprise-architectural-patterns.html' title='Enterprise Architectural Patterns'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-3660997581025235951</id><published>2024-11-04T10:12:00.001+05:30</published><updated>2024-11-04T10:13:00.123+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="design pattern"/><title type='text'>Software Patterns &amp; Practices</title><content type='html'>&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;The article describes how to deal with Design patterns and practices while developing your application. This article is basically a pointer to all the design patterns associated with the series. Please bookmark this to get links updated for all other articles that are added to the series. Click on a link below to read a pattern.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;heading-wrapper&quot; data-heading-level=&quot;h2&quot; style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; outline-color: inherit; position: relative;&quot;&gt;&lt;a aria-label=&quot;Section titled: Introduction&quot; class=&quot;anchor-link docon docon-link&quot; href=&quot;https://learn.microsoft.com/en-us/archive/technet-wiki/18030.software-patterns-practices#introduction&quot; style=&quot;-webkit-font-smoothing: antialiased; border: 0px; box-sizing: inherit; clip-path: inset(50%); clip: rect(1px, 1px, 1px, 1px); cursor: pointer; direction: ltr; display: inline-block; font-family: docons; font-size: 1rem; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-variant-position: normal; height: 1px; inset-block-start: 1.38125rem; inset-inline-start: -1.875rem; line-height: 16px; margin: -1px; opacity: 0; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: normal; overflow: hidden; padding: 0px; position: absolute; speak: none; text-align: center; text-decoration-line: none; transform: translateY(-50%) scale(1); transition: opacity 0.1s linear; width: 1px;&quot;&gt;&lt;/a&gt;&lt;h2 class=&quot;heading-anchor&quot; id=&quot;introduction&quot; style=&quot;box-sizing: inherit; font-size: clamp(1.59375rem, 18.7895px + 1.39803vw, 2.125rem); line-height: 1.3; margin-inline-start: -1.875rem; margin: 32px 0px 12px; outline-color: inherit; padding-inline-start: 1.875rem; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Introduction&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Software patterns are there and widely followed in the industry for a long time. In Software engineering, a pattern is a generalized solution to a common problem, a software design or an architecture for a given problem. This is the widely used solution to a problem specific to an industry, a person or a goal. A Software pattern can never be identified as a silver bullet to a problem but rather it is widely accepted a solution to a problem. There could be always a notion of adjustment to a pattern to adjust the specific need of the project that is worked on by the developers.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Patterns are essentially formalisms and naming of nice idioms of coding. It is a way to give experience to programmers. It is a nice way to know that both the developers are talking about the same thing while discussing a problem.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 1rem 0px 0px; outline-color: inherit; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Software patterns are first introduced in 1995 by &quot;gang of four&quot;: Design Patterns by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. In this book, it is first discussed capabilities and pitfalls of Object oriented programming, and later on, it discusses the classic Design Patterns on OOPS.&amp;nbsp;They introduced the first requirement of a software pattern while developing a piece of software in the industry. Better organizing a code is a lifelong learning experience for every developer and it is hard to follow when some functionality is needed to be implemented by a programmer. A software pattern just gives a sense of guidance to a developer while implementing a code or functionality for a problem.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;heading-wrapper&quot; data-heading-level=&quot;h2&quot; style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; outline-color: inherit; position: relative;&quot;&gt;&lt;a aria-label=&quot;Section titled: Software Patterns are generally categorised into&quot; class=&quot;anchor-link docon docon-link&quot; href=&quot;https://learn.microsoft.com/en-us/archive/technet-wiki/18030.software-patterns-practices#software-patterns-are-generally-categorised-into&quot; style=&quot;-webkit-font-smoothing: antialiased; border: 0px; box-sizing: inherit; clip-path: inset(50%); clip: rect(1px, 1px, 1px, 1px); cursor: pointer; direction: ltr; display: inline-block; font-family: docons; font-size: 1rem; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-variant-position: normal; height: 1px; inset-block-start: 1.38125rem; inset-inline-start: -1.875rem; line-height: 16px; margin: -1px; opacity: 0; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: normal; overflow: hidden; padding: 0px; position: absolute; speak: none; text-align: center; text-decoration-line: none; transform: translateY(-50%) scale(1); transition: opacity 0.1s linear; width: 1px;&quot;&gt;&lt;/a&gt;&lt;h2 class=&quot;heading-anchor&quot; id=&quot;software-patterns-are-generally-categorised-into&quot; style=&quot;box-sizing: inherit; font-size: clamp(1.59375rem, 18.7895px + 1.39803vw, 2.125rem); line-height: 1.3; margin-inline-start: -1.875rem; margin: 32px 0px 12px; outline-color: inherit; padding-inline-start: 1.875rem; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Software Patterns are generally categorised into&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;&lt;ol style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: decimal; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18031.design-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;design pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Design Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: decimal; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18032.enterprise-architectural-patterns.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;enterprise architectural pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Enterprise Architectural Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: decimal; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18033.software-design-principles.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Software Principles&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class=&quot;heading-wrapper&quot; data-heading-level=&quot;h3&quot; style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; outline-color: inherit; position: relative;&quot;&gt;&lt;a aria-label=&quot;Section titled: Design Patterns&quot; class=&quot;anchor-link docon docon-link&quot; href=&quot;https://learn.microsoft.com/en-us/archive/technet-wiki/18030.software-patterns-practices#design-patterns&quot; style=&quot;-webkit-font-smoothing: antialiased; border: 0px; box-sizing: inherit; clip-path: inset(50%); clip: rect(1px, 1px, 1px, 1px); cursor: pointer; direction: ltr; display: inline-block; font-family: docons; font-size: 1rem; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-variant-position: normal; height: 1px; inset-block-start: 1.1375rem; inset-inline-start: -1.875rem; line-height: 16px; margin: -1px; opacity: 0; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: normal; overflow: hidden; padding: 0px; position: absolute; speak: none; text-align: center; text-decoration-line: none; transform: translateY(-50%) scale(1); transition: opacity 0.1s linear; width: 1px;&quot;&gt;&lt;/a&gt;&lt;h3 class=&quot;heading-anchor&quot; id=&quot;design-patterns&quot; style=&quot;box-sizing: inherit; font-size: clamp(1.3125rem, 15.4737px + 1.15132vw, 1.75rem); line-height: 1.3; margin-inline-start: -1.875rem; margin: 30px 0px 18px; outline-color: inherit; padding-inline-start: 1.875rem; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18031.design-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;design pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Design Patterns&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;&lt;/div&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18034.creational-patterns.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Creational Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Creational Patterns&lt;/span&gt;&lt;/a&gt;&lt;ul style=&quot;box-sizing: inherit; list-style: none; margin: 0px 0px 0px 20px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18037.singleton-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Singleton Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Singleton Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18038.factory-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Factory Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Factory Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18039.factory-method.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Factory Method&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Factory Method&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18040.abstract-factory.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Abstract Factory Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Abstract Factory Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18041.builder-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Builder Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Builder Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18042.prototype-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Prototype Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Prototype Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18035.structural-patterns.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Structurall Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Structural Patterns&lt;/span&gt;&lt;/a&gt;&lt;ul style=&quot;box-sizing: inherit; list-style: none; margin: 0px 0px 0px 20px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18043.adapter-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Adapter Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Behavorial Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18044.bridge-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Bridge Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Bridge Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18045.decorator-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Decorator Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Decorator Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18046.composite-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Composite Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Composite Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18047.flyweight-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Flyweight Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Flyweight Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18048.memento-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Memento Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Memento Pattern&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18036.behavioral-patterns.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Creational Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Behavorial Patterns&lt;/span&gt;&lt;/a&gt;&lt;ul style=&quot;box-sizing: inherit; list-style: none; margin: 0px 0px 0px 20px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18049.mediator-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Mediator Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Mediator Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18050.observer-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Observer Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Observer Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18051.iterator-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Iterator Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Iterator Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18030.software-patterns-practices/edit.aspx#&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Visitor Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Visitor Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18233.null-object-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Null Object Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Null Object Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18232.chain-of-responsibility-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Chain of Responsibility Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Chain of Responsibility Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18234.command-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Command Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Command Patterns&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: circle; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18235.interpreter-pattern.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Interpreter Pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Interpreter Pattern&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;heading-wrapper&quot; data-heading-level=&quot;h3&quot; style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; outline-color: inherit; position: relative;&quot;&gt;&lt;a aria-label=&quot;Section titled: Enterprise Architectural Patterns&quot; class=&quot;anchor-link docon docon-link&quot; href=&quot;https://learn.microsoft.com/en-us/archive/technet-wiki/18030.software-patterns-practices#enterprise-architectural-patterns&quot; style=&quot;-webkit-font-smoothing: antialiased; border: 0px; box-sizing: inherit; clip-path: inset(50%); clip: rect(1px, 1px, 1px, 1px); cursor: pointer; direction: ltr; display: inline-block; font-family: docons; font-size: 1rem; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-variant-position: normal; height: 1px; inset-block-start: 1.1375rem; inset-inline-start: -1.875rem; line-height: 16px; margin: -1px; opacity: 0; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: normal; overflow: hidden; padding: 0px; position: absolute; speak: none; text-align: center; text-decoration-line: none; transform: translateY(-50%) scale(1); transition: opacity 0.1s linear; width: 1px;&quot;&gt;&lt;/a&gt;&lt;h3 class=&quot;heading-anchor&quot; id=&quot;enterprise-architectural-patterns&quot; style=&quot;box-sizing: inherit; font-size: clamp(1.3125rem, 15.4737px + 1.15132vw, 1.75rem); line-height: 1.3; margin-inline-start: -1.875rem; margin: 30px 0px 18px; outline-color: inherit; padding-inline-start: 1.875rem; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18032.enterprise-architectural-patterns.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;enterprise architectural pattern&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Enterprise Architectural Patterns&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div class=&quot;heading-wrapper&quot; data-heading-level=&quot;h3&quot; style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; outline-color: inherit; position: relative;&quot;&gt;&lt;a aria-label=&quot;Section titled: Software Principles&quot; class=&quot;anchor-link docon docon-link&quot; href=&quot;https://learn.microsoft.com/en-us/archive/technet-wiki/18030.software-patterns-practices#software-principles&quot; style=&quot;-webkit-font-smoothing: antialiased; border: 0px; box-sizing: inherit; clip-path: inset(50%); clip: rect(1px, 1px, 1px, 1px); cursor: pointer; direction: ltr; display: inline-block; font-family: docons; font-size: 1rem; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-variant-position: normal; height: 1px; inset-block-start: 1.1375rem; inset-inline-start: -1.875rem; line-height: 16px; margin: -1px; opacity: 0; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: normal; overflow: hidden; padding: 0px; position: absolute; speak: none; text-align: center; text-decoration-line: none; transform: translateY(-50%) scale(1); transition: opacity 0.1s linear; width: 1px;&quot;&gt;&lt;/a&gt;&lt;h3 class=&quot;heading-anchor&quot; id=&quot;software-principles&quot; style=&quot;box-sizing: inherit; font-size: clamp(1.3125rem, 15.4737px + 1.15132vw, 1.75rem); line-height: 1.3; margin-inline-start: -1.875rem; margin: 30px 0px 18px; outline-color: inherit; padding-inline-start: 1.875rem; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18033.software-design-principles.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Software Principles&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;&lt;/div&gt;&lt;ul style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; list-style: none; margin: 16px 0px 16px 38px; outline-color: inherit; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18061.single-responsibility-principle.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Single Responsibility Principle&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Single Responsibility Principle&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18062.open-closed-principle-ocp.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Open Close Principle&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Open Close Principle&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18063.liskov-substitution-principle.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Liskov&#39;s Substitution Principle&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Liskov&#39;s Substitution Principle&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18064.interface-segregation-principle.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Interface Segregation Principle&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Interface Segregation Principle&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18065.dependency-inversion-principle.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Dependency Inversion Principle&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Dependency Inversion Principle&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18067.package-cohesion-principle.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Package Cohesion Principles&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Package Cohesion Principles&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: inherit; list-style: disc; margin: 0px; outline-color: inherit; outline-style: initial; outline-width: 0px; padding: 0px;&quot;&gt;&lt;a data-linktype=&quot;external&quot; href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/18068.package-coupling-principles.aspx&quot; style=&quot;background-color: white; box-sizing: inherit; cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration-line: none;&quot; title=&quot;Package Coupling Principles&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Package Coupling Principles&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;heading-wrapper&quot; data-heading-level=&quot;h2&quot; style=&quot;box-sizing: inherit; font-family: &amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; outline-color: inherit; position: relative;&quot;&gt;&lt;a aria-label=&quot;Section titled: Conclusion&quot; class=&quot;anchor-link docon docon-link&quot; href=&quot;https://learn.microsoft.com/en-us/archive/technet-wiki/18030.software-patterns-practices#conclusion&quot; style=&quot;-webkit-font-smoothing: antialiased; border: 0px; box-sizing: inherit; clip-path: inset(50%); clip: rect(1px, 1px, 1px, 1px); cursor: pointer; direction: ltr; display: inline-block; font-family: docons; font-size: 1rem; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-variant-position: normal; height: 1px; inset-block-start: 1.38125rem; inset-inline-start: -1.875rem; line-height: 16px; margin: -1px; opacity: 0; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: normal; overflow: hidden; padding: 0px; position: absolute; speak: none; text-align: center; text-decoration-line: none; transform: translateY(-50%) scale(1); transition: opacity 0.1s linear; width: 1px;&quot;&gt;&lt;/a&gt;&lt;h2 class=&quot;heading-anchor&quot; id=&quot;conclusion&quot; style=&quot;box-sizing: inherit; font-size: clamp(1.59375rem, 18.7895px + 1.39803vw, 2.125rem); line-height: 1.3; margin-inline-start: -1.875rem; margin: 32px 0px 12px; outline-color: inherit; padding-inline-start: 1.875rem; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Conclusion&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span face=&quot;&amp;quot;Segoe UI&amp;quot;, SegoeUI, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif&quot; style=&quot;font-size: 16px;&quot;&gt;Patterns are the widely accepted solution to problems. It is important to at least know the patterns of creating some kind of architecture that suits your needs. There is always an element of improvement in this industry. Let&#39;s hope as this wiki grows and we can add more and more content to it. There would be much more talks in the betterment of the software industry.&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/3660997581025235951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2024/11/software-patterns-practices.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/3660997581025235951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/3660997581025235951'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2024/11/software-patterns-practices.html' title='Software Patterns &amp; Practices'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-659277562699337859</id><published>2015-03-11T03:12:00.000+05:30</published><updated>2015-03-11T03:12:31.969+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="async"/><category scheme="http://www.blogger.com/atom/ns#" term="await"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="C# 6.0"/><category scheme="http://www.blogger.com/atom/ns#" term="exception filters"/><category scheme="http://www.blogger.com/atom/ns#" term="nameof"/><category scheme="http://www.blogger.com/atom/ns#" term="null condition"/><category scheme="http://www.blogger.com/atom/ns#" term="struct"/><title type='text'>C# 6.0: Language features and its internals Part 2</title><content type='html'>As discussed &lt;a href=&quot;http://www.abhisheksur.com/2015/03/c-60-language-features-and-its.html&quot; target=&quot;_blank&quot;&gt;in my last article on C# 6.0 features&lt;/a&gt;&amp;nbsp;we have discussed some of the interesting features like : Auto property initialization, Expression bodied functions, Static class uses and string interpolation method. In this post, we will take the discussion ahead with more language features introduced with the new language.&lt;br /&gt;
&lt;br /&gt;
The features will be covered with basic introduction to internals are :&lt;br /&gt;
&lt;br /&gt;
5. Null Conditional operators&lt;br /&gt;
6. Exception filters&lt;br /&gt;
7. nameof operator&lt;br /&gt;
8. Dictionary initializers&lt;br /&gt;
9. await in try / finally.&lt;br /&gt;
10. Parameterless constructor for struct&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Feature 5 : Null conditional operators&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Getting into NullReferenceException or &quot;Object reference not set to instance of an object&quot; is one of the most common exception that every developer must see while working with the langauge. It has been a common problem where developers need to give extra stress to check the null value before calling any member functions. Null for compiler is unknown, and hence if you call a method on null, it will point nowhere and hence throws NullReferenceException and exists the stack.&lt;br /&gt;
&lt;br /&gt;
To handle nulls Microsoft had introduced few language constructs already like Null coalesce operator (??) or Conditional operators. But with the new feature introduced in C# 6.0, the language team has introduced another operator which checks for null.&lt;br /&gt;
&lt;br /&gt;
Null Conditional operator is a new construct that gives away a shortcut to condition the null check before calling its members.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; zipcode = (address == &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt;? &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt; : address.zipcode);

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; zipcode = (person == &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt;? &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt; : (person.address == &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt; ? &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt; : person.address.zipcode))
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Here in the above two lines you can see how the complexity rises when there are multiple number of null checking on an expression. In the first statement the address is checked with null and when it has address, it will only then evaluate the zipcode. On the second statement, the person object is checked with null, then its address and then finally the zipcode is evaluated.&lt;br /&gt;
&lt;br /&gt;
With null conditional operator the code would look like :&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; zipcode = address?.zipcode;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; zipcode = person?.address?.zipcode;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Here the code is reduced greatly even though the actual expression logic remains the same. The ? mark is used for null conditioning. Null conditional operators does not exists as well, it is the same representation as that of the previous conditional operators. If you try to look into reflector, you will see it like :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkOZU0Fp_MRPyJfMdmOO3pMYJdBZrxXQjNhdwt9GWXeSpgtoDy-LeSfFCuanZU2gYjbSXRigvo5jpynopGRfD60v4sUxnaK5ikTCk-E1fujzxzAD5hkI8W6hrTQ43YTj4kNqPKo8SmBnc/s1600/09-03-2015+01-56-03.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkOZU0Fp_MRPyJfMdmOO3pMYJdBZrxXQjNhdwt9GWXeSpgtoDy-LeSfFCuanZU2gYjbSXRigvo5jpynopGRfD60v4sUxnaK5ikTCk-E1fujzxzAD5hkI8W6hrTQ43YTj4kNqPKo8SmBnc/s1600/09-03-2015+01-56-03.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
You can see the null conditional operators are replaced by the compiler with normal conditional statements.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Feature 6 : Exception Filters&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now after so many syntactic sugar introduced with latest version of C#, this is the only new feature that directly relates to IL (Intermediate Language). From the very inception, the exception filters were there in CLR but was not exposed to the C# language. With C# 6.0, the exception filters finally came into existence and finally as a C# developer you can make use of it.&lt;br /&gt;
&lt;br /&gt;
In C# the exception block contains try/catch/finally with multiple catch blocks supported. Based on type of the exception that has been encountered during runtime, the runtime chooses the appropriate catch block to execute. Exception filters allows you to filter out the catch blocks to ensure which catch block can handle the exception. With exception filters in place, there could be multiple catch blocks with same type where the type determines which filter it will call first.&lt;br /&gt;
&lt;br /&gt;
Let us take a look at the code :&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;ExceptionFilters&lt;/span&gt;
    {
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;LogException&lt;/span&gt;(Exception ex)
        {
            &lt;span style=&quot;color: #888888;&quot;&gt;//Log&lt;/span&gt;
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;false&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;LogAgainException&lt;/span&gt;(Exception ex)
        {
            &lt;span style=&quot;color: #888888;&quot;&gt;//Log&lt;/span&gt;
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;true&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;CallMe&lt;/span&gt;()
        {
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;try&lt;/span&gt;
            {
                &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;ArgumentException&lt;/span&gt;(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Exception&quot;&lt;/span&gt;);
            }
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;catch&lt;/span&gt; (Exception ex) when (LogException(ex))
            {
                &lt;span style=&quot;color: #888888;&quot;&gt;//Keep exception stack intact&lt;/span&gt;
            }
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;catch&lt;/span&gt;(Exception ex) when (LogAgainException(ex))
            {
                &lt;span style=&quot;color: #888888;&quot;&gt;// Calling the catch&lt;/span&gt;
            }
            
        }
    }
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Here the ArgumentException is thrown when CallMe is invoked. The Exception filters are specified using when keyword just like in VB.NET. So the execution is like, it will call LogException method, executes the code and see whether the return statement is true or false. If it is true, it executes the catch block and exit, or otherwise it move and call LogAgainException method.&lt;br /&gt;
&lt;br /&gt;
The exception filter expects a boolean value, hence the call to LogException should be a method returning bool or otherwise we need a comparison operator to always evaluate the when statement to boolean. Exception filters allows the developer to run &lt;a href=&quot;http://blogs.msdn.com/b/ericlippert/archive/2004/09/01/224064.aspx&quot; target=&quot;_blank&quot;&gt;arbitary code between the exception&lt;/a&gt;&amp;nbsp;and the catch block execution without interfering the original stack trace of the exception object.&lt;br /&gt;
&lt;br /&gt;
I have already told you that exception filters is a CLR concept. The IL is laid out as :&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;.try&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;---&lt;/span&gt; to &lt;span style=&quot;color: #333333;&quot;&gt;---&lt;/span&gt; filter &lt;span style=&quot;color: #333333;&quot;&gt;---&lt;/span&gt; handler &lt;span style=&quot;color: #333333;&quot;&gt;---&lt;/span&gt; to &lt;span style=&quot;color: #333333;&quot;&gt;---&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
This tells the compiler to execute try block from line no --- to line ----. It will then call filter line and then call the handler which executes some bunch of lines. Cool ? Yes.&lt;br /&gt;
&lt;br /&gt;
One small addition that I would want to add, if an exception filter encounters an exception and is left unhandled, the compiler handles it for you and automatically skip the exception block and moves to the next catch block. For instance if LogException in the code above throws an exception, it will call LogAgainException without modifying the Stack for ex.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Feature 7 : nameof Operator&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
nameof is a new addition to operator list supported by C#. This new operator is nothing but a compiler trick, where the compiler determines the name of a Property, Function or an Extension method and writes it directly in compiled output. For instance,&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; name1 = nameof(&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;.MyProp); &lt;span style=&quot;color: #888888;&quot;&gt;// evaluates MyProp&lt;/span&gt;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; name2 = nameof(DateTime.Now);&lt;span style=&quot;color: #888888;&quot;&gt;//evaluates Now&lt;/span&gt;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; name3 = nameof(Console.WriteLine); &lt;span style=&quot;color: #888888;&quot;&gt;//evaluates WriteLine&lt;/span&gt;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; name4 = nameof(&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; List&amp;lt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt;&amp;gt;().FirstOrDefault); &lt;span style=&quot;color: #888888;&quot;&gt;// Evaluates FirstOrDefault&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;pre style=&quot;line-height: 16.25px;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; name5 = nameof(name4);//Evaluates name4&lt;/pre&gt;
&lt;pre style=&quot;line-height: 16.25px;&quot;&gt;&lt;/pre&gt;
The nameof operator works on any type where the type has a name. In case you specify a variable, the nameof operator will evaluate to the name of the variable.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Feature 8 : Dictionary initializers&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Dictionary is one of the common array object which used often to send data between objects. Unlike arrays, Dictionaries form an array of KeyValuePair. In modern days, Dictionary is used interchangeably with arrays because of its flexibility of defining key value set.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; list = &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; List&amp;lt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt;&amp;gt;();
list.Add(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhishek&quot;&lt;/span&gt;);
list.Add(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhijit&quot;&lt;/span&gt;);

&lt;span style=&quot;color: #888888;&quot;&gt;//Access&lt;/span&gt;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; first = list[&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;0&lt;/span&gt;];
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; second = list[&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;1&lt;/span&gt;];
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Here you can see a list is used to store string data, where index giving you the reference to individual objects. If I write the same with dictionary, it will look like :&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; dict = &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;,&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt;&amp;gt;();
dict.Add(&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhishek&quot;&lt;/span&gt;);
dict.Add(&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhijit&quot;&lt;/span&gt;);

&lt;span style=&quot;color: #888888;&quot;&gt;//Access&lt;/span&gt;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; first = dict[&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;0&lt;/span&gt;];
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; second = dict[&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;1&lt;/span&gt;];
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Even though the basics remain the same, the developers are increasingly inclined to use the later as it gives a flexibility to assign any index. You can define &quot;Abhishek&quot; to 10 and &quot;Abhijit&quot; to 20 without the limitation of fixed incremental index usage of dictionary.&lt;br /&gt;
&lt;br /&gt;
As more and more people are going to Dictionary, language team thought about giving easier constructs to define Dictionary. Even though we can go without it, but it is a nice to have feature.

In C# 6.0, you can define dictionary using the following syntax :
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; dict = &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;,&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt;&amp;gt;
{
&lt;span style=&quot;color: #0000cc;&quot;&gt;   [10]&lt;/span&gt; = &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhishek&quot;&lt;/span&gt;,
&lt;span style=&quot;color: #0000cc;&quot;&gt;   [20]&lt;/span&gt; = &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhijit&quot;&lt;/span&gt;
};

&lt;span style=&quot;color: #888888;&quot;&gt;//Access&lt;/span&gt;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; first = dict[&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;10&lt;/span&gt;];
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; second = dict[&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;20&lt;/span&gt;];
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Or even if the key is declared as string, you can also use like:&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; dict = &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt;,&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt;&amp;gt;
{
&lt;span style=&quot;color: #0000cc;&quot;&gt;   [&quot;first&quot;]&lt;/span&gt; = &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhishek&quot;&lt;/span&gt;,
&lt;span style=&quot;color: #0000cc;&quot;&gt;   [&quot;second&quot;]&lt;/span&gt; = &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhijit&quot;&lt;/span&gt;
};

&lt;span style=&quot;color: #888888;&quot;&gt;//Access&lt;/span&gt;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; first = dict[&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;first&quot;&lt;/span&gt;];
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; second = dict[&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;second&quot;&lt;/span&gt;];
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
This way it is very easier to declare and use dictionaries. The last two syntaxes were introduced in C# 6.0.&lt;br /&gt;
&lt;br /&gt;
Now if you think of the actual implementation, there is nothing as such. If you try to sneak peek on the compiled code, you will be seeing the same code with object being initialized inside the constructor.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgicAgzvtWQfkeavk_3oPlO0Q_radxgoL-s6rFGN9GEOFpKyFXnGPqJXBR-ydcIKOYh9YwOYuHL7gDpJa4UlxKgQhM_vLBXK3J7p52zKB9R8RgNiNX_GJ3AQqT7QpMfOHY_Gq-vdt2igMM/s1600/11-03-2015+02-25-09.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgicAgzvtWQfkeavk_3oPlO0Q_radxgoL-s6rFGN9GEOFpKyFXnGPqJXBR-ydcIKOYh9YwOYuHL7gDpJa4UlxKgQhM_vLBXK3J7p52zKB9R8RgNiNX_GJ3AQqT7QpMfOHY_Gq-vdt2igMM/s1600/11-03-2015+02-25-09.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Here even though the new construct is used, the dictionary object is actually initialized in constructor itself. The code is re-written by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Feature 9: Await in catch and finally&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you are not using async / await stuffs too often you might have already overlooked that you cannot specify await in catch or finally block before the latest version of C#. Microsoft has initially thought that it wont be possible to allow awaits in catch/finally because the compiler creates a state machine which slices each and e&lt;a href=&quot;http://www.abhisheksur.com/2010/10/c-50-asynchronous-made-easy.html&quot; target=&quot;_blank&quot;&gt;very await statements into a sequence of calls&lt;/a&gt; which can pause and resume the function upon request. But as try/catch/finally are handled by CLR, allowing such thing will indicate every errors in the state machine is properly handled and also each of try/catch/finally would need their individual state machines each.&lt;br /&gt;
&lt;br /&gt;
Based on the complexity, microsoft haven&#39;t provided the feature in previous version, but as everything is handled by the compiler itself, it is a very important feature to have as a programmers perspective hence in latest version of C# 6.0, the feature have been revised and await in catch/finally is allowed.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;async&lt;/span&gt; Task&amp;lt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt;&amp;gt; DownloadUrl(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; url)
        {
            WebClient client = &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; WebClient();
            client.BaseAddress = &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;www.abhisheksur.com&quot;&lt;/span&gt;;
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;try&lt;/span&gt;
            {
                &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;await&lt;/span&gt; client.DownloadStringTaskAsync(url);
            }
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;catch&lt;/span&gt;
            {
                &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;await&lt;/span&gt; client.DownloadStringTaskAsync(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;mvp&quot;&lt;/span&gt;);
            }
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;finally&lt;/span&gt;
            {
                &lt;span style=&quot;color: #888888;&quot;&gt;//Await is also allowed.&lt;/span&gt;
            }
        }
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Hence you can successfully compile the code above where the await works during the catch execution.&lt;br /&gt;
&lt;br /&gt;
If you try looking at the code in reflector it will look very ugly with so many of &lt;a href=&quot;http://www.codeproject.com/Articles/127291/C-vNext-New-Asynchronous-Pattern&quot; target=&quot;_blank&quot;&gt;StateMachine declarations&lt;/a&gt; and so many of goto statements to properly navigate to lines inside the state machine on failure. It would be nice if you can look into it personally, but if there is any problem understanding the implementation, feel free to ask me in discussions.&lt;br /&gt;
&lt;br /&gt;
But as a benefit, you get this feature ready.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Feature 10: Parameterless constructor for struct&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you are unaware, there was no parameterless constructors in struct. &amp;nbsp;This is because of the fact that ValueTypes has a unique behavior where it will be automatically assigned a default memory when declared.&lt;br /&gt;
&lt;br /&gt;
For instance,&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; x;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Here int is a struct (System.Int32) and the value of x would be automatically 0. You can even declare array of a struct. For instance,&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;MyStruct&lt;/span&gt;
{
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; Property1{&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;get&lt;/span&gt;;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;set&lt;/span&gt;;}
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; Property2 {&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;set&lt;/span&gt;;}
}

MyStruct[] array = &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; MyStruct[&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;10&lt;/span&gt;];
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Now the Struct MyStruct will automatically get the default(MyStruct) in the array even though its not explicitly constructed. If you want to know more &lt;a href=&quot;http://www.abhisheksur.com/2010/10/hidden-facts-on-c-constructor-in.html&quot; target=&quot;_blank&quot;&gt;why struct does not support default constructor, feel free to read the article I posted&lt;/a&gt;. 
&lt;br /&gt;
&lt;br /&gt;
In C# 6.0 the parameterless constructor is allowed. This is also a trick made by the compiler. It actually replaces the default constructor with the parameterless constructor passed in when the new operator is used to construct the object.&lt;br /&gt;
&lt;br /&gt;
So if you say,&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;MyStruct s = &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; MyStruct();
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
The .NET will call the parameterless constructor for you.
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
There are lot more things coming with the new framework, new concepts, technologies etc. which I will cover one after another. Here is everything that are coming with C# 6.0 which is expected soon.&lt;br /&gt;
&lt;br /&gt;
Let me know your thoughts.&lt;br /&gt;
&lt;br /&gt;
Happy coding.</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/659277562699337859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2015/03/c-60-language-features-and-its_11.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/659277562699337859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/659277562699337859'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2015/03/c-60-language-features-and-its_11.html' title='C# 6.0: Language features and its internals Part 2'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkOZU0Fp_MRPyJfMdmOO3pMYJdBZrxXQjNhdwt9GWXeSpgtoDy-LeSfFCuanZU2gYjbSXRigvo5jpynopGRfD60v4sUxnaK5ikTCk-E1fujzxzAD5hkI8W6hrTQ43YTj4kNqPKo8SmBnc/s72-c/09-03-2015+01-56-03.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-4026498073600879264</id><published>2015-03-08T21:55:00.000+05:30</published><updated>2015-03-11T03:16:52.687+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="Auto property initialization"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="C# 6.0"/><category scheme="http://www.blogger.com/atom/ns#" term="expression bodies functions"/><category scheme="http://www.blogger.com/atom/ns#" term="static class"/><category scheme="http://www.blogger.com/atom/ns#" term="string interpolation"/><title type='text'>C# 6.0: Language features and its internals Part 1</title><content type='html'>C# have been one of the most evolving language in recent times. It was not more than a couple of years when some of the coolest features &lt;a href=&quot;http://www.abhisheksur.com/2010/10/c-50-asynchronous-made-easy.html&quot; target=&quot;_blank&quot;&gt;were introduced with C# 5.0&lt;/a&gt; and today we have announced the next version of C#. In this post we will try to look deep into these features and try to see what exactly is coming in the new version. I would go deeper than just demonstrating the feature so that you are well acquainted on what exactly you would be getting from these features.&lt;br /&gt;
&lt;br /&gt;
1. Auto Property Initializer&lt;br /&gt;
2. Expression bodied Function&lt;br /&gt;
3. Static Class Uses&lt;br /&gt;
4. String Interpolation&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.abhisheksur.com/2015/03/c-60-language-features-and-its_11.html&quot; target=&quot;_blank&quot;&gt;More in Part 2 of the post&lt;/a&gt;.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Feature 1 : &amp;nbsp;Auto Property Initializer&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Auto properties are not new to C#. It was there since C# 3.0. The auto properties does not require a backing field to be defined which was done automatically during compilation. So as a coder, you can get a ready-made property without writing much of code. As auto properties does not have backing field exposed, you cannot initialize the backing field during object initialization, rather you have to initialize explicitly in constructors.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;AutoPropertyInitialier&lt;/span&gt;
    {
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; FirstName { &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;set&lt;/span&gt;; }
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; LastName { &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;set&lt;/span&gt;; }

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; FullName { &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;set&lt;/span&gt;; }

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;AutoPropertyInitialier&lt;/span&gt;()
        {
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;.FirstName = &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhishek&quot;&lt;/span&gt;;
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;.LastName = &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Sur&quot;&lt;/span&gt;;

            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;.FullName = &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;.FirstName + &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot; &quot;&lt;/span&gt; + &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;.LastName;
        }
    }
&lt;/pre&gt;
&lt;/div&gt;
You can see in the above code block, the FirstName and LastName were Auto - Implemented properties, and both of them were initialized during constructor call, as the backing fields are not exposed for them. Think of a situation when your class is pretty big and you want to introduce a new property, you need to again initialize it inside constructor. This is the pain of the developer.&lt;br /&gt;
&lt;br /&gt;
With C# 6.0, the initialization of auto-implemented properties is damn easy. Take a look into the code below :&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;AutoPropertyInitializer&lt;/span&gt;
    {
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; FirstName { &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;set&lt;/span&gt;; } =  &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhishek&quot;&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; LastName { &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;get&lt;/span&gt;; } = &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Sur&quot;&lt;/span&gt;;

        &lt;span style=&quot;color: #888888;&quot;&gt;//public string FullName { get; } = this.FirstName + this.LastName;&lt;/span&gt;

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; FullName { &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;get&lt;/span&gt;; }

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;AutoPropertyInitializer&lt;/span&gt;()
        {
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;.FullName = &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;.FirstName + &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot; &quot;&lt;/span&gt; + &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;.LastName;
        }
    }
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Here the properties FirstName and LastName were initialized directly after the declaration. You can notice the LastName were intentionally made readonly by not mentioning the setter. The backing field produced for a readonly property is also a readonly variable.&lt;br /&gt;
&lt;br /&gt;
The FullName though is initialized inside constructor as the object initialization works before the constructor call, and hence initialization cannot evaluate &quot;this&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix1S2y5mTs9yNn1Eyaft_Dj7Y5bbH89gWdN3a7naw3kbpxK2nE-FOCP7UdXU9ul6NZ85wZ8vwumZVMDDXTJtLAjWrNrj3rVe8rmpvabqZl16vumNxaWDizn-rtr5qdKVvlZPFej5b6Wcw/s1600/08-03-2015+17-50-21.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix1S2y5mTs9yNn1Eyaft_Dj7Y5bbH89gWdN3a7naw3kbpxK2nE-FOCP7UdXU9ul6NZ85wZ8vwumZVMDDXTJtLAjWrNrj3rVe8rmpvabqZl16vumNxaWDizn-rtr5qdKVvlZPFej5b6Wcw/s1600/08-03-2015+17-50-21.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
In the above image, the C# representation of actual IL is shown which clearly indicates that the properties do have their backing fields. You can also notice the backing fields for property LastName is defined as readonly. The auto-property initialization is handled very cautiously during compilation and is abstract to you and relieves some of the pain points on writing un-necessary code.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Feature 2 : Expression bodies functions&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Similar to Auto property initialization, C# 6.0 also comes up with expression bodies functions a long awaited feature. Expression bodied function is also a syntactic sugar implemented in the language which adds the flexibility on how you define member functions.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Lambda expressions are not new to the language, but you might already know you cannot assign a lambda to a member function if the member function is not defined with a delegate. But if you read &lt;a href=&quot;http://www.abhisheksur.com/2010/12/internals-of-delegate.html&quot; target=&quot;_blank&quot;&gt;my internals to Lamba expression&lt;/a&gt;, you already know that for each lambda declaration the compiler creates a backing function body, but that function body cannot be exposed to class level. C# 6.0 enhances the language to allow you to define a member function with lanbda expressions.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;ExpressionBodiedFunction&lt;/span&gt;
    {
       
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;WelcomeMsg&lt;/span&gt;(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; name) =&amp;gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt;.Format(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Welcome {0}&quot;&lt;/span&gt;, name);

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; HelloMsg =&amp;gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Abhishek&quot;&lt;/span&gt;;

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;Print&lt;/span&gt;() =&amp;gt; Console.WriteLine(&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;.HelloMsg);

    }
&lt;/pre&gt;
&lt;/div&gt;
In the above code block the WelcomeMsg is a member function that takes a string argument and returns a string. As per lambda rules, a lambda which has a return statement does not require a return keyword, hence the WelcomeMsg returns the expression with string.Format.&lt;br /&gt;
&lt;br /&gt;
The second property is HelloMsg which is a property like method where the getter of the property HelloMsg will return the string &quot;Abhishek&quot;. Remember, as property is also auto-implemented, the get keyword is also automatically evaluated by the compiler.&lt;br /&gt;
&lt;br /&gt;
The last method &quot;Print&quot; is a void method and hence require a non-returning expression. The Console.WriteLine calls the property HelloMsg to print &quot;Abhishek&quot;.&lt;br /&gt;
&lt;br /&gt;
Now how does the compiler handles the lambda now without an explicit declaration of delegates ? Well, the answer is simple. The compiler re-writes the lambda into a full functional method body.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEWJwAVlosYl-ebr6YmmRfybMIDxm0UP2VlshhAdOjHrtvmHUBKpl5fg3QAXnux7CdOKSKea2RB6d6bNa9A6MiGIXMGIXfcd92zc_pJIaOwdOXos0XRMl9S7doLWjzGRKu3ipK03ndaac/s1600/08-03-2015+18-14-03.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEWJwAVlosYl-ebr6YmmRfybMIDxm0UP2VlshhAdOjHrtvmHUBKpl5fg3QAXnux7CdOKSKea2RB6d6bNa9A6MiGIXMGIXfcd92zc_pJIaOwdOXos0XRMl9S7doLWjzGRKu3ipK03ndaac/s1600/08-03-2015+18-14-03.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Here the WelcomeMsg, HelloMsg and Print after compilation is just a class level methods. The compiler entirely re-written the class into a strongly typed method bodies.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Feature 3 : Static class uses&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The C# language teams identified the developers pain points very well, and implemented the Static class uses in the language. If you are using Static types it is always a nice to have feature in the language such that we can omit the repetitive static method call.&lt;br /&gt;
&lt;br /&gt;
For instance, say I want to print a number of lines on screen, using Console.WriteLine. How about if we don&#39;t need to mention Console each line when we call WriteLine ? Static class uses does the same thing. Static class uses also recognize extension methods, hence if say a static class defines extension methods, if you add it, it will automatically recognize the extension methods as well.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;static&lt;/span&gt; System.Console;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;static&lt;/span&gt; System.Linq.Enumerable;

    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;UseStatic&lt;/span&gt;
    {
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;CallMe&lt;/span&gt;()
        {

            WriteLine(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Hi&quot;&lt;/span&gt;);

            &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; range = Range(&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;10&lt;/span&gt;, &lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;10&lt;/span&gt;);
            &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;var&lt;/span&gt; check = range.Where(e =&amp;gt; e &amp;gt; &lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;13&lt;/span&gt;);
            &lt;span style=&quot;color: #888888;&quot;&gt;// Static extension method can &lt;/span&gt;
            &lt;span style=&quot;color: #888888;&quot;&gt;// only be called with fulll representation&lt;/span&gt;
        }
    }
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
In the above code the WriteLine is automatically detected as we added the head using static statement. The Range is also declared inside System.Linq.Enumerable which is automatically determined and Where is an extension function. The static uses automatically recognized the extension methods as well.&lt;br /&gt;
&lt;br /&gt;
If you look at the internals of the static uses, the compiler rewrites the static type calls on every occurrences of its method call.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyiPMCwh6FxnipcjY5VKx-3IXUKsvjHX4lJWdDf2hLqUJg9dBq9fbBi9chUJMzlTXZG4IoBOUV6AOMnPzXjGXSn8wczBUS1begSbJmrN54ytyzwtRmqC2w8sHUwkZKpxkYB394EB8wmec/s1600/08-03-2015+18-42-46.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyiPMCwh6FxnipcjY5VKx-3IXUKsvjHX4lJWdDf2hLqUJg9dBq9fbBi9chUJMzlTXZG4IoBOUV6AOMnPzXjGXSn8wczBUS1begSbJmrN54ytyzwtRmqC2w8sHUwkZKpxkYB394EB8wmec/s1600/08-03-2015+18-42-46.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
In the actual IL, you can see, the WriteLine is padded with its appropriate type Console and Range is also associated with Enumerable. The re-writing is done by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Feature 4 : String Interpolation&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
String interpolation is another interesting feature introduced with recent version of C# 6.0. Interpolation is not new with strings. We can do string interpolation using string.Format before, but the problem is the code looks really ugly when using interpolation constructs.&lt;br /&gt;
&lt;br /&gt;
For instance,&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; myString = &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;FullName :&quot;&lt;/span&gt; + p.First + &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot; &quot;&lt;/span&gt; + p.Last;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; myString = &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt;.Format(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;FullName : {0} {1}&quot;&lt;/span&gt;, p.First, p.Last);
&lt;/pre&gt;
&lt;/div&gt;
Here the first instance, is normal string concatenation. This creates &lt;a href=&quot;http://dailydotnettips.com/2012/02/12/the-string-intern-pool/&quot; target=&quot;_blank&quot;&gt;an issue with multiple memory allocation if not string interned&lt;/a&gt;. The second statement uses string.Format to format a given string and replaces the {} arguments with the proper arguments as parameter to the method. Now while dealing with multiple occurrences of these kind of string placeholders might look very ugly and unmaintainable and error prone.&lt;br /&gt;
&lt;br /&gt;
C# 6.0 comes with a new technique where the string interpolation can take place in between the strings, or rather than putting numeric placeholders, you can use the actual values.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; myString = &lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;FullName : {p.First, 5} {p.Last, 20}&quot;&lt;/span&gt;;
Console.WriteLine(myString);

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;string&lt;/span&gt; my2ndString = &lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;FullName from EBF = {this.EBF.FullName}&quot;&lt;/span&gt;;
Console.WriteLine(my2ndString);
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Here the string need to be started with a $ sign which indicates that the new kind of string interpolation to occur. The {p.First, 5} will be replaced with the value of p.First aligned to 5 characters.&lt;br /&gt;
&lt;br /&gt;
Now what does the compiler do when these kind of interpolation is encountered. Well, you might be surprised to see, that the string is actually replaced by a call of String.Format during compilation.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4NXkCRWPqehBtf8SiLyIGgIclrduieoDL9ZajSCzG8GCiPJX9eUE4NfuoQ1_uozFaKY2CL6l5df4b0XSp97T2tr9qmIIqKXnfFh-aTdrik9yot3qnE4Tns5voGYnKZeOJFMiu2lLselc/s1600/08-03-2015+21-50-54.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4NXkCRWPqehBtf8SiLyIGgIclrduieoDL9ZajSCzG8GCiPJX9eUE4NfuoQ1_uozFaKY2CL6l5df4b0XSp97T2tr9qmIIqKXnfFh-aTdrik9yot3qnE4Tns5voGYnKZeOJFMiu2lLselc/s1600/08-03-2015+21-50-54.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
So here you can see the actual statement after compilation is nothing but a string.Format call. So string interpolation is also a compiler trick.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
So whatever we have seen in this post are few compiler trick introduced to enhance the language C# 6.0. There are few more features introduced which I will discuss in coming article.&lt;br /&gt;
&lt;br /&gt;
I hope this post comes helpful.&lt;br /&gt;
&lt;br /&gt;
Happy Coding.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.abhisheksur.com/2015/03/c-60-language-features-and-its_11.html&quot; target=&quot;_blank&quot;&gt;Also check Part 2 of this post&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/4026498073600879264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2015/03/c-60-language-features-and-its.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/4026498073600879264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/4026498073600879264'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2015/03/c-60-language-features-and-its.html' title='C# 6.0: Language features and its internals Part 1'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix1S2y5mTs9yNn1Eyaft_Dj7Y5bbH89gWdN3a7naw3kbpxK2nE-FOCP7UdXU9ul6NZ85wZ8vwumZVMDDXTJtLAjWrNrj3rVe8rmpvabqZl16vumNxaWDizn-rtr5qdKVvlZPFej5b6Wcw/s72-c/08-03-2015+17-50-21.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-3951405022881819463</id><published>2014-11-09T13:56:00.000+05:30</published><updated>2014-11-09T13:56:36.827+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ALM"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure"/><category scheme="http://www.blogger.com/atom/ns#" term="book"/><category scheme="http://www.blogger.com/atom/ns#" term="cookbook"/><category scheme="http://www.blogger.com/atom/ns#" term="Extention"/><category scheme="http://www.blogger.com/atom/ns#" term="internals"/><category scheme="http://www.blogger.com/atom/ns#" term="Testing"/><category scheme="http://www.blogger.com/atom/ns#" term="TFS"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Phone"/><title type='text'>.NET Book : Visual Studio 2013 Expert Development Cookbook </title><content type='html'>Friends,

It gives me immense pleasure to tell you that my new book &lt;a href=&quot;https://www.packtpub.com/application-development/visual-studio-2013-and-net-45-expert-cookbook&quot; target=&quot;_blank&quot;&gt;&quot;Visual Studio 2013 and .NET 4.5 Expert Development Cookbook&quot;&lt;/a&gt; has been released few days back. It is the continuation to my previous book &lt;a href=&quot;http://www.abhisheksur.com/2013/04/net-book-visual-studio-2012-and-net-45.html&quot; target=&quot;_blank&quot;&gt;&quot;Visual Studio 2012 and .NET 4.5 Expert Development Cookbook&quot;&lt;/a&gt;&amp;nbsp;which has released last year. In this post, I will discuss some of the interesting parts of the book and help you understand what exactly you are expected to learn from this book. It has been tremendous effort for last 1 year which let me release this book for you. I hope this book will stand out to your expectation.&lt;br /&gt;
&lt;br /&gt;
After &lt;a href=&quot;http://www.abhisheksur.com/2013/05/want-copy-of-visual-studio-2012-and-net.html&quot; target=&quot;_blank&quot;&gt;tremendous success &lt;/a&gt;on my first book, presenting the next version of the book.&amp;nbsp;Visual Studio 2013 enables you to develop and manage consumer-focused and business-oriented apps. It provides best-in-class tools that propel developers to create new apps or evolve existing ones. In conjunction, .NET 4.5 provides expansive capabilities for developers to work on all forms of apps and services, from client to mobile and from web to cloud, enabling them to focus solely on business logic rather than architecture.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
This practical guide teaches you how to work with new changes in technology under the arena of .NET. It provides in-depth analysis and expert advice on various elements of .NET, applying them in code using detailed practical examples, and helping you understand the entire technology in easy, small steps. This book provides solutions to common development problems that you as a developer often face, thereby helping you to adapt the latest technologies as well as get grips on modern app development using .NET 4.5.&lt;/div&gt;
&lt;a href=&quot;https://www.packtpub.com/application-development/visual-studio-2013-and-net-45-expert-cookbook&quot;&gt;&lt;span id=&quot;goog_2074126941&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://www.packtpub.com/application-development/visual-studio-2013-and-net-45-expert-cookbook&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;Visual Studio 2013 Expert Development Cookbook&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNaWiCDyRP7B1UyyMa8F0eXqdFw9my9Xdqp6ebQuUeTUfcFQSBq53P_xsQZjxBKDIVwVeu4bNMvrd3F7BM06TBWk_Mp3gx6w8h5fvd_bZf5eV937VEa0DgRM8QVqUgBIPpqd7H5UCCS58/s1600/9724EN_Visual+Studio+2013+and+.NET+4.5+Expert+Cookbook.jpg&quot; height=&quot;320&quot; title=&quot;Visual Studio 2013 Expert Development Cookbook&quot; width=&quot;257&quot; /&gt;&lt;span id=&quot;goog_2074126954&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_2074126942&quot;&gt;&lt;/span&gt;&lt;/a&gt;&lt;span id=&quot;goog_2074126938&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h3&gt;
What you will learn from this book&lt;/h3&gt;
&lt;ul style=&quot;background-color: white; border: 0px; font-family: sans-serif; font-size: 12px; line-height: 18px; list-style: none; margin: 0px; padding: 0px;&quot;&gt;
&lt;li style=&quot;background: url(https://www.packtpub.com/sites/all/themes/packt_v4/images/new-li-tick.png) 0px 4px no-repeat transparent; list-style-image: none; list-style-type: none; margin: 0.15em 0px 0.15em 0.5em; padding: 0px 0px 0.2em 1.5em;&quot;&gt;Get to grips with Visual Studio 2013 IDE and its various components utilizing its tools to debug your code better&lt;/li&gt;
&lt;li style=&quot;background: url(https://www.packtpub.com/sites/all/themes/packt_v4/images/new-li-tick.png) 0px 4px no-repeat transparent; list-style-image: none; list-style-type: none; margin: 0.15em 0px 0.15em 0.5em; padding: 0px 0px 0.2em 1.5em;&quot;&gt;Get to grips with Visual Studio 2013 IDE and its various components utilizing its tools to debug your code better&lt;/li&gt;
&lt;li style=&quot;background: url(https://www.packtpub.com/sites/all/themes/packt_v4/images/new-li-tick.png) 0px 4px no-repeat transparent; list-style-image: none; list-style-type: none; margin: 0.15em 0px 0.15em 0.5em; padding: 0px 0px 0.2em 1.5em;&quot;&gt;Understand the Windows Phone 8 development environment and gain practical experience on app development on the platform&lt;/li&gt;
&lt;li style=&quot;background: url(https://www.packtpub.com/sites/all/themes/packt_v4/images/new-li-tick.png) 0px 4px no-repeat transparent; list-style-image: none; list-style-type: none; margin: 0.15em 0px 0.15em 0.5em; padding: 0px 0px 0.2em 1.5em;&quot;&gt;Create service-oriented applications using WCF and study advanced use cases on implementing a RESTful service with WCF&lt;/li&gt;
&lt;li style=&quot;background: url(https://www.packtpub.com/sites/all/themes/packt_v4/images/new-li-tick.png) 0px 4px no-repeat transparent; list-style-image: none; list-style-type: none; margin: 0.15em 0px 0.15em 0.5em; padding: 0px 0px 0.2em 1.5em;&quot;&gt;Test your application inside Visual Studio 2013 IDE and advanced use case scenarios to handle testing issues&lt;/li&gt;
&lt;li style=&quot;background: url(https://www.packtpub.com/sites/all/themes/packt_v4/images/new-li-tick.png) 0px 4px no-repeat transparent; list-style-image: none; list-style-type: none; margin: 0.15em 0px 0.15em 0.5em; padding: 0px 0px 0.2em 1.5em;&quot;&gt;Effectively utilize the various components of Team Foundation Server for better management of code&lt;/li&gt;
&lt;li style=&quot;background: url(https://www.packtpub.com/sites/all/themes/packt_v4/images/new-li-tick.png) 0px 4px no-repeat transparent; list-style-image: none; list-style-type: none; margin: 0.15em 0px 0.15em 0.5em; padding: 0px 0px 0.2em 1.5em;&quot;&gt;Extend Visual Studio 2013 IDE to add your own custom changes enhancing your experience&lt;/li&gt;
&lt;li style=&quot;background: url(https://www.packtpub.com/sites/all/themes/packt_v4/images/new-li-tick.png) 0px 4px no-repeat transparent; list-style-image: none; list-style-type: none; margin: 0.15em 0px 0.15em 0.5em; padding: 0px 0px 0.2em 1.5em;&quot;&gt;Discover the advanced usage of cloud computing with Windows Azure and its various components&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 18px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;h2&gt;
To summarise each chapters :&amp;nbsp;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 1, A Guide to Debugging with Visual Studio&lt;/b&gt;, focuses on giving you a basic understanding of the different environments set up inside Visual Studio and deals with all the necessary tools present inside Visual Studio to help in debugging a source. This chapter clarifies the debugging procedures in detail, followed by quick and easy sample code to help find bugs.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 2, Enhancements to WCF 4.5&lt;/b&gt;, deals with the Service Oriented Architecture using WCF. This chapter gives you knowledge on common problems that a developer needs to know and provides you with sample recipes to deal with the most common problems. This chapter also gives a clear understanding on all the new features that came along with new releases.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 3, Building Touch-sensitive Device Applications Using Windows Phone 8.1&lt;/b&gt;,&lt;/div&gt;
&lt;div&gt;
provides a quick introduction on device application development with the Windows Phone environment. This chapter provides simple solutions to some of the common problems of developing a Windows Phone application.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 4, Working with Team Foundation Server&lt;/b&gt;, deals with the source control functionality using Visual Studio ALM. The chapter provides detailed, step-by-step recipes to deal with development issues using a Team Foundation Server with the configuration and easy implementation of a successful TFS Server.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 5, Testing Applications Using Visual Studio 2013&lt;/b&gt;, provides a deeper insight on testing a full-fledged application. This chapter provides all the relevant information that you need to know about testing inside Visual Studio, enabling you to write tests quickly in easy steps and a clear understanding of what is going on under the hood.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 6, Extending Visual Studio IDE&lt;/b&gt;, focuses on presenting interesting facts related to adding more functionality in Visual Studio. The need to customize Visual Studio itself is sometimes necessary to allow a developer to customize the tools inside the integrated environment. This chapter shows you points that will help in dealing with extensions on Visual Studio IDE in easy steps.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Chapter 7, Windows Azure and Cloud Computing&lt;/b&gt;, demonstrates the Microsoft implementation of cloud computing, enabling you to quickly adapt Azure in your own solution in easy steps. This chapter gives recipes to help a developer port their existing on-premise applications to the cloud.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;
What you can get ?&lt;/h2&gt;
&lt;div&gt;
First of all, don&#39;t forget to read through the first chapter, which is given for free :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h3&gt;
&lt;a href=&quot;https://www.packtpub.com/application-development/visual-studio-2013-and-net-45-expert-cookbook&quot;&gt;Sample Chapter&lt;/a&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h2&gt;
Or you can Purchase the book from :&lt;/h2&gt;
&lt;h2&gt;
Purchase this book online&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
If you are interested to purchase it online, you can get it from the following links :&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.packtpub.com/application-development/visual-studio-2013-and-net-45-expert-cookbook&quot; target=&quot;_blank&quot;&gt;Buy from packtpub.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/Visual-Studio-2013-Expert-Cookbook/dp/1849689725&quot; target=&quot;_blank&quot;&gt;Buy from Amazon.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Buy from&amp;nbsp;&lt;a href=&quot;http://www.barnesandnoble.com/w/visual-studio-2013-and-net-45-expert-cookbook-abhishek-sur/1117228690?ean=9781849689724&quot;&gt;Barnes and Noble&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h2&gt;
Write a review and get this book for free :&amp;nbsp;&lt;/h2&gt;
&lt;br /&gt;
Just like my previous book, if you are writing a review on the book, please do let me know, I can provide you a free copy of the book from my publisher. The process is :&lt;br /&gt;
&lt;br /&gt;
1. Write a review in your blog, dzone with a link to my book and send it to me.&lt;br /&gt;
2. Share the blog in Twitter and / or facebook.&lt;br /&gt;
3. Like us on&amp;nbsp;&lt;a href=&quot;http://facebook.com/dotnetbook&quot; style=&quot;background-color: white; border: 0px; color: #20328e; font-family: inherit; font-size: 15px; font-style: italic; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Facebook&lt;/a&gt;&amp;nbsp;to get more updates on the book.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #222222; font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;i&gt;Best of Luck. Have fun.&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
I am sure you will like this book. Do let me know your feedback on it. Write to me at contact@abhisheksur.com on any problem you face while reading this book.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Happy Programming !!!&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; font-family: sans-serif; font-size: 12px; line-height: 18px; list-style: none; margin: 0px; padding: 0px;&quot;&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/3951405022881819463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2014/11/net-book-visual-studio-2013-expert.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/3951405022881819463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/3951405022881819463'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2014/11/net-book-visual-studio-2013-expert.html' title='.NET Book : Visual Studio 2013 Expert Development Cookbook '/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNaWiCDyRP7B1UyyMa8F0eXqdFw9my9Xdqp6ebQuUeTUfcFQSBq53P_xsQZjxBKDIVwVeu4bNMvrd3F7BM06TBWk_Mp3gx6w8h5fvd_bZf5eV937VEa0DgRM8QVqUgBIPpqd7H5UCCS58/s72-c/9724EN_Visual+Studio+2013+and+.NET+4.5+Expert+Cookbook.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-8166352869056511176</id><published>2013-07-09T09:49:00.000+05:30</published><updated>2013-07-09T09:53:31.711+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 3.5"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.0"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.5"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CodeProject"/><category scheme="http://www.blogger.com/atom/ns#" term="MVVM"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Phone7"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows8"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>Advanced Usage of Grouping in CollectionView with ItemsPresenter</title><content type='html'>CollectionView is an object that we generally use while dealing with a collection in WPF. It is an object structure that supports a collection as well some of the inherent features which a user might always need while dealing with a collection. Some of the features like Sorting, Grouping, Filtering are automatically implemented in a CollectionView. &amp;nbsp;I have written one article on&lt;a href=&quot;http://www.abhisheksur.com/2010/08/woring-with-icollectionviewsource-in.html&quot;&gt; how to deal with CollectionView way back in Aug 2010&lt;/a&gt;&amp;nbsp;which explains almost everything you need to do while dealing with collection in WPF. But it does not give the entire story.&lt;br /&gt;
&lt;br /&gt;
Controls that can show a Collection in WPF is somehow derived from ItemsPresenter. The ItemsPresenter has a property called ItemsSource which takes an object of ICollectionView, and hence it is one of the important interfaces considered so far.&lt;br /&gt;
&lt;br /&gt;
There are some advanced scenarios where the general Grouping or sorting does not makes sense. Here in this article I am going to deal with such advanced scenarios which might be worth mentioning.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Advanced Grouping with CollectionView&lt;/h3&gt;
Groping in ICollectionView is done by adding GroupDescription. Let us consider the case with some code:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;ListCollectionView collectionView = new ListCollectionView(this.MyCollection);
collectionView.GroupDescriptions.Add(new PropertyGroupDescription(&quot;GroupProperty&quot;));
return collectionView;
&lt;/pre&gt;
&lt;br /&gt;
The ListCollectionView is an implementation of ICollectionView which allows you specify a GroupDescription on a Collection. Here in the above code, the MyCollection is an ObservableCollection that adds a GroupDescription on GroupProperty.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;public class GroupedObjects
{
&amp;nbsp; &amp;nbsp;// Other properties
&amp;nbsp; &amp;nbsp; public string GroupProperty { get; set; }
}&lt;/pre&gt;
&lt;br /&gt;
Here the GroupedObject represents each object in the collection. The GroupProperty is of type string and hence when two object has same GroupProperty value, it will be treated on the same group in the collection.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;this.MyCollection.Add(new GroupedObjects { GroupProperty = &quot;A&quot; });
this.MyCollection.Add(new GroupedObjects { GroupProperty = &quot;A&quot; });&lt;/pre&gt;
&lt;br /&gt;
For instance, the first two objects belong to the same group.&lt;br /&gt;
&lt;br /&gt;
Now when showing the Group on the ItemsPresenter, you need to show the GroupProperty in the header by defining the GroupStyle.&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&amp;lt;ListView.GroupStyle&amp;gt;
    &amp;lt;GroupStyle&amp;gt;
        &amp;lt;GroupStyle.HeaderTemplate&amp;gt;
            &amp;lt;DataTemplate&amp;gt;
                &amp;lt;TextBlock Text=&quot;{Binding Name}&quot; /&amp;gt;
            &amp;lt;/DataTemplate&amp;gt;
        &amp;lt;/GroupStyle.HeaderTemplate&amp;gt;
    &amp;lt;/GroupStyle&amp;gt;
&amp;lt;/ListView.GroupStyle&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
Here the Name property is automatically assigned to the GroupProperty value for each Group while the elements are getting added. Thus while defining GroupStyle, if you specify Binding on Name, it will show the Group header.&lt;br /&gt;
&lt;br /&gt;
Now think of a situation, where you need multiple data for a Group. The Name supports objects and hence you can specify a whole object for Name. Lets change our class a little bit.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;public class MyCustomGroup
{
&amp;nbsp; &amp;nbsp; &amp;nbsp; public string Type { get; set; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; public string DisplayText {get; set;}
}
public class GroupedObjects
{
&amp;nbsp; &amp;nbsp; &amp;nbsp;public string Item {get; set;}
&amp;nbsp; &amp;nbsp; &amp;nbsp;public MyCustomGroup {get;set;}
}&lt;/pre&gt;
&lt;br /&gt;
Here the MyCustomGroup defines the group of GroupedObjects. Hence if you specify MyCustomGroup in properties, it will assign the whole MyCustomGroup to the Name property of the Style. You can easily define the GroupStyle like this :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&amp;lt;ListView.GroupStyle&amp;gt;
    &amp;lt;GroupStyle&amp;gt;
        &amp;lt;GroupStyle.HeaderTemplate&amp;gt;
            &amp;lt;DataTemplate&amp;gt;
&amp;lt;StackPanel Orientation=&quot;Horizonta&quot;&amp;gt;
                     &amp;lt;TextBlock Text=&quot;{Binding Name.Type}&quot; /&amp;gt;
                     &amp;lt;TextBlock Text=&quot;{Binding Name.DisplayText&quot; /&amp;gt;
               &amp;lt;/StackPanel&amp;gt;
            &amp;lt;/DataTemplate&amp;gt;
        &amp;lt;/GroupStyle.HeaderTemplate&amp;gt;
    &amp;lt;/GroupStyle&amp;gt;
&amp;lt;/ListView.GroupStyle&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
Here the Name holds the entire object and the properties can be evaluated. But how does it then determine the equality of the Groups ? Well, the PropertyGroupDescription calls the Equals method on Group each time the item is evaluated. So if you override equals and return boolean based on the actual group, it can easily determine the group.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;public class MyCustomGroup
{
&amp;nbsp; &amp;nbsp; &amp;nbsp; public string Type { get; set; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; public string DisplayText {get; set;}
      public override bool Equals(object obj)
      {
         var groupdata = obj as MyCustomGroup;
        return this.Type.Equals(groupData.Type);&lt;/pre&gt;
&lt;pre&gt;      }
}&lt;/pre&gt;
Here the Equals is called to determine the equality of two MyCustomGroup objects. Implementing this will do the job.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Moving the Group Equality to another method than Equals&lt;/h4&gt;
Sometimes, in advanced scenarios, you might also wonder how to deal the equality of Group in a separate method when the actual Equals method is used somewhere else in your framework. You could do that by inheriting the PropertyGroupDescription class and create an own implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;public class MyCustomGroup
{
&amp;nbsp; &amp;nbsp; &amp;nbsp; public string Type { get; set; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; public string DisplayText {get; set;}
     public override bool Equals(object obj)
      {
         var groupdata = obj as MyCustomGroup;
        return this.DisplayText.Equals(groupData.DisplayText);
      }
      public bool GroupEquals(object obj)
      {
         var groupdata = obj as MyCustomGroup;
        return this.Type.Equals(groupData.Type);
      }
}&lt;/pre&gt;
Consider the class MyCustomGroup, it already have an Equals operator implemented which equates DisplayText. There is a separate method called GroupEquals which needed to be used while equating groups. Here is what you need to do :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;   public class MyGroupDescription : PropertyGroupDescription
    {
        public MyGroupDescription(string groupName) : base(groupName) { }
        public override bool NamesMatch(object thisgroup, object othergroup)
        {
            var groupdata = thisgroup as MyCustomGroup;
            return groupdata.GroupEquals(othergroup);
        }
    }
&lt;/pre&gt;
Here we have derived the PropertyGroupDescription and overridden the NamesMatch which in turn calls the Equals operator on the object. We rather redirected the same to GroupEquals instead. &amp;nbsp;You can even inherit from abstract type GroupDescription while in that case, you will have responsibility to override GroupNameForItem as well. The GroupNameForItem has responsibility to determine the Group object for an item.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Conclusion&lt;/h3&gt;
&lt;br /&gt;
Generally, &lt;a href=&quot;http://www.abhisheksur.com/2010/08/woring-with-icollectionviewsource-in.html&quot;&gt;Grouping an ICollectionView&lt;/a&gt; is rather very easy to implement, until when I struck into a situation where I needed to implement grouping all myself. I tried to search over internet and found no good link which explains the entire story. I hope in case of need for advanced grouping, you can still make use of ICollectionView in WPF rather than moving in wrong direction. I hope you will find this post handy.&lt;br /&gt;
&lt;br /&gt;
Thank you for reading.&lt;br /&gt;
&lt;br /&gt;
Happy programming.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/8166352869056511176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2013/07/advanced-usage-of-grouping-in.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/8166352869056511176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/8166352869056511176'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2013/07/advanced-usage-of-grouping-in.html' title='Advanced Usage of Grouping in CollectionView with ItemsPresenter'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-6022709299066543295</id><published>2013-06-24T04:30:00.003+05:30</published><updated>2013-06-28T18:47:11.604+05:30</updated><title type='text'>Windows Phone 7.5 and F# - A book in the market</title><content type='html'>Hi Friends,&lt;br /&gt;
&lt;br /&gt;
I am excited to announce that one of my friend cum MVP (Lohith) has written a pretty nice book on Windows Phone 7.5 using F# recently. I have given an honor to read the book from PacktPub and wanted to write a review of the same today.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter wise review :&amp;nbsp;&lt;/h3&gt;
&lt;br /&gt;
&lt;b&gt;1. Setting Up Windows Phone Development with F#.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This chapter gives an insight on Windows Phone and gives you an introduction on how to setup Windows Phone Development using F#.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2. F# Windows Phone Project Overview&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This chapter demonstrates about Windows Phone Projects and creates a simple project using the Project templates.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3. Working with Windows Phone Controls&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This chapter gives insights on some of the common controls that you might use while developing day to day applications in Windows Phone. It also makes you familiar with F# language syntaxes as you go ahead and create the applications yourself.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;4. &amp;nbsp;Windows Phone Screen Orientations&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Screen orientations is a feature of any smart devices nowadays. This chapter gives an introduction on how screen orientation works in Windows Phone and creates applications that respond to Orientation changes.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;5. Windows Phone Gesture Events&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
A number of gestures discussed which are commonly used and created an application that responds to gestures.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;6. Windows Phone Navigation&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Navigation between different pages in Windows Phone is tricky. This chapter discusses some of the good ways of navigation between pages inside an app. The chapter clearly demonstrates the navigation techniques with the help of sample applications in this chapter.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;7. Windows Phone and Data Access&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Isolated Storage is one of the basic storage in Windows Phone. This chapter demonstrates how to use Isolated storage to store data inside an app. The author guides you with a simple application that can store and then retrieve the data stored in Isolated storage.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;8. Launchers and Choosers&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The chapter demonstrates various Launchers and Choosers in the application and gives sample code on how to use each of them.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;9. Windows Phone Sensors&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Any Windows Phone device you own will have multiple sensors associated with it. The Chapter demonstrates how to use Windows Phone Sensors inside your application with Sample code.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Conclusion&lt;/h3&gt;
Overall, I like this book. Even though the book is for beginners, but it hits all the major parts and parcels of the code. It does not target to make you understand F# as a language, but it will get you through with building applications using F#. I would recommend this book if you want to build Windows Phone Applications using F#.&lt;br /&gt;
&lt;br /&gt;
Links&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; list-style-type: circle; margin: 15px 0px 15px 20px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; line-height: 1.5em; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://bit.ly/11fSTU4&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Buy from packtpub.com&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; line-height: 1.5em; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://www.amazon.com/dp/1849687846/?tag=packtpubli-20&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Buy from Amazon.com&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; line-height: 1.5em; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Buy from&amp;nbsp;&lt;a href=&quot;http://www.amazon.co.uk/dp/1849687846/?tag=packtpubli-21&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;Amazon.UK&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
Thank you.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/6022709299066543295/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2013/06/windows-phone-75-and-f-book-in-market.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/6022709299066543295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/6022709299066543295'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2013/06/windows-phone-75-and-f-book-in-market.html' title='Windows Phone 7.5 and F# - A book in the market'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-3481647213948619953</id><published>2013-05-06T01:37:00.000+05:30</published><updated>2013-05-26T01:26:59.576+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.5"/><category scheme="http://www.blogger.com/atom/ns#" term="book"/><category scheme="http://www.blogger.com/atom/ns#" term="CodeProject"/><category scheme="http://www.blogger.com/atom/ns#" term="cookbook"/><category scheme="http://www.blogger.com/atom/ns#" term="free"/><category scheme="http://www.blogger.com/atom/ns#" term="gift"/><category scheme="http://www.blogger.com/atom/ns#" term="giveaways"/><title type='text'>Want a copy of Visual Studio 2012 and .NET 4.5 Expert Cookbook for free in simple steps?</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Visual Studio 2012 and .NET 4.5 Expert Development cookbook is your ready-made reference to all the problems we face while working with Visual Studio and .NET 4.5. It gives you explicit references to some of the interesting topics that as a developer you always wanted to master or want to collect and store securely so that it is available to you just the time when needed. It has been my honor to put up such important things into one book and make you understand development better.&amp;nbsp;&lt;/div&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #222222; font-family: MuseoSans500, Helvetica, Arial, Verdana, Tahoma, sans-serif; font-size: 21px; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizelegibility; vertical-align: baseline;&quot;&gt;
To give you some instances :&amp;nbsp;&lt;/h3&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin: 15px 0px 15px 20px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Internals of .NET Memory Management and Garbage Collection Techniques.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Solution to 10 common mistakes made by developers while writing code&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Securing code from reverse engineering using Obfuscation&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Writing Multi-threaded application more quickly and easily.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Working with Performance boosters in ASP.NET Web Applications.&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;HTML5 and CSS3&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Write enhanced application in MVVM model.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Building Applications using WinJS and XAML in Windows 8&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Enable Push notification to update Tiles, Toast, Batch notifications of your Windows 8 Applications&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;And many more like this ...&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px;&quot;&gt;I am overwhelmed to receive great responses for my articles on&lt;/span&gt;&lt;a href=&quot;http://www.abhisheksur.com/2011/03/internals-to-net.html&quot; style=&quot;background-color: white; border: 0px; color: #20328e; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;&amp;nbsp;&quot;Internals of .NET&quot;&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px;&quot;&gt;&amp;nbsp;&amp;nbsp;on my blog but I wrote this book in such a way so that you can take most out of the under the hood items of Language and CLR and use those skills while writing or architecting your own application. &amp;nbsp;This is reference book only for developers and experts with more emphasis given on practicals rather than the theory.&amp;nbsp; To know more about the book you can go to the&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.packtpub.com/visual-studio-11-and-dotnet-4-5-expert-development-cookbook/book&quot; style=&quot;background-color: white; border: 0px; color: #20328e; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;publisher site using this link&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px;&quot;&gt;&amp;nbsp;. Moreover, I remember of putting up a draft&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://www.abhisheksur.com/2013/04/net-book-visual-studio-2012-and-net-45.html&quot; style=&quot;background-color: white; border: 0px; color: #20328e; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;about the book as well on my blog&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px;&quot;&gt;&amp;nbsp;&amp;nbsp;which you can try for more knowledge. &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 22px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; color: #222222; font-family: MuseoSans500, Helvetica, Arial, Verdana, Tahoma, sans-serif; font-size: 23px; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizelegibility; vertical-align: baseline;&quot;&gt;
I want to win a free copy!&lt;/h2&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px;&quot;&gt;As you know I am very much active in the community and love to share my knowledge with the .NET community, it is my pleasure to announce that you can win a copy of this book for free. There are 3 copies of the book to be won from here. All you have to do is :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;ol style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin: 15px 0px 15px 20px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Leave a comment down below with the reason why you should be the lucky winner. Write on the topic &quot;why you would like to win this book&quot;.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Share this post on&amp;nbsp;&lt;a href=&quot;http://www.facebook.com/sharer.php?u=http://dotnet.dzone.com/articles/want-free-copy-visual-studio&amp;amp;t=Check%20out%20this%20free%20giveaways,%20do%20not%20miss!!&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Facebook&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;http://twitter.com/intent/tweet?url=http://dotnet.dzone.com/articles/want-free-copy-visual-studio&amp;amp;hashtags=csharp,dotnet,book,giveaways,winrt&amp;amp;text=Win%20a%20free%20Visual%20Studio%202012%20and%20.NET%204.5%20Expert%20Cookbook!&amp;amp;via=abhi2434&amp;amp;related=abhi2434&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Twitter&lt;/a&gt;&amp;nbsp;with a mention to&amp;nbsp;&lt;a href=&quot;http://twitter.com/abhi2434&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;&quot;&gt;@abhi2434&lt;/a&gt;&amp;nbsp;&amp;nbsp;(my twitter handle) so that I can have a count on them, the more is the count, the more will be your chances.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Like us on&amp;nbsp;&lt;a href=&quot;http://facebook.com/dotnetbook&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Facebook&amp;nbsp;&lt;/a&gt;&amp;nbsp;to get more updates on the book.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;b&gt;The best motivation wins&lt;/b&gt;&amp;nbsp;and the winner will be notified through email. So be sure to leave any reference of your contact (like facebook url, twitter or anything you feel safe, so that we can contact you).&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Thats it ... Good Luck to you all !!!.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;i&gt;&lt;b&gt;The Contest ends on 1st June 2013 ( 6 AM PST) and winners will be contacted and published within 3 days from that.&amp;nbsp;&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;i&gt;&lt;b&gt;So hurry up!!&amp;nbsp;Don&#39;t&amp;nbsp;miss the opportunity.&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;http://www.packtpub.com/visual-studio-11-and-dotnet-4-5-expert-development-cookbook/book&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;Visual Studio 2012 and .NET 4.5 Expert Development Cookbook&quot; src=&quot;http://dotnet.dzone.com/sites/all/files/6709EN.jpg&quot; style=&quot;border: 0px; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot; /&gt;&lt;/a&gt;&lt;i&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; color: #222222; font-family: MuseoSans500, Helvetica, Arial, Verdana, Tahoma, sans-serif; font-size: 23px; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizelegibility; vertical-align: baseline;&quot;&gt;
What else to win from the same contest?&amp;nbsp;&lt;/h2&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Well, as a matter of fact, we have decided to give away some additional things with the Book. Here is some of the additional gifts that we are going to provide to the winners.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin: 15px 0px 15px 20px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b&gt;One T-Shirt for every winner&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b&gt;One USB Flash drive.&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b&gt;One big poster with .NET architecture printed for reference.&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b&gt;One Pen + Pad which suits your desktop.&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b&gt;1 free license to either &lt;a href=&quot;http://rd.gt/Z50RQi&quot;&gt;.NET Reflector, SmartAssembly or ANTS Memory Profiler from&amp;nbsp;&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://rd.gt/Z50RQi&quot; imageanchor=&quot;1&quot; rel=&quot;nofollow&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;111&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD9eVpnNUgSoTREQhPVNUm-BX_HQ6BvX8zZM-Xo7xN6yyJ_ENKsk1RsjDgFlgBklXFQNjT8VrZs7bJu5cyH2civ9C0SoBU0Cg_KCuw2Nt4gcF5A2u0h8HgAzLvCPACcCT5ZN70pSFZndc/s320/RGLogo_SimpleTools_OnWhite_RGB.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b style=&quot;background-color: white; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px;&quot;&gt;So Hurry !!! Don&#39;t miss this opportunity.&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/div&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #222222; font-family: MuseoSans500, Helvetica, Arial, Verdana, Tahoma, sans-serif; font-size: 21px; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizelegibility; vertical-align: baseline;&quot;&gt;
Who is this book for ?&amp;nbsp;&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #222222; font-family: Helvetica, arial, verdana;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 22px;&quot;&gt;This book is aimed at Visual Studio 2012 and .Net developers who want to gain advanced understanding and sharpen their existing&amp;nbsp;skill sets&amp;nbsp;and adapt to new .NET technologies. Basic understanding of .NET and C# is assumed. The purpose of this book is to give under the hood expertise in .NET and help you to face common problems on latest technologies.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Visual Studio 2012 and .NET 4.5 Expert Development Cookbook&amp;nbsp; is a step-by-step tutorial providing Visual Studio 2012 and .Net developers with useful techniques to develop the latest .NET technologies using Visual Studio 2012.&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px;&quot;&gt;This book covers all the essential areas of Visual Studio 2012 IDE and delves into step-by-step instructions that highlights various techniques to build, design, asynchronous better multithreaded applications using recent updates on .NET 4.5 and learn better ways to create secure ASP.NET web based applications in .NET 4.5 using JQuery and HTML5.&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #222222; font-family: MuseoSans500, Helvetica, Arial, Verdana, Tahoma, sans-serif; font-size: 21px; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizelegibility; vertical-align: baseline;&quot;&gt;
I can&#39;t wait and want to buy a copy now !&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin-bottom: 1.2em; margin-top: 0.6em; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Well, thank you so much for your support. Below are the links that would help you buy this book.&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px; margin: 15px 0px 15px 20px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://www.packtpub.com/visual-studio-11-and-dotnet-4-5-expert-development-cookbook/book&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Buy from packtpub.com&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://www.amazon.com/dp/184968670X/?tag=packtpubli-20&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Buy from Amazon.com&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Buy from&amp;nbsp;&lt;a href=&quot;http://www.amazon.co.uk/dp/184968670X/?tag=packtpubli-21&quot; style=&quot;border: 0px; color: #20328e; font-family: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;Amazon.UK&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Helvetica, arial, verdana; font-size: 15px; line-height: 22px;&quot;&gt;You can also try Ebook version in PDF, Mobi, EPub formats.&amp;nbsp; Thank you.&amp;nbsp;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/3481647213948619953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2013/05/want-copy-of-visual-studio-2012-and-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/3481647213948619953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/3481647213948619953'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2013/05/want-copy-of-visual-studio-2012-and-net.html' title='Want a copy of Visual Studio 2012 and .NET 4.5 Expert Cookbook for free in simple steps?'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD9eVpnNUgSoTREQhPVNUm-BX_HQ6BvX8zZM-Xo7xN6yyJ_ENKsk1RsjDgFlgBklXFQNjT8VrZs7bJu5cyH2civ9C0SoBU0Cg_KCuw2Nt4gcF5A2u0h8HgAzLvCPACcCT5ZN70pSFZndc/s72-c/RGLogo_SimpleTools_OnWhite_RGB.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-6134463480917742725</id><published>2013-04-21T04:08:00.000+05:30</published><updated>2013-05-06T01:54:17.292+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET infrastructure"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET Memory Management"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net4.5"/><category scheme="http://www.blogger.com/atom/ns#" term="async"/><category scheme="http://www.blogger.com/atom/ns#" term="book"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CodeProject"/><category scheme="http://www.blogger.com/atom/ns#" term="cookbook"/><category scheme="http://www.blogger.com/atom/ns#" term="html5"/><category scheme="http://www.blogger.com/atom/ns#" term="internals"/><category scheme="http://www.blogger.com/atom/ns#" term="jquery"/><category scheme="http://www.blogger.com/atom/ns#" term="multithreading"/><category scheme="http://www.blogger.com/atom/ns#" term="MVVM"/><category scheme="http://www.blogger.com/atom/ns#" term="push technology"/><category scheme="http://www.blogger.com/atom/ns#" term="TPL"/><category scheme="http://www.blogger.com/atom/ns#" term="TPL Data Flows"/><category scheme="http://www.blogger.com/atom/ns#" term="VS2012"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows8"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>.NET Book : Visual Studio 2012 and .NET 4.5 Expert Development Cookbook (Must Read)</title><content type='html'>Friends,&lt;br /&gt;
&lt;br /&gt;
It is my great honor to tell you that my book has finally been released this week. If you have ever liked any of my blogs or internals, you would like this book for sure. There are lot of things to learn from the book and I can assure you that you wont be upset with this book if you buy it.&lt;br /&gt;
&lt;br /&gt;
The &lt;a href=&quot;http://www.packtpub.com/visual-studio-11-and-dotnet-4-5-expert-development-cookbook/book&quot; target=&quot;_blank&quot;&gt;&quot;Visual Studio 2012 and .NET 4.5 Expert Development Cookbook&quot;&lt;/a&gt;&amp;nbsp;is a book that guides you through steps to ensure you enrich the best experience with the latest technology in the best amount of time possible. The book focusses to give you under the hood expertise in .NET technologies it tends to cover and adapts you the best to face common problems of these technologies. The book is divided in forms of&amp;nbsp;recipes. Each of these recipes gives you clear insight of the problem and step by step process to solve the issue practically. It also addresses the advanced features associated with each of those recipes that gives you additional advantage on getting precise knowledge about the problem and its associated issues.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjVCRJ-qsbvR-QWDKi8GSvFxQvCzTS2-Xmx0rBe6TXU5RxQNaI7nKU9N7aThTQYogZiEYqzCX6u4nMdfx1JzkrY35OXakOmE6eVE9wfGuvrh6hRkRqbb50p4VINcXYSBajZcg-PtQdZKs/s1600/2-19-2013+11-53-20+AM.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjVCRJ-qsbvR-QWDKi8GSvFxQvCzTS2-Xmx0rBe6TXU5RxQNaI7nKU9N7aThTQYogZiEYqzCX6u4nMdfx1JzkrY35OXakOmE6eVE9wfGuvrh6hRkRqbb50p4VINcXYSBajZcg-PtQdZKs/s320/2-19-2013+11-53-20+AM.png&quot; width=&quot;259&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3&gt;
What you will learn from this book&lt;/h3&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;background-color: white; border: 0px; font-family: sans-serif; font-size: 12px; line-height: 18px; list-style: none; margin: 0px; padding: 0px;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; list-style-image: url(http://dgdsbygo8mp3h.cloudfront.net/sites/default/files/new-design-assets/orange-bullet.png); list-style-type: disc; margin: 0px 0px 0px 2em; padding: 0px;&quot;&gt;Basic usage of Visual Studio 2012 IDE and its various components and better utilization of the tool while writing code&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; list-style-image: url(http://dgdsbygo8mp3h.cloudfront.net/sites/default/files/new-design-assets/orange-bullet.png); list-style-type: disc; margin: 0px 0px 0px 2em; padding: 0px;&quot;&gt;Understand memory management techniques to build better applications&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; list-style-image: url(http://dgdsbygo8mp3h.cloudfront.net/sites/default/files/new-design-assets/orange-bullet.png); list-style-type: disc; margin: 0px 0px 0px 2em; padding: 0px;&quot;&gt;Understand the .NET infrastructure with in-depth analysis of its internals&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; list-style-image: url(http://dgdsbygo8mp3h.cloudfront.net/sites/default/files/new-design-assets/orange-bullet.png); list-style-type: disc; margin: 0px 0px 0px 2em; padding: 0px;&quot;&gt;Architect solutions that leverage the full power of .NET language gems, understanding when to use what&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; list-style-image: url(http://dgdsbygo8mp3h.cloudfront.net/sites/default/files/new-design-assets/orange-bullet.png); list-style-type: disc; margin: 0px 0px 0px 2em; padding: 0px;&quot;&gt;Implement multithreaded / asynchronous applications using recent updates on .NET 4.5 and compare the past approaches&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; list-style-image: url(http://dgdsbygo8mp3h.cloudfront.net/sites/default/files/new-design-assets/orange-bullet.png); list-style-type: disc; margin: 0px 0px 0px 2em; padding: 0px;&quot;&gt;Create secure ASP.NET web based applications in .NET 4.5 with use of JQuery and HTML5 for rapid application development&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; list-style-image: url(http://dgdsbygo8mp3h.cloudfront.net/sites/default/files/new-design-assets/orange-bullet.png); list-style-type: disc; margin: 0px 0px 0px 2em; padding: 0px;&quot;&gt;Architect advanced .NET client applications using MVVM with WPF 4.5&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: 1.5em; list-style-image: url(http://dgdsbygo8mp3h.cloudfront.net/sites/default/files/new-design-assets/orange-bullet.png); list-style-type: disc; margin: 0px 0px 0px 2em; padding: 0px;&quot;&gt;Understand touch sensitive devices and leverage skills to develop multi-touch applications inside Windows 8&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
To summarise each chapters :&amp;nbsp;&lt;/h2&gt;
&lt;b&gt;Chapter 1 : Introduction to Visual Studio IDE Features &lt;a href=&quot;http://www.packtpub.com/sites/default/files/9781849686709_Chapter_01.pdf?utm_source=packtpub&amp;amp;utm_medium=free&amp;amp;utm_campaign=pdf&quot; target=&quot;_blank&quot;&gt;(Download this chapter for free)&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
It starts with a basic introduction to Visual Studio IDE and gives the developer insights into how to increase productivity of development &amp;nbsp;using a common set of tools and features present inside the IDE&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Chapter 2 :&amp;nbsp;Basics of .NET Programs and Memory Management&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This chapter introduces the intersection of a .NET program and its core components. It dives deep in demonstrating the .NET infrastructure with detailed explanation of memory management and related techniques. It also covers the internals of .NET and understand some of the few great features that you might never came across.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Chapter 3 : Asynchronous Programming in .NET&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The chapter focuses on introducing all existing techniques to deal with threading in .NET followed by the newer patterns that takes over the existing working principles with in-depth explanation on their working principles.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Chapter 4 : Enhancements to ASP.NET&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The chapter gives you an introduction to latest enhancements of &amp;nbsp;ASP.NET 4.5 with HTML5 and jQuery. It also introduces some of the performance boosters available in .NET 4.5 and Visual Studio 2012 with ASP.NET.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Chapter 5 : Enhancements to WPF&lt;/b&gt;&lt;br /&gt;
It introduces the enhancements to WPF 4.5 and the major components of WPF. It gives a practical implementation of MVVM based WPF application covering all the facets required to program in WPF environment.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Chapter 6 : Building Touch-sensitive Device Applications in Windows 8&lt;/b&gt;&lt;br /&gt;
The chapter introduces the new programming model for developing Windows 8 style tiles application. It gives a step-by-step introduction in how to program using HTML5 and JavaScript as well as WPF and C# for developing Windows 8 applications.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Chapter 7 : Communication and Sharing Using Windows 8&lt;/b&gt;&lt;br /&gt;
It focuses on how to implement network-enabled applications in Windows 8 with step by step implementation on how sharing and searching works inside the Windows 8 environment.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Appendix : .NET languages and its Construct&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
It focuses on giving insights on how languages work in the .NET framework and C# with details explanation with examples of various features of C# language.&lt;br /&gt;
&lt;br /&gt;
You can download this Appendix from &lt;a href=&quot;http://www.packtpub.com/sites/default/%20files/downloads/6709EN_Appendix_NET_Languages_and_its_Construct.pdf&quot; target=&quot;_blank&quot;&gt;http://www.packtpub.com/sites/default/&lt;/a&gt;&lt;a href=&quot;http://www.packtpub.com/sites/default/%20files/downloads/6709EN_Appendix_NET_Languages_and_its_Construct.pdf&quot; target=&quot;_blank&quot;&gt;files/downloads/6709EN_Appendix_NET_Languages_and_its_Construct.pdf&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Working with a varied set of upcoming technologies is a challenge. Visual Studio 2012 is all about enabling you to develop and manage these consumer-focused and business-focused apps. It provides best-in-class tools that propel developers to create new apps or evolve existing ones, and it enables individuals and teams to deliver continuous value and agility. In conjunction, .NET 4.5 provides expansive capabilities for developers to work on all forms of apps and services, from client to mobile to web to cloud, enabling them to get to the market fast. This book shows you exactly how to do this, and much more. It focuses on giving expertise on upcoming technologies through complete architectural insights of .NET infrastructure and hands on examples.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;a href=&quot;http://www.packtpub.com/visual-studio-11-and-dotnet-4-5-expert-development-cookbook/book&quot; target=&quot;_blank&quot;&gt;&quot;Visual Studio 2012 and .NET 4.5 Expert Development Cookbook&quot;&lt;/a&gt; is a step-by-step practical guide that teaches you how to work with new changes on technology under .NET. It provides in-depth analysis and expert advice on various elements of .NET, applying them in code using detailed practical examples. The book provides solutions to common development problems and helps you adapt to the latest technologies and get to grips with modern app development for the .NET 4.5 platform.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;a href=&quot;http://www.packtpub.com/visual-studio-11-and-dotnet-4-5-expert-development-cookbook/book&quot; target=&quot;_blank&quot;&gt;This cookbook&lt;/a&gt; gets you started on Visual Studio 2012 IDE and its various tooling capabilities. It provides expert knowledge on .NET infrastructure, internals of assemblies, and a basic introduction of Intermediate language. Common C# concepts and ideas are demonstrated through an example-driven approach.&lt;br /&gt;
&lt;br /&gt;
The recipes provide an overall view of ASP.NET Web applications and introduce the new performance boosters in .NET 4.5. It also gives a basic introduction to HTML 5 and JQuery library to enhance Web applications. It provides a complete introduction to Client applications using WPF and MVVM patterns and looks at some of the major enhancements on WPF 4.5. It shows you how to write applications for Windows 8 and provides expert advice on how to write applications in WinRT, either using XAML and C# or HTML/JavaScript.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.packtpub.com/visual-studio-11-and-dotnet-4-5-expert-development-cookbook/book&quot; target=&quot;_blank&quot;&gt;&quot;Visual Studio 2012 and .NET 4.5 Expert Development Cookbook&quot;&lt;/a&gt; gives you better understanding of&amp;nbsp; overall .NET infrastructure using the latest technology updates, providing a broad guide for a basic developer to become an expert on .NET.
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Finally, I have written this book to give you clear insights on the ongoing problems and changing technologies. People liked me before when I was presenting problems in my blog, I have kept the same approach on this book and I am sure as a reader I can justice your time from this book.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;
Purchase this book online&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If you are interested to purchase it online, you can get it from the following links :&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.packtpub.com/visual-studio-11-and-dotnet-4-5-expert-development-cookbook/book&quot; target=&quot;_blank&quot;&gt;Buy from packtpub.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/dp/184968670X/?tag=packtpubli-20&quot; target=&quot;_blank&quot;&gt;Buy from Amazon.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Buy from&amp;nbsp;&lt;a href=&quot;http://www.amazon.co.uk/dp/184968670X/?tag=packtpubli-21&quot;&gt;Amazon.UK&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
I am sure you will like this book. Do let me know your feedback on it. Write to me at contact@abhisheksur.com on any problem you face while reading this book.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Happy Programming !!!&amp;nbsp;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/6134463480917742725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2013/04/net-book-visual-studio-2012-and-net-45.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/6134463480917742725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/6134463480917742725'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2013/04/net-book-visual-studio-2012-and-net-45.html' title='.NET Book : Visual Studio 2012 and .NET 4.5 Expert Development Cookbook (Must Read)'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjVCRJ-qsbvR-QWDKi8GSvFxQvCzTS2-Xmx0rBe6TXU5RxQNaI7nKU9N7aThTQYogZiEYqzCX6u4nMdfx1JzkrY35OXakOmE6eVE9wfGuvrh6hRkRqbb50p4VINcXYSBajZcg-PtQdZKs/s72-c/2-19-2013+11-53-20+AM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-4632605116201792960</id><published>2013-02-17T22:50:00.000+05:30</published><updated>2013-02-17T22:50:26.513+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="gesture"/><category scheme="http://www.blogger.com/atom/ns#" term="kinect"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>A new book on Kinect by Abhijit Jana - A must read</title><content type='html'>Kinect is one of the revolutionary device that were introduced lately in Microsoft ecosystem. The use of Kinect devices has increased in great extend in recent times and people are using it more and more in their day to day life. The use of Kinect is not only limited only with the gaming world, but its use is now widely spread over commercial applications too. Microsoft has released the &lt;b&gt;&lt;a href=&quot;http://www.microsoft.com/en-us/kinectforwindows/&quot; target=&quot;_blank&quot;&gt;Kinect SDK&lt;/a&gt;&lt;/b&gt; that can interact with the hardware and program on them. It is a kind of Fun working with Kinect and also writing small applications for it.&lt;br /&gt;
&lt;br /&gt;
Recently I have read a book on &quot;&lt;a href=&quot;http://www.packtpub.com/kinect-for-windows-software-development-kit-programming-guide/book&quot; target=&quot;_blank&quot;&gt;Kinect for Windows SDK Programming Guide&lt;/a&gt;&quot; by &lt;a href=&quot;http://abhijitjana.net/&quot; target=&quot;_blank&quot;&gt;Abhijit Jana&lt;/a&gt;. It is a book with great details about&lt;b&gt;&lt;a href=&quot;http://www.microsoft.com/en-us/kinectforwindows/&quot; target=&quot;_blank&quot;&gt; Kinect SDK&lt;/a&gt;&lt;/b&gt; and the Hardware. I enjoyed reading this book and thought of sharing my&amp;nbsp;experiences&amp;nbsp;with you such that if you are new in Kinect and want to write code on it, you might find this review helpful.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a class=&quot;lightbox-processed&quot; href=&quot;http://www.packtpub.com/sites/default/files/2380OT.jpg&quot; rel=&quot;lightbox[images]&quot; style=&quot;background-color: white; border: 0px; color: #f68c23; font-family: sans-serif; font-size: 12px; font: inherit; line-height: 18px; margin: 0px auto; padding: 0px; text-align: center; text-decoration: initial;&quot; title=&quot;Kinect for Windows SDK Programming Guide&quot;&gt;&lt;img alt=&quot;Kinect for Windows SDK Programming Guide&quot; class=&quot;bookimage&quot; src=&quot;http://dgdsbygo8mp3h.cloudfront.net/sites/default/files/imagecache/productview_larger/2380OT.jpg&quot; style=&quot;border: 0px; font-size: 12px; font: inherit; margin: 0px; padding: 0px; vertical-align: bottom;&quot; title=&quot;Kinect for Windows SDK Programming Guide&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Kinect for Windows SDK Programming Guide by Abhijit Jana&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 1&lt;/h3&gt;
The book starts with the basic introduction to the evolution of the device, introduction of&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Natural_user_interface&quot; target=&quot;_blank&quot;&gt;Natural User Interface&lt;/a&gt;&amp;nbsp;and the differences of the Kinect device and Xbox platform. It then take us further introducing each and every component of the device and makes the hardware introduction ready. It is always good to know about the hardware components before going further with the SDK and programming interfaces. It seems this book has taken care of these details correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 2&amp;nbsp;&lt;/h3&gt;
As we are kind of already get a basic introduction of Hardware, the book goes on to do the same with the software components and the &lt;a href=&quot;http://www.microsoft.com/en-us/kinectforwindows/&quot; target=&quot;_blank&quot;&gt;Kinect SDK&lt;/a&gt;. In this chapter the author clearly introduces how to use the SDK, what are the&amp;nbsp;components&amp;nbsp;we need to install to correctly communicate windows with the hardware. I should also mention, this chapter also introduces some other software tools which might come handy while doing the development. The chapter also introduces the features of Kinect device in short paragraphs to get things really started.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 3&amp;nbsp;&lt;/h3&gt;
&lt;br /&gt;
The real start of writing something is here. I like this chapter because it introduces the SDK by explaining each and every step correctly, such that if you are a beginner, you can start along to build this Infobox. Even Kinect SDK is so simple laid out, it is really fun and simple to create application using it. BTW, it uses WPF to design the sample, that might sometimes challenging. Well, if you want to learn WPF, &lt;a href=&quot;http://www.abhisheksur.com/2010/12/wpf-tutorial.html&quot; target=&quot;_blank&quot;&gt;I will encourage to read this&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 4&lt;/h3&gt;
&lt;br /&gt;
This chapter introduces Kinect Camera. It introduces how to retrieve color stream and processing it into a ImageControl. Here you will understand how you can stream the RGB set on the canvas and also save pictures form it. It also introduces how to change the elevation of Camera, putting effects on stream, inverting color and everything about camera elegantly. Overall this chapter will give you a good insight on the Camera API.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 5&lt;/h3&gt;
This chapter is about depth mapping. The Kinect sensor provides Depthstream channels which can be utilized to create responding apps. This chapter gives an insight on how to utilize depth camera to determine the position of an object. The application looks cool to me.&lt;br /&gt;
&lt;br /&gt;
Depth masking is one of the most interesting thing in Kinect. The chapter proves to be good one to introduce the various tricks to handle the depth of an object projected on camera.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 6&lt;/h3&gt;
&lt;br /&gt;
Well, probably now as we know everything in Kinect, it comes with something really constructive. This chapter introduces Skeleton Tracking. I must thank Microsoft to have SkeletonStream inbuilt on the SDK and also the Author to introduce and present it beautifully.&lt;br /&gt;
&lt;br /&gt;
Again, this chapter creates a simple application to detect each section of the skeleton. I really enjoyed to track certain Joints on the skeleton while building this application and playing around with JointCollection in real time with the device.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 7&lt;/h3&gt;
&lt;br /&gt;
Well Chapter 7 is regarding the Microphone present in Kinect device. This is more like basic application development to explore sound API on Kinect device.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 8&lt;/h3&gt;
As Chapter 7 being more on introductory level, I got really excited when I read Chapter 8. This chapter introduces Speech Recognisation. I know I did some speech recognisation applications before, but using Kinect, it is unique and exciting. &amp;nbsp;Speech Recognisation works well with Kinect and built a solid application using this chapter is fun.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 9&lt;/h3&gt;
&lt;br /&gt;
Gesture&amp;nbsp;recognition. Well, Its another interesting chapter where I learnt how to detect various gesture of a man, like clapping, moving hand etc. Funda is quite simple, you need to play around with the distance between joints. The idea will be much more clear if you can read this chapter. The chapter also builds up a gesture detection engine, which is what really interesting here, in this chapter.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 10&lt;/h3&gt;
&lt;br /&gt;
Finally it is time to interact with multiple kinect devices. I am yet to read this chapter, but as per I saw, it detects all the devices connected with a machine and combines the streams of all of them into a single application.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Chapter 11&lt;/h3&gt;
&lt;br /&gt;
Chapter 11 is one of the most interesting chapter where client server interaction is shown. It works with Augmented reality, Face tracking system etc.&lt;br /&gt;
&lt;br /&gt;
That&#39;s all. Now after reading the whole book, I am very confident to start writing my own real world application using Kinect device. I will share more of Kinect when I build one myself.&lt;br /&gt;
&lt;br /&gt;
After you read this book, probably you would be more inclined towards utilizing what you have learned from here. The trends currently show we are moving towards more touch/gesture sensitive UI in future. Kinect is the future of modern UI.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
My Review&lt;/h3&gt;
&lt;br /&gt;
The book really kept its promises. It has a lot of examples to deal with so that you could utilize the SDK in real time and also describes every bits and pieces of the API as a whole. I would really recommend this book to all who have interest on Kinect API. The book starts from beginners level and so it does not depend how much experienced you are it would definitely be useful.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.packtpub.com/sites/default/files/9781849692380_Chapter_01.pdf&quot; target=&quot;_blank&quot;&gt;Download the Sample Chapter from here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;border: 0px; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 12px; line-height: 19.1875px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
If you are interested to purchase it online, you can get that from the publisher packtpub site as well as from amazon or flipkart too. Here are the links to get quick details of the book and link to purchase it online&amp;nbsp;&lt;/div&gt;
&lt;ul style=&quot;font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 12px; line-height: 19.1875px;&quot;&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.packtpub.com/kinect-for-windows-software-development-kit-programming-guide/book&quot; rel=&quot;nofollow&quot; style=&quot;border: 0px; color: #6e218a; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-decoration: initial; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Buy from packtpub.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B00ATYE418/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&amp;amp;tag=kunsbl-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B00ATYE418&quot; rel=&quot;nofollow&quot; style=&quot;border: 0px; color: #6e218a; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-decoration: initial; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Buy Kindle Edition from amazon.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/1849692386/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&amp;amp;tag=kunsbl-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=1849692386&quot; rel=&quot;nofollow&quot; style=&quot;border: 0px; color: #6e218a; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-decoration: initial; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Buy Paper Back Edition from amazon.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.flipkart.com/kinect-windows-sdk-programming-guide-1849692386/p/itmdfkwkgyazpgf4?pid=9781849692380&amp;amp;affid=kunal2383y&quot; rel=&quot;nofollow&quot; style=&quot;border: 0px; color: #6e218a; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-decoration: initial; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Buy from flipkart.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;div style=&quot;border: 0px; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 12px; line-height: 19.1875px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;border: 0px; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 12px; line-height: 19.1875px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Hope you will like this book and Happy coding.&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/4632605116201792960/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2013/02/a-new-book-on-kinect-by-abhijit-jana.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/4632605116201792960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/4632605116201792960'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2013/02/a-new-book-on-kinect-by-abhijit-jana.html' title='A new book on Kinect by Abhijit Jana - A must read'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-1139626862318288022</id><published>2012-08-23T05:28:00.002+05:30</published><updated>2012-08-23T05:29:36.674+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>NotifyIcon with WPF applications</title><content type='html'>NotifyIcon is an utility form System.Windows.Forms which can be used by any application to invoke the default notification from the system tray. As per my latest requirement, I have to create an application that runs on system tray and occationally shows notification using the system tray default notifications. While working with it, I have wasted a considerable amount of time, and thought it would be worth mentioning the same in a blog.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Steps :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
1. Start a WPF Application and add Reference to System.Windows.Forms and System.Drawing to the project.&lt;br /&gt;
2. Create an instance of NotifyIcon on the Code behind of the WPF application.&lt;br /&gt;
3. Specify the Icon property for the NotifyIcon.&lt;br /&gt;
Remember, you should specify the Icon property as it is a mandatory before you can show notifyIcons from the application.&lt;br /&gt;
4. Make the NotifyIcon visible.&lt;br /&gt;
5. Call ShowBallonTip after minimizing the window to System Tray.&lt;br /&gt;
&lt;br /&gt;
In my sample application, I have just created one button on the Window and when it is clicked, I show up a notifyIcon on the system tray.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;Window&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;x&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;Class&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;NotifyIconSample.MainWindow&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;xmlns&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;xmlns&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;Title&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;MainWindow&quot;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;Height&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;350&quot;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;Width&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;525&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #a31515;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;Grid&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #a31515;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;Button&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;Click&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;Button_Click&quot;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;Content&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;Click&amp;nbsp;to&amp;nbsp;Open&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #a31515;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;Grid&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;Window&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;&quot;&gt;&lt;/pre&gt;
&lt;br /&gt;
Code :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;NotifyIcon&lt;/span&gt;&amp;nbsp;nIcon&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;NotifyIcon&lt;/span&gt;();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;MainWindow()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;Button_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;RoutedEventArgs&lt;/span&gt;&amp;nbsp;e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.WindowState&amp;nbsp;=&amp;nbsp;System.Windows.&lt;span style=&quot;color: #2b91af;&quot;&gt;WindowState&lt;/span&gt;.Minimized;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.nIcon.Icon&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Icon&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;@&quot;../../Cartman-General.ico&quot;&lt;/span&gt;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.nIcon.ShowBalloonTip(5000,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Hi&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;This&amp;nbsp;is&amp;nbsp;a&amp;nbsp;BallonTip&amp;nbsp;from&amp;nbsp;Windows&amp;nbsp;Notification&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;ToolTipIcon&lt;/span&gt;.Info);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;&quot;&gt;&lt;/pre&gt;
&lt;br /&gt;
Note : I have wasted lot of time just to ensure that the Icon property is mandatory for the NotifyIcon to work on. So it is important to note that you must specify it before using it.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/1139626862318288022/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2012/08/notifyicon-with-wpf-applications.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/1139626862318288022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/1139626862318288022'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2012/08/notifyicon-with-wpf-applications.html' title='NotifyIcon with WPF applications'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-8915459665827660660</id><published>2012-03-18T19:51:00.001+05:30</published><updated>2012-03-18T19:51:18.971+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="Online Session"/><category scheme="http://www.blogger.com/atom/ns#" term="Teched"/><title type='text'>Microsoft TechEd 2012 on the Go.. Are you attending?</title><content type='html'>Well, &amp;nbsp;Microsoft is going Big with their event TechEd 2012 which will be held just in 2 days from now. Everyone is excited to visit Bangaluru for this awesome event and learn lot of technology. I am going to visit Bangalore soon. If you are going, just text me at contact@abhisheksur.com and come and say hi to me during the event.&lt;br /&gt;
&lt;br /&gt;
Visit the link below to know more about the event&lt;br /&gt;
&lt;a href=&quot;https://india.msteched.com/&quot; target=&quot;_blank&quot;&gt;Microsoft TechEd India 2012 -&amp;gt; Go Big&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now if you cannot join us in Bangaluru for this event, you can still see the event live. Register yourself immediately.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-color: #f7f7f7; color: #333333; font-family: Helvetica, Arial, sans-serif; font-size: 12px; height: 105px; line-height: 16px; width: 550px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; style=&quot;padding-left: 40px; padding-right: 40px; padding-top: 40px; width: 743px;&quot; valign=&quot;top&quot;&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;height: 23px; width: 470px;&quot;&gt;&lt;thead style=&quot;color: #003366;&quot;&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;width: 337px;&quot;&gt;&lt;a href=&quot;http://india.msteched.com/&quot; shape=&quot;rect&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #003366; outline-color: initial; outline-style: initial; outline-width: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;&quot; height=&quot;74&quot; src=&quot;http://www.microsoft.com/india/images/teched-live-images/MVP_03.jpg&quot; style=&quot;border-bottom-style: solid; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-style: solid; border-left-width: 0px; border-right-style: solid; border-right-width: 0px; border-top-style: solid; border-top-width: 0px; border-width: initial;&quot; width=&quot;120&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td align=&quot;right&quot; style=&quot;width: 333px;&quot; valign=&quot;middle&quot;&gt;&lt;img alt=&quot;&quot; height=&quot;54&quot; src=&quot;http://www.microsoft.com/india/images/teched-live-images/gobig.jpg&quot; style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial;&quot; width=&quot;160&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; style=&quot;padding-bottom: 60px; padding-left: 40px; padding-right: 40px; padding-top: 60px;&quot; valign=&quot;top&quot;&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;height: 116px; width: 470px;&quot;&gt;&lt;thead style=&quot;color: #003366;&quot;&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; style=&quot;color: #ec5526; font-family: tahoma, verdana; font-size: 50px; font-weight: bold; line-height: 54px; width: 431px;&quot; valign=&quot;top&quot;&gt;Catch TechEd Online for FREE!!!&lt;/td&gt;&lt;td align=&quot;left&quot; style=&quot;width: 274px;&quot; valign=&quot;middle&quot;&gt;&lt;a href=&quot;http://ctracker.communitiesrus.in/L/Go.aspx?t=C19L134H1&quot; shape=&quot;rect&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #003366; outline-color: initial; outline-style: initial; outline-width: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;img align=&quot;absMiddle&quot; alt=&quot;&quot; height=&quot;116&quot; src=&quot;http://www.microsoft.com/india/images/teched-live-images/techedlive-750_03.jpg&quot; style=&quot;border-bottom-style: solid; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-style: solid; border-left-width: 0px; border-right-style: solid; border-right-width: 0px; border-top-style: solid; border-top-width: 0px; border-width: initial; vertical-align: middle;&quot; width=&quot;184&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; height=&quot;34&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; style=&quot;height: 34px; padding-right: 5px; width: 335px;&quot; valign=&quot;top&quot;&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; height=&quot;33&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot; style=&quot;background-color: #f36523; color: white; font-family: &#39;segoe ui&#39;, tahoma, verdana; font-size: 13px; font-weight: bold; line-height: 20px; padding-bottom: 7px; padding-top: 7px; width: 331px;&quot; valign=&quot;top&quot;&gt;&lt;a href=&quot;http://ctracker.communitiesrus.in/L/Go.aspx?t=C19L134H1&quot; shape=&quot;rect&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: white; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 7px; padding-top: 7px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Register for TechEd Live!&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/td&gt;&lt;td align=&quot;center&quot; style=&quot;background-color: #f36523; color: white; font-family: &#39;segoe ui&#39;, tahoma, verdana; font-size: 13px; font-weight: bold; line-height: 20px; padding-bottom: 7px; padding-top: 7px; width: 331px;&quot; valign=&quot;top&quot;&gt;&lt;a href=&quot;http://kolkatageeks.com/Events/TechEd2012.aspx&quot; shape=&quot;rect&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: white; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 7px; padding-top: 7px; text-decoration: none;&quot;&gt;Click to Read Details!&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;br /&gt;I hope to see you all around.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/8915459665827660660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2012/03/microsoft-teched-2012-on-go-are-you.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/8915459665827660660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/8915459665827660660'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2012/03/microsoft-teched-2012-on-go-are-you.html' title='Microsoft TechEd 2012 on the Go.. Are you attending?'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-5473926769437689405</id><published>2012-02-27T04:58:00.000+05:30</published><updated>2012-02-27T04:58:04.015+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.0"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.5"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET Memory Management"/><category scheme="http://www.blogger.com/atom/ns#" term="architecture"/><category scheme="http://www.blogger.com/atom/ns#" term="beyondrelational"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CodeProject"/><category scheme="http://www.blogger.com/atom/ns#" term="design pattern"/><category scheme="http://www.blogger.com/atom/ns#" term="Memory Allocation"/><title type='text'>Inter-Process Communication using MemoryMappingFile</title><content type='html'>In an operating system, a Memory Mapping file are virtual storage place which has direct byte to byte correlation between the Virtual Address Space and the corresponding physical storage. So when we access the Virtual Address space via a memory mapping file we are directly communicating with the kernel space where the file is actually loaded. The portion of calculation between the physical storage and logical storage is hence avoided.&lt;br /&gt;
&lt;br /&gt;
Memory Mapping files allows&amp;nbsp;application&amp;nbsp;to access files in the same way as memory. Generally as address between the physical storage and virtual memory address space, we cannot access the physical address directly. But using Memory Mapping Files, the process loads a specific range of address within the process address space with which the storage of memory into the file can be done by just assigning value to a dereferenced pointers. The IO operation on a MemoryMapping file is so fast that from the programmers point of view it seems to be like accessing the memory rather than actual physical storage. To increase performance memory mapping files are not actually stored to the disk file as well, but rather it will be stored automatically in background when FlushViewOfFile is executed or paging file is written. To Read more about memory mapping files, &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms810613.aspx&quot; target=&quot;_blank&quot;&gt;read here.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Memory Mapping file inside .NET Framework&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
.NET introduces a separate namespace to handle Memory Mapping files. Previously, we needed to do this using unmanaged Api&#39;s but with the introduction of managed API into the .NET framework library, it becomes very easy to handle MemoryMapping file directly from .NET library.&lt;br /&gt;
&lt;br /&gt;
As memory mapping files are loaded into memory on a separate range of address space, two process can easily share the same page file instance and thus interprocess communication can be made with fast access to memory. It is recommended to back data with an actual disk file when large data is loaded into memory, so that there is no memory leak on the system when there is large memory pressure.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;MemoryMapping with backup Paging file (For large data communication)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
We generally use backed up memory file in the hard disk when the memory that needs to be shared between the process goes out of physical memory available on the pc or when you think that the data that needs to be loaded can be very expensive and sensitive to remain only in memory.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; FILENAME = &lt;span class=&quot;str&quot;&gt;&quot;LargeFile.dat&quot;&lt;/span&gt;;
&lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; MemoryMappedFile GetMemoryMapFile(FileMode mode)
{
   &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; path = Path.Combine(defaultPath, FILENAME);
   &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; mmf = MemoryMappedFile.CreateFromFile(path, mode, &lt;span class=&quot;str&quot;&gt;&quot;INTERPROC&quot;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.length, MemoryMappedFileAccess.ReadWriteExecute);
  &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; mmf;
}&lt;/pre&gt;
&lt;br /&gt;
The code above gets the reference of MemoryMappedFile using a disk backup paging file. The CreateFromFile static method of MemoryMappedFile exposes an option to specify path of the actual file location where the memory mapping file content needs to be mapped. By opening the file you can load the views of memory mapping file as you are accessing the file content from memory. You can also use OpenExisting or CreateNew methods if you are sure of the specific requirement of usage.&lt;br /&gt;
&lt;br /&gt;
In the above code, you can see I have specified the length of the file as well as a fixed name &quot;INTERPROC&quot; which indicates the name of the shared memory location which other process can call to access. The length of the file needs to be a multiple of 1024 always, hence if you are not using the content of the file, the paging location will still be occupied with null content. This ensures the mapping file always remains in same context as the loaded memory. The file based Memory Mapping files are not loaded totally when you try to access, but rather it provides views in terms of what data you are currently accessing.&lt;br /&gt;
&lt;br /&gt;
Once the file is opened, you can read the content of it using :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; mf = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.GetMemoryMapFile(FileMode.OpenOrCreate);
   &lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt;(mf)
   {
        &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; dsize = Marshal.SizeOf(&lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(T));
        T dData;
        &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; offset = dsize * index;
        &lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; accessor = mf.CreateViewAccessor(0, length))
         {
             accessor.Read(offset, &lt;span class=&quot;kwrd&quot;&gt;out&lt;/span&gt; dData);
             &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; dData;
         }
  }
&lt;/pre&gt;
&lt;br /&gt;
Here once the MemoryMappedFile is loaded into memory, you can use CreateViewAccessor to create a separate view to see the content of the data. Here I have loaded the entire data at a time, but it is better to create View content as soon as you want to read its content. Once the data is loaded you can use Read method to get data from the memory.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; mf = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.GetMemoryMapFile(FileMode.OpenOrCreate);
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; (mf)
{
&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; dsize = Marshal.SizeOf(&lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(T));
&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; offset = dsize * index;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; accessor = mf.CreateViewAccessor(0, length))
{
    accessor.Write(offset, &lt;span class=&quot;kwrd&quot;&gt;ref&lt;/span&gt; dData);
}
}&lt;/pre&gt;
&lt;br /&gt;
Almost identical to it, you can use write method to write content into the memory.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Remember&lt;/b&gt;&lt;br /&gt;
One thing that you need to remember, when you Dispose the memory content from one process that means all the content that are loaded into view needs to be rewritten to the disk file, such that the other process needs to reopen and recreate the view again. If you want to access some specific view without writing to the page file often after using it, tweak the behavior by not disposing the MemoryMappedFile (removing the using block from here) and the operating system will automatically manage the destruction of View.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;MemoryMapping without backup Paging file (For small data communication)&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
When the load of memory file is small, it would not be always good to have a large paging file created in background and wasting large amount of memory of the system. Sometimes we need to share content only between the process and when no process is accessing the shared memory, the operating system needs to dispose the content. Regards to this requirement, you can use MemoryMappedFiles to be stored only into memory and be called using the name of Memory created.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; MemoryMappedFile GetMemoryMapFile()
{

    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; security = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; MemoryMappedFileSecurity();
    security.SetAccessRule(
        &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; System.Security.AccessControl.AccessRule&amp;lt;MemoryMappedFileRights&amp;gt;(&lt;span class=&quot;str&quot;&gt;&quot;EVERYONE&quot;&lt;/span&gt;,
            MemoryMappedFileRights.ReadWriteExecute, System.Security.AccessControl.AccessControlType.Allow));

    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; mmf = MemoryMappedFile.CreateOrOpen(&lt;span class=&quot;str&quot;&gt;&quot;InterPROC&quot;&lt;/span&gt;,
                    &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.length,
                    MemoryMappedFileAccess.ReadWriteExecute,
                    MemoryMappedFileOptions.None,
                    security,
                    HandleInheritability.Inheritable);

    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; mmf;

}&lt;/pre&gt;
&lt;br /&gt;
In the code above, I have created a MemoryMappedFile using CreateOrOpen and named the actual memory being created as &quot;InterProc&quot;. Now this will create a file into the memory without any reference to it into disk file. &amp;nbsp;The HandleInheritability states that the child processes can also access the memory file.&lt;br /&gt;
&lt;br /&gt;
You can also specify security on the memory using MemoryMappedFileSecurity and add Access rule to the security blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; T ReadEntry&amp;lt;T&amp;gt;(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; index) where T : &lt;span class=&quot;kwrd&quot;&gt;struct&lt;/span&gt;
{
    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; mf = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.GetMemoryMapFile();

    &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; dsize = Marshal.SizeOf(&lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(T));
    T dData;
    &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; offset = dsize * index;
    &lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; accessor = mf.CreateViewAccessor(0, length))
    {
        accessor.Read(offset, &lt;span class=&quot;kwrd&quot;&gt;out&lt;/span&gt; dData);
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; dData;
    }
}

&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; WriteEntry&amp;lt;T&amp;gt;(T dData, &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; index) where T : &lt;span class=&quot;kwrd&quot;&gt;struct&lt;/span&gt;
{
    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; mf = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.GetMemoryMapFile();
    &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; dsize = Marshal.SizeOf(&lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(T));
    &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; offset = dsize * index;
    &lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; accessor = mf.CreateViewAccessor(0, &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.length))
    {
        accessor.Write(offset, &lt;span class=&quot;kwrd&quot;&gt;ref&lt;/span&gt; dData);
    }
}&lt;/pre&gt;
&lt;br /&gt;
You can read from and write to the file in the same way as you did for the file based shared memory, but one thing you need to remember again, you cannot close/dispose the MemoryMappedFile as this will &amp;nbsp;erase all the content that you write into the View.&lt;br /&gt;
&lt;br /&gt;
Here you can see, I didnt use using block or even wrote the Dispose of MemoryMappedFile as it is important.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://skydrive.live.com/embed?cid=BAFA39A62A57009C&amp;amp;resid=BAFA39A62A57009C%21857&amp;amp;authkey=AIBgo38S6AZl_UI&quot; target=&quot;_blank&quot;&gt;Download the Source code&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Using the code&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In the sample application that I have provided with this article, there is an interface that you can use to handle both Large and small Communicators. Ideally these classes needs to be used based on the requirement on real world .&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;interface&lt;/span&gt; ICommunicator
    {
        T ReadEntry&amp;lt;T&amp;gt;(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; index) where T : &lt;span class=&quot;kwrd&quot;&gt;struct&lt;/span&gt;;
        &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; WriteEntry&amp;lt;T&amp;gt;(T dData, &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; index) where T : &lt;span class=&quot;kwrd&quot;&gt;struct&lt;/span&gt;;
    }&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; index = 0;
ICommunicator lcom = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SmallCommunicator();&lt;span class=&quot;rem&quot;&gt;//new LargeCommunicator(&quot;D:\\&quot;);&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;// My Try&lt;/span&gt;
while (&lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;)
{
    DummyData dData = lcom.ReadEntry&amp;lt;DummyData&amp;gt;(index);
    Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Existing Data at 0 position : {0}&quot;&lt;/span&gt;, dData);

    Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Write Data Id&quot;&lt;/span&gt;);
    dData.Id = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Write new Data&quot;&lt;/span&gt;);
    dData.Data = Convert.ToInt32(Console.ReadLine());

    lcom.WriteEntry&amp;lt;DummyData&amp;gt;(dData, index);

    Console.ReadKey(&lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);
}&lt;/pre&gt;
Thus it will open a SmallCommunicator (or LargeCommunicator) and read/Write data into it.

&lt;br /&gt;
&lt;br /&gt;
Hope that helps!&lt;br /&gt;
&lt;br /&gt;
Happy Coding.</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/5473926769437689405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2012/02/inter-process-communication-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/5473926769437689405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/5473926769437689405'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2012/02/inter-process-communication-using.html' title='Inter-Process Communication using MemoryMappingFile'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-350497784722476311</id><published>2012-02-04T05:25:00.000+05:30</published><updated>2012-02-04T05:25:59.009+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.0"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET Memory Management"/><category scheme="http://www.blogger.com/atom/ns#" term="architecture"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CodeProject"/><category scheme="http://www.blogger.com/atom/ns#" term="design pattern"/><category scheme="http://www.blogger.com/atom/ns#" term="GC"/><category scheme="http://www.blogger.com/atom/ns#" term="Memory Allocation"/><category scheme="http://www.blogger.com/atom/ns#" term="WeakReference"/><title type='text'>Optimizing INPC Objects against memory leaks using WeakEvents</title><content type='html'>Working with WPF has always been a fun. Dealing with animation and richness in UI to its optimum  level often gives you an edge to present something to your client and to ensure that your client shouts with a &quot;WOW!&quot;. The Wow factor of applications can give you high rank in the first place, but increases expectation from the software. It is practically very hard to maintain with this expectation as time progresses. The survival of the fittest chooses one which best suits to the problem.&lt;br /&gt;
&lt;br /&gt;
One of the major problems that developers face today is the memory leaks in an applications. Often the software that is built looks great but does not follow basic guidelines to ensure that the application is not memory hungry or even there are no existing memory leaks.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Note : By memory leak we mean, some portion of memory is not reclaimed by the garbage collector even though the object is not in use.&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
By this way, the memory usage of the application increases at a certain extent and finally crashes with the OutOfMemoryException. To detect a memory leak there exists a large number of tools of which some are free while others are used as commercial purposes. Most of these problems can be &lt;a href=&quot;http://www.codeproject.com/Articles/38068/Best-Practices-of-Memory-Usage&quot; target=&quot;_blank&quot;&gt;fixed by either using Disposable pattern&lt;/a&gt; ( IDisposable interface) or manually de - referencing each and every object that are not in use. Sometimes, this can be also done in destructor / finalizers in .net too (but remember using destructors lose GC cycle).&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
GC algorithm actually tries to find all reachable objects in the entire heap and creates a map. It then puts the reachable objects one by one into the heap releasing memory of all unreachable objects. This is called Heap Compaction. By reachable objects we mean those objects to which the application still has strong reference, and the items which can be called in future. Thus it is important to release any strong reference of a memory when it is not in use, so that GC can collect it.&lt;br /&gt;
&lt;br /&gt;
Even though Garbage Collector separates all the reachable objects with non-reachables, there is one exception to this. .NET framework exposes WeakReference as a special type in the system, which can hold objects that are reachable but still it will be collected by the garbage collector. You can look into it in detail in my post :&amp;nbsp;&lt;a href=&quot;http://www.abhisheksur.com/2010/07/garbage-collection-algorithm-with-use.html&quot;&gt;Garbage Collection Algorithm with the use of WeakReference&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;The Problem&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now coming back to the application, sometimes it is even difficult to identify a memory leak when it exists inside of its framework. One of such scenario is when a large portion of memory is held by the EventHandler where the source has an EventHandler which is connected with a strong reference of the target which has the event. Let me explain it more :&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_9ycgfmHGxCLoT608OnjiZNEdJBVgOaE3qtk0Dpya7AZwm-IMGjjZv391XP63QLRhSNIWwLQzxz3DZkiLkRSuQTG9tyP5sMQmZbw5JO98i8I-T9jeLkpPoFgMfGj65MJtBIfKPX1UUnk/s1600/StrongReference.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_9ycgfmHGxCLoT608OnjiZNEdJBVgOaE3qtk0Dpya7AZwm-IMGjjZv391XP63QLRhSNIWwLQzxz3DZkiLkRSuQTG9tyP5sMQmZbw5JO98i8I-T9jeLkpPoFgMfGj65MJtBIfKPX1UUnk/s1600/StrongReference.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Object A holding strong reference of Object B through the use of EventHandler&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
In the above figure, let say Object A is an object that exposes one Event. Suppose Object A is an INPC container and exposes PropertyChanged Event from it. Object B on the other hand consumes Object A and adds an EventHandler inside B. Now it invokes statement to add this handler to the Object A using the code below :&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;A a1 = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; A();
a1.PropertyChanged += &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; PropertyChangedEventHandler(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.A_PropertyChanged);&lt;/pre&gt;
&lt;br /&gt;
So now object A can call A_PropertyChanged event handler defined inside Object B directly.&lt;br /&gt;
At a certain point, lets say Object A is no longer in use and is de-referenced from B by doing :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;a1 = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;br /&gt;
Here the de-referencing works good, but you are missing the fact that a1 still holds reference of B through the Event PropertyChanged, and will not be GCed until B is de-referenced as well. Here is the problem of memory leak. If B is a Static object and creates lots of A throughout the program, this problem can really leak lots of memory and eventually can load the process to crash.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;The Solution&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To deal with such a problem, we need a Co-ordinator for the Event such that the event raised by the object does not go directly to the Object B, rather it calls an intermediate listener which routes the event to the handler of Object B.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim9d_37qNz3n796M2zJKks7vLI9Qr7F9ijsnMskVeUtBVpJTuUanCHRWv4dqnwYLsHGpcvf3RAXjR9aFgDVrYDIdElfU_x9RtnQjkOQMz6mel41IjQ_lOAtGrwD_Xiaj2awHRVt57fX6M/s1600/WeakListener.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim9d_37qNz3n796M2zJKks7vLI9Qr7F9ijsnMskVeUtBVpJTuUanCHRWv4dqnwYLsHGpcvf3RAXjR9aFgDVrYDIdElfU_x9RtnQjkOQMz6mel41IjQ_lOAtGrwD_Xiaj2awHRVt57fX6M/s1600/WeakListener.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The Object A is not communicating directly with Object B, rather it connects with a WeakListener which exposes one WeakReference object to hold B&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
In the above figure, we can see, the Listener co-ordinates the event with the EventHandler thus de-referencing Object A and Listener from Object B will remove all the references from it. Lets implement this approach using code.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;interface&lt;/span&gt; IPropertyChanged
    {
        &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; OnPropertyChanged(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, PropertyChangedEventArgs e);
    }

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; WeakEventListener : IDisposable
    {
        &lt;span class=&quot;kwrd&quot;&gt;readonly&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; locker = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt;();
        WeakReference weakListener;
        INotifyPropertyChanged target;
        IPropertyChanged source;

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; WeakEventListener(IPropertyChanged source, INotifyPropertyChanged target)
        {
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.source = source;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.target = target;
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.target != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.target.PropertyChanged += &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; PropertyChangedEventHandler(target_PropertyChanged);
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.weakListener = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; WeakReference(source);
        }

        &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; target_PropertyChanged(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, PropertyChangedEventArgs e)
        {
            &lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; source = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;lock&lt;/span&gt; (locker)
            {
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (weakListener != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                {
                    source = weakListener.Target;
                }
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (source == &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                {
                    ReleaseListener();
                    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt;;
                }
            }
            IPropertyChanged notifier = source &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; IPropertyChanged;
            notifier.OnPropertyChanged(sender, e);

        }

        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; ReleaseListener()
        {
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (target != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
            {
                target.PropertyChanged -= &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; PropertyChangedEventHandler(target_PropertyChanged);
                target = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;
                weakListener = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;
            }
        }
        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; IDisposable Members

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Dispose()
        {
            &lt;span class=&quot;kwrd&quot;&gt;lock&lt;/span&gt; (locker)
            {
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ReleaseListener();
            }
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;
    }&lt;/pre&gt;
So here I have implemented one dummy implementation of WeakEventListener. Here the IPropertyChanged &amp;nbsp;interface is used to reference the object inside the Listener for simplicity.&lt;br /&gt;
&lt;br /&gt;
In the above implementation, you can see, I have used two object.&amp;nbsp;Preferably&amp;nbsp;consider object A in figure with INotifyPropertyChanged object target and IPropertyChanged as object B such that object B creates reference to both INotifyPropertyChanged as well as WeakEventListener. Now if B is derived from interface IPropertyChanged and define the eventhandler inside it, the WeakEventListener can invoke it without holding a strong reference of it.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; A : INotifyPropertyChanged
{
    &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; myProperty;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; MyProperty
    {
        &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt; { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; myProperty; }
        &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;
        {
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.myProperty = value;
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.PropertyChanged != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.PropertyChanged(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; PropertyChangedEventArgs(&lt;span class=&quot;str&quot;&gt;&quot;MyProperty&quot;&lt;/span&gt;));
        }
    }

    &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; INotifyPropertyChanged Members

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;event&lt;/span&gt; PropertyChangedEventHandler PropertyChanged;

    &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;
}

&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; B : IPropertyChanged
{
    A a1;
    WeakEventListener wlistener;

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; B(A a1)
    {
        &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.a1 = a1;
        wlistener = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; WeakEventListener(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;, a1);
    }

    &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; IPropertyChanged Members

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; OnPropertyChanged(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, PropertyChangedEventArgs e)
    {
        MessageBox.Show(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;Property {0}, has been changed&quot;&lt;/span&gt;, e.PropertyName));
    }

    &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;


    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; ReleaseA()
    {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.wlistener != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.wlistener.Dispose();
        &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.wlistener = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;
        &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.a1 = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;
    }

}&lt;/pre&gt;
&lt;br /&gt;
Now here class A implements INotifyPropertyChanged and invokes it when any of its property is changed. Class B, on the other hand implements IPropertyChanged and provides a eventhandler of PropertyChanged. But as it is using WeakEventListener you can call ReleaseA to release any strong reference of a1 from it and also dispose the listener object. Therefore you can keep on using the object B irrespective of any memory leak been created.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Alternatives inside Framework&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
WPF has a framework alternative to do the same thing. A number of class are available on the framework which help in implementing the same thing. Lets see how to do this using framework interfaces :&lt;br /&gt;
&lt;br /&gt;
1. Create a class and derive it from WeakEventManager.&lt;br /&gt;
2. Implement IWeakEventListener interface to define listener.&lt;br /&gt;
3. Use AddListener and RemoveListener to add and remove the objects.&lt;br /&gt;
&lt;br /&gt;
Lets see how I implement the same thing.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; A : INotifyPropertyChanged
{
       
    &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; myProperty;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; MyProperty
    {
        &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt; { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; myProperty; }
        &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;
        {
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.myProperty = value;
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.PropertyChanged != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.PropertyChanged(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; PropertyChangedEventArgs(&lt;span class=&quot;str&quot;&gt;&quot;MyProperty&quot;&lt;/span&gt;));
        }
    }
    &lt;span class=&quot;rem&quot;&gt;//code to raise the event&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;event&lt;/span&gt; PropertyChangedEventHandler PropertyChanged;
}
&lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; B : IWeakEventListener
{
    A a1;

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; B(A a1)
    {
        &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.a1 = a1;
        PropertyChangedEventManager.AddListener(a1, &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;MyProperty&quot;&lt;/span&gt;);
            
    }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt; ReceiveWeakEvent(Type managerType, &lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)
    {
        PropertyChangedEventArgs pe = e &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; PropertyChangedEventArgs;

        MessageBox.Show(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;Property {0}, has been changed&quot;&lt;/span&gt;, pe.PropertyName));

        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;
    }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; ReleaseA()
    {
        PropertyChangedEventManager.RemoveListener(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.a1, &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;MyProperty&quot;&lt;/span&gt;);
        &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.a1 = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;
    }

}&lt;/pre&gt;
&lt;br /&gt;
Here the PropertyChangedEventManager is a special class derived from Dispatcher object deals with INPC objects by holding a collection of all those INPC in the whole process and calling appropriate objects when event is raised. Thus ReceiveWeakEvent will be called, just like what we did earlier in B when A raises the event provided you implement IWeakEventListener interface on it.&lt;br /&gt;
&lt;br /&gt;
The ReleaseA is used to release the object A from memory without any strong reference been held.&lt;br /&gt;
&lt;br /&gt;
There is also a CollectionChangedEventManager to deal with ObservableCollection events or even you can build your own by deriving from WeakEventManager.&lt;br /&gt;
&lt;br /&gt;
I hope the post will help you. Please let me know your thoughts.&lt;br /&gt;
&lt;br /&gt;
Thanks for reading.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/350497784722476311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2012/02/optimizing-inpc-objects-against-memory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/350497784722476311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/350497784722476311'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2012/02/optimizing-inpc-objects-against-memory.html' title='Optimizing INPC Objects against memory leaks using WeakEvents'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_9ycgfmHGxCLoT608OnjiZNEdJBVgOaE3qtk0Dpya7AZwm-IMGjjZv391XP63QLRhSNIWwLQzxz3DZkiLkRSuQTG9tyP5sMQmZbw5JO98i8I-T9jeLkpPoFgMfGj65MJtBIfKPX1UUnk/s72-c/StrongReference.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-1173288162753909344</id><published>2012-01-04T01:05:00.003+05:30</published><updated>2012-01-04T01:05:46.370+05:30</updated><title type='text'>I am reviewing Microsoft&#39;s 70-515 C# exam PrepKit from UCertify</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-u2ppxyTkMbX7oiLG4xo6K8ISsK52A1zWzztJAaDPWSMGeSsCgPhS08ff47BZKrmfmM-RL7GkA22RhU3Wte2lI_azY8ohtv1KimHoqdiZ8V3eZ4wcC7C8gtfddsAKNv1xKCASoeSDn2M/s1600/logo.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-u2ppxyTkMbX7oiLG4xo6K8ISsK52A1zWzztJAaDPWSMGeSsCgPhS08ff47BZKrmfmM-RL7GkA22RhU3Wte2lI_azY8ohtv1KimHoqdiZ8V3eZ4wcC7C8gtfddsAKNv1xKCASoeSDn2M/s1600/logo.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;I have got a offer from uCertify to review their PrepKit and I have accepted that challenge and now I am reviewing&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: red; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: red; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;b&gt;&lt;a href=&quot;http://www.ucertify.com/exams/Microsoft/70-515-CSHARP.html&quot; style=&quot;color: #1155cc;&quot; target=&quot;_blank&quot;&gt;70-515 Exam .NET 4.0&lt;/a&gt;&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;PrepKit&amp;nbsp;from uCertify. Initially it looks like a simple tool that has a number of practice sets listed on the initial screen to try out few tests. The home screen also contains few links that points to Study Materials related to the exam that you are registered for. Lets take a look how the initial screen looks like : &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidnIO92y75glnJFeQaqrdyv5YqW9bts7-sxvMlSsxf2hrvkQSQIIVn1m14azSux9LhIyg_W_VHPSBQVsrj4Itm3CgdEPVRAHaVh8SXoRhJAi7csPvEbDMTwGWmDMMK1N1G44g2Ky-2-LM/s1600/ucertify.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;544&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidnIO92y75glnJFeQaqrdyv5YqW9bts7-sxvMlSsxf2hrvkQSQIIVn1m14azSux9LhIyg_W_VHPSBQVsrj4Itm3CgdEPVRAHaVh8SXoRhJAi7csPvEbDMTwGWmDMMK1N1G44g2Ky-2-LM/s640/ucertify.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222;&quot;&gt;&lt;span style=&quot;font-family: arial, sans-serif; font-size: x-small;&quot;&gt;The menu contains different links to Tests, Quiz, Notes, Articles, Reports etc for easy&amp;nbsp;navigation.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;As soon as I am done with the full review I will post it for you all.&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;If you are looking for a Certification, you can buy it from them :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.ucertify.com/&quot;&gt;http://www.ucertify.com/&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
Thanks and stay tune.</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/1173288162753909344/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2012/01/i-am-reviewing-microsofts-70-515-c-exam.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/1173288162753909344'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/1173288162753909344'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2012/01/i-am-reviewing-microsofts-70-515-c-exam.html' title='I am reviewing Microsoft&#39;s 70-515 C# exam PrepKit from UCertify'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-u2ppxyTkMbX7oiLG4xo6K8ISsK52A1zWzztJAaDPWSMGeSsCgPhS08ff47BZKrmfmM-RL7GkA22RhU3Wte2lI_azY8ohtv1KimHoqdiZ8V3eZ4wcC7C8gtfddsAKNv1xKCASoeSDn2M/s72-c/logo.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-447698324613444450</id><published>2012-01-02T02:24:00.002+05:30</published><updated>2012-01-02T02:24:50.211+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="MVP"/><title type='text'>Awarded Microsoft MVP in a row</title><content type='html'>Its new years eve. I was struck in&amp;nbsp;traffic&amp;nbsp;to join a Birthday party of one of my friend. Its all of a sudden I realized that it is my MVP&amp;nbsp;renewal&amp;nbsp;date too. I forgot it totally.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0tYQRuUc7IiC2Fak6YdufAAduaxtXSOg3VRciF3rtd1xyIDYHpkG7ypUgpbEz7Hg80GxaLOg0UGtsWFwLTf27wxOQEohPP2WinBq2xx3NOo49xHNxel-aMANrKtu8zYvUIFMqU2KRAcg/s1600/Ive-Been-Awarded-Microsoft-MVP-For-Second-Time-600x242.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;129&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0tYQRuUc7IiC2Fak6YdufAAduaxtXSOg3VRciF3rtd1xyIDYHpkG7ypUgpbEz7Hg80GxaLOg0UGtsWFwLTf27wxOQEohPP2WinBq2xx3NOo49xHNxel-aMANrKtu8zYvUIFMqU2KRAcg/s320/Ive-Been-Awarded-Microsoft-MVP-For-Second-Time-600x242.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I opened my Mobile, browsed to my account and saw, I have got a mail from MVP Award Team.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&quot;&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: Calibri; font-size: 13px;&quot;&gt;Dear Abhishek Sur,&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: Calibri; font-size: 13px;&quot; /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: Calibri; font-size: 13px;&quot;&gt;Congratulations! We are pleased to present you with the 2012 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in Client App Dev technical communities during the past year.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: Calibri; font-size: 13px;&quot; /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: Calibri; font-size: 13px;&quot;&gt;The Microsoft MVP Award provides us the unique opportunity to celebrate and honor your significant contributions and say &quot;Thank you for your technical leadership.&quot;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: Calibri; font-size: 13px;&quot; /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: Calibri; font-size: 13px;&quot;&gt;Nestor Portillo&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: Calibri; font-size: 13px;&quot;&gt;Director&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: Calibri; font-size: 13px;&quot;&gt;&lt;b&gt;Community &amp;amp; Online Support&quot;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: rgba(255, 255, 255, 0.917969); color: #222222; font-family: Calibri; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #222222; font-family: Calibri; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
I am really passionate about this award and I am really happy to receive this award for yet another time in Client App Dev category. This came to me as a New Years Gift. Thank you so much Microsoft for considering my activities and I want to personally thank &lt;a href=&quot;http://www.abhishekkant.net/&quot; target=&quot;_blank&quot;&gt;Mr. Abhishek Kant&lt;/a&gt;, as my MVP Lead, &amp;nbsp;&lt;a href=&quot;http://abhijitjana.net/&quot; target=&quot;_blank&quot;&gt;Abhijit Jana&lt;/a&gt;, &lt;a href=&quot;http://www.kunal-chowdhury.com/&quot; target=&quot;_blank&quot;&gt;Kunal Chowdhury&lt;/a&gt;, &lt;a href=&quot;http://amitbansal.net/&quot; target=&quot;_blank&quot;&gt;Amit Bansal&lt;/a&gt;, &lt;a href=&quot;http://debugmode.net/&quot; target=&quot;_blank&quot;&gt;Dhananjay Kumar&lt;/a&gt;, &lt;a href=&quot;http://blog.sqlauthority.com/&quot; target=&quot;_blank&quot;&gt;Pinal Dave&lt;/a&gt;, &lt;a href=&quot;http://www.amazedsaint.com/&quot; target=&quot;_blank&quot;&gt;Anoop Madhusudanan&lt;/a&gt; and last but not the least my own &lt;a href=&quot;http://www.kolkatageeks.com/&quot; target=&quot;_blank&quot;&gt;Community KolkataGeeks&lt;/a&gt; all of whom inspired me so much on my community activities. I would also like to thank the whole Microsoft Team for providing us such an opportunity to be in touch with this elite group.&lt;br /&gt;
&lt;br /&gt;
And finally thank you to all my blog readers. I feel&amp;nbsp;truly&amp;nbsp;honored&amp;nbsp;to receive such an award.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKmmZJ2sUVkF9hz8QXxlc11EGQPgsZtN1utUnSQQuqCQ92viYgEF7pAVi2KIB0eTKmjQ4nqk37vXbWvHchMBXJK8PiGBhgh6Upq0nwEQUglZ2iQpKxMbVyZkIRmmFta0tBGsipN4YCmWs/s1600/New-Year-2012-4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKmmZJ2sUVkF9hz8QXxlc11EGQPgsZtN1utUnSQQuqCQ92viYgEF7pAVi2KIB0eTKmjQ4nqk37vXbWvHchMBXJK8PiGBhgh6Upq0nwEQUglZ2iQpKxMbVyZkIRmmFta0tBGsipN4YCmWs/s320/New-Year-2012-4.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Happy New Year to all of you. Its time to party..... .&lt;br /&gt;
&lt;br /&gt;
:)</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/447698324613444450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2012/01/awarded-microsoft-mvp-in-row.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/447698324613444450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/447698324613444450'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2012/01/awarded-microsoft-mvp-in-row.html' title='Awarded Microsoft MVP in a row'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0tYQRuUc7IiC2Fak6YdufAAduaxtXSOg3VRciF3rtd1xyIDYHpkG7ypUgpbEz7Hg80GxaLOg0UGtsWFwLTf27wxOQEohPP2WinBq2xx3NOo49xHNxel-aMANrKtu8zYvUIFMqU2KRAcg/s72-c/Ive-Been-Awarded-Microsoft-MVP-For-Second-Time-600x242.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-6953338459218754226</id><published>2011-12-27T08:53:00.000+05:30</published><updated>2011-12-27T08:53:08.972+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="tips"/><title type='text'>Daily DotNet Tips 1 year and onwards</title><content type='html'>Friends,&lt;br /&gt;
&lt;br /&gt;
We are excited to celebrate 1st&amp;nbsp;Anniversary&amp;nbsp;of our site &lt;a href=&quot;http://dailydotnettips.com/&quot; target=&quot;_blank&quot;&gt;DailyDotnetTips &lt;/a&gt;today. It aims to share useful programming tips for .net developers.This site completely design for sharing Tips and Tricks, useful Code Snippet which anyone use in daily development work and targeted anything related with .NET.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Here is some of the statistics :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Founded : 27th December 2010&lt;/li&gt;
&lt;li&gt;No of Posts : 250&lt;/li&gt;
&lt;li&gt;No &lt;a href=&quot;http://www.facebook.com/DailyDotNetTips&quot; target=&quot;_blank&quot;&gt;facebook likes&lt;/a&gt; : 502&lt;/li&gt;
&lt;li&gt;No of participants : 7&lt;/li&gt;
&lt;li&gt;No of &lt;a href=&quot;http://twitter.com/dailydotnettips&quot; target=&quot;_blank&quot;&gt;Twitter &lt;/a&gt;followers : 348&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5Nc3ScQAEvF0kn3bvUjDi0CDa3Qq4YnCyMhRCCdTREEWmwkd7a6jPledONVHkvDR3IOmLdcOtuWU8oZYQC0IHkqMUSYpqYCaTtj33T29IO5Dwocs3vzsldFp6VZc0_6cDxW2PhtX3UwE/s1600/402700_287720581280834_149132408472986_876037_898308886_n.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;466&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5Nc3ScQAEvF0kn3bvUjDi0CDa3Qq4YnCyMhRCCdTREEWmwkd7a6jPledONVHkvDR3IOmLdcOtuWU8oZYQC0IHkqMUSYpqYCaTtj33T29IO5Dwocs3vzsldFp6VZc0_6cDxW2PhtX3UwE/s640/402700_287720581280834_149132408472986_876037_898308886_n.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
We are still a long way to go. Follow us and be a part of it.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://dailydotnettips.com/&quot; target=&quot;_blank&quot;&gt;www.dailydotnettips.com&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/6953338459218754226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2011/12/daily-dotnet-tips-1-year-and-onwards.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/6953338459218754226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/6953338459218754226'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2011/12/daily-dotnet-tips-1-year-and-onwards.html' title='Daily DotNet Tips 1 year and onwards'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5Nc3ScQAEvF0kn3bvUjDi0CDa3Qq4YnCyMhRCCdTREEWmwkd7a6jPledONVHkvDR3IOmLdcOtuWU8oZYQC0IHkqMUSYpqYCaTtj33T29IO5Dwocs3vzsldFp6VZc0_6cDxW2PhtX3UwE/s72-c/402700_287720581280834_149132408472986_876037_898308886_n.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-3473036252261382377</id><published>2011-11-10T21:31:00.001+05:30</published><updated>2011-11-10T21:33:59.747+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Developer Conference"/><category scheme="http://www.blogger.com/atom/ns#" term="Metro"/><category scheme="http://www.blogger.com/atom/ns#" term="Online Session"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows8"/><title type='text'>DEVCON – Kolkata, A New Beginning on 12th November, 2011</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;background-color: white; font-family: verdana; font-size: 12px; font: normal normal normal 1.01em/normal verdana; line-height: 1.5em; margin-bottom: 12px; margin-top: 12px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;&quot;&gt;
November 12th , we are getting together for a big event&amp;nbsp;&lt;a href=&quot;http://kolkatageeks.com/DevCon2011.aspx&quot; style=&quot;border-bottom-color: rgb(255, 255, 255); border-bottom-style: dashed; border-bottom-width: 1px; color: navy; font: normal normal normal 1.01em/normal verdana; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Developer Conference 2011&lt;/a&gt;&amp;nbsp;Organized by&amp;nbsp;&lt;a href=&quot;http://kolkatageeks.com/&quot; style=&quot;border-bottom-color: rgb(255, 255, 255); border-bottom-style: dashed; border-bottom-width: 1px; color: navy; font: normal normal normal 1.01em/normal verdana; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Microsoft User Group Kolkata (KolkataGeeks)&lt;/a&gt;&amp;nbsp;.&amp;nbsp; Developer Conference is the premier technical event for technology professionals at Kolkata interested in learning, connecting and exploring latest Microsoft technologies.&amp;nbsp; This is also going to be community Launch event for&amp;nbsp;&lt;em style=&quot;font: normal normal normal 1.01em/normal verdana; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Office 365&lt;/em&gt;. So be there and enjoy the flavor of cutting edge Microsoft technologies.&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: verdana; font-size: 12px; font: normal normal normal 1.01em/normal verdana; line-height: 1.5em; margin-bottom: 12px; margin-top: 12px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;&quot;&gt;
&lt;span id=&quot;more-3353&quot; style=&quot;font: normal normal normal 1.01em/normal verdana; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: verdana; font-size: 12px; font: normal normal normal 1.01em/normal verdana; line-height: 1.5em; margin-bottom: 12px; margin-top: 12px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;&quot;&gt;
This is a full day event and you can attend this&amp;nbsp; event in person at&amp;nbsp;&lt;a href=&quot;http://www.bing.com/mapindia/default.aspx?v=2&amp;amp;FORM=LMLTCP&amp;amp;cp=22.544695%7E88.357726&amp;amp;style=r&amp;amp;lvl=17&amp;amp;tilt=-90&amp;amp;dir=0&amp;amp;alt=-1000&amp;amp;phx=0&amp;amp;phy=0&amp;amp;phscl=1&amp;amp;cid=BAFA39A62A57009C%21762&amp;amp;encType=1&quot; style=&quot;border-bottom-color: rgb(255, 255, 255); border-bottom-style: dashed; border-bottom-width: 1px; color: navy; font: normal normal normal 1.01em/normal verdana; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;Bharatiya Bhasha Parisad&amp;nbsp;&lt;/a&gt;36A, Shakespeare Sarani, 4th Floor&amp;nbsp; Kolkata – 700017.&amp;nbsp; Overall there are 7 different sessions which primarily focused on latest Microsoft Technologies.&amp;nbsp; .&amp;nbsp; Check the&amp;nbsp;&lt;a href=&quot;http://kolkatageeks.com/DevCon2011.aspx&quot; style=&quot;border-bottom-color: rgb(255, 255, 255); border-bottom-style: dashed; border-bottom-width: 1px; color: navy; font: normal normal normal 1.01em/normal verdana; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Dev Con&lt;/a&gt;&amp;nbsp;Web Site for more information.&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: verdana; font-size: 12px; font: normal normal normal 1.01em/normal verdana; line-height: 1.5em; margin-bottom: 12px; margin-top: 12px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;&quot;&gt;
I’ll be presenting on “&lt;em style=&quot;font: normal normal normal 1.01em/normal verdana; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Windows 8 Metro Style Application&lt;/em&gt;“.&amp;nbsp; In this session I will talk about latest Windows release and how you can get best out of it through your Metro Style applications. There will be lots of demo in this session.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: verdana; font-size: 12px; font: normal normal normal 1.01em/normal verdana; line-height: 1.5em; margin-bottom: 12px; margin-top: 12px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;&quot;&gt;
Check out session details and agenda from here&amp;nbsp;&lt;a href=&quot;http://kolkatageeks.com/DevCon2011.aspx&quot; style=&quot;border-bottom-color: rgb(255, 255, 255); border-bottom-style: dashed; border-bottom-width: 1px; color: navy; font: normal normal normal 1.01em/normal verdana; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot; title=&quot;http://kolkatageeks.com/DevCon2011.aspx&quot;&gt;http://kolkatageeks.com/DevCon2011.aspx&lt;/a&gt;&amp;nbsp;.&amp;nbsp; You can register for this event over here&amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://kolkatageeks.com/DevCon2011/Register.aspx&quot; style=&quot;border-bottom-color: rgb(255, 255, 255); border-bottom-style: dashed; border-bottom-width: 1px; color: navy; font: normal normal normal 1.01em/normal verdana; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot; title=&quot;http://kolkatageeks.com/DevCon2011/Register.aspx&quot;&gt;http://kolkatageeks.com/DevCon2011/Register.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: verdana; font-size: 12px; font: normal normal normal 1.01em/normal verdana; line-height: 1.5em; margin-bottom: 12px; margin-top: 12px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;&quot;&gt;
See you there !&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/3473036252261382377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2011/11/devcon-kolkata-new-beginning-on-12th.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/3473036252261382377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/3473036252261382377'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2011/11/devcon-kolkata-new-beginning-on-12th.html' title='DEVCON – Kolkata, A New Beginning on 12th November, 2011'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-701057140440559889</id><published>2011-10-31T06:06:00.001+05:30</published><updated>2011-10-31T06:06:38.355+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.5"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CodeProject"/><category scheme="http://www.blogger.com/atom/ns#" term="Metro"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows8"/><category scheme="http://www.blogger.com/atom/ns#" term="WinRT"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>Layout adjustments Snapping and OrientationChanges in Metro Applications</title><content type='html'>If you have read &lt;a href=&quot;http://www.abhisheksur.com/2011/10/understanding-basic-winrt-metro.html&quot;&gt;my first article on Windows 8 metro styled application&lt;/a&gt;, you might already know about the working principle of it. I have talked about the capabilities for an application and settings which end user can configure for an application. In this post I will take a look at the basic layout structure that one needs to follow while creating an application in WinRT Metro styles so that it is best suited to perform well.&lt;br /&gt;
&lt;br /&gt;
Layout is the most important part of any application. The best design for an application gets more credit and love from the users than applications that are designed bad. Metro style applications runs in full screen. Your application does not include a &amp;nbsp;Title Bar, status bar or anything. Microsoft gave us some of the basic layout guidelines that one needs to follow. Lets talk about them here to make you understand how you should layout your application in Metro Applications to utilize maximum flexibility of it.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
Lets start defining a layout and explain each section.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;UserControl&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;LayoutSample.MainPage&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;xmlns:x&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;xmlns:d&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;xmlns:mc&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;mc:Ignorable&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;d&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;Loaded&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UserControl_Loaded&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;d:DesignHeight&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;768&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;d:DesignWidth&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1366&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;LayoutRoot&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Background&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;#FF0C0C0C&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ColumnDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Auto&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ColumnDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;320&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt; 
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ColumnDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;*&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;RowDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Height&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Auto&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;RowDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Height&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;*&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Rectangle&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;rctSpacerLeft&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;120&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Border&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;brdHeader&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Height&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;140&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;ColumnSpan&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;TextBlock&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;HorizontalAlignment&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Left&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;VerticalAlignment&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Center&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;My Basic Layout&quot;&lt;/span&gt;
                       &lt;span class=&quot;attr&quot;&gt;FontSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;40&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Border&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ListBox&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;lstBasicItems&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Row&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt;
                 &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;DataTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;StackPanel&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Orientation&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Vertical&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;TextBlock&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;{Binding Name}&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;HorizontalAlignment&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Center&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;TextBlock&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;{Binding Description}&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;HorizontalAlignment&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Left&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;StackPanel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;DataTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ListBox&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;grdLayoutRight&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Row&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DataContext&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;{Binding ElementName=lstBasicItems, Path=SelectedItem}&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;RowDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Height&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Auto&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;RowDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Height&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;*&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ColumnDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Auto&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ColumnDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;*&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;TextBlock&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Name&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;FontSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;14&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;TextBox&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;{Binding Name}&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;TextBlock&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Description&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;FontSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;14&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Row&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;TextBox&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;{Binding Description}&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Row&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;UserControl&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
This is a basic layout of an application which shows a list of data in the left hand side in a ListBox and the Right hand side shows few textboxes to edit the data.&amp;nbsp;Following the convension, each application should have a left margin of 120 px. In this layout the First Column of the LayoutRoot grid is specified Auto. Auto indicates that the portion of the screen will be sized to content. In this section I specified a Rectangle with width 120px.&lt;br /&gt;
Again the Application needs to have a Heading. I have specified the heading in the First Row of the Grid. The ListBox is taken as 320px, this is because when the application is snapped, it takes 320px of size based on the design resolution. The Grid is *(star) Sized, hence it will adjust the size based on the available space.&lt;br /&gt;
&lt;br /&gt;
Now if you run this code, you will see something like this :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXb1q-QFMEgPwbqCFXtCicdw3844Hjjy597JZwy-jJf5fCqlk3zPblDgjj-ZXHjWLq3dkezpeH60723aenjr3F-AGT3BaGnOn0AJPeX67zTvPl2LuQO05grIH4weWSyLXaxXiBGQM9Aow/s1600/Fill.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXb1q-QFMEgPwbqCFXtCicdw3844Hjjy597JZwy-jJf5fCqlk3zPblDgjj-ZXHjWLq3dkezpeH60723aenjr3F-AGT3BaGnOn0AJPeX67zTvPl2LuQO05grIH4weWSyLXaxXiBGQM9Aow/s1600/Fill.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Here the ListBox takes 320 px of size and the Grid takes the rest of the available space. Now if you snap the application with another application, it will not adjust the size automatically. Lets write code so that it does.&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; MainPage()
{
    InitializeComponent();
    var currentView = ApplicationLayout.GetForCurrentView();
    currentView.LayoutChanged += &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; TypedEventHandler&amp;lt;ApplicationLayout, ApplicationLayoutChangedEventArgs&amp;gt;(currentView_LayoutChanged);
}

&lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; currentView_LayoutChanged(ApplicationLayout sender, ApplicationLayoutChangedEventArgs args)
{
    &lt;span class=&quot;kwrd&quot;&gt;switch&lt;/span&gt; (args.Layout)
    {
        &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; ApplicationLayoutState.Filled:
        &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; ApplicationLayoutState.FullScreen:
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.rctSpacerLeft.Visibility = Windows.UI.Xaml.Visibility.Visible;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.brdHeader.Visibility = Windows.UI.Xaml.Visibility.Visible;
            &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
        &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; ApplicationLayoutState.Snapped:
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.rctSpacerLeft.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.brdHeader.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
    }
}&lt;/pre&gt;
&lt;br /&gt;
So here you can see I have made the rctSpacerLeft and brdHeader visible only when the state of the application is Filled (that means when some other application is snapped with the application) or when the application is FullScreen (that means when the whole application is showed up). But these elements need to be Collapsed whenever the application is in Snapped mode(when the current application is snapped).&lt;br /&gt;
&lt;br /&gt;
You should already know, basically applications has 3 states. One when the size of the application is 320px long (called snapped ), when the application is filled most of the space just leaving 320px of the entire screen for some other application or when the application is full screen.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbebwfUWuBZrWFvllrD90D65qkO30zGf61NNrGCPCg4b3f516Ux8kaO1NIXXAj7nh64CzPcdRel68GMWPJV6Qyd-GHkXcDMW6IVi1PEa_JFLEJe6F4eF_ZYAa3PaMeLFtL9LJrWUEhtXg/s1600/filled.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbebwfUWuBZrWFvllrD90D65qkO30zGf61NNrGCPCg4b3f516Ux8kaO1NIXXAj7nh64CzPcdRel68GMWPJV6Qyd-GHkXcDMW6IVi1PEa_JFLEJe6F4eF_ZYAa3PaMeLFtL9LJrWUEhtXg/s1600/filled.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In the above image, I have just snapped the Tweet@rama that comes preinstalled with Windows 8. You can see the Grid is sized smaller than the previous one sharing the the 320 px of the entire screen to the other application. &amp;nbsp;Here the Margin is kept intact.&lt;br /&gt;
&lt;br /&gt;
But when the current application is snapped state, we need to show the entire thing in 320px. So the application needs to adjust itself to be meaningful to the User.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivn6MHIr-z_VPRWKc34FC65m4mZ3E9gf2AuZsb6INlNevgHkugTNb7C9mlN1yUPwxWSbxHsb9sJG8qJ5VfZQpmLWX4D8g0rFGLW-1K2qk8tkSBNJNq-ewXcpGCEvCZw6j6EGabq2aikfU/s1600/snapped.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivn6MHIr-z_VPRWKc34FC65m4mZ3E9gf2AuZsb6INlNevgHkugTNb7C9mlN1yUPwxWSbxHsb9sJG8qJ5VfZQpmLWX4D8g0rFGLW-1K2qk8tkSBNJNq-ewXcpGCEvCZw6j6EGabq2aikfU/s1600/snapped.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
When I snap the current application with Tweet@rama, you can see, it removes the header, the spacer margin and the Grid that is auto sized.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Responding to Rotation&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Responding to Ration of the device is another important consideration that you should always keep in mind while designing a Metro styled application. To know the Native Orientation of the device when the application gets started, you can use the DisplayProperties.CurrentOrientation property.&lt;br /&gt;
&lt;br /&gt;
Lets modify the code to show the Orientation of current device in header. By default the orientation is Landscape.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUUdDsArb-be0HYuIueUPhZ4PzHzoKBdgjJwgAkZfGRzxVoV-aohVvsDzvKt0FCnentxwRW1ElSczprP6AtuSv-ggPgQXfNiee3pCoVma9zWfa20D2IOM2w6iXsh0IVWQ63p-DXqoV_Yk/s1600/orientation.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUUdDsArb-be0HYuIueUPhZ4PzHzoKBdgjJwgAkZfGRzxVoV-aohVvsDzvKt0FCnentxwRW1ElSczprP6AtuSv-ggPgQXfNiee3pCoVma9zWfa20D2IOM2w6iXsh0IVWQ63p-DXqoV_Yk/s1600/orientation.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The above image shows up the current Orientation of the device. Lets edit the xaml a bit to introduce it.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Border&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;brdHeader&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Height&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;140&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;ColumnSpan&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;TextBlock&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;HorizontalAlignment&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Left&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;VerticalAlignment&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Center&quot;&lt;/span&gt;
                 &lt;span class=&quot;attr&quot;&gt;FontSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;40&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Run&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;My Basic Layout&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Run&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;runOrientation&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;TextBlock&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Border&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
I have added a couple of Run statement to allow changing the Orientation text in one particular Run block inside the TextBlock. Now lets handle the OrientationChanged Event of DisplayProperties to get the current Orientation. To do this lets add this code : 
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; MainPage()
{
    InitializeComponent();
    var currentView = ApplicationLayout.GetForCurrentView();

    currentView.LayoutChanged += &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; TypedEventHandler&amp;lt;ApplicationLayout, ApplicationLayoutChangedEventArgs&amp;gt;(currentView_LayoutChanged);

    DisplayProperties.OrientationChanged += &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DisplayPropertiesEventHandler(DisplayProperties_OrientationChanged);
}

&lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; DisplayProperties_OrientationChanged(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender)
{
    &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.WriteOrientation();
}
&lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; WriteOrientation()
{
    &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.runOrientation.Text = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot; ({0})&quot;&lt;/span&gt;, DisplayProperties.CurrentOrientation);
}&lt;/pre&gt;
Here we initialize the new event handler for &lt;b&gt;OrientationChanged &lt;/b&gt;in constructor of MainPage, which will call the event whenever the orientation of the device is changed. &lt;b&gt;DisplayProperties &lt;/b&gt;also lists many other display related properties like &lt;b&gt;ColorProfileChanged&lt;/b&gt;, &lt;b&gt;LogicalDpiChanged &lt;/b&gt;etc but they are rarely needed. You can read&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.display.displayproperties&quot;&gt; them from here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://skydrive.live.com/embedicon.aspx/.Public/LayoutSample.zip?cid=bafa39a62a57009c&amp;amp;sc=documents&quot;&gt;Download Sample Project&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To write a general purpose application, it is very important that your application maintains proper layout when the device changes its size or shape. The objective of the post is to get you through understanding how you could form a good layout for your application. I hope you have already got the basics of how to layout the application in Metro Environments.&lt;br /&gt;
&lt;br /&gt;
I hope this post helped you.&lt;br /&gt;
&lt;br /&gt;
Thank you for reading.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/701057140440559889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2011/10/layout-adjustments-snapping-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/701057140440559889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/701057140440559889'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2011/10/layout-adjustments-snapping-and.html' title='Layout adjustments Snapping and OrientationChanges in Metro Applications'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXb1q-QFMEgPwbqCFXtCicdw3844Hjjy597JZwy-jJf5fCqlk3zPblDgjj-ZXHjWLq3dkezpeH60723aenjr3F-AGT3BaGnOn0AJPeX67zTvPl2LuQO05grIH4weWSyLXaxXiBGQM9Aow/s72-c/Fill.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-7249585573269021996</id><published>2011-10-30T06:47:00.000+05:30</published><updated>2011-10-30T12:01:59.948+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.5"/><category scheme="http://www.blogger.com/atom/ns#" term="Geolocator"/><category scheme="http://www.blogger.com/atom/ns#" term="Metro"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows8"/><category scheme="http://www.blogger.com/atom/ns#" term="WinRT"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>Understanding basic WinRT Metro Applications and Application Capabilities</title><content type='html'>Just about a month ago, WinRT was introduced with all new style of application development that can work better with Multi Touch Enabled devices. We call it as Metro Applications. In this post, I will discuss how to develop your first metro applications and how to work with its layout changes.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;How to Start&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Before we start talking directly about Metro Style application, let us see how to install it first. I refer to use OracleVM which you can find for &lt;a href=&quot;http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html&quot;&gt;free from this link&lt;/a&gt;, and install. &amp;nbsp;This will install a Virtual Machine in which you can install the Developer Preview of Windows 8.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;br /&gt;
After your Virtual Machine is ready download &lt;a href=&quot;http://wdp.dlws.microsoft.com/WDPDL/9B8DFDFF736C5B1DBF956B89D8A9D4FD925DACD2/WindowsDeveloperPreview-64bit-English-Developer.iso&quot;&gt;Windows 8 Developer Preview from this link&lt;/a&gt;. Remember you need to install Windows Developer Preview with Developer Tools 64 Bit which is 4.8GB in size if you are willing to develop Metro Style Application. If you have something else, you do not have option than install it again. ( I have lost several hours trying on other windows previews). If you are having problems while installing Windows 8 in your Virtual Box, please follow the steps mentioned here.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After you install Windows 8 in your virtual machine please make sure you change the resolution to something above 1152. It is important because anything below this will turn of certain things. You cannot open Metro Apps or you cannot apply Partial fill settings of your application when the resolution is below this range. &lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Another Important consideration&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
You must remember, Metro application does not support closing the application, at least now. Hence if you start a new application the other application will keep on running in background. &amp;nbsp;You can switch back to that by hovering the left hand side of the screen and dragging back to the working area. Shortcut to do this is Windows + Tab. &amp;nbsp;The only way to close is either using an explicit close button from the application itself, or using Alt + F4 &amp;nbsp;key from the keyboard.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The Desktop Tile&lt;/span&gt;&lt;br /&gt;
Metro application is designed in such a way that the tiles are capable of update itself and it is easier to work with them using your hand. But like me most of the people might want the desktop on which we are all familiar of in windows. Yes Metro has a Tile called Desktop Tile that can present you with the very old Desktop with applications that are meant to run in desktop. &amp;nbsp;You can move back and forth to this Desktop tile when you want.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgvDPctFpTMl_0ND2_xyNZC-A8G3FCXHstGJbjrxMYgPb2NKuJkYWwLKDGtbovOlp0o8oZXwX3fq9HdtYMNwWohx7xhJQ07ccKn2S5ZFuxp9H5LlUhLDEKLiCnxoXXXxv7qhIdRpBTYOg/s1600/winrt.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;304&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgvDPctFpTMl_0ND2_xyNZC-A8G3FCXHstGJbjrxMYgPb2NKuJkYWwLKDGtbovOlp0o8oZXwX3fq9HdtYMNwWohx7xhJQ07ccKn2S5ZFuxp9H5LlUhLDEKLiCnxoXXXxv7qhIdRpBTYOg/s640/winrt.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So the one that is marked represents the Desktop Tile. You can also see Visual Studio and other developer tools appear in the same picture as Tile. The Visual Studio Express will help you build your first metro applications.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Application Store&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Application store is another important point to note for Metro style application. After you package a metro style application you need to publish it and upload it to Application Store with all the important information of it clearly. The user that needs the application should connect to the application store and download the same. This way the user is always aware of what he is downloading and what the application does.&lt;br /&gt;
&lt;br /&gt;
Now as you know much about Metro applications, lets start writing one metro application.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;What are Capabilities?&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Just like Silverlight or Windows Phone, Metro applications run in a very constrained mode. That means when you install the metro application you should provide the entire rules which the application should follow. That is to say if you do not specify that the application needs internet access to run the application, you would not get it from the application either. Hence Capabilities are defined set of rules that govern the application to access certain functionalities that application needs. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmHRlHiHTEQGxc_9EYPF0hH-sCr9iSevYVFrvLynsUV8lqveucmRHMRrm5sPyGYa6suSTwf_ERFYYMcfM1kGQneMYyvT6mFgw4tv_yPdZH92dTe7J-CW-DoZxk0nB9DZNCuxxLgWJ0hpU/s1600/capabilities.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;450&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmHRlHiHTEQGxc_9EYPF0hH-sCr9iSevYVFrvLynsUV8lqveucmRHMRrm5sPyGYa6suSTwf_ERFYYMcfM1kGQneMYyvT6mFgw4tv_yPdZH92dTe7J-CW-DoZxk0nB9DZNCuxxLgWJ0hpU/s640/capabilities.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
When you create a blank application in Visual Studio, you will see a appmanifest file that exists for each application. It is nothing but an XML file where you need to specify capabilities, Application related metadata etc. You can easily open that file in XML editor and add Capabilities like below :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Capabilities&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;    
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Capability&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;internetClient&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Capabilities&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
But you dont need to. If you double click on the File Package.appmanifest, you can edit to add Capabilities from a list of Capabilities that are commonly used. For instance Internet is checked by default. Lets add Location in this list. Location will allow you to get Latitude/Longitude information of the device.&lt;br /&gt;
&lt;br /&gt;
When you run an application, it deploys the application automatically to metro application without the need of Application store. Hence you dont need to wait until the application store approves your application to run. &amp;nbsp;This is called as side loading which the end user cannot do as it is&amp;nbsp;explicitly&amp;nbsp;restricted to Visual Studio. Now if you run your application, you will see a blank black screen appear after the initial flash screen.&lt;br /&gt;
&lt;br /&gt;
Lets run the project and swipe the application by hand to see some settings. You can also hover over the left hand bottom of your application to open the same settings or use Windows + I.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2iKPWUxtciQMJIhRsJsaSF1SfUu1HdhnqmcAMRAtkIkjChfwfgL5oYHqjVn76_cjuKEnHPtI9nNvpP9NbEVi_IuSSQX61fUS8xc_uFSjvOJbjv56CC9OPFggNs3FnDmUSM5dFe1Rvku4/s1600/settings.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;490&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2iKPWUxtciQMJIhRsJsaSF1SfUu1HdhnqmcAMRAtkIkjChfwfgL5oYHqjVn76_cjuKEnHPtI9nNvpP9NbEVi_IuSSQX61fUS8xc_uFSjvOJbjv56CC9OPFggNs3FnDmUSM5dFe1Rvku4/s640/settings.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Here you can see some standard settings that appear on the bottom of the sidebar. The Application information is also specified in the top of the side bar. And a special link which indicates the application capabilities. &amp;nbsp;Lets click on it to see which capabilities are there for me.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHwsaQUDh4pp72F1xYxBparQs-C0a1YJ4uaIgg37Zju-q8R0s92gaK1uCJjvWEJgWmyAe-M8ngEqOPVhap9QvZ25XATwO63997wpkIWXsY_wdpceR_fQufEIk2eH5FzDfRVdd1OuCNlFY/s1600/capabilities1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHwsaQUDh4pp72F1xYxBparQs-C0a1YJ4uaIgg37Zju-q8R0s92gaK1uCJjvWEJgWmyAe-M8ngEqOPVhap9QvZ25XATwO63997wpkIWXsY_wdpceR_fQufEIk2eH5FzDfRVdd1OuCNlFY/s1600/capabilities1.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
I have asked for Location, Proximity and Internet access, and hence it shows up in this list. &amp;nbsp;You can see there is one additional settings called Location listed as Off above the list.&lt;br /&gt;
&lt;br /&gt;
Certain features needs explicit access by the user when the application request it. Location is taken as sensitive capability, and hence it will again ask the user to enable it when you first call it and the user has the option to block this too.&lt;br /&gt;
&lt;br /&gt;
Now lets write some code to access the Location and see what happens to the application.&lt;br /&gt;
&lt;br /&gt;
We add some basic XAML to the application which adds one TextBlock and one Button. So when the Button is clicked the Textblock updates the current location of the device.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lets see how xaml looks like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;UserControl&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Metro1SimpleApp.MainPage&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;xmlns:x&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;xmlns:d&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;xmlns:mc&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;mc:Ignorable&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;d&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;Loaded&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;UserControl_Loaded&quot;&lt;/span&gt;
    &lt;span class=&quot;attr&quot;&gt;d:DesignHeight&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;768&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;d:DesignWidth&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1366&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;LayoutRoot&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Background&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;#FF0C0C0C&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.RowDefinitions&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;RowDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Height&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;120&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;RowDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Height&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;*&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ColumnDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;120&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ColumnDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;*&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;StackPanel&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Orientation&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Vertical&quot;&lt;/span&gt;  &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Row&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Grid&lt;/span&gt;.&lt;span class=&quot;attr&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;TextBlock&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;x:Name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;txtLocation&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Your Current Location is : &quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Button&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Click&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Button_Click&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Content&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Update Location&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
         &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;StackPanel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Grid&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;UserControl&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
Here the code adds one TextBlock and a Button that acts just like regular controls. If you try to know from inside these controls are wrappers to WinRT controls. &amp;nbsp;Now the Button has a Click Handler defined and the UserControl also defines the Loaded event handler.&lt;br /&gt;
&lt;br /&gt;
Now lets write code for those handlers :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; async &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Button_Click(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, RoutedEventArgs e)
{
    await UpdateGeoLocationAsync();
}

&lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; async &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; UserControl_Loaded(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, RoutedEventArgs e)
{
    await UpdateGeoLocationAsync();
}

&lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; async Task UpdateGeoLocationAsync()
{
    Geolocator location = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Geolocator();
    Geoposition position = await location.GetGeopositionAsync();

    &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.txtLocation.Text = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;Your current position is :({0}, {1} &quot;&lt;/span&gt;, position.Coordinate.Latitude, position.Coordinate.Longitude);
}&lt;/pre&gt;
&lt;br /&gt;
Geolocator is an WinRT API that calls for a GeoPosition either by using&amp;nbsp;satellite&amp;nbsp;position (if appropriate sensor is found in the device) or using internet address of the IP. Now this is slow API and hence WinRT allows you to only invoke asynchoronous call to this api. We use the new async support here to call the API.&lt;br /&gt;
&lt;br /&gt;
If you dont know about async, &lt;a href=&quot;http://www.codeproject.com/KB/cs/async.aspx&quot;&gt;please read my article&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
We add the contextual await to call from both the UserControl.Loaded and Button.Click event handlers.&lt;br /&gt;
&lt;br /&gt;
When I run the application, it will first ask to unblock the Location API. I have already told you, the location API is taken as sensitive and hence you as an user for the application have the settings to block and unblock. &amp;nbsp;You will see something like below :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyJ5qoY0wvWzLygv45ESufr3OXNQ33dHKnFuY_PMbp-BfULsyjUlAQe1IHkCa9oyq3eqBP6ORC_PreGftEJOI2OnDu2_z9rlLh8KhwVhQ2uVLtrvlbUXPxiNfrrLvsbyJ1oFGYUNERqTk/s1600/allowcapability.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;382&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyJ5qoY0wvWzLygv45ESufr3OXNQ33dHKnFuY_PMbp-BfULsyjUlAQe1IHkCa9oyq3eqBP6ORC_PreGftEJOI2OnDu2_z9rlLh8KhwVhQ2uVLtrvlbUXPxiNfrrLvsbyJ1oFGYUNERqTk/s640/allowcapability.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Thus it asks to turn on location service. If you allow then only the application can get Location data. Lets allow it, you will see the location is updated.&lt;br /&gt;
&lt;br /&gt;
If you are moving, you can click on the Button on the application to update your location when needed.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2387myXEUixwS1egtSiqeQnV8vqL8vNjAU_ze_zBM0TIXcv7Ym9soTMIuUwa0umoeodstCl99Lgz6hPlO1IWjeo0_JyqBt-PMGRoW8miVE2ug-k5kh-WfpVGVPo4kg3l-tfwbbTPRBRM/s1600/capability3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2387myXEUixwS1egtSiqeQnV8vqL8vNjAU_ze_zBM0TIXcv7Ym9soTMIuUwa0umoeodstCl99Lgz6hPlO1IWjeo0_JyqBt-PMGRoW8miVE2ug-k5kh-WfpVGVPo4kg3l-tfwbbTPRBRM/s1600/capability3.PNG&quot; /&gt;&lt;/a&gt;Now after you unblock the location API for the first time, if you go to settings, you will see the Location capability is now enabled for you. You can turn on or off whenever you want.&lt;br /&gt;
&lt;br /&gt;
To run on or off, you can drag the button to the right or left.&lt;br /&gt;
&lt;br /&gt;
You can &lt;a href=&quot;https://skydrive.live.com/embedicon.aspx/.Public?cid=bafa39a62a57009c&amp;amp;sc=documents&quot;&gt;download the sample from here.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Even though for a developer coming from normal Windows application it may seem to you as weird to have such kind of security enabled for your application, but world is moving towards it and this will benefit the end user to have clear knowledge about what the application is capable of. Hence it adds up security to the whole system. &lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
This is still very early stage of WinRT to talk about. There may be some amount of changes in final release of it. But yet it is good to learn about it. I hope you like my post. I will update with more posts on WinRT metro application in near future.&lt;br /&gt;
&lt;br /&gt;
Thanks for reading.</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/7249585573269021996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2011/10/understanding-basic-winrt-metro.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/7249585573269021996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/7249585573269021996'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2011/10/understanding-basic-winrt-metro.html' title='Understanding basic WinRT Metro Applications and Application Capabilities'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgvDPctFpTMl_0ND2_xyNZC-A8G3FCXHstGJbjrxMYgPb2NKuJkYWwLKDGtbovOlp0o8oZXwX3fq9HdtYMNwWohx7xhJQ07ccKn2S5ZFuxp9H5LlUhLDEKLiCnxoXXXxv7qhIdRpBTYOg/s72-c/winrt.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-4682476537647830506</id><published>2011-10-21T06:31:00.000+05:30</published><updated>2011-10-21T06:31:15.001+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.5"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Patterns"/><category scheme="http://www.blogger.com/atom/ns#" term="Regex"/><title type='text'>Regular Expressions with Timeout in .NET 4.5</title><content type='html'>.NET 4.5 Developer preview is out with Visual Studio 2011. I was already thinking to try &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms171868%28v=VS.110%29.aspx&quot;&gt;out what&#39;s new in .NET 4.5 myself&lt;/a&gt; and share what exactly been changed.&lt;br /&gt;
&lt;br /&gt;
Lets start by the new Regex Api introduced with the framework. The improvement that has been made is minor yet handy at certain cases. The Regex class of .NET 4.5 supports Timeout. Lets take a look how to work with it.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&amp;nbsp;Lets try to write a simplest RegEx validator to look into it. 

&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
{
    Regex regexpr = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Regex(&lt;span class=&quot;str&quot;&gt;&quot;[A-Z ]{10}&quot;&lt;/span&gt;, RegexOptions.Singleline, TimeSpan.FromMilliseconds(1));
    Match mch = regexpr.Match(&lt;span class=&quot;str&quot;&gt;&quot;ABHISHEK SUR&quot;&lt;/span&gt;);
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (mch.Success)
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Match found&quot;&lt;/span&gt;);
    &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Not matched&quot;&lt;/span&gt;);

}
&lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt; (RegexMatchTimeoutException ex)
{
    Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Regex Timeout for {1} after {2} elapsed. Tried pattern {0}&quot;&lt;/span&gt;, ex.Pattern, ex.Message, ex.MatchTimeout);
}
&lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt; (ArgumentOutOfRangeException ex)
{
    Console.WriteLine(ex.ToString());
}
&lt;span class=&quot;kwrd&quot;&gt;finally&lt;/span&gt;
{
    Console.ReadKey(&lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);
}&lt;/pre&gt;
&lt;br /&gt;
Here in the code you can see I simply check a string with a Regular expression. It eventually finds success as Pattern matches the string. Now this code is little different than what we have been doing for last few years. The constructor overload of Regex now supports a Timespan seed, which indicates the timeout value after which the Regular expression validator would automatically generate a RegexMatchTimeoutException. The Match defined within the Regex class can generate timeout after a certain time exceeds.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;You can specify &lt;b&gt;Regex.InfiniteMatchTimeout&lt;/b&gt; to specify that the timeout does not occur. The value of &lt;b&gt;InfiniteMatchTimeout &lt;/b&gt;is -1ms internally and you can also use Timespan.Frommilliseconds(-1) as value for timespan which will indicate that the Regular expression will never timeout which being the default behavior of our normal Regex class.

Regex also supports AppDomain to get default value of the Timeout. You can set timeout value for &lt;b&gt;&quot;REGEX_DEFAULT_MATCH_TIMEOUT&quot;&lt;/b&gt; in AppDomain to set it all the way through the Regular expressions being used in the same &lt;b&gt;AppDomain&lt;/b&gt;. 

Lets take a look how it works.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
{
    AppDomain.CurrentDomain.SetData(&lt;span class=&quot;str&quot;&gt;&quot;REGEX_DEFAULT_MATCH_TIMEOUT&quot;&lt;/span&gt;, TimeSpan.FromMilliseconds(2));

    Regex regexpr = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Regex(&lt;span class=&quot;str&quot;&gt;&quot;[A-Z ]{10}&quot;&lt;/span&gt;, RegexOptions.Singleline);
    Match mch = regexpr.Match(&lt;span class=&quot;str&quot;&gt;&quot;ABHISHEK SUR&quot;&lt;/span&gt;);
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (mch.Success)
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Match found&quot;&lt;/span&gt;);
    &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Not matched&quot;&lt;/span&gt;);

}
&lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt; (RegexMatchTimeoutException ex)
{
    Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Regex Timeout for {1} after {2} elapsed. Tried pattern {0}&quot;&lt;/span&gt;, ex.Pattern, ex.Message, ex.MatchTimeout);
}
&lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt; (ArgumentOutOfRangeException ex)
{
    Console.WriteLine(ex.ToString());
}
&lt;span class=&quot;kwrd&quot;&gt;finally&lt;/span&gt;
{
    Console.ReadKey(&lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);
}&lt;/pre&gt;
Now this works exactly the same as the previous one. Here the Regex constructor automatically checks the AppDomain value and applies it as default. If it is not present, it will take -1 as default which is Infinite TImeout and also if explicitely timeout is specified after the default value from AppDomain, the Regex class is smart enough to use the explicitly set value only to itself for which it is specified. 

The Regex Constructor generates a TypeInitializationException if appdomain value of Timespan is invalid. 

Lets check the internal structure. 

&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetlhidhiAzaqPl7HkiUcJntExVhQdMHa56HY5RVqCOzC8ffHXJ708_AFtVcXf5rrirVFCpSLI_AQx0OVUDhIPmNW9phWWI3zaAlQsk5PW4aAcsdTQnQhWg6llYmc82RxZQ-bkW-i1maE/s1600/timeoutregex.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetlhidhiAzaqPl7HkiUcJntExVhQdMHa56HY5RVqCOzC8ffHXJ708_AFtVcXf5rrirVFCpSLI_AQx0OVUDhIPmNW9phWWI3zaAlQsk5PW4aAcsdTQnQhWg6llYmc82RxZQ-bkW-i1maE/s1600/timeoutregex.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
This is the actual code that runs in background and generates the timeouts. Infact while scanning the string with the pattern, there is a call to CheckTimeout which checks whether the time specified is elapsed for the object. The CheckTimeout throws the exception from itself.&lt;br /&gt;
&lt;br /&gt;
The Constructor sets DefaultMatchTimeout when the object is created taking it from AppDomain data elements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you read MSDN thoroughly, it suggests to use Timeouts when specifying the Regular expressions. If the pattern is supplied from external or you are not sure about the pattern that needs to be applied to the string, it is always recommended to use Timeouts. Basically you should also specify a rational limit of AppDomain regex default to ensure no regular expression can ever hang your application.&lt;br /&gt;
&lt;br /&gt;
This is a small tip on the new Regex enhancements introduced with .NET 4.5 recently. &amp;nbsp;I hope you like it. More to come shortly, stay tune.&lt;br /&gt;
&lt;br /&gt;
Thank you for reading</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/4682476537647830506/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2011/10/regular-expressions-with-timeout-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/4682476537647830506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/4682476537647830506'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2011/10/regular-expressions-with-timeout-in-net.html' title='Regular Expressions with Timeout in .NET 4.5'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetlhidhiAzaqPl7HkiUcJntExVhQdMHa56HY5RVqCOzC8ffHXJ708_AFtVcXf5rrirVFCpSLI_AQx0OVUDhIPmNW9phWWI3zaAlQsk5PW4aAcsdTQnQhWg6llYmc82RxZQ-bkW-i1maE/s72-c/timeoutregex.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-1202276433845520074</id><published>2011-10-07T05:34:00.001+05:30</published><updated>2011-10-07T05:34:52.571+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="architecture"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Reflection"/><category scheme="http://www.blogger.com/atom/ns#" term="tips"/><title type='text'>Generic Types and Static Members</title><content type='html'>One of my friend recently asked me a question that I think I should share with you. Say you have a Static Implementation of a Type T which you pass as Open Type in your Generic Class. Now the problem is how to get reference to the Static Members or invoke a method that is Static to the Type from the Open Type T. &amp;nbsp;In this post, I will demonstrate few implementations that help you getting the Static implementation.&lt;br /&gt;
&lt;br /&gt;
First of all, According to C# documentation, any type allocates its static members once per Type rather than once per Open Type. Now lets define this using the code below :&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; MyType&amp;lt;T&amp;gt; &lt;span class=&quot;kwrd&quot;&gt;where&lt;/span&gt; T : &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt;
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Counter;
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; MyType()
    {
        Counter = 0;
    }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; MyType()
    {
        Counter++;
    }
}&lt;/pre&gt;
&lt;br /&gt;
Here this is actually a Generic Type that keeps track &amp;nbsp;of the count of objects that per type creates. The Type instance here MyType&amp;lt;T&amp;gt; is called Open Type and can take form of any Type. &amp;nbsp;Now lets create object of MyType.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;MyType&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt; ss = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; MyType&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt;();
ss = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; MyType&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt;();
ss = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; MyType&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt;();
MyType&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt;&amp;gt; oo = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; MyType&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt;&amp;gt;();
oo = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; MyType&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt;&amp;gt;();
oo = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; MyType&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt;&amp;gt;();

Console.WriteLine(MyType&amp;lt;string&amp;gt;.Counter);

Console.ReadKey(&lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;br /&gt;
Now we create 3 instance of string and 3 of Object. Thus the Console.WriteLine should show 6, right? .... Wrong.. Actually we here create two types using Generic Type MyType, one is MyType&amp;lt;string&amp;gt; and another is MyType&amp;lt;object&amp;gt;. So here MyType generates its own closed type and each of the type creates its Type interface when first instance of the object is called for, or rather when the Static constructor is called.&lt;br /&gt;
&lt;br /&gt;
Thus if I call MyType&amp;lt;X&amp;gt;.Counter it will show 0 and will create a new Type and call the Static constructor immediately.&lt;br /&gt;
&lt;br /&gt;
Now this is very easy here to call static members of a Generic type, but what if we want to call Static member of the Type we pass into as Generic Argument. Lets see...&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; MyType
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Try2CalMe()
    {
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Wow. You finally called me!&quot;&lt;/span&gt;);
    }

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; CallMe()
    {
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Called CallMe&quot;&lt;/span&gt;);
    }
}&lt;/pre&gt;
&lt;br /&gt;
Lets say I have a class defined with one static method and one instance method. As I have already told you that Generic Static members create its memory when it creates it first object, the same is true for non generic types. Hence when an instance of MyType is passed within  a Generic Type as Type argument, you would already have the memory allocated for the Type. Now let us consider using this Type for our Generic Class. 
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; MyGenericClass&amp;lt;T&amp;gt; 
{
    T MyTObject { get; set; }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; InstanceMethod()
    {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.MyTObject != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.MyTObject.CallMe();
    }
}&lt;/pre&gt;
&lt;br /&gt;
Well the line which calls CallMe leads to a problem, because the Generic Type does not have any idea about what Type it is going to take.  Say for instance if I pass int variable as T it will take  that also. Well to fix this problem we can put a constraint to Type T with a Where clause. But that doesnt solve our problem either. Even though we can call CallMe we cannot call Try2CallMe. 

There are few approaches that you can take to solve this problem.

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Working with your friend Reflection :&lt;br /&gt;&lt;br /&gt;Reflection API can call any method from a Type. You can check whether the static Method is there in the type that is passed during Runtime and if exists you can call it. Lets try to call the method using Reflection :&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; MyGenericClass&amp;lt;T&amp;gt; &lt;span class=&quot;kwrd&quot;&gt;where&lt;/span&gt; T : MyType
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; T MyTObject { get; set; }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; InstanceMethod()
    {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.MyTObject != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
        {
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.MyTObject.CallMe();

            &lt;span class=&quot;rem&quot;&gt;//Calling static member using Reflection&lt;/span&gt;

            Type currentType = &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(T);
            var method = currentType.GetMethod(&lt;span class=&quot;str&quot;&gt;&quot;Try2CalMe&quot;&lt;/span&gt;, BindingFlags.Static | BindingFlags.Public);
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(method != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;) &lt;span class=&quot;rem&quot;&gt;// Method exists&lt;/span&gt;
                method.Invoke(&lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;); &lt;span class=&quot;rem&quot;&gt;//We pass null as object for static member&lt;/span&gt;

        }
    }
}&lt;/pre&gt;
&lt;br /&gt;
So here we first pass MyType as constraint (even though it makes the type strict to inherited members of MyType) and calling the member using Reflection. Yes, it can call it absolutely.&lt;/li&gt;
&lt;li&gt;Putting it in intermediate Abstract base class:

&lt;br /&gt;&lt;br /&gt;Another option, or probably better approach is to create an intermediate abstract base class for all your types and call it. &amp;nbsp;It is another option for you and probably a better one but remember, all of your members share the same static member here.&lt;br /&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;abstract&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; MyAType
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Try2CalMe()
    {
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Wow. You finally called me!&quot;&lt;/span&gt;);
    }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;virtual&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; CallMe()
    {
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Called CallMe&quot;&lt;/span&gt;);
    }
}
&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; MyGenericClass&amp;lt;T&amp;gt; &lt;span class=&quot;kwrd&quot;&gt;where&lt;/span&gt; T : MyAType
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; T MyTObject { get; set; }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; InstanceMethod()
    {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.MyTObject != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
        {
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.MyTObject.CallMe();

            &lt;span class=&quot;rem&quot;&gt;//Calling static member Directly here&lt;/span&gt;
            MyAType.Try2CalMe();
               

        }
    }
}&lt;/pre&gt;
&lt;br /&gt;
Here we create an abstract base class for MyType and we pass it as generic constraint. So any class that inherits from this base class can go as a Type for the class MyGenericClass and which in turn can call its static member directly. &lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There might be some other option available and known to you. I would like you to share that with me.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I hope you like this post.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Thanks.&amp;nbsp;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/1202276433845520074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2011/10/generic-types-and-static-members.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/1202276433845520074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/1202276433845520074'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2011/10/generic-types-and-static-members.html' title='Generic Types and Static Members'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-6070026622596817533</id><published>2011-09-26T14:53:00.000+05:30</published><updated>2011-09-27T00:09:20.364+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET 3.5"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.0"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET Memory Management"/><category scheme="http://www.blogger.com/atom/ns#" term="architecture"/><category scheme="http://www.blogger.com/atom/ns#" term="beyondrelational"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CodeProject"/><category scheme="http://www.blogger.com/atom/ns#" term="Finalize"/><category scheme="http://www.blogger.com/atom/ns#" term="internals"/><category scheme="http://www.blogger.com/atom/ns#" term="Memory Allocation"/><category scheme="http://www.blogger.com/atom/ns#" term="Patterns"/><title type='text'>Internals of .NET Objects and Use of SOS</title><content type='html'>Well, now getting deeper into the facts, lets talk about how objects are created in .NET and how type system is laid out in memory for this post in my &lt;a href=&quot;http://www.abhisheksur.com/2011/03/internals-to-net.html&quot;&gt;Internals Series&lt;/a&gt;. &amp;nbsp;As this is going to be very deep dive post, I would recommend to read this only if you want to kill your time to know the internal details of .NET runtime and also you have considerable working experience with the CLR types and type system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recently I have been talking with somebody regarding the actual difference between the C++ type system and managed C# type system. I fact the CLR Type system is different from the former as any object (not a value type) is in memory contains a baggage of information when laid out in memory. This makes CLR objects considerable different from traditional C++ programs.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Classification of Types&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In .NET there are mainly two kind of Types.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;Value Types (derived from System.ValueType)&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Reference &amp;nbsp;Type (derived directly from System.Object)&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Even though ValueTypes are internally inherited from System.Object in its core, but CLR treats them very differently. &amp;nbsp;Indeed from your own perception the &lt;a href=&quot;http://www.abhisheksur.com/2011/07/valuetypes-and-referencetypes-under.html&quot;&gt;Value Types are actually allocated in stacks (occationally)&lt;/a&gt; while reference types are allocated in Heaps. This is to reduce the additional contension of GC heaps for Heap allocation, GC cycles,&amp;nbsp;occasional&amp;nbsp;call to OS for additional memory needs etc. The object that is allocated in managed Heap is called Managed Object and the pointer that is allocated in stack to refer to the actual object in heap is called &lt;b&gt;Object Reference &lt;/b&gt;(which is sometimes called as Managed Pointer).&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Additional&amp;nbsp;to this basic difference a Value Type is treated completely different from CLR point of view. CLR treats any object that is derived from System.ValueType differently in respect of any other object derived from System.Object directly. The memory of a ValueType contains just the value of its fields and the size of the Value Type is just the addition to its content, while for reference types the size is completely different. Let us consider looking at the memory layout of both the types.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgErg6C59hjiT8wPXPlQ-paUxEYsKk-4iLzik8z0C0NpBbYaqb2bmyRxtSLXwPAa2uDHz1yw1joIkHaM9anWO3zZfk_rL04YJMvJuMskahIB-WbSbN3QXMAze7Xr918J3E14aAQkC4akvw/s1600/stack.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgErg6C59hjiT8wPXPlQ-paUxEYsKk-4iLzik8z0C0NpBbYaqb2bmyRxtSLXwPAa2uDHz1yw1joIkHaM9anWO3zZfk_rL04YJMvJuMskahIB-WbSbN3QXMAze7Xr918J3E14aAQkC4akvw/s1600/stack.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In case of Value Types, the Managed Pointer holds reference to the initial location of the actual Memory.Thus in this case, the Managed pointer holds reference to 0x0000 which is the address location of Field 1. Hence CLR needs to do pointer arithmetic to find Fields ... N. &amp;nbsp;Thus we can easily use Sizeof operator on ValueTypes to get the actual size of the object.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The reference Types on the other hand holds some complex informations in its header.Lets define the individual blocks that comprises one object using a diagram.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8O281HNzd3vrQvKEPfQR_tpY2_T_4IK0iAtvZGIWvfpTSjL1afIfwqIq5TyT5uDJ8ARj8O9TC8b8eavr8iU_nR3sJb7kI-32wUOw-QMV9mWa3dxk-l9_sA04tjmKHQcYUS3odStCgAYo/s1600/reference1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8O281HNzd3vrQvKEPfQR_tpY2_T_4IK0iAtvZGIWvfpTSjL1afIfwqIq5TyT5uDJ8ARj8O9TC8b8eavr8iU_nR3sJb7kI-32wUOw-QMV9mWa3dxk-l9_sA04tjmKHQcYUS3odStCgAYo/s1600/reference1.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In the diagram, I have depicted the entire layout of memory for a reference type. The initial Managed Pointer here for reference types holds the address of Reference to RTTI address (Run Time Type Information). The initial 4 bytes of the memory is allocated for Synchronization Block. In CLR every object holds its own lock information by itself using this storage. There is another important consideration that you need to think of, is every CLR object holds its Type&amp;nbsp;information&amp;nbsp;inside it. This ensures that every object can explain its own type from itself without any dependency from outside. Hence the reference types are Self&amp;nbsp;Explanatory&amp;nbsp;types and programs can use these&amp;nbsp;information&amp;nbsp;while casting, polymorphism, dynamic binding, reflection etc. &amp;nbsp;Even though the Method Table structure reside outside the actual object, the RTTI Address holds the initial address of the Method Table runtime object which holds all the informations regarding the Type of the object. We query the information of the Runtime Type using the GetType method from any reference Type. The .NET runtime creates a special object of Type which helps to find out the actual type information.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
On the other hand, the ValueTypes are simply a chunk of memory without any clue of what it acutally contains. This is the major difference between the two types.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
During instantiation, a valuetype automatically calls its default constructor when it is declared. You cannot define &lt;a href=&quot;http://www.abhisheksur.com/2010/10/hidden-facts-on-c-constructor-in.html&quot;&gt;default constructor for a ValueType&lt;/a&gt;. But language (like C#) puts additional restriction to ensure that the valuetype is initialized before it is used to save additional constructor calls.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
ReferenceType on the other hand must have an object assigned to it using new operator. The new operator first allocates memory of its fields with default values and then calls the constructor.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Caveats of CLR Variables&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Value Type variable directly represents memory of a Stack.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Reference Type represents a pointer (or probably we should call it as Reference) that refer to the start location of the object produced in Heap. The reference points to RTTI address location.&lt;/li&gt;
&lt;li&gt;CPU registers can hold managed pointers as well as managed objects. Hence in certain cases, you can either store your value type or a reference to a Object in CPU registers depending on your need.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;AppDomain wide managed Table contains all the references pointing to the managed object references that are marked by GC. It also holds static ValueTypes and static Reference Types.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Implicit Object Reference (this)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There is nothing new with &quot;this&quot;. Any instance member have access to this pointer even though they are Value Type or a Reference. The method generally pass the object from which it is called as &quot;this&quot; as first argument of the call. Hence it is available inside any method. &quot;this&quot; pointer for ValueType points to the first instance field address location while the &quot;this&quot; pointer for the Reference Type points to the address of Method Table information.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;How CLR Methods are called ?&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There are two types of method being called in CLR. One with invoking &lt;b&gt;call&lt;/b&gt; IL instruction which needs the current object to be loaded in stack before any other argument passed as parameters; and other by using &lt;b&gt;CallVirt &lt;/b&gt;which is almost similar to call, but produces an additional instruction to validate the object reference. &amp;nbsp;The call statement does not produce NullReferenceException to a call to the method, but passes null as &quot;this&quot; pointer. But eventually if there is any instruction that requires access to its field or any other method call, it will produce NullReferenceException. CallVirt directly produces NullReferenceException prior to the call to the method when the object does not assign anything.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
When using Interface based methods, the ValueType generally needs to be boxed to produce Method Table &amp;nbsp;information so that the Virtual Methods could be called by CLR. &amp;nbsp;The Reference type does not bother to invoke callvirt which actually translates it based on the type of the runtime object rather than the original type it is called from (interface&amp;nbsp;reference).&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delegates on the other hand is a special type that holds reference of methods. MSIL has two opcodes to deal with them, ldvirtftn that load virtually a method, and ldftn. The ldftn loads the method address into stack. &amp;nbsp;The type of the method token loaded by this IL instruction can be searched to MethodTable of the type to get the actual address of the method. Delegates generally pass the object on which the member needs to be executed as Target and the method address stored in delegate instance to invoke the method. In case of Static method call the target is apssed as null. The process of retrieving an storing address to a delegate is expensive and is called delegate binding.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delegates are derived from a special type called System.Delegate in .NET CLR. A delegate can hold multiple methods in a chain. You can add more methods of same signature to a delegate which will be invoked sequentially by calling the last method added to it first and thereby calling the first method that is added as the final method in delegate chain. The return statement of the final method call is actually passed to the caller.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Trying out some basic debugging with Son of Strike(SOS)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Before we start SOS debugging with Visual Studio, you should recollect that there are three important data structure that you need to keep in mind.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;MethodTable &lt;/b&gt;: Stores all&amp;nbsp;information&amp;nbsp;about a Type. Holds information regarding static data, table of method descriptors, pointers to EEClass, pointers to other Methods from other VTable and pointers to Constructors.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;EEClass &lt;/b&gt;: This is almost same structure as of Method Table, but holds more static data information.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;MethodDesc &lt;/b&gt;: Information regarding a particular method such as IL or JIT&#39;ed informations.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Now let us consider a dummy class to start debugging.&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; MyClass
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; RefCounter;
    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; age;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; MyClass(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; name, &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; age)
    {
        &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Name = name;
        &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Age = age;
        MyClass.RefCounter++;
    }
    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; name;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Name
    {
        get
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; name;
        }
        set
        {
            name = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;;
        }
    }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Age
    {
        get
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; age;
        }
        set
        {
            age = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;;
        }
    }
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GetNext(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; age)
    {
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Getting next at age&quot;&lt;/span&gt; + age);
    }
}&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;
Here I have defined one static field, two member fields, a parameterized constructor and one instance method to start testing. We will use SOS to test instance of this code.&lt;br /&gt;
&lt;br /&gt;
So as we know already when an object is created, the memory contains an object reference to the actual object placed in heap. Hence lets create an object of it in Main.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Main(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;[] args)
{
    MyClass obj = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; MyClass(&lt;span class=&quot;str&quot;&gt;&quot;Abhishek&quot;&lt;/span&gt;, 28);
    obj.GetNext(20);
}&lt;/pre&gt;
&lt;br /&gt;
To start debugging you need to enable native debugging. To do this, Right Click on project =&amp;gt; Debug =&amp;gt; Enable unmanaged code debugging. Now put a breakpoint on the first line and step into the constructor. Lets say I go until one instance field is loaded. Now open &lt;b&gt;Intermediate Window &lt;/b&gt;and type&lt;b&gt;&amp;nbsp;.load C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\sos.dll. &lt;/b&gt;Please replace the exact location if folder structure differs.&lt;br /&gt;
&lt;br /&gt;
Now once the extension is loaded we can examine the instance of &lt;b&gt;MyClass&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
We call &amp;nbsp;!&lt;b&gt;DumpStackObjects &lt;/b&gt;to dump the object that is loaded in memory. We see something like below :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX4CbidgCMJX_3nmkc6ajvNqlht7-5tgw4NedG-ci_9iRgJztHlzuqjf-f_qrQyLP9o0LOapwacosat0ywlTxhBwc-qh_zRX9svhtjj5Y859ti0z6pTfSbXqKKlSLevGEXSCxl9cutAqo/s1600/dumpobject.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX4CbidgCMJX_3nmkc6ajvNqlht7-5tgw4NedG-ci_9iRgJztHlzuqjf-f_qrQyLP9o0LOapwacosat0ywlTxhBwc-qh_zRX9svhtjj5Y859ti0z6pTfSbXqKKlSLevGEXSCxl9cutAqo/s1600/dumpobject.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
These are the managed objects that are loaded into memory. Our concern is to see instance of &lt;b&gt;MyClass&lt;/b&gt;. So copy the object reference handle of the corresponding Object &amp;nbsp;of &lt;b&gt;MyClass &lt;/b&gt;( in our &amp;nbsp;case it is&amp;nbsp;00c2c1d0). Now lets use !&lt;b&gt;DumpObj&amp;nbsp;&lt;/b&gt;00c2c1d0&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZhZcIrBwAdWxBJyqRbFmYqOWNP6cIU8QdjCBIT_VKcLVDAXmdQDbjJL-lbK0KIAZUw1P-AxuTGzUgcDZ78yZuIgZVBarQeV6rwz9r3cN3G36cQU712BC3n5gMoygr3-27dqGLnpQ1M7k/s1600/dumpobj.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZhZcIrBwAdWxBJyqRbFmYqOWNP6cIU8QdjCBIT_VKcLVDAXmdQDbjJL-lbK0KIAZUw1P-AxuTGzUgcDZ78yZuIgZVBarQeV6rwz9r3cN3G36cQU712BC3n5gMoygr3-27dqGLnpQ1M7k/s1600/dumpobj.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The instruction actually dumped the entire object with the address to MethodTable, EEClass and size of the object in bytes. &amp;nbsp;You can see the size of the object in heap is 16 bytes. This is because the Objects in CLR holds more than the fields and members (like sync headers, method pointers etc.) &amp;nbsp;It also lists the fields currently in memory. You can see Value for name has an address as we execute this after the instruction line name in constructor but before age. &amp;nbsp;Now if I pass through all the lines of constructor it will show the memory address of all the members. You can use !DumpObject to play around the addresses of Name (00c2c1b0) or age or any instance member from here onwards.&lt;br /&gt;
&lt;br /&gt;
Now lets try few more commands to get interesting behaviors. There are few commands that you can try. !CLRSTACK dumps the managed code on the stack on the CurrentThread. !DumpStack on the other hand dumps both managed and native stack. Lets try !CLRStack now, the output will be like this :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNcWmOQwqSfBXe4qih_sdclVrD6Wp08E3iLbByLwilz1EFB8QGCFfmJJCEzmuw1IbtvRH6Ce6BvOPsojr7sD0bRVeIUNu9G83eJhrhPniw44X4TlCIDWO4mcLnP59TuxlR0qp_ucCdWjE/s1600/clrstack2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNcWmOQwqSfBXe4qih_sdclVrD6Wp08E3iLbByLwilz1EFB8QGCFfmJJCEzmuw1IbtvRH6Ce6BvOPsojr7sD0bRVeIUNu9G83eJhrhPniw44X4TlCIDWO4mcLnP59TuxlR0qp_ucCdWjE/s1600/clrstack2.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
Here I have moved to the call to &lt;b&gt;GetNext &lt;/b&gt;method. Hence you can see the &lt;b&gt;GetNext &lt;/b&gt;and &lt;b&gt;Main &lt;/b&gt;in stack for the command&lt;b&gt; !CLRStack&lt;/b&gt;. With additional argument like -p -l produces the result with better output listing all the parameters passes to the method. You can see this represents the first parameter for the method &lt;b&gt;GetNext&lt;/b&gt;, as I have told you which holds the object obj (in our case).&lt;br /&gt;
&lt;br /&gt;
Similarly you can use&lt;b&gt; &lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;b&gt;!DumpStack&lt;/b&gt; to dump both the native and managed objects and&lt;b&gt; !EEStack&lt;/b&gt; to execute &lt;b&gt;!DumpStack&lt;/b&gt; on all threads.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;To conclude,&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;This post is just the starting point of your understanding. There are lots of depth in this topic. You can try an&amp;nbsp;excellent&amp;nbsp;article on &lt;a href=&quot;http://msdn.microsoft.com/en-us/magazine/cc163791.aspx&quot;&gt;MSDN magazine here&lt;/a&gt;, which talks more on CLR object creation. If you want to know more on internals of .NET, you can also try my &lt;a href=&quot;http://www.abhisheksur.com/2011/03/internals-to-net.html&quot;&gt;Internal Series here&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;Thank you for reading, give your feedback.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 18px;&quot;&gt;Stay tune for more.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/6070026622596817533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2011/09/internals-of-net-objects-and-use-of-sos.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/6070026622596817533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/6070026622596817533'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2011/09/internals-of-net-objects-and-use-of-sos.html' title='Internals of .NET Objects and Use of SOS'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgErg6C59hjiT8wPXPlQ-paUxEYsKk-4iLzik8z0C0NpBbYaqb2bmyRxtSLXwPAa2uDHz1yw1joIkHaM9anWO3zZfk_rL04YJMvJuMskahIB-WbSbN3QXMAze7Xr918J3E14aAQkC4akvw/s72-c/stack.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-5912551752591387581</id><published>2011-09-24T14:14:00.000+05:30</published><updated>2011-09-24T14:14:50.176+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.0"/><category scheme="http://www.blogger.com/atom/ns#" term="beyondrelational"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CodeProject"/><category scheme="http://www.blogger.com/atom/ns#" term="internals"/><title type='text'>Internals of Interface and its Implementation</title><content type='html'>As many of my followers requested me to write few things that I missed out from the &lt;a href=&quot;http://www.abhisheksur.com/2011/03/internals-to-net.html&quot;&gt;Internals Series&lt;/a&gt;, I should continue with it. In this post, I will cover the internals of Interface implementation and mostly talk about explicit interface implementation, as most of the developers seems to be in confusion with it. I hope you will like the post.&lt;br /&gt;
&lt;br /&gt;
Beginning from the basics, Interfaces are the most important part of any application. Interfaces are language construct that does not implement anything but declares a few members upfront. Generally we use interfaces to create a contract between the two or more communication agents. Another important thing that everyone would be knowing already, Interfaces are meant to be implemented. That means whenever you are creating a class, all the members that were there in the interface are meant to be implemented completely. .NET (or probable any other standard language) disallows the creation of objects on types that are not fully defined. Hence abstract classes also coming into play here. They are classes that have few members undefined or abstract. Once you&amp;nbsp;don&#39;t&amp;nbsp;have concrete implementation, you cannot create an instance of a type. Notably, you can say&lt;b&gt; &quot;Interface is a types that does not belong to the System.Object or implement it when it reside inside an assembly&quot;&lt;/b&gt;. But ironically you could also says that once the type is implemented, it would probably inherit from System.object by default.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
Another important OOPS feature is that you can hold reference of any concrete type to any of its base implementations. By this what I mean, if say class X derived from Y and implements Z (where Z is an interface) you can say either&lt;i&gt; Y y1 = new X()&lt;/i&gt; or &lt;i&gt;Z z1 = new X().&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Now lets define an interface and start some tweaks some of its behaviors.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;interface&lt;/span&gt; IA
{
    &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GetX();
}&lt;/pre&gt;
&lt;br /&gt;
Let us suppose we have an interface IA which has a method GetX(). Now you should remember, it is not allowed to use access specifier for members of an interface as that mean the implementers of this interface needs to specify access specifiers for its members and it would appear to all implemtors that these members are public. &amp;nbsp;Now lets see one implementation of it.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; A : IA
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GetX()
    {
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Here is X: Normal&quot;&lt;/span&gt;);
    }
    &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; IA.GetX()
    {
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;Here is X: Explicitely&quot;&lt;/span&gt;);
    }
}&lt;/pre&gt;
&lt;br /&gt;
A is a class which implements IA, and hence need to declare one member GetX. Now you can see here we have defined two implementation of the same method GetX. The other one is Explicit implementation of IA. &amp;nbsp;The explicit declaration of a method can only be done for Interfaces (not allowed for normal classes) and allows you to differentiate the calls to GetX to its explicit implementation when interface is used rather than a normal derived reference is used. &amp;nbsp;Hence if I call :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;A a1 = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; A();
a1.GetX(); &lt;span class=&quot;rem&quot;&gt;// prints Here is X: Normal&lt;/span&gt;

IA a2 = a1;
a2.GetX(); &lt;span class=&quot;rem&quot;&gt;//Prints Here is X: Explicitely&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
You can see here compiler replaces the call to some explicit implementation based on the reference itself.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;There are few &lt;b&gt;basic characteristics of Explictely implemented methods&lt;/b&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;They are not overridable and cannot be made virtual.&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;They can only be called with appropriate interface name, as the methods in Vtable is not&amp;nbsp;determined&amp;nbsp;by its name but by the reference it calls for.&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;You cannot specify any access specifier for the implementation of Explicit method.}&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;They remain private and does not belong to a member of actual concrete class. For instance, if I remove the normal implementation of GetX and try calling the code below :&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;dynamic a1 = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; A();
a1.GetX();&lt;/pre&gt;
&lt;br /&gt;
It produces an exception, as A does not contain the member GetX().&lt;br /&gt;Now if we see the IL for the implementation :&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfHFba80aMICiIKdKC2x3YlsQK1508x0V2TiV5P1pr2oZsFg6P-Y5TrjLZYCwugvbBpexn-uJE2V6D5FV9sd7HxELiWYbRlpGVFDx4cm4ltiPe2oSgCVrxktb8vIHRmDBGdnnfxL0Jmvs/s1600/explicit.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfHFba80aMICiIKdKC2x3YlsQK1508x0V2TiV5P1pr2oZsFg6P-Y5TrjLZYCwugvbBpexn-uJE2V6D5FV9sd7HxELiWYbRlpGVFDx4cm4ltiPe2oSgCVrxktb8vIHRmDBGdnnfxL0Jmvs/s1600/explicit.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So here you can see the explicit declaration defines two important attributes, viz, newslot, virtual and final.&lt;br /&gt;
&lt;br /&gt;
newslot defines a new pointer in the VTable. Thus it is a completely new method created in vtable that can only be called by reference of the interface explicitely.&lt;br /&gt;
&lt;br /&gt;
virtual : you must already know virtual means the object could be overridable at runtime.&lt;br /&gt;
final : means sealed.&lt;br /&gt;
&lt;br /&gt;
Hence it is a sealed method with a new entry in VTable.&lt;br /&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;They are privately inherited and can be implemented only in the class where the Interface is actually implemented, not in any of its parent. For instance :&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;interface&lt;/span&gt; IA
{
    &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GetX();
}
&lt;span class=&quot;kwrd&quot;&gt;abstract&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; A : IA
{
}
&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; B : A
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GetX()
    {
        ((IA)&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).GetX();
    }
    &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; IA.GetX()
    {
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;New Impleentation&quot;&lt;/span&gt;);
    }
}&lt;/pre&gt;
&lt;br /&gt;
The above code produces an exception&lt;br /&gt;
&lt;b&gt;&quot;Inconsistent accessibility: base class &#39;TestInterfaceApplication.A&#39; is less accessible than class &#39;TestInterfaceApplication.B&#39;&quot;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Which means the GetX() method is private to B and cannot be implemented there. &lt;br /&gt;&lt;/li&gt;
&lt;li&gt;But remember, interface inheritence is supported. Thus the code below compiles fine :&lt;br /&gt;&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;interface&lt;/span&gt; IA
{
    &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GetX();
}
&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;interface&lt;/span&gt; IB : IA
{
}
&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; B : IB
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GetX()
    {
        ((IA)&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).GetX();
    }
    &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; IA.GetX()
    {
        Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;New Impleentation&quot;&lt;/span&gt;);
    }
}&lt;/pre&gt;
&lt;br /&gt;This is because interface implementation is not actually possible in CLR without marking both of them in concrete class so that the Types can be cast to any of the parent interfaces. So when you specify an Interface implementation, the two interfaces remains as individual types and when you implement the derived interface, it will actually implement the two interfaces for you. Its just a compiler trick. &amp;nbsp;Lets see the IL.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhunq1Z6l2rbKx247mNRln8eJnuwNh3IypoFxV1sNskl__MzKFV0J4fzmamu0TKv0UGCB1VVUv0npelALzVNsHtbb_cJ-TxC3KZ3aLMAlYVQUcs4zuOlJK9H0KdKkRnGl8Gp2jgH50jzQI/s1600/interfaceimplementation.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhunq1Z6l2rbKx247mNRln8eJnuwNh3IypoFxV1sNskl__MzKFV0J4fzmamu0TKv0UGCB1VVUv0npelALzVNsHtbb_cJ-TxC3KZ3aLMAlYVQUcs4zuOlJK9H0KdKkRnGl8Gp2jgH50jzQI/s1600/interfaceimplementation.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
So here you can see, if I implement a Derived interface IB from IA, the actual class actually implements both the interface explicitly.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Practical uses&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Explicit interfaces are generally used when you need two implementation of same method or property to co-exist. We generally create Explicit interfaces to specify default behaviour of a class. As explicit methods are actually attached to the interface itself, so at any level of Inherited member, it can be cast easily to get the default implementation (which is in fact not overridable).&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Even though there might be some further cases where it comes really handy, I would like to leave them for you. Post your comments regarding some other practical implementation or something you would like to address to me.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Thanks, I hope you find it interesting.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Happy programming.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/5912551752591387581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2011/09/internals-of-interface-and-its.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/5912551752591387581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/5912551752591387581'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2011/09/internals-of-interface-and-its.html' title='Internals of Interface and its Implementation'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfHFba80aMICiIKdKC2x3YlsQK1508x0V2TiV5P1pr2oZsFg6P-Y5TrjLZYCwugvbBpexn-uJE2V6D5FV9sd7HxELiWYbRlpGVFDx4cm4ltiPe2oSgCVrxktb8vIHRmDBGdnnfxL0Jmvs/s72-c/explicit.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2366485263164379453.post-6009748124979915923</id><published>2011-09-12T05:04:00.001+05:30</published><updated>2011-09-12T05:04:52.182+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET 4.0"/><category scheme="http://www.blogger.com/atom/ns#" term="architecture"/><category scheme="http://www.blogger.com/atom/ns#" term="beyondrelational"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CodeProject"/><category scheme="http://www.blogger.com/atom/ns#" term="Configuration"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>Writing a Custom ConfigurationSection to handle a Collection</title><content type='html'>Configuration is one of the major thing that you need to keep in mind while building any application. Either its an Windows Forms application or a Web site, configuration file is always needed. We write all the configuration that are needed to be changed after it is being deployed in confugration files. It is an XML File which lists all the configuration blocks itself and also allows you to define your own custom configuration sections yourself. Today I am building my own custom configuration section and show how easily you can build yourself.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
While dealing with Configurations, there are two things that you need to address&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;ConfigurationSection&lt;/li&gt;
&lt;li&gt;ConfigurationElement&lt;/li&gt;
&lt;li&gt;ConfigurationElementCollection&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;
For most of the simple configurations, it is pretty much common to use these two classes, but when you need more complex configuration block, like appsettings which actually puts a Collection of ConfigurationElements, you might need to use ConfigurationElementCollection to hold the collection of ConfigurationElement.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here in the article I will build one Configuration similar to appsettings so that it would be easier to build one for your own application.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJuPwD3MwM3fe2j1TOgLh5bFhh22zjEZQunm1JSH4CKPvuBreDV42BXR7VXCbphdYpIEgun3Z1_MXtduL6pFN0-rh9C5JbjV3R2-P0deq6HyMmUUjMLxiFoKSMYwD2zxSkG2JetOhT4s4/s1600/configsection.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJuPwD3MwM3fe2j1TOgLh5bFhh22zjEZQunm1JSH4CKPvuBreDV42BXR7VXCbphdYpIEgun3Z1_MXtduL6pFN0-rh9C5JbjV3R2-P0deq6HyMmUUjMLxiFoKSMYwD2zxSkG2JetOhT4s4/s1600/configsection.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;ConfgurationSection &lt;/b&gt;maps to the whole configuration, reading through the whole configuration you define in your config file. It has its own serialization and deserialization technique internally to open and close one specific ConfigurationSection when you want. For each Configuration file, it searches the Type of the ConfigSection, (in out case it is ConnectionSection which is within the assembly Configurationsettings). The name of the section indicates the Tag which you use for your ConfigurationSection.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ConfigurationElement &lt;/b&gt;maps with the individual element of the Section. It generally points to the entire XML configuration Tag that we use for the configuration. It is the serialized object with all the information about your configuration. When used as a Collection (as in our case) the ConfigurationElement maps to individual configuration blocks (in our case it is Element).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ConfigurationElementCollection &lt;/b&gt;: Each ConfigurationSection can have a collection of ConfigurationElement. In our case Servers represents the collection of Element.&lt;br /&gt;
&lt;br /&gt;
Now lets see how we code to retrieve data from this Configuration.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Implementation of ConfigurationElement&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
On the lowest level, each Configuration block in the collection represents one .NET object. Lets think that the enter tag here is converted to a .NET object and vice-versa. So how your .NET object would look like ?&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Element : ConfigurationElement
{
    [ConfigurationProperty(&lt;span class=&quot;str&quot;&gt;&quot;name&quot;&lt;/span&gt;, DefaultValue = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;, IsKey = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;, IsRequired = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; name
    {
        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;)&lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;name&quot;&lt;/span&gt;]; }
        set { &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;name&quot;&lt;/span&gt;] = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }
    }
    [ConfigurationProperty(&lt;span class=&quot;str&quot;&gt;&quot;servername&quot;&lt;/span&gt;, DefaultValue = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;, IsKey = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;, IsRequired = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; servername
    {
        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;)&lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;servername&quot;&lt;/span&gt;]; }
        set { &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;servername&quot;&lt;/span&gt;] = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }
    }

    [ConfigurationProperty(&lt;span class=&quot;str&quot;&gt;&quot;isactive&quot;&lt;/span&gt;, DefaultValue = &lt;span class=&quot;str&quot;&gt;&quot;true&quot;&lt;/span&gt;, IsKey = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;, IsRequired = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt; isactive
    {
        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt;)&lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;isactive&quot;&lt;/span&gt;]; }
        set { &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;isactive&quot;&lt;/span&gt;] = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }
    }

    [ConfigurationProperty(&lt;span class=&quot;str&quot;&gt;&quot;userid&quot;&lt;/span&gt;, DefaultValue = &lt;span class=&quot;str&quot;&gt;&quot;abhi&quot;&lt;/span&gt;, IsKey = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;, IsRequired = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; userid
    {
        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;)&lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;userid&quot;&lt;/span&gt;]; }
        set { &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;userid&quot;&lt;/span&gt;] = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }
    }

    [ConfigurationProperty(&lt;span class=&quot;str&quot;&gt;&quot;password&quot;&lt;/span&gt;, DefaultValue = &lt;span class=&quot;str&quot;&gt;&quot;password&quot;&lt;/span&gt;, IsKey = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;, IsRequired = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; password
    {
        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;)&lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;password&quot;&lt;/span&gt;]; }
        set { &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;password&quot;&lt;/span&gt;] = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }
    }
}&lt;/pre&gt;
&lt;br /&gt;
Here the class Element represents exactly as we define our Configuration element in the collection. Our Element in configuration looks like :&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Element&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;RemoteServer&quot;&lt;/span&gt;
                    &lt;span class=&quot;attr&quot;&gt;servername&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;68.240.22.19&quot;&lt;/span&gt;
                    &lt;span class=&quot;attr&quot;&gt;userid&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;abhijit&quot;&lt;/span&gt;
                    &lt;span class=&quot;attr&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;passcode&quot;&lt;/span&gt;
                    &lt;span class=&quot;attr&quot;&gt;isactive&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So our idea to create a type that maps to this. &amp;nbsp;Remember XML is case - sensitive.&lt;br /&gt;
Hence we create a class. We map the individual Properties with ConfigurationProperty. You can see each individual property has few attributes that you can define. Such as, &amp;nbsp;DefaultValue would be used whenever the attribute is not present in actual configuration; IsRequired indicate that the property is mandatory etc.&lt;br /&gt;
&lt;br /&gt;
You should always consider one of the property of the &lt;b&gt;ConfigurationElement &lt;/b&gt;as Key field. Key field represents the unique identifier for the object.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Implementation of ConfigurationElementCollection&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now as we have a collection of Element in our configuration block, we need to wrap the individual Element inside a ConfigurationElementCollection. This class is an abstract implementation of a ConfigCollection. It has few members that we need to address. Lets see how do we implement it.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;[ConfigurationCollection(&lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(Element))]
&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; ServerAppearanceCollection : ConfigurationElementCollection
{
    &lt;span class=&quot;kwrd&quot;&gt;internal&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; PropertyName = &lt;span class=&quot;str&quot;&gt;&quot;Element&quot;&lt;/span&gt;;

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; ConfigurationElementCollectionType CollectionType
    {
        get
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; ConfigurationElementCollectionType.BasicMapAlternate;
        }
    }
    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; ElementName
    {
        get
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; PropertyName;
        }
    }

    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt; IsElementName(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; elementName)
    {
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; elementName.Equals(PropertyName, StringComparison.InvariantCultureIgnoreCase);
    }


    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt; IsReadOnly()
    {
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;
    }


    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; ConfigurationElement CreateNewElement()
    {
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Element();
    }

    &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; GetElementKey(ConfigurationElement element)
    {
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; ((Element)(element)).name;
    }

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; Element &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;[&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; idx]
    {
        get
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (Element)BaseGet(idx);
        }
    }
}&lt;/pre&gt;
&lt;br /&gt;
First and foremost, we need to annotate the class using ConfigurationCollection attribute. Generally, each configurationSection is read by the .NET configuration reader using Reflection. It chooses appropriate classes based on the Attribute. Hence it is important to define this for each configuration.&lt;br /&gt;
&lt;br /&gt;
Here the first thing that you notice is we define an Indexer for the class and return BaseGet(index). The BaseGet actually reads the configuration collection and use Reflection to create object of the ConfigurationElement.&lt;br /&gt;
&lt;br /&gt;
Another important thing that you need to address in this implementation is CreateNewElement. You need to return the actual implementation of your ConfigurationElement here. The ElementName represents the name of the Tag that you use in Config file.&lt;br /&gt;
&lt;br /&gt;
Implementation of ConfigurationSection&lt;br /&gt;
&lt;br /&gt;
Finally we need to actually map the collection to a single ConfigurationSection. Lets see the implementation first :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; ConnectionSection  : ConfigurationSection
{
    [ConfigurationProperty(&lt;span class=&quot;str&quot;&gt;&quot;Servers&quot;&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; ServerAppearanceCollection ServerElement
    {
        get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; ((ServerAppearanceCollection)(&lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;Servers&quot;&lt;/span&gt;])); }
        set { &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;[&lt;span class=&quot;str&quot;&gt;&quot;Servers&quot;&lt;/span&gt;] = &lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;; }
    }
}&lt;/pre&gt;
&lt;br /&gt;
Here basically we create an object of our Collection and return the whole XML block using base[&quot;name of the block&quot;]. You must notice that we wrapped the whole configuration inside one XML tag called Servers. We use this to indicate the whole collection.&lt;br /&gt;
&lt;br /&gt;
As a Side Note&lt;br /&gt;
&lt;br /&gt;
Yes, of course you can read configuration directly without using existing APIs available. This article demonstrates how to handle complex configuration blocks for your application.&lt;br /&gt;
&lt;br /&gt;
If you are looking for something simplier than this, check the following links :&lt;br /&gt;
&lt;a href=&quot;http://haacked.com/archive/2007/03/12/custom-configuration-sections-in-3-easy-steps.aspx&quot;&gt;3 Easy steps to create Configuration&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
In much simple scenario you dont need to use ConfigurationSectionCollection rather you can simply use ConfigurationSection itself to handle your entire configuration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;To Get information about Configuration&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To &amp;nbsp;retrieve the information of the configuration lets define a class and enumerate all the Element objects that can be found from Configuration.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; ConfigSettings
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; ConnectionSection ServerAppearanceConfiguration
    {
        get
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (ConnectionSection)ConfigurationManager.GetSection(&lt;span class=&quot;str&quot;&gt;&quot;serverSection&quot;&lt;/span&gt;);
        }
    }

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; ServerAppearanceCollection ServerApperances
    {
        get
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ServerAppearanceConfiguration.ServerElement;
        }
    }

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; IEnumerable&amp;lt;Element&amp;gt; ServerElements
    {
        get
        {
            &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (Element selement &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ServerApperances)
            {
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (selement != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                    &lt;span class=&quot;kwrd&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; selement;
            }
        }
    }
}&lt;/pre&gt;
&lt;br /&gt;
Here we use GetSection to get the specific section that we have created, and we can easily cast the object returned by GetSection to ConnectionSection. The GetSection automatically creates the instance of the class (if everything is alright) . Now as our section also contains a Collection of custom settings, we have yield the elements from ServerAppearanceCollection.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://skydrive.live.com/embedicon.aspx/.Public?cid=bafa39a62a57009c&amp;amp;sc=documents&quot;&gt;Download Source application&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Conclusion&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Use of Custom Section for app.config is generally very handy. The System.Configuration api exposes a number of good classes that can handle configuration for you. Here I have shown how to create a section that might act similar to AppSettings or any collection oriented settings.&lt;br /&gt;
&lt;br /&gt;
I hope this will come handy.&lt;br /&gt;
&lt;br /&gt;
Thanks for reading.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.abhisheksur.com/feeds/6009748124979915923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.abhisheksur.com/2011/09/writing-custom-configurationsection-to.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/6009748124979915923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2366485263164379453/posts/default/6009748124979915923'/><link rel='alternate' type='text/html' href='http://www.abhisheksur.com/2011/09/writing-custom-configurationsection-to.html' title='Writing a Custom ConfigurationSection to handle a Collection'/><author><name>Abhishek Sur</name><uri>http://www.blogger.com/profile/17866196639844722961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJuPwD3MwM3fe2j1TOgLh5bFhh22zjEZQunm1JSH4CKPvuBreDV42BXR7VXCbphdYpIEgun3Z1_MXtduL6pFN0-rh9C5JbjV3R2-P0deq6HyMmUUjMLxiFoKSMYwD2zxSkG2JetOhT4s4/s72-c/configsection.PNG" height="72" width="72"/><thr:total>1</thr:total></entry></feed>