Here example how i made mine
this would be a first set of methods
[ServiceContract]
public partial interface IDefaultInterface
{
[OperationContract]
string getData1();
}
public partial class CDefaultClass : IDefaultInterface
{
public getData1(){ return "data 1"; }
}
this would be another set of methods you would like split
[ServiceContract]
public partial interface IDefaultInterface2
{
[OperationContract]
string getData2();
}
public partial class CDefaultClass2 : IDefaultInterface2
{
public getData2(){ return "data 2"; }
}
the following is my derivatives logic with comments
namespace wcfMyService
{
// this list all derivation for the easy to follow service.
// this service will have LOTS of function so ability
// to split in multiple classes was necessary
// on client side we only see 1 set of function all mixed together
// but at least working on it it's easy to follow for us since we have a structure
#region Class Derivation
public class CDerivative : CDefaultClass { }
public partial class CDefaultClass : CDefaultClass2 { }
// NOTE THAT ALL NEW CLASSES MUST :
// - Be PARTIAL classes
// - Implement their OWN interface
// new class would be
// public partial class CDefaultClass2 : CMyNewClass { }
// and so on. previous class derive from the new class
#endregion
#region Interface Derivation
[ServiceContract]
public interface IDerivative : IDefaultInterface { }
public partial interface IDefaultInterface : IDefaultInterface2 { }
// NOTE THAT ALL NEW INTERFACE MUST :
// - Be PARTIAL Interface
// - Have attribute [ServiceContract]
// - all methods need [OperationContract] as usual
// new class interface would be
// public partial interface IDefaultInterface2 : IMyNewClass { }
// and so on. previous class interface derive from the new class interface
#endregion
}
Now your normal service interface you simply add the derivation AND interface so end point see all functions of all derived class. No code required inside as Class implement their own methods from their individual interface. So no cluster of millions of methods in each class
[ServiceContract]
public interface IService : IDerivative
{
}
Finally you need to code the SVC/ASMX (whatever) as following so it expose everything for WSDL and such. Again no code needed in this class either
public partial class Service : CDerivative, IService
{
}
So overall all you need to do when you want new methods in another class for better structure just create partial interface and partial class as you would normally create a service contract and operation. Then simply go in the derivative file and add you interface and class to the derivation. since they all implement their own interface ONLY there shouldn't be any collision and when you code you will never see methods of other classes.
I like this organization very much and make nice tree view with proper folder and i can quickly spot a method out of the thousands in there.