public Factory(FactoryId factoryId, FactoryName name) { this.factoryId = factoryId; this.Name = name; this.producedOnions = new List<Onion>(); }
public void OpenFactory(FactoryId id) { if (_state.Id != null) throw DomainError.Named("factory-already-created", "Factory was already created"); Apply(new FactoryOpened(id)); }
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); }
// 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 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); }
// 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; }
//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); }
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); } }
public CurseWordUttered(FactoryId id, string theWord, string meaning) { Id = id; TheWord = theWord; Meaning = meaning; }
public FactoryOpened(FactoryId id) { Id = id; }
public Factory Load(FactoryId factoryId) { return (Factory)Database.Select(factoryId); }
// announcements inside the factory that we react to and realize WHEN thisEventTypeHappened happens public void When(FactoryOpened theEvent) { Id = theEvent.Id; }
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); } }
public ShipmentReceivedInCargoBay(FactoryId id, InventoryShipment shipment) { Id = id; Shipment = shipment; }
// 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; }
public OpenFactory(FactoryId id) { Id = id; }
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 CarProduced(FactoryId id, string employeeName, string carModel, CarPart[] parts) { Id = id; EmployeeName = employeeName; CarModel = carModel; Parts = parts; }
void When(FactoryOpened e) { Id = e.Id; }
public UnpackAndInventoryShipmentInCargoBay(FactoryId id, string employeeName) { Id = id; EmployeeName = employeeName; }
public AssignEmployeeToFactory(FactoryId id, string employeeName) { Id = id; EmployeeName = employeeName; }
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; }
public ShipmentUnpackedInCargoBay(FactoryId id, string employeeName, InventoryShipment[] inventoryShipments) { Id = id; EmployeeName = employeeName; InventoryShipments = inventoryShipments; }
public ReceiveShipmentInCargoBay(FactoryId id, string shipmentName, CarPart[] carParts) { Id = id; ShipmentName = shipmentName; CarParts = carParts; }