Exemplo n.º 1
0
 protected override Expression VisitClosedIEnumerable(ClosedIEnumerableCallSite callSite, ParameterExpression provider)
 {
     return(Expression.NewArrayInit(
                callSite.ItemType,
                callSite.ServiceCallSites.Select(cs =>
                                                 Expression.Convert(
                                                     VisitCallSite(cs, provider),
                                                     callSite.ItemType))));
 }
        protected override object VisitClosedIEnumerable(ClosedIEnumerableCallSite closedIEnumerableCallSite, ServiceProvider provider)
        {
            var array = Array.CreateInstance(
                closedIEnumerableCallSite.ItemType,
                closedIEnumerableCallSite.ServiceCallSites.Length);

            for (var index = 0; index < closedIEnumerableCallSite.ServiceCallSites.Length; index++)
            {
                var value = VisitCallSite(closedIEnumerableCallSite.ServiceCallSites[index], provider);
                array.SetValue(value, index);
            }
            return(array);
        }
        protected override Type VisitClosedIEnumerable(ClosedIEnumerableCallSite closedIEnumerableCallSite,
                                                       CallSiteValidatorState state)
        {
            Type result = null;

            foreach (var serviceCallSite in closedIEnumerableCallSite.ServiceCallSites)
            {
                var scoped = VisitCallSite(serviceCallSite, state);
                if (result == null)
                {
                    result = scoped;
                }
            }
            return(result);
        }
 protected abstract TResult VisitClosedIEnumerable(ClosedIEnumerableCallSite closedIEnumerableCallSite, TArgument argument);