I have a solution with many concrete implementations each in their own class library which all implement one of four main interfaces that I have built. I have also created a factory object for each interface to dynamically load the requested object. ie
public static IDataIngestorFormat GetDataIngestionFormat(string typeName, IDataIngestor di)
{
Type format = Type.GetType(typeName);
object formatInstance = Activator.CreateInstance(format, di);
IDataIngestorFormat instance = formatInstance as IDataIngestorFormat;
return instance;
}
Everything is working as expected until I come to the usage of these objects. I have a some unit test projects for each of the interfaces and concrete objects as well as a WCF REST service and an API layer that require access however will fail on the CreateInstance unless I copy the concrete objects (with a Post Build Event) to the output path of each of these client projects which are in the same solution.
Now for my question - this approach works, but I would prefer to not have to remember to add these in to all of my client projects every time I create a new concrete implementation.
Is there an easy way to achieve this or am I going to have to remember to visit all of my client projects every time I add a new concrete implementation?
如果可以使用命名约定来保证每个客户端程序集和相关单元测试程序集的唯一名称,则只需更改构建输出路径,即可将所有内容构建到顶层构建目录中。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.