Adding classes into Business logic project

Nov 19, 2007 at 12:39 PM
I am interesting in following :

After code generation i would like to create (throughout generation) one class for each operation and to store them into Business Logic project. Is that possible and if it is, what i have to do (some custom recipes, and custom links ) ?

Nov 19, 2007 at 8:03 PM
That is possible but you will certainly need to update the service contract model in order to specify the role information that is tipically associated with a model element. (when you say "operation" I assume a service contract operation right?).
BTW, soome of the details about this extensibility scenario will be addressed in the upcoming (anytime soon) "Extensibility Hands-on lab" that will be published along with the current building Hands-on.

So here are a few tips:
- Add the "BusinessLogicRole" to the Operation shape in theServiceContract project, DslDefinition.dsl file, in the "Custom Attributes" property of this shape. (this will result in code like this)


- Now you need to update the WCFOperationContract class in Microsoft.Practices.ServiceFactory.Extenders.ServiceContract.Wcf project or the similar class in the ASMX extender and add the artifact link property. You can also add a new extender library (my suggestion) and add a partial class that extends the original one. Your new extender Operation class may be something like this:

public class MyOperation: ObjectExtender<Operation>
     [Category("WCF Settings"),
     Description("Specifies how the code will be generated."),
       DisplayName("Artifact Link"),
    public MyBusinessLogicLink ArtifactLink
		if (this.ModelElement != null &&
		this.ModelElement.ServiceContractModel != null)
			return ArtifactLinkFactory.CreateInstance<MyBusinessLogicLink>(
		return null;
This code assumes that you have an artifact link class named "MyBusinessLogicLink" that points to your tt file that will generate your business logic class.

As I said, this is just a head start but you will likely need some more samples and directions that you will find in the Extensibility Hands-on.
Let me know if you need further details before this Hands-on comes out so this won't be a blocking issue for you.
Nov 20, 2007 at 12:38 PM
Edited Nov 20, 2007 at 12:39 PM
Yes i mean on these operations, thanks a lot i make it on. There is only some additional customizations for appropriate code genaration and these are :

in operation.cs Microsoft.Practices.ServiceFactory.Extenders.ServiceContract.Wcf namespace add following into public ICollection<IArtifactLink> ArtifactLinks function :
List<IArtifactLink> links = new List<IArtifactLink>();
if (ObjectExtender is IArtifactLinkContainer)
IArtifactLinkContainer container = (IArtifactLinkContainer)ObjectExtender;
this enables insertation of Operation into ArtifactLinks.

2. In addition to BusinessLogicRole in dsl model there is one more extra setting - adding DomainProperty on Operation shape which is named Namespace, this one enables final class genartion from link class.

Thank you Charly, best regards