So I am building out a largish WCF REST service and wanted to break down my code by splitting out logical implementation code into different code files.
I have three main logical separation: "Categories", "Topics" and "Posts".
Heres the thing, I only wanted to specify one SVC file in my web.config <service> node base address and then just configure an endpoint for each logical element.
I started by creating an Interface for each element, Categories, Topics and Posts then specifying an endpoint for each element referring to the relevant interface.
The problem with one .svc file is that you can only point it to a single class type.
Anyway my thought was to break out the implementation code for each element into a partial class and have each declaration of that partial class implement the relevant interface. My reckoning was that when the compiler pulls together each partial class declaration it would treat it like a single class declaration implementing three interfaces.
Instead the compiler complained that I can't have multiple base classes in a partial class? I don't see why this isn't possible, can anyone explain why this might be?
So to clarify in C# I can have the following:
public class InsiderSpecialsWebService : IInsiderSpecialsCategoryWebService,
IInsiderSpecialsTopicWebService,
IInsiderSpecialsPostWebService
But I can't have
public partial class InsiderSpecialsWebService : IInsiderSpecialsCategoryWebService public partial class InsiderSpecialsWebService : IInsiderSpecialsTopicWebService public partial class InsiderSpecialsWebService : IInsiderSpecialsPostWebService
I suspect it's the way the compiler pulls together the partial class files, but I don't see why this isn't technically possible.
I got around this by creating a Repository class that does the grunt work for each logical element and just calling the relevant repository class method from each web service method. I think it's still nicer than having multiple services configured and hence multiple.svc files or lumping all your implementation code into one large class.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.