예제 #1
0
 public ReifiedOperationBinder(IReificationBinder <TEnvironment> platform)
 {
     _platform = platform;
 }
예제 #2
0
        /// <summary>
        /// Binds a reified operation to a given environment.
        /// </summary>
        /// <typeparam name="TEnvironment">The environment type.</typeparam>
        /// <param name="operation">The operation to bind.</param>
        /// <param name="binder">The binder to use.</param>
        /// <returns>
        /// A lambda expression to evaluate the reified operation.
        /// </returns>
        public static Expression <Action <TEnvironment> > Bind <TEnvironment>(this ReifiedOperation operation, IReificationBinder <TEnvironment> binder)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }
            if (binder == null)
            {
                throw new ArgumentNullException(nameof(binder));
            }

            var flattener = new ReifiedOperationFlattener();
            var opBinder  = new ReifiedOperationBinder <TEnvironment>(binder);
            var flattened = flattener.Visit(operation);
            var bound     = opBinder.Visit(flattened);

            return(binder.Optimize(bound));
        }