/// <summary> /// Изменить активное состояние /// </summary> /// <param name="newStateID">ID нового состояния</param> private async void ChangeState(StateBuilder.StateID newStateID) { //old state if (currentState != null) { LinkState(currentState, false); } /* * LOADING SCREEN * Нужно легкое состояние, которое будет быстро загружаться, Фон картинка, какой либо текст подсказка(игровая), иконка загрузки * */ //new state currentState = await StateBuilder.GetStateAsync(newStateID); LinkState(currentState, true); //Myra.Graphics2D.UI.Desktop.Widgets.Add(); if (currentState.Initialized) { return; } currentState.ChangeStateRequest += ChangeState; currentState.Initialized = true; }
public IInSyntax<TState, TEvent> In(TState state) { var s = stateDict[state]; var builder = new StateBuilder<TState, TEvent>(s, stateDict, factory); return builder; }
public MessageActivityBuilder(StateBuilder <TWorkflow, TInstance> builder, MessageEvent <TBody> eevent) { _builder = builder; _event = eevent; _exceptionHandler = new MessageEventExceptionHandler <TInstance, TBody>(); _executor = new MessageActivityExecutor <TInstance, TBody>(builder.State, eevent, _exceptionHandler); }
public void BeforeEach() { _fsm = Substitute.For <IFsm>(); _builder = new StateBuilder { Id = StateEnum.A }; }
public SimpleActivityBuilder(StateBuilder <TWorkflow, TInstance> builder, SimpleEvent eevent) { _builder = builder; _event = eevent; _exceptionHandler = new SimpleEventExceptionHandler <TInstance>(); _executor = new SimpleActivityExecutor <TInstance>(builder.State, eevent, _exceptionHandler); }
public static AddressBuilder Simple() { return(Default() .WithLine1(() => GetRandom.String(1, 50)) .WithCity(() => GetRandom.String(1, 50)) .WithState(() => StateBuilder.Simple().Build()) .WithPostalCode(() => GetRandom.String(10, 10))); }
public StateBuilder AddState(string name) { var state = new State(name); _states.Add(name, state); var builder = new StateBuilder(state); return(builder); }
public static AddressBuilder JoeCustomerShipping() { return(Simple() .WithLine1("123 Any St.") .WithLine2("Suite 456") .WithCity("Columbus") .WithState(() => StateBuilder.Simple().Build()) .WithPostalCode("43210")); }
protected override void Given() { base.Given(); var model = StateBuilder.Simple().Build(); _model = SUT.AddAsync(AdminUserId, model).Result; Assert.IsNotNull(SUT.GetAsync(AdminUserId, _model.Id).Result); }
public StateBuilder <TState, StateMachineBuilder <TState> > State <TContext, TContextState>(string stateName, TContext context) where TContextState : ContextState <TContext>, TState, new() { var builder = new StateBuilder <TContextState, StateMachineBuilder <TState> >(stateName, this, _root); builder.ContractState.SetContext(context); return(builder as StateBuilder <TState, StateMachineBuilder <TState> >); }
public void It_should_trigger_a_callback_with_a_StateBuilder_argument() { StateBuilder stateBuilder = null; _builder .State(StateEnum.A, (state) => stateBuilder = state) .Build(); Assert.IsNotNull(stateBuilder); }
protected override void Given() { base.Given(); _models = new List <State> { StateBuilder.Simple().Build(), StateBuilder.Simple().Build() }; _originalCount = SUT.CountAsync().Result; }
public void Syntax() { IEntryActionSyntax <int, int> s = new StateBuilder <int, int>(null, null, null); // ReSharper disable once UnusedVariable Action a = () => s .ExecuteOnEntry(() => { }) .ExecuteOnEntry((int i) => { }) .ExecuteOnEntry(() => Task.CompletedTask) .ExecuteOnEntry((int i) => Task.CompletedTask) .ExecuteOnEntryParametrized(p => { }, 4) .ExecuteOnEntryParametrized(p => { }, "test") .ExecuteOnEntryParametrized(p => Task.CompletedTask, 4) .ExecuteOnEntryParametrized(p => Task.CompletedTask, "test") .ExecuteOnExit(() => { }) .ExecuteOnExit((string st) => { }) .ExecuteOnExit(() => Task.CompletedTask) .ExecuteOnExit((string st) => Task.CompletedTask) .ExecuteOnExitParametrized(p => { }, 4) .ExecuteOnExitParametrized(p => { }, "test") .ExecuteOnExitParametrized(p => Task.CompletedTask, 4) .ExecuteOnExitParametrized(p => Task.CompletedTask, "test") .On(3) .If(() => true).Goto(4).Execute(() => { }).Execute((int i) => { }).Execute(() => Task.CompletedTask).Execute((int i) => Task.CompletedTask) .If(() => Task.FromResult(true)).Goto(4).Execute(() => { }).Execute((int i) => { }).Execute(() => Task.CompletedTask).Execute((int i) => Task.CompletedTask) .If(() => true).Goto(4) .If(() => true).Execute(() => { }).Execute((int i) => { }).Execute(() => Task.CompletedTask).Execute((int i) => Task.CompletedTask) .If((Func <string, bool>) this.AGuard).Execute(() => { }).Execute((int i) => { }).Execute(() => Task.CompletedTask).Execute((int i) => Task.CompletedTask) .If((Func <string, Task <bool> >) this.AAsyncGuard).Execute(() => { }).Execute((int i) => { }).Execute(() => Task.CompletedTask).Execute((int i) => Task.CompletedTask) .Otherwise().Goto(4).Execute(() => { }).Execute((int i) => { }).Execute(() => Task.CompletedTask).Execute((int i) => Task.CompletedTask) .On(5) .If(() => true).Execute(() => { }) .Otherwise() .On(2) .If <int>(i => i != 0).Goto(7) .Otherwise().Goto(7) .On(1) .If(() => true).Goto(7).Execute(() => { }).Execute <string>(argument => { }) .On(1) .If(() => true).Execute(() => { }) .If(() => true).Execute((string argument) => { }) .Otherwise().Execute(() => { }).Execute((int i) => { }) .On(4) .Goto(5).Execute(() => { }).Execute <string>(argument => { }) .On(5) .Execute(() => { }).Execute((int i) => { }) .On(7) .Goto(4) .On(8) .On(9); }
public void Configure(StateBuilder <TWorkflow, TInstance> builder) { SimpleEvent eevent = _getEvent(builder); if (builder.State == builder.Model.FinalState) { throw new WorkflowDefinitionException("Events can not be specified for the final workflow state"); } var activityBuilder = new SimpleActivityBuilder <TWorkflow, TInstance>(builder, eevent); _configurators.Each(x => x.Configure(activityBuilder)); builder.AddActivity(activityBuilder.GetActivityExecutor()); }
public void Syntax() { IEntryActionSyntax<int, int> s = new StateBuilder<int, int>(null, null, null); // ReSharper disable once UnusedVariable Action a = () => s .ExecuteOnEntry(() => { }) .ExecuteOnEntry((int i) => { }) .ExecuteOnEntryParametrized(p => { }, 4) .ExecuteOnEntryParametrized(p => { }, "test") .ExecuteOnExit(() => { }) .ExecuteOnExit((string st) => { }) .ExecuteOnExitParametrized(p => { }, 4) .ExecuteOnExitParametrized(p => { }, "test") .On(3) .If(() => true).Goto(4).Execute(() => { }).Execute((int i) => { }) .If(() => true).Goto(4) .If(() => true).Execute(() => { }).Execute((int i) => { }).Execute(() => { }) .If<string>(this.AGuard).Execute(() => { }).Execute((int i) => { }) .Otherwise().Goto(4) .On(5) .If(() => true).Execute(() => { }) .Otherwise() .On(2) .If<int>(i => i != 0).Goto(7) .Otherwise().Goto(7) .On(1) .If(() => true).Goto(7).Execute(() => { }).Execute<string>(argument => { }) .On(1) .If(() => true).Execute(() => { }) .If(() => true).Execute((string argument) => { }) .Otherwise().Execute(() => { }).Execute((int i) => { }) .On(4) .Goto(5).Execute(() => { }).Execute<string>(argument => { }) .On(5) .Execute(() => { }).Execute((int i) => { }) .On(7) .Goto(4) .On(8) .On(9); }
public ForStateContext(StateBuilder stateBuilder) { _stateBuilder = stateBuilder; }
public void GivenWorkEffort_WhenCreatingModel_ThenValuesAreSet() { // Arrange var frequencies = new TimeFrequencies(this.Session); var purposes = new ContactMechanismPurposes(this.Session); //// Customer Contact and Address Data var customer = new OrganisationBuilder(this.Session).WithName("Customer").Build(); var customerContact = new PersonBuilder(this.Session).WithFirstName("Customer").WithLastName("Contact").Build(); var organisation = new Organisations(this.Session).Extent().First(o => o.IsInternalOrganisation); var customerRelation = new CustomerRelationshipBuilder(this.Session).WithCustomer(customer).WithInternalOrganisation(organisation).Build(); var usa = new Countries(this.Session).Extent().First(c => c.IsoCode.Equals("US")); var michigan = new StateBuilder(this.Session).WithName("Michigan").WithCountry(usa).Build(); var northville = new CityBuilder(this.Session).WithName("Northville").WithState(michigan).Build(); var postalCode = new PostalCodeBuilder(this.Session).WithCode("48167").Build(); var billingAddress = this.CreatePostalAddress("Billing Address", "123 Street", "Suite S1", northville, postalCode); var shippingAddress = this.CreatePostalAddress("Shipping Address", "123 Street", "Dock D1", northville, postalCode); var phone = new TelecommunicationsNumberBuilder(this.Session).WithCountryCode("1").WithAreaCode("616").WithContactNumber("774-2000").Build(); customer.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.BillingAddress, billingAddress)); customer.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.ShippingAddress, shippingAddress)); customerContact.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.GeneralPhoneNumber, phone)); //// Work Effort Data var salesPerson = new PersonBuilder(this.Session).WithFirstName("Sales").WithLastName("Person").Build(); var salesOrder = this.CreateSalesOrder(customer, organisation); var workOrder = this.CreateWorkEffort(organisation, customer, customerContact, salesOrder.SalesOrderItems.First); var employee = new PersonBuilder(this.Session).WithFirstName("Good").WithLastName("Worker").Build(); var employment = new EmploymentBuilder(this.Session).WithEmployee(employee).WithEmployer(organisation).Build(); var salesOrderItem = salesOrder.SalesOrderItems.First; ((SalesOrderDerivedRoles)salesOrder).AddValidOrderItem(salesOrderItem); //// Work Effort Inventory Assignmets var part1 = this.CreatePart("P1"); var part2 = this.CreatePart("P2"); var part3 = this.CreatePart("P3"); this.Session.Derive(true); var inventoryAssignment1 = this.CreateInventoryAssignment(workOrder, part1, 11); var inventoryAssignment2 = this.CreateInventoryAssignment(workOrder, part2, 12); var inventoryAssignment3 = this.CreateInventoryAssignment(workOrder, part3, 13); //// Work Effort Time Entries var yesterday = DateTimeFactory.CreateDateTime(this.Session.Now().AddDays(-1)); var laterYesterday = DateTimeFactory.CreateDateTime(yesterday.AddHours(3)); var today = DateTimeFactory.CreateDateTime(this.Session.Now()); var laterToday = DateTimeFactory.CreateDateTime(today.AddHours(4)); var tomorrow = DateTimeFactory.CreateDateTime(this.Session.Now().AddDays(1)); var laterTomorrow = DateTimeFactory.CreateDateTime(tomorrow.AddHours(6)); var standardRate = new RateTypes(this.Session).StandardRate; var overtimeRate = new RateTypes(this.Session).OvertimeRate; var timeEntryYesterday = this.CreateTimeEntry(yesterday, laterYesterday, frequencies.Day, workOrder, standardRate); var timeEntryToday = this.CreateTimeEntry(today, laterToday, frequencies.Hour, workOrder, standardRate); var timeEntryTomorrow = this.CreateTimeEntry(tomorrow, laterTomorrow, frequencies.Minute, workOrder, overtimeRate); employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryYesterday); employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryToday); employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryTomorrow); this.Session.Derive(true); // Act var model = new WorkTaskModel.Model(workOrder); // Assert Assert.Equal(3, model.TimeEntries.Length); Assert.Single(model.TimeEntriesByBillingRate); }
public OnContext(StateBuilder stateBuilder) { _stateBuilder = stateBuilder; }
protected override void Given() { base.Given(); _model = StateBuilder.Simple().Build(); }
public void GivenWorkEffortPrintDocument_WhenPrinting_ThenMediaCreated() { // Arrange var frequencies = new TimeFrequencies(this.Session); var purposes = new ContactMechanismPurposes(this.Session); //// Customer Contact and Address Data var customer = new OrganisationBuilder(this.Session).WithName("Customer").Build(); var customerContact = new PersonBuilder(this.Session).WithFirstName("Customer").WithLastName("Contact").Build(); var organisation = new Organisations(this.Session).Extent().First(o => o.IsInternalOrganisation); var customerRelation = new CustomerRelationshipBuilder(this.Session).WithCustomer(customer).WithInternalOrganisation(organisation).Build(); var usa = new Countries(this.Session).Extent().First(c => c.IsoCode.Equals("US")); var michigan = new StateBuilder(this.Session).WithName("Michigan").WithCountry(usa).Build(); var northville = new CityBuilder(this.Session).WithName("Northville").WithState(michigan).Build(); var postalCode = new PostalCodeBuilder(this.Session).WithCode("48167").Build(); var billingAddress = this.CreatePostalAddress("Billing Address", "123 Street", "Suite S1", northville, postalCode); var shippingAddress = this.CreatePostalAddress("Shipping Address", "123 Street", "Dock D1", northville, postalCode); var phone = new TelecommunicationsNumberBuilder(this.Session).WithCountryCode("1").WithAreaCode("616").WithContactNumber("774-2000").Build(); customer.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.BillingAddress, billingAddress)); customer.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.ShippingAddress, shippingAddress)); customerContact.AddPartyContactMechanism(this.CreatePartyContactMechanism(purposes.GeneralPhoneNumber, phone)); //// Work Effort Data var salesPerson = new PersonBuilder(this.Session).WithFirstName("Sales").WithLastName("Person").Build(); var salesRepRelation = new SalesRepRelationshipBuilder(this.Session).WithCustomer(customer).WithSalesRepresentative(salesPerson).Build(); var salesOrder = this.CreateSalesOrder(customer, organisation); var workOrder = this.CreateWorkEffort(organisation, customer, customerContact, salesOrder.SalesOrderItems.First); var employee = new PersonBuilder(this.Session).WithFirstName("Good").WithLastName("Worker").Build(); var employment = new EmploymentBuilder(this.Session).WithEmployee(employee).WithEmployer(organisation).Build(); var salesOrderItem = salesOrder.SalesOrderItems.First; salesOrder.AddValidOrderItem(salesOrderItem); //// Work Effort Inventory Assignmets var part1 = this.CreatePart("P1"); var part2 = this.CreatePart("P2"); var part3 = this.CreatePart("P3"); this.Session.Derive(true); var inventoryAssignment1 = this.CreateInventoryAssignment(workOrder, part1, 11); var inventoryAssignment2 = this.CreateInventoryAssignment(workOrder, part2, 12); var inventoryAssignment3 = this.CreateInventoryAssignment(workOrder, part3, 13); //// Work Effort Time Entries var yesterday = DateTimeFactory.CreateDateTime(this.Session.Now().AddDays(-1)); var laterYesterday = DateTimeFactory.CreateDateTime(yesterday.AddHours(3)); var today = DateTimeFactory.CreateDateTime(this.Session.Now()); var laterToday = DateTimeFactory.CreateDateTime(today.AddHours(4)); var tomorrow = DateTimeFactory.CreateDateTime(this.Session.Now().AddDays(1)); var laterTomorrow = DateTimeFactory.CreateDateTime(tomorrow.AddHours(6)); var timeEntryYesterday = this.CreateTimeEntry(yesterday, laterYesterday, frequencies.Day, workOrder); var timeEntryToday = this.CreateTimeEntry(today, laterToday, frequencies.Hour, workOrder); var timeEntryTomorrow = this.CreateTimeEntry(tomorrow, laterTomorrow, frequencies.Minute, workOrder); employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryYesterday); employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryToday); employee.TimeSheetWhereWorker.AddTimeEntry(timeEntryTomorrow); this.Session.Derive(true); // Act workOrder.Print(); this.Session.Derive(); this.Session.Commit(); // Assert Assert.True(workOrder.PrintDocument.ExistMedia); var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var outputFile = System.IO.File.Create(System.IO.Path.Combine(desktopDir, "workTask.odt")); var stream = new System.IO.MemoryStream(workOrder.PrintDocument.Media.MediaContent.Data); stream.CopyTo(outputFile); stream.Close(); }
private State(StateBuilder builder) : base(builder.Id, builder.RowVersion) { Name = builder.Name; PolishName = builder.PolishName; }
protected void MapState <TState>(StateBuilder <TState> orderStateBuilder, Func <T, TState> getter, Action <T, TState> setter) { }
public static StateBuilder MyCustomStateBuilderMethod(this StateBuilder builder) { return(builder.AddAction(new ActionEnter((action) => { }))); }