Thursday, April 5, 2012

Entry of Windows Communication Service (WCF)

I'm studying WCF. It's so nice and useful framework so that I'm going to log my understanding into the blog.


The simple WCF code is here.
 [DataContract]  
 public class Eval  
 {  
   [DataMember]  
   public string Submitter;  
   [DataMember]  
   public DateTime Timesent;  
   [DataMember]  
   public string Comments;  
 }  
 [ServiceContract]  
 public interface IEvalService  
 {  
   [OperationContract]  
   void SubmitEval(Eval eval);  
   [OperationContract]  
   List<Eval> GetEvals();  
 }  
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single, 
    ConcurrencyMode=ConcurrencyMode.Multiple)]
 public class EvalService : IEvalService  
 {  
   List<Eval> evals = new List<Eval>();  
   public void SubmitEval(Eval eval)  
   {  
     evals.Add(eval);  
   }  
   public List<Eval> GetEvals()  
   {  
     return evals;  
   }  
 }  

So, I studied new things about ServiceBehavior attribute.
ServiceBehavior has two enum parameters mainly that are InstanceContextMode and ConcurrencyMode.
InstanceContextMode has Single, Percall, and Persession that are about instanciation. Also ConcurrencyMode has Single, Multiple, and Reentrant that are about threading.


In detail, here is msdn documents.
http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.aspx
http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontextmode.aspx
http://msdn.microsoft.com/en-us/library/system.servicemodel.concurrencymode.aspx


I'm going to continue this series depend on my study progress.
Thanks.

No comments:

Post a Comment