Ejemplo n.º 1
0
        public Factory(FactoryId factoryId, FactoryName name)
        {
            this.factoryId = factoryId;
            this.Name = name;

            this.producedOnions = new List<Onion>();
        }
Ejemplo n.º 2
0
        public void OpenFactory(FactoryId id)
        {
            if (_state.Id != null)
                throw DomainError.Named("factory-already-created", "Factory was already created");

            Apply(new FactoryOpened(id));
        }
Ejemplo n.º 3
0
        public void Execute(ConsoleEnvironment env, string[] args)
        {
            int factoryId = 1;

            if (args.Length > 0)
            {
                int.TryParse(args[0], out factoryId);
            }
            var id    = new FactoryId(factoryId);
            var story = new List <ICommand>
            {
                new OpenFactory(id),
                new AssignEmployeeToFactory(id, "Luke"),
                new AssignEmployeeToFactory(id, "Han"),
                new ReceiveShipmentInCargoBay(id, "from uncle Ben", new[]
                {
                    new CarPart("wheel", 10),
                    new CarPart("light saber", 2),
                    new CarPart("C3P0", 1),
                }),
                new ReceiveShipmentInCargoBay(id, "from Yoda", new[]
                {
                    new CarPart("engine", 2),
                    new CarPart("chassis", 1),
                }),
                new UnpackAndInventoryShipmentInCargoBay(id, "Han"),
                new ProduceACar(id, "Luke", "model-t")
            };

            foreach (var command in story)
            {
                env.FactoryAppService.Execute(command);
            }
        }
        public IEnumerable<Onion> ProduceOnions(FactoryId factoryId, OnionQuantity quanity)
        {
            var produceOnions = this.onionDomainService.ProduceOnions(quanity);

            this.factoryDomainService.AssignProducedOnions(factoryId, produceOnions);

            return produceOnions;
        }
        public void AssignProducedOnions(FactoryId factoryId, IEnumerable<Onion> producedOnions)
        {
            var factory = this.repository.Load(factoryId);

            factory.Assign(producedOnions);

            this.repository.Update(factory);
        }
Ejemplo n.º 6
0
        // Aggregate's method below modify internal "state" variables by doing their work and generating Events

        public void OpenFactory(FactoryId id)
        {
            // if the thing that tracks an aggregate's state already has and Id, the agg with that Id already exists!
            if (_aggregateState.Id != null)
                throw DomainError.Named("factory-already-created", "Factory was already created");

            RecordAndRealizeThat(new FactoryOpened(id));
        }
Ejemplo n.º 7
0
        public void OpenFactory(FactoryId id)
        {
            if (_state.Id != null)
            {
                throw DomainError.Named("factory-already-created", "Factory was already created");
            }

            Apply(new FactoryOpened(id));
        }
        private void HandleOpenFactoryClicked(object sender, OpenFactoryEventArgs e)
        {
            Logger.Log("Handling Open Factory Clicked Event");

            var factoryId = new FactoryId(e.FactoryName.Replace(" ", "_"));
            var factoryName = new FactoryName(e.FactoryName);

            this.onionProductionApplicationService.OpenFactory(factoryId, factoryName);
        }
Ejemplo n.º 9
0
        // Aggregate's method below modify internal "state" variables by doing their work and generating Events

        public void OpenFactory(FactoryId id)
        {
            // if the thing that tracks an aggregate's state already has and Id, the agg with that Id already exists!
            if (_aggregateState.Id != null)
            {
                throw DomainError.Named("factory-already-created", "Factory was already created");
            }

            RecordAndRealizeThat(new FactoryOpened(id));
        }
        public Factory OpenFactory(FactoryId factoryId, FactoryName name)
        {
            var factory = new Factory(factoryId, name);

            factory.Open(this.factoryOpened);

            this.repository.Save(factory);

            return factory;
        }
Ejemplo n.º 11
0
        //private void UpdateHeight() {
        //    Height = Math.Max(MConnectors.Count(c => c.Type == ConnectorType.InputConnector),
        //                      MConnectors.Count(c => c.Type == ConnectorType.OutputConnector)) * 13 + 45;
        //}

        public void Serialize(XmlWriter writer, NodeEditor editor)
        {
            writer.WriteAttributeString("id", InstanceId.ToString());
            writer.WriteAttributeString("factoryId", FactoryId.ToString());
            writer.WriteAttributeString("uniqueName", UniqueName);
            writer.WriteAttributeString("x", Location.X.ToString());
            writer.WriteAttributeString("y", Location.Y.ToString());
            writer.WriteAttributeString("title", Title);

            Node.Serialize(writer);
        }
        private void HandleProduceOnionClicked(object sender, ProduceOnionsEventArgs e)
        {
            Logger.Log("Handling Produce Onion Clicked Event");

            var factoryId = new FactoryId(e.FactoryName.Replace(" ", "_"));
            OnionQuantity onionQuantity = e.NumberOf.Onions();

            var onions = this.onionProductionApplicationService.ProduceOnions(factoryId, onionQuantity);

            this.view.Update(onions);
        }
Ejemplo n.º 13
0
        public void Execute(ConsoleEnvironment env, string[] args)
        {
            int factoryId = 1;

            if (args.Length > 0)
            {
                int.TryParse(args[0], out factoryId);
            }

            var id = new FactoryId(factoryId);

            var story = new List <ICommand>
            {
                // create some Command messages that are defined in Messages.cs
                // and were auto-generated by lokad-codedsl from the text in Messages.ddd
                new OpenFactory(id),
                new AssignEmployeeToFactory(id, "Luke"),
                new AssignEmployeeToFactory(id, "Han"),
                new ReceiveShipmentInCargoBay(id, "from uncle Ben", new[]
                {
                    new CarPart("wheel", 10),
                    new CarPart("light saber", 2),
                    new CarPart("C3P0", 1),
                }),
                new ReceiveShipmentInCargoBay(id, "from Yoda", new[]
                {
                    new CarPart("engine", 2),
                    new CarPart("chassis", 1),
                }),
                new UnpackAndInventoryShipmentInCargoBay(id, "Han"),
                new ProduceACar(id, "Luke", "model-t")
            };

            // we have a story as a list of Commands, now send each one of the Commands to
            // the Application Service that is hosting the Factory Aggregate
            // the Events generated by the Factory Aggregate's that process the Commands will be
            // output to the console in a human-readable way and can be read like a "story about a day in this factory"
            foreach (var command in story)
            {
                env.FactoryAppService.Execute(command);
            }
        }
Ejemplo n.º 14
0
 public CurseWordUttered(FactoryId id, string theWord, string meaning)
 {
     Id = id;
     TheWord = theWord;
     Meaning = meaning;
 }
Ejemplo n.º 15
0
 public FactoryOpened(FactoryId id)
 {
     Id = id;
 }
Ejemplo n.º 16
0
 public Factory Load(FactoryId factoryId)
 {
     return (Factory)Database.Select(factoryId);
 }
Ejemplo n.º 17
0
 // announcements inside the factory that we react to and realize WHEN thisEventTypeHappened happens
 public void When(FactoryOpened theEvent)
 {
     Id = theEvent.Id;
 }
Ejemplo n.º 18
0
        public void Execute(ConsoleEnvironment env, string[] args)
        {
            int factoryId = 1;
            if (args.Length>0)
            {
                int.TryParse(args[0], out factoryId);
            }
            
            var id = new FactoryId(factoryId);

            var story = new List<ICommand>
                {
                    // create some Command messages that are defined in Messages.cs 
                    // and were auto-generated by lokad-codedsl from the text in Messages.ddd
                    new OpenFactory(id),
                    new AssignEmployeeToFactory(id, "Luke"),
                    new AssignEmployeeToFactory(id, "Han"),
                    new ReceiveShipmentInCargoBay(id, "from uncle Ben", new[]
                        {
                            new CarPart("wheel", 10),
                            new CarPart("light saber", 2),
                            new CarPart("C3P0", 1),
                        }),
                    new ReceiveShipmentInCargoBay(id, "from Yoda", new[]
                        {
                            new CarPart("engine", 2),
                            new CarPart("chassis", 1),
                        }),
                    new UnpackAndInventoryShipmentInCargoBay(id, "Han"),
                    new ProduceACar(id, "Luke", "model-t")
                };

            // we have a story as a list of Commands, now send each one of the Commands to
            // the Application Service that is hosting the Factory Aggregate
            // the Events generated by the Factory Aggregate's that process the Commands will be
            // output to the console in a human-readable way and can be read like a "story about a day in this factory"
            foreach (var command in story)
            {
                env.FactoryAppService.Execute(command);
            }
        }
Ejemplo n.º 19
0
 public ShipmentReceivedInCargoBay(FactoryId id, InventoryShipment shipment)
 {
     Id = id;
     Shipment = shipment;
 }
Ejemplo n.º 20
0
 // announcements inside the factory that we react to and realize WHEN thisEventTypeHappened happens
 // we have to decided to make the trade off between completely private WHEN methods and making them public
 // to keep the syntax more simple while we take advantage of the interface capabilities of the DSL tool via IFactoryState
 public void When(FactoryOpened theEvent)
 {
     Id = theEvent.Id;
 }
Ejemplo n.º 21
0
 public OpenFactory(FactoryId id)
 {
     Id = id;
 }
Ejemplo n.º 22
0
        public void Execute(ConsoleEnvironment env, string[] args)
        {
            int factoryId = 1;
            if (args.Length>0)
            {
                int.TryParse(args[0], out factoryId);
            }
            var id = new FactoryId(factoryId);
            var story = new List<ICommand>
                {
                    new OpenFactory(id),
                    new AssignEmployeeToFactory(id, "Luke"),
                    new AssignEmployeeToFactory(id, "Han"),
                    new ReceiveShipmentInCargoBay(id, "from uncle Ben", new[]
                        {
                            new CarPart("wheel", 10),
                            new CarPart("light saber", 2),
                            new CarPart("C3P0", 1),
                        }),
                    new ReceiveShipmentInCargoBay(id, "from Yoda", new[]
                        {
                            new CarPart("engine", 2),
                            new CarPart("chassis", 1),
                        }),
                    new UnpackAndInventoryShipmentInCargoBay(id, "Han"),
                    new ProduceACar(id, "Luke", "model-t")
                };

            foreach (var command in story)
            {
                env.FactoryAppService.Execute(command);
            }
        }
Ejemplo n.º 23
0
 public CarProduced(FactoryId id, string employeeName, string carModel, CarPart[] parts)
 {
     Id = id;
     EmployeeName = employeeName;
     CarModel = carModel;
     Parts = parts;
 }
Ejemplo n.º 24
0
 void When(FactoryOpened e)
 {
     Id = e.Id;
 }
Ejemplo n.º 25
0
 public UnpackAndInventoryShipmentInCargoBay(FactoryId id, string employeeName)
 {
     Id = id;
     EmployeeName = employeeName;
 }
Ejemplo n.º 26
0
 public AssignEmployeeToFactory(FactoryId id, string employeeName)
 {
     Id = id;
     EmployeeName = employeeName;
 }
Ejemplo n.º 27
0
 public ProduceACar(FactoryId id, string employeeName, string carModel)
 {
     Id = id;
     EmployeeName = employeeName;
     CarModel = carModel;
 }
        public Factory OpenFactory(FactoryId factoryId, FactoryName factoryName)
        {
            Factory factory = this.factoryDomainService.OpenFactory(factoryId, factoryName);

            return factory;
        }
Ejemplo n.º 29
0
 void When(FactoryOpened e)
 {
     Id = e.Id;
 }
Ejemplo n.º 30
0
 public ShipmentUnpackedInCargoBay(FactoryId id, string employeeName, InventoryShipment[] inventoryShipments)
 {
     Id = id;
     EmployeeName = employeeName;
     InventoryShipments = inventoryShipments;
 }
Ejemplo n.º 31
0
 public ReceiveShipmentInCargoBay(FactoryId id, string shipmentName, CarPart[] carParts)
 {
     Id = id;
     ShipmentName = shipmentName;
     CarParts = carParts;
 }