IModule.AddServices(Workitem workitem)

Topics: CAB & Smart Client Software Factory
Dec 3, 2005 at 9:39 AM
originally posted by: jdressel

Looking at the current implementation of ModuleMetadata.LoadServices(WorkItem workItem), it would seem necessary that the IModule.AddServices() should be IModule.AddServices(WorkItem workItem) instead? Otherwise, what workitem is the Module to custom add the services to? The former ModuleInit had knowledge of the ApplicationHost. I scanned the Unit tests for an example use of IModule.AddService impl in the CompositeUI.Tests.VSTSMocks.Src but did not find one. For example, a failing test is to alter the TestModule of ModuleExposingServices.cs to add a service not decorated with a ServiceAttribute via AddServices().
Dec 3, 2005 at 10:35 AM
originally posted by: jdressel

After further investigation, an alternative could have ModuleInit.cs looking something like the following:

public class ModuleInit
{
private WorkItem parentWorkItem;

Dependency
public WorkItem ParentWorkItem
{
get { return parentWorkItem; }
set { parentWorkItem = value; }
}

public virtual void AddServices(){}
public virtual void Load(){}

}
Dec 3, 2005 at 11:52 AM
originally posted by: BradWilsonMSFT

Yes, or if you'd rather not expose a public setter:

public class MyModuleInit : ModuleInit
{
private WorkItem parentWorkItem;

InjectionConstructor
public MyModuleInit(ServiceDependency WorkItem parentWorkItem)
{
this.parentWorkItem = parentWorkItem;
}
}
Dec 3, 2005 at 12:39 PM
originally posted by: jdressel

Yes, thank you. I prefer the InjectionConstructor approach.