Esempio n. 1
0
        protected override object VisitIEnumerable(IEnumerableCallSite enumerableCallSite, ILEmitResolverBuilderContext argument)
        {
            if (enumerableCallSite.ServiceCallSites.Length == 0)
            {
                argument.Generator.Emit(OpCodes.Call, ExpressionResolverBuilder.GetArrayEmptyMethodInfo(enumerableCallSite.ItemType));
            }
            else
            {
                // var array = new ItemType[];
                // array[0] = [Create argument0];
                // array[1] = [Create argument1];
                // ...
                argument.Generator.Emit(OpCodes.Ldc_I4, enumerableCallSite.ServiceCallSites.Length);
                argument.Generator.Emit(OpCodes.Newarr, enumerableCallSite.ItemType);
                for (int i = 0; i < enumerableCallSite.ServiceCallSites.Length; i++)
                {
                    // duplicate array
                    argument.Generator.Emit(OpCodes.Dup);
                    // push index
                    argument.Generator.Emit(OpCodes.Ldc_I4, i);
                    // create parameter
                    ServiceCallSite parameterCallSite = enumerableCallSite.ServiceCallSites[i];
                    VisitCallSite(parameterCallSite, argument);
                    if (parameterCallSite.ServiceType.IsValueType)
                    {
                        argument.Generator.Emit(OpCodes.Unbox_Any, parameterCallSite.ServiceType);
                    }

                    // store
                    argument.Generator.Emit(OpCodes.Stelem, enumerableCallSite.ItemType);
                }
            }

            return(null);
        }
Esempio n. 2
0
 public ExpressionsServiceProviderEngine(
     IEnumerable <ServiceDescriptor> serviceDescriptors,
     IServiceProviderEngineCallback callback,
     IInterceptingProxyFactory interceptingProxyFactory) : base(serviceDescriptors, callback, interceptingProxyFactory)
 {
     _expressionResolverBuilder = new ExpressionResolverBuilder(RuntimeResolver, this, Root);
 }
Esempio n. 3
0
        public CompiledServiceProviderEngine(IEnumerable <ServiceDescriptor> serviceDescriptors, IServiceProviderEngineCallback callback) : base(serviceDescriptors, callback)
        {
#if IL_EMIT
            ResolverBuilder = new ILEmitResolverBuilder(RuntimeResolver, this, Root);
#else
            ResolverBuilder = new ExpressionResolverBuilder(RuntimeResolver, this, Root);
#endif
        }
 protected override Func <ServiceProviderEngineScope, object> RealizeService(IServiceCallSite callSite)
 {
     if (_realized3 == null)
     {
         var realizedService = ExpressionResolverBuilder.Build(callSite);
         _realized2[callSite.ServiceType] = realizedService;
         return(realizedService);
     }
     else
     {
         return(base.RealizeService(callSite));
     }
 }
 public ExpressionsServiceProviderEngine(IEnumerable <ServiceDescriptor> serviceDescriptors, IServiceProviderEngineCallback callback) : base(serviceDescriptors, callback)
 {
     _expressionResolverBuilder = new ExpressionResolverBuilder(RuntimeResolver, this, Root);
 }
Esempio n. 6
0
 public ExpressionsServiceProviderEngine(ServiceProvider serviceProvider)
 {
     _expressionResolverBuilder = new ExpressionResolverBuilder(serviceProvider);
 }
 public CompiledServiceProviderEngine(ServiceProvider provider)
 {
     ResolverBuilder = new(provider);
 }