Esempio n. 1
0
 /// <summary>
 /// Sets the <see cref="MultiRequest{TInstance, TKey, TRequest, TResponse}"/> property.
 /// </summary>
 /// <typeparam name="TKey"></typeparam>
 /// <typeparam name="TRequest"></typeparam>
 /// <typeparam name="TResponse"></typeparam>
 /// <param name="stateMachine"></param>
 /// <param name="property"></param>
 /// <param name="request"></param>
 static void InitializeMultiRequest <TKey, TRequest, TResponse>(
     AutomatonymousStateMachine <TInstance> stateMachine,
     PropertyInfo property,
     MultiRequest <TInstance, TKey, 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 multi-request property is not writable: {property.Name}");
     }
 }