Thursday, 12 May 2016

Split WCF service class using partial

In WCF service, If you have lots of methods in your single service then you can physically split those methods ,and arrange them as per your requirements.


Interface:  

ICalculator.cs

[ServiceContract] 
public interface ICalculator 
{ 
   [OperationContract]
   double Add(double n1, double n2);
   [OperationContract]
   double Subtract(double n1, double n2);
   [OperationContract]
   double Multiply(double n1, double n2);
   [OperationContract]
   double Divide(double n1, double n2);
}

Service Class:

1. CalculatorService.cs
public partial class CalculatorService : ICalculator
{
  double Add(double n1, double n2){}
  double Subtract(double n1, double n2){}
}

2. CalculatorService2.cs
public partial class CalculatorService : ICalculator
{
  double Multiply(double n1, double n2){}
  double Divide(double n1, double n2){}
}



No comments:

Post a Comment

Parent-Child class declaration and initialization

using System; namespace CSharpDemo {     public class A     {         public void print()         {             Console.Wr...