internal ServiceData(IConfigurationSolver solver, IServiceInfo s, ConfigurationStatus serviceStatus, StartDependencyImpact impact = StartDependencyImpact.Unknown) : this(s, serviceStatus, impact) { Family = new ServiceFamily(solver, this); _inheritedServicesWithThis = new ServiceData[] { this }; Initialize(); }
public void the_last_instance_is_the_default() { var family = new ServiceFamily(typeof(IWidget), new IDecoratorPolicy[0], new Instance[] { ConstructorInstance.For <IWidget, AWidget>(), ConstructorInstance.For <IWidget, ColorWidget>(), }); family.Default.As <ConstructorInstance>().ImplementationType.ShouldBe(typeof(ColorWidget)); }
public void stores_all_in_order() { var allInstances = new Instance[] { ConstructorInstance.For <IWidget, AWidget>(), ConstructorInstance.For <IWidget, AWidget>(), ConstructorInstance.For <IWidget, ColorWidget>(), ConstructorInstance.For <IWidget, MoneyWidget>(), }; var family = new ServiceFamily(typeof(IWidget), new IDecoratorPolicy[0], allInstances); family.All.ShouldBe(allInstances); }
public void setting_the_is_default_property_on_instance() { var family = new ServiceFamily(typeof(IWidget), new IDecoratorPolicy[0], new Instance[] { ConstructorInstance.For <IWidget, AWidget>(), ConstructorInstance.For <IWidget, AWidget>(), ConstructorInstance.For <IWidget, AWidget>(), ConstructorInstance.For <IWidget, ColorWidget>(), ConstructorInstance.For <IWidget, ColorWidget>(), ConstructorInstance.For <IWidget, MoneyWidget>(), }); family.Instances["moneyWidget"].IsDefault.ShouldBeTrue(); family.Instances.Values.Where(x => x.Name != "moneyWidget").Each(x => x.IsDefault.ShouldBeFalse()); }
private ServiceFamily FindOrCreateServiceFamily(IServiceInfo s) { bool exists; ServiceFamily family = _serviceFamilies.GetByKey(s, out exists); if (!exists) { family = new ServiceFamily(_serviceVertices.GetByKey(s), this); if (family.ParentServiceFamily == null) { _rootFamilies.Add(family); } } return(family); }
public void make_all_the_names_unique() { var family = new ServiceFamily(typeof(IWidget), new IDecoratorPolicy[0], new Instance[] { ConstructorInstance.For <IWidget, AWidget>(), ConstructorInstance.For <IWidget, AWidget>(), ConstructorInstance.For <IWidget, AWidget>(), ConstructorInstance.For <IWidget, ColorWidget>(), ConstructorInstance.For <IWidget, ColorWidget>(), ConstructorInstance.For <IWidget, MoneyWidget>(), }); family.Instances.ContainsKey("aWidget1").ShouldBeTrue(); family.Instances.ContainsKey("aWidget2").ShouldBeTrue(); family.Instances.ContainsKey("aWidget3").ShouldBeTrue(); family.Instances.ContainsKey("colorWidget1").ShouldBeTrue(); family.Instances.ContainsKey("colorWidget2").ShouldBeTrue(); family.Instances.ContainsKey("moneyWidget").ShouldBeTrue(); }
public ServiceFamily(YodiiGraphVertex rootVertex, YodiiLayout parent) { SubPlugins = new Dictionary <IPluginInfo, YodiiGraphVertex>(); SubServices = new Dictionary <IServiceInfo, ServiceFamily>(); Debug.Assert(rootVertex.IsService); _parent = parent; RootVertex = rootVertex; RootVertexSize = _parent.VertexSizes[RootVertex]; RootService = rootVertex.LabServiceInfo.ServiceInfo; if (RootService.Generalization != null) { var generalizationFamily = parent.FindOrCreateServiceFamily(RootService.Generalization); ParentServiceFamily = generalizationFamily; ParentServiceFamily.RegisterSubService(this); } }
public LamarMissingRegistrationException(ServiceFamily family) : base($"No service registrations exist for {family.ServiceType.FullNameInCode()} or can be derived because:\n{family.CannotBeResolvedMessage ?? "No registrations"}") { }
internal void RegisterSubService(ServiceFamily s) { Debug.Assert(!SubServices.Keys.Contains(s.RootService)); SubServices.Add(s.RootService, s); }