ASP.NET 4.5 has introduced model binding and strongly typed templates for ASP.NET server controls.This simplifies the way a plain .NET object can be bound as a datasource of a server control like a GridView.Let’s get started off with a simple example of how model binding works.
Archive for the ‘.NET’ Category
ASP.NET 4.5 Web Forms ModelBinding – Custom Value Providers
Posted: December 8, 2012 in .NET, ASP.NETTags: ASP.NET 4.5, Server Controls, VS 2012
Static Classes & Singleton in C#
Posted: August 12, 2012 in .NET, C#Tags: Singletons, Static Classes
Singleton is the most widely known Design Pattern. Singleton makes sure that one only one instance of a class is created and the same instance is used by other programs and classes.An implementation of a Singleton class is shown below:
The “new” keyword in C# is one of the most commonly known and used keywords in C#.It is used as an operator for instantiating objects of a class as shown below.
Workflow and Host Communication in WF 4.0–Bookmarks
Posted: April 22, 2012 in .NET, C#, WFTags: Bookmarks, WF4.0
In the last post we have discussed at length about different mechanisms of parameter passing and obtaining results from a workflow.In this post we will discuss about another extremely important aspect of workflow and host communication i.e. Bookmarks. Bookmarks as the name suggests is a like Bookmark for a book. When created at a particular point in the execution of the workflow , the execution is suspended and the workflow waits to be resumed.When a bookmark is resumed it starts executing exactly from the same point.
Workflow and Host Communication in WF 4.0–Parameter Passing
Posted: April 8, 2012 in .NET, WFTags: Parameter Passing, WF, WF4.0
Workflow host is an application responsible for executing the workflow and managing different workflow lifecycle events like start, completion, idle, unloaded etc.Now the workflow host should be capable of exchanging information with the workflow. This information exchange can be broadly categorized into:
a) The parameters/arguments needed to start the workflow and to get the results back after workflow has executed.
b) The intermediate data needs at different stages of a long running workflow (e.g. when the workflow is waiting for a specific input like Manager’s Approval).
In this post we will concentrate on the different mechanisms of parameter passing and getting results back. In the subsequent posts we will move into more complex scenarios related to long running workflows.
WF 4.0 provides two classes for hosting and managing the workflows System.Activities.WorkflowInvoker and System.Activities.WorkflowApplication.WorkflowInvoker provides a simple model to execute the workflow like a method call whereas WorkflowApplication much greater flexibility to execute and manage the workflow instance. To start with we will explore the different mechanisms to pass data back and forth using WorkflowInvoker and WorkflowApplication.
Roslyn CTP–Syntax Tree–Part II–Singleton Checker
Posted: November 20, 2011 in .NET, C#Tags: C#, Roslyn CTP
In the last post related to Roslyn we developed a very basic syntax walker. In this post we will see how we can use the same for code analysis and checking. As a good practice we generally try to avoid having instance members in a singleton class. This is true if you are making your business logic layer classes Singleton and would prefer to avoid mess up by multiple threads. In order to check that we need to check the following:
a) Whether the class has any instance fields or properties
b) Whether class is a singleton i.e having a private constructor
Let’s consider the following singleton class:

