예제 #1
0
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            T foundModel = this.FindModel(moduleModel, visibility);

            if (foundModel != null)
            {
                if (this.Model == null)
                {
                    this.Model      = foundModel;
                    this.Module     = moduleInstance;
                    this.Visibility = visibility;
                }
                else
                {
                    // If same visibility -> ambiguous types
                    if (this.Visibility == visibility)
                    {
                        throw new Exception("AmbigiousType"); //AmbiguousTypeException(type);
                    }
                }
            }

            // Break if we have found a model and visibility has changed since the find
            return(!(this.Model != null && this.Visibility != visibility));
        }
예제 #2
0
 public Resolution(ApplicationModel application,
                   LayerModel layer,
                   ModuleModel module,
                   ObjectDescriptor objectDescriptor,
                   CompositeMethodModel method,
                   FieldInfo field)
 {
     this.Application      = application;
     this.Layer            = layer;
     this.Module           = module;
     this.ObjectDescriptor = objectDescriptor;
     this.Method           = method;
     this.Field            = field;
 }
예제 #3
0
파일: Binder.cs 프로젝트: attila3453/alsing
 public Resolution(ApplicationModel application,
                   LayerModel layer,
                   ModuleModel module,
                   ObjectDescriptor objectDescriptor,
                   CompositeMethodModel method,
                   FieldInfo field)
 {
     this.Application = application;
     this.Layer = layer;
     this.Module = module;
     this.ObjectDescriptor = objectDescriptor;
     this.Method = method;
     this.Field = field;
 }
예제 #4
0
        public static LayerModel NewModel(LayerAssembly layer)
        {
            var moduleModels = new List <ModuleModel>();

            foreach (ModuleAssemblyImpl module in layer.Modules)
            {
                ModuleModel moduleModel = module.AssembleModule();
                moduleModels.Add(moduleModel);
            }

            //TODO:fix usedLayerModel

            var usedLayersModel = new List <LayerModel>();

            var layerModel = new LayerModel(layer.Name, layer.MetaInfo, usedLayersModel, moduleModels);

            return(layerModel);
        }
예제 #5
0
        public ModuleInstance(ModuleModel moduleModel, LayerInstance layerInstance, TransientsModel transientsModel,
                              EntitiesModel entitiesModel, ObjectsModel objectsModel, ValuesModel valuesModel,
                              ServicesModel servicesModel, ImportedServicesModel importedServicesModel)
        {
            this.Model = moduleModel;
            this.LayerInstance = layerInstance;
            this.Transients = new TransientsInstance(transientsModel, this);
            this.Entities = new EntitiesInstance(entitiesModel, this);
            this.Objects = new ObjectsInstance(objectsModel, this);
            this.Values = new ValuesInstance(valuesModel, this);
            this.Services = servicesModel.NewInstance(this);
            this.ImportedServices = importedServicesModel.NewInstance(this);

            this.TransientBuilderFactory = new TransientBuilderFactoryInstance(this);
            this.ObjectBuilderFactory = new ObjectBuilderFactoryInstance();
            this.ValueBuilderFactory = new ValueBuilderFactoryInstance(this);
            this.UnitOfWorkFactory = new UnitOfWorkFactoryInstance();
            this.ServiceFinder = new ServiceFinderInstance(this);

            this.entityFinders = new Dictionary<Type, EntityFinder>();
            this.transientFinders = new Dictionary<Type, TransientFinder>();
            this.ObjectFinders = new Dictionary<Type, ObjectFinder>();
            this.valueFinders = new Dictionary<Type, ValueFinder>();
        }
예제 #6
0
        public ModuleInstance(ModuleModel moduleModel, LayerInstance layerInstance, TransientsModel transientsModel,
                              EntitiesModel entitiesModel, ObjectsModel objectsModel, ValuesModel valuesModel,
                              ServicesModel servicesModel, ImportedServicesModel importedServicesModel)
        {
            this.Model            = moduleModel;
            this.LayerInstance    = layerInstance;
            this.Transients       = new TransientsInstance(transientsModel, this);
            this.Entities         = new EntitiesInstance(entitiesModel, this);
            this.Objects          = new ObjectsInstance(objectsModel, this);
            this.Values           = new ValuesInstance(valuesModel, this);
            this.Services         = servicesModel.NewInstance(this);
            this.ImportedServices = importedServicesModel.NewInstance(this);

            this.TransientBuilderFactory = new TransientBuilderFactoryInstance(this);
            this.ObjectBuilderFactory    = new ObjectBuilderFactoryInstance();
            this.ValueBuilderFactory     = new ValueBuilderFactoryInstance(this);
            this.UnitOfWorkFactory       = new UnitOfWorkFactoryInstance();
            this.ServiceFinder           = new ServiceFinderInstance(this);

            this.entityFinders    = new Dictionary <Type, EntityFinder>();
            this.transientFinders = new Dictionary <Type, TransientFinder>();
            this.ObjectFinders    = new Dictionary <Type, ObjectFinder>();
            this.valueFinders     = new Dictionary <Type, ValueFinder>();
        }
예제 #7
0
 public void Visit(ModuleModel model)
 {
     throw new NotImplementedException();
 }
예제 #8
0
        public ModuleModel AssembleModule()
        {
            var compositeModels = new List<TransientModel>();
            var entityModels = new List<EntityModel>();
            var objectModels = new List<ObjectModel>();
            var valueModels = new List<ValueModel>();
            var serviceModels = new List<ServiceModel>();
            var importedServiceModels = new List<ImportedServiceModel>();

            if (this.name == null)
            {
                throw new Exception("Module must have name set");
            }

            var moduleModel = new ModuleModel(this.name,
                                              this.metaInfo, new TransientsModel(compositeModels),
                                              new EntitiesModel(entityModels),
                                              new ObjectsModel(objectModels),
                                              new ValuesModel(valueModels),
                                              new ServicesModel(serviceModels),
                                              new ImportedServicesModel(importedServiceModels));

            foreach (TransientDeclarationImpl transientDeclaration in this.transientDeclarations)
            {
                transientDeclaration.AddTransients(compositeModels, this.metaInfoDeclaration);
            }

            foreach (ValueDeclarationImpl valueDeclaration in this.valueDeclarations)
            {
                valueDeclaration.AddValues(valueModels, this.metaInfoDeclaration);
            }

            foreach (EntityDeclarationImpl entityDeclaration in this.entityDeclarations)
            {
                entityDeclaration.AddEntities(entityModels, this.metaInfoDeclaration);
            }

            foreach (ServiceDeclarationImpl serviceDeclaration in this.serviceDeclarations)
            {
                serviceDeclaration.AddServices(serviceModels, this.metaInfoDeclaration);
            }

            return moduleModel;

            //    for( ObjectDeclarationImpl objectDeclaration : objectDeclarations )
            //{
            //    objectDeclaration.addObjects( objectModels );
            //}

            //for( ImportedServiceDeclarationImpl importedServiceDeclaration : importedServiceDeclarations )
            //{
            //    importedServiceDeclaration.addServices( importedServiceModels );
            //}

            //// Check for duplicate service identities
            //Set<String> identities = new HashSet<String>();
            //for( ServiceModel serviceModel : serviceModels )
            //{
            //    String identity = serviceModel.identity();
            //    if( identities.contains( identity ) )
            //    {
            //        throw new DuplicateServiceIdentityException(
            //            "Duplicated service identity: " + identity + " in module " + moduleModel.name()
            //        );
            //    }
            //    identities.add( identity );
            //}
            //for( ImportedServiceModel serviceModel : importedServiceModels )
            //{
            //    String identity = serviceModel.identity();
            //    if( identities.contains( identity ) )
            //    {
            //        throw new DuplicateServiceIdentityException(
            //            "Duplicated service identity: " + identity + " in module " + moduleModel.name()
            //        );
            //    }
            //    identities.add( identity );
            //}

            //for( ImportedServiceModel importedServiceModel : importedServiceModels )
            //{
            //    boolean found = false;
            //    for( ObjectModel objectModel : objectModels )
            //    {
            //        if( objectModel.type().equals( importedServiceModel.serviceImporter() ) )
            //        {
            //            found = true;
            //            break;
            //        }
            //    }
            //    if( !found )
            //    {
            //        Class<? extends ServiceImporter> serviceFactoryType = importedServiceModel.serviceImporter();
            //        ObjectModel objectModel = new ObjectModel( serviceFactoryType, Visibility.module, new MetaInfo() );
            //        objectModels.add( objectModel );
            //    }
            //}
        }
예제 #9
0
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            this.Service = moduleInstance.GetServiceFor(this.Type, visibility);

            return this.Service == null;
        }
예제 #10
0
        public ModuleModel AssembleModule()
        {
            var compositeModels       = new List <TransientModel>();
            var entityModels          = new List <EntityModel>();
            var objectModels          = new List <ObjectModel>();
            var valueModels           = new List <ValueModel>();
            var serviceModels         = new List <ServiceModel>();
            var importedServiceModels = new List <ImportedServiceModel>();

            if (this.name == null)
            {
                throw new Exception("Module must have name set");
            }

            var moduleModel = new ModuleModel(this.name,
                                              this.metaInfo, new TransientsModel(compositeModels),
                                              new EntitiesModel(entityModels),
                                              new ObjectsModel(objectModels),
                                              new ValuesModel(valueModels),
                                              new ServicesModel(serviceModels),
                                              new ImportedServicesModel(importedServiceModels));

            foreach (TransientDeclarationImpl transientDeclaration in this.transientDeclarations)
            {
                transientDeclaration.AddTransients(compositeModels, this.metaInfoDeclaration);
            }

            foreach (ValueDeclarationImpl valueDeclaration in this.valueDeclarations)
            {
                valueDeclaration.AddValues(valueModels, this.metaInfoDeclaration);
            }

            foreach (EntityDeclarationImpl entityDeclaration in this.entityDeclarations)
            {
                entityDeclaration.AddEntities(entityModels, this.metaInfoDeclaration);
            }

            foreach (ServiceDeclarationImpl serviceDeclaration in this.serviceDeclarations)
            {
                serviceDeclaration.AddServices(serviceModels, this.metaInfoDeclaration);
            }

            return(moduleModel);

            //    for( ObjectDeclarationImpl objectDeclaration : objectDeclarations )
            //{
            //    objectDeclaration.addObjects( objectModels );
            //}

            //for( ImportedServiceDeclarationImpl importedServiceDeclaration : importedServiceDeclarations )
            //{
            //    importedServiceDeclaration.addServices( importedServiceModels );
            //}

            //// Check for duplicate service identities
            //Set<String> identities = new HashSet<String>();
            //for( ServiceModel serviceModel : serviceModels )
            //{
            //    String identity = serviceModel.identity();
            //    if( identities.contains( identity ) )
            //    {
            //        throw new DuplicateServiceIdentityException(
            //            "Duplicated service identity: " + identity + " in module " + moduleModel.name()
            //        );
            //    }
            //    identities.add( identity );
            //}
            //for( ImportedServiceModel serviceModel : importedServiceModels )
            //{
            //    String identity = serviceModel.identity();
            //    if( identities.contains( identity ) )
            //    {
            //        throw new DuplicateServiceIdentityException(
            //            "Duplicated service identity: " + identity + " in module " + moduleModel.name()
            //        );
            //    }
            //    identities.add( identity );
            //}

            //for( ImportedServiceModel importedServiceModel : importedServiceModels )
            //{
            //    boolean found = false;
            //    for( ObjectModel objectModel : objectModels )
            //    {
            //        if( objectModel.type().equals( importedServiceModel.serviceImporter() ) )
            //        {
            //            found = true;
            //            break;
            //        }
            //    }
            //    if( !found )
            //    {
            //        Class<? extends ServiceImporter> serviceFactoryType = importedServiceModel.serviceImporter();
            //        ObjectModel objectModel = new ObjectModel( serviceFactoryType, Visibility.module, new MetaInfo() );
            //        objectModels.add( objectModel );
            //    }
            //}
        }
예제 #11
0
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            moduleInstance.GetServicesFor(this.Type, visibility, this.Services);

            return(true);
        }
예제 #12
0
 protected abstract T FindModel(ModuleModel model, Visibility visibility);
예제 #13
0
 public void Visit(ModuleModel model)
 {
     throw new NotImplementedException();
 }
예제 #14
0
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            this.Service = moduleInstance.GetServiceFor(this.Type, visibility);

            return(this.Service == null);
        }
예제 #15
0
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            moduleInstance.GetServicesFor(this.Type, visibility, this.Services);

            return true;
        }