예제 #1
0
 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();
 }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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());
        }
예제 #5
0
        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);
        }
예제 #6
0
        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();
        }
예제 #7
0
            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"}")
 {
 }
예제 #9
0
 internal void RegisterSubService(ServiceFamily s)
 {
     Debug.Assert(!SubServices.Keys.Contains(s.RootService));
     SubServices.Add(s.RootService, s);
 }