Exemplo n.º 1
0
        public static Saga Create(Type sagaType, SagaId id)
        {
            var instance = (Saga)Activator.CreateInstance(sagaType);

            SetPropertyValue(instance, "Id", id);
            return(instance);
        }
Exemplo n.º 2
0
        public static TSaga Create <TSaga>(SagaId id) where TSaga : Saga
        {
            //return (TSaga)Activator.CreateInstance(typeof(TSaga), new object[] { id });
            //private static readonly ParameterExpression YCreator_Arg_Param = Expression.Parameter(typeof(int), "z");
            //private static readonly Func<int, X> YCreator_Arg = Expression.Lambda<Func<int, X>>(
            //   Expression.New(typeof(Y).GetConstructor(new[] { typeof(int), }), new[] { YCreator_Arg_Param, }),
            //   YCreator_Arg_Param
            //).Compile();
            //static X CreateY_CompiledExpression_Arg(int z)
            //{
            //    return YCreator_Arg(z);
            //}
            var instance = Activator.CreateInstance <TSaga>();

            SetPropertyValue(instance, "Id", id);
            return(instance);
        }
Exemplo n.º 3
0
        public static TSaga Create <TSaga>(
            SagaId id,
            SagaContextId contextId,
            LocalDateTime startedOn,
            LocalDateTime nextProcessingTimeDueOn,
            LocalDateTime?nextRetryTime,
            bool isExpired,
            bool isCompleted) where TSaga : Saga
        {
            var instance = Create <TSaga>(id);

            instance.ContextId = contextId;
            instance.StartedOn = startedOn;
            instance.NextProcessingTimeDueOn = nextProcessingTimeDueOn;
            instance.NextRetryTime           = nextRetryTime;
            instance.IsExpired   = isExpired;
            instance.IsCompleted = isCompleted;
            return(instance);
        }
Exemplo n.º 4
0
        public static Saga Create(
            Type sagaType,
            SagaId id,
            SagaContextId contextId,
            LocalDateTime startedOn,
            LocalDateTime nextProcessingTimeDueOn,
            LocalDateTime?nextRetryTime,
            bool isExpired,
            bool isCompleted)
        {
            var instance = Create(sagaType, id);

            instance.ContextId = contextId;
            instance.StartedOn = startedOn;
            instance.NextProcessingTimeDueOn = nextProcessingTimeDueOn;
            instance.NextRetryTime           = nextRetryTime;
            instance.IsExpired   = isExpired;
            instance.IsCompleted = isCompleted;
            return(instance);
        }
Exemplo n.º 5
0
        public static Saga Create(
            string typeName,
            SagaId id,
            SagaContextId contextId,
            LocalDateTime startedOn,
            LocalDateTime nextProcessingTimeDueOn,
            LocalDateTime?nextRetryTime,
            bool isExpired,
            bool isCompleted)
        {
#if NET45
            var instance = (Saga)Activator.CreateInstance(null, typeName).Unwrap();
#else
            var instance = (Saga)Activator.CreateInstance(null, typeName);
#endif
            SetPropertyValue(instance, "Id", id);
            instance.ContextId = contextId;
            instance.StartedOn = startedOn;
            instance.NextProcessingTimeDueOn = nextProcessingTimeDueOn;
            instance.NextRetryTime           = nextRetryTime;
            instance.IsExpired   = isExpired;
            instance.IsCompleted = isCompleted;
            return(instance);
        }