Posts

Showing posts from October, 2010

Interview Questions - Part 2

When to use Interface? Use an interface when: There are a group of related methods that may be called. A class only needs one implementation of the method. The class using the interface will want to cast that interface to other interface or class types. The method being implemented is linked to the type or identity of the class: for example, comparison methods. When to use delegates? Use a delegate when: An eventing design pattern is used. It is desirable to encapsulate a static method. The caller has no need access other properties, methods, or interfaces on the object implementing the method. Easy composition is desired. A class may need more than one implementation of the method. Service contracts? Data Contracts? What keyword shadowing? What is keyword yield? What are different kinds of Cursors? What are different kinds of triggers? What is var? What is the difference between memory table v/s temp tables? Why u have not used cursors in ur project? When u ll go for win forms and web...

Message Headers for WCF Request

Often do we want to pass some data to some or maybe all our service operations. This data is usually context data such as user tokens (user information), or environmental preferences of the user or machine (in Respond terminology: UserConext object). In these kind of situations, we would rather not add additional context parameters to the contracts or our services, because we don’t want to involve implementation data / context data with the business parameters of our services. A nice and easy way to pass that data is to use MessageHeaders. In order to do this we follow these steps: Add the context data to the outgoing message headers. Call the operation (Nothing special here). Extract the data from the incoming message headers. Using an OperationContextScope In order to add the message header, you should have a OperationContext for your call. An OperationContext will automaticly be created for the call, and will be available in the service side. If one wishes to add the message he...