WCF Large interface with one endpoint address

I have a wcf service that provides a fairly large number of service methods on a single endpoint address. Until now, all service methods are implemented in one class of contractual services. This class of contracted services implements several service contract interfaces. Now I would like to divide the implementation of the methods of the service contract into several classes in order to avoid the growth of the class of the contract. I am using a self-hosting script with ServiceHost. ServiceHost simply takes the type of one type that implements the methods of the service, so it seems that everything should be implemented in this class. Of course, the flesh of methods can be divided into several classes. But is there a way to split methods into several classes?

+5
source share
3 answers

You can implement the service as a partial class , which allows you to split the implementation into several files.

If the requirement is to save a single endpoint and one interface, then there is no other way to split it — the one class you create must implement the entire interface.

I propose to simplify the implementation of the service as much as possible, and simply each method should be single-line, which delegates the operation of the actual implementation, which can then be divided into several classes. Perhaps it would even be advisable to do one per operation? This is a sample that I used before with success.

+5
source

, , .

, , , .

, , .

0

. , . , - . .

. ( ) . - ServiceHost . .

, , , .

0

All Articles