WAQS: CustomAttribute

7 reasons to use WAQS

WAQS documentation

 

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.

For example:

[Custom]
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()
{
    FooBody();
}


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.

This entry was posted in 16868. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>