protected virtual InstanceFactory createFactory(Type pluggedType) { if (pluggedType.IsGenericType) { PluginFamily family = _genericsGraph.CreateTemplatedFamily(pluggedType, _profileManager); if (family != null) { return(InstanceFactory.CreateFactoryForFamily(family, _profileManager)); } } return(InstanceFactory.CreateFactoryForType(pluggedType, _profileManager)); }
public void GetTemplatedFamily() { var pluginGraph = new PluginGraph(); PluginFamily family = pluginGraph.FindFamily(typeof(IGenericService <>)); family.AddPlugin(typeof(GenericService <>), "Default"); family.AddPlugin(typeof(SecondGenericService <>), "Second"); family.AddPlugin(typeof(ThirdGenericService <>), "Third"); var genericsGraph = new GenericsPluginGraph(); genericsGraph.AddFamily(family); PluginFamily templatedFamily = genericsGraph.CreateTemplatedFamily(typeof(IGenericService <int>), new ProfileManager()); Assert.IsNotNull(templatedFamily); Assert.AreEqual(typeof(IGenericService <int>), templatedFamily.PluginType); }