Exemple #1
0
 public LayerInstance(LayerModel model, ApplicationInstance applicationInstance, IList<ModuleInstance> moduleInstances, UsedLayersInstance usedLayersInstance)
 {
     this.Model = model;
     this.ApplicationInstance = applicationInstance;
     this.moduleInstances = moduleInstances;
     this.UsedLayersInstance = usedLayersInstance;
     //   this.moduleActivator = new Activator();
 }
        public ApplicationInstance NewInstance()
        {
            var layerInstances = new List<LayerInstance>();
            var applicationInstance = new ApplicationInstance(this, layerInstances);

            foreach (LayerModel layer in this.layers)
            {
                LayerInstance layerInstance = layer.NewInstance(applicationInstance, null);
                layerInstances.Add(layerInstance);
            }

            return applicationInstance;
        }
Exemple #3
0
        public LayerInstance NewInstance(ApplicationInstance applicationInstance, UsedLayersInstance usedLayerInstance)
        {
            var moduleInstances = new List<ModuleInstance>();
            var layerInstance = new LayerInstance(this, applicationInstance, moduleInstances, usedLayerInstance);

            foreach (ModuleModel module in this.modules)
            {
                ModuleInstance moduleInstance = module.NewInstance(layerInstance);
                moduleInstances.Add(moduleInstance);
            }

            return layerInstance;
        }
Exemple #4
0
        private static void Run(ApplicationInstance applicationInstance)
        {
            Module experimentalModule = applicationInstance.FindModule("DomainLayer", "ExperimentalModule");

            TransientBuilder<Customer> customerBuilder = experimentalModule.TransientBuilderFactory.NewTransientBuilder<Customer>();
            ValueBuilder<Address> addressBuilder = experimentalModule.ValueBuilderFactory.NewValueBuilder<Address>();

            Address protoAddress = addressBuilder.Prototype();
            protoAddress.City = "Foo City";
            protoAddress.StreetName = "Acme road 123";
            protoAddress.ZipCode = "888-555";

            var protoCustomer = customerBuilder.PrototypeFor<Customer>();
            protoCustomer.Name = "Acme Inc";
            protoCustomer.Email = "*****@*****.**";
            protoCustomer.Address = addressBuilder.NewInstance();

            Customer customer = customerBuilder.NewInstance();

            customer.Print();

            customer.SayHello();

            //customer.Address.City = "abc"; //should throw, immutable object

            Address otherAddress = addressBuilder.NewInstance();

            bool areEqual = customer.Address.Equals(otherAddress);

            if (areEqual)
            {
                Console.WriteLine("customer.Address and otherAddress are equal");
            }

            //customer.SayHelloTo(null); //should throw, name is not optional

            CustomerRepository customerRepo = experimentalModule
                    .ServiceFinder
                    .FindService<CustomerRepository>()
                    .Get();

            var id = customerRepo as Identity;
            Console.WriteLine(id.Identity);

            Customer x = customerRepo.NewCustomer("arne");

            customer.SayHelloTo("Roger");

            Console.ReadLine();
        }