Ejemplo n.º 1
0
 /// <summary>Constructor.</summary>
 /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are <c>null</c></exception>
 /// <exception cref="InvalidOperationException">Thrown when the requested operation is invalid.</exception>
 /// <param name="root">The root.</param>
 /// <param name="conditionEmitter">The condition emitter.</param>
 /// <param name="contextType">Type of the context.</param>
 public StateMachineEmitter([NotNull] StateSwitchBuilder <TComparand, TInput> root, [NotNull] IConditionEmitter <TComparand, TInput> conditionEmitter, Type contextType)
 {
     this.Root             = root ?? throw new ArgumentNullException(nameof(root));
     this.ConditionEmitter = conditionEmitter ?? throw new ArgumentNullException(nameof(conditionEmitter));
     this.InputParameter   = Expression.Parameter(typeof(TInput), "input");
     this.StateParameter   = Expression.Parameter(typeof(int).MakeByRefType(), "state");
     this.ContextParameter = Expression.Parameter(contextType ?? typeof(object).MakeByRefType(), "context");
     this.StartLabel       = Expression.Label("start");
     if (this.GetIdForBuilder(this.Root) != 0)
     {
         throw new InvalidOperationException("Internal error: Unexpected root ID");
     }
 }
Ejemplo n.º 2
0
 /// <summary>Constructor.</summary>
 /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are <c>null</c></exception>
 /// <exception cref="InvalidOperationException">Thrown when the requested operation is invalid.</exception>
 /// <param name="root">The root.</param>
 /// <param name="conditionEmitter">The condition emitter.</param>
 public StateMachineEmitter([NotNull] StateSwitchBuilder <TComparand, TInput> root, [NotNull] IConditionEmitter <TComparand, TInput> conditionEmitter) : this(root, conditionEmitter, null)
 {
 }