コード例 #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
ファイル: ServiceFamilyTester.cs プロジェクト: yuzd/lamar
        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
ファイル: ServiceFamilyTester.cs プロジェクト: yuzd/lamar
        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
ファイル: ServiceFamilyTester.cs プロジェクト: yuzd/lamar
        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
ファイル: ServiceFamilyTester.cs プロジェクト: yuzd/lamar
        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);
                }
            }
コード例 #8
0
 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);
 }