public void OverrideProfile(TypePath typePath, string instanceKey) { _pluginGraph.Log.WithType(typePath, "while trying to add an override for a Profile", pluginType => { var instance = new ReferencedInstance(instanceKey); _pluginGraph.SetDefault(_lastProfile, pluginType, instance); }); }
public void GenericsTypeAndProfileOrMachine() { PluginGraph pluginGraph = PluginGraph.BuildGraphFromAssembly(typeof(IService <>).Assembly); pluginGraph.SetDefault("1", typeof(IService <>), new ReferencedInstance("Default")); pluginGraph.SetDefault("2", typeof(IService <>), new ReferencedInstance("Plugged")); var manager = new Container(pluginGraph); var plug = manager.GetInstance <IPlug <string> >(); manager.SetDefaultsToProfile("1"); Assert.IsInstanceOfType(typeof(Service <string>), manager.GetInstance(typeof(IService <string>))); manager.SetDefaultsToProfile("2"); Assert.IsInstanceOfType(typeof(ServiceWithPlug <string>), manager.GetInstance(typeof(IService <string>))); manager.SetDefaultsToProfile("1"); Assert.IsInstanceOfType(typeof(Service <string>), manager.GetInstance(typeof(IService <string>))); }