Exemplo n.º 1
0
 static void InitializeSchedule <T>(AutomatonymousStateMachine <TInstance> stateMachine, PropertyInfo property, Schedule <TInstance, T> schedule)
     where T : class
 {
     if (property.CanWrite)
     {
         property.SetValue(stateMachine, schedule);
     }
     else if (ConfigurationHelpers.TryGetBackingField(stateMachine.GetType().GetTypeInfo(), property, out var backingField))
     {
         backingField.SetValue(stateMachine, schedule);
     }
     else
     {
         throw new ArgumentException($"The schedule property is not writable: {property.Name}");
     }
 }
Exemplo n.º 2
0
 static void InitializeRequest <TRequest, TResponse>(AutomatonymousStateMachine <TInstance> stateMachine, PropertyInfo property,
                                                     Request <TInstance, TRequest, TResponse> request)
     where TRequest : class
     where TResponse : class
 {
     if (property.CanWrite)
     {
         property.SetValue(stateMachine, request);
     }
     else if (ConfigurationHelpers.TryGetBackingField(stateMachine.GetType().GetTypeInfo(), property, out var backingField))
     {
         backingField.SetValue(stateMachine, request);
     }
     else
     {
         throw new ArgumentException($"The request property is not writable: {property.Name}");
     }
 }