Sometimes you want to use many contexts in a service method.
Currently Func<IContext> is not supported in WAQS specifications.
Because WAQS generated types are partial, you can extend them. But I think it’s a shame to extend the client context, the client context interface, the WCF service data contract, the WCF service, the service interface and the service (in order to use WAQS architecture).
To avoid it, WAQS proposes a Custom attribute.
In Specifications, you define your method with anything as body (it will be ignored) and with Custom attribute.
public static void Foo()
throw new NotImplementedException();
From this, WAQS generates code in each layers.
In the service one (the one that should contain the method body), WAQS generates a call to a method with the same signature with Body as a method name suffix.
public void Foo()
This code does not compile because FooBody method is not generated by WAQS.
You wanted a custom implementation, you have to define it yourself.
But with this way, you only have one method to implement.
Then, in this method you can use _contextFactory or _serviceFactory class fields to create a new context.