static SyncOperationDescriptor CreateSyncDescriptor( IType targetType, IMethod method, Func <IOperation, IEnumerable <IOperationInterceptor> > syncInterceptorProvider, IObjectBinderLocator binderLocator, IDependencyResolver resolver, Func <IEnumerable <IOperationInterceptorAsync> > systemInterceptors) { var attribCache = new Dictionary <Type, object[]>(3) { [typeof(IOperationInterceptor)] = WarmUpAttribCache <IOperationInterceptor>(method.Owner, method), [typeof(IOperationInterceptorProvider)] = WarmUpAttribCache <IOperationInterceptorProvider>(method.Owner, method), [typeof(HttpOperationAttribute)] = WarmUpAttribCache <HttpOperationAttribute>(method) }; IOperationAsync factory() { var syncMethod = new SyncMethod(targetType, method, binderLocator, resolver, attribCache); return(syncMethod.Intercept(syncInterceptorProvider).AsAsync().Intercept(systemInterceptors())); } return(new SyncOperationDescriptor(method, factory)); }
//// TODO: Remove when support for arrays is added to containers // ReSharper disable once UnusedMember.Global public MethodBasedOperationCreator(IDependencyResolver resolver, IObjectBinderLocator binderLocator) : this(binderLocator, resolver, resolver.ResolveAll <IMethodFilter>().ToArray(), resolver.Resolve <IOperationInterceptorProvider>()) { }
public static IOperationAsync FromType(Type methodType, IMethod method, IObjectBinderLocator binderLocator = null) { return((IOperationAsync)Activator.CreateInstance( typeof(AsyncMethod <>) .MakeGenericType(method.OutputMembers.Single().StaticType.GenericTypeArguments), method, binderLocator)); }
protected AbstractMethodOperation(IMethod method, IObjectBinderLocator binderLocator) { binderLocator = binderLocator ?? new DefaultObjectBinderLocator(); OwnerType = (IType)method.Owner; Method = method; Binders = method.InputMembers.ToDictionary(x => x, binderLocator.GetBinder); Inputs = Binders.Select(x => new InputMember(x.Key, x.Value, x.Key.IsOptional)); }
public MethodBasedOperation(IObjectBinderLocator binderLocator, IType ownerType, IMethod method) { _method = method; _ownerType = ownerType; _parameterBinders = method.InputMembers.ToDictionary(x => x, x => binderLocator.GetBinder(x)); Inputs = _parameterBinders.Select(x => new InputMember(x.Key, x.Value, x.Key.IsOptional)); ExtendedProperties = new NullBehaviorDictionary <object, object>(); }
public MultipartFormDataObjectCodec( ICommunicationContext context, ICodecRepository codecs, IDependencyResolver container, ITypeSystem typeSystem, IObjectBinderLocator binderLocator) : base(context, codecs, container, typeSystem, binderLocator) { }
static SyncOperationDescriptor CreateSyncDescriptor(IMethod method, Func <IOperation, IEnumerable <IOperationInterceptor> > syncInterceptorProvider, IObjectBinderLocator binderLocator, IDependencyResolver resolver, IEnumerable <IOperationInterceptorAsync> systemInterceptors) { return(new SyncOperationDescriptor(method, () => { var syncMethod = new SyncMethod(method, binderLocator, resolver); return syncMethod.Intercept(syncInterceptorProvider).AsAsync().Intercept(systemInterceptors); })); }
public static IEnumerable <OperationDescriptor> CreateOperationDescriptors(IEnumerable <IType> handlers, IEnumerable <IOperationInterceptorAsync> asyncInterceptors, Func <IEnumerable <IMethod>, IEnumerable <IMethod> > filters = null, Func <IOperation, IEnumerable <IOperationInterceptor> > syncInterceptors = null, IObjectBinderLocator binderLocator = null, IDependencyResolver resolver = null) { filters = filters ?? new TypeExclusionMethodFilter <object>().Filter; return(from handler in handlers from method in filters(handler.GetMethods()) select CreateOperationDescriptor(method, asyncInterceptors, syncInterceptors, binderLocator, resolver)); }
public static OperationDescriptor CreateOperationDescriptor(IMethod method, IEnumerable <IOperationInterceptorAsync> asyncInterceptors = null, Func <IOperation, IEnumerable <IOperationInterceptor> > syncInterceptorProvider = null, IObjectBinderLocator binderLocator = null, IDependencyResolver resolver = null) { asyncInterceptors = asyncInterceptors?.ToList() ?? Enumerable.Empty <IOperationInterceptorAsync>(); return(CreateTaskDescriptor(method, binderLocator, resolver, asyncInterceptors) ?? CreateTaskOfTDescriptor(method, binderLocator, resolver, asyncInterceptors) ?? CreateSyncDescriptor(method, syncInterceptorProvider ?? (op => Enumerable.Empty <IOperationInterceptor>()), binderLocator, resolver, asyncInterceptors)); }
static OperationDescriptor CreateTaskDescriptor(IMethod method, IObjectBinderLocator binderLocator, IDependencyResolver resolver, IEnumerable <IOperationInterceptorAsync> systemInterceptors) { if (!method.OutputMembers.Single().StaticType.IsTask()) { return(null); } return(new AsyncOperationDescriptor(method, () => new AsyncMethod(method, binderLocator, resolver).Intercept(systemInterceptors))); }
protected AbstractMethodOperation(IType targetType, IMethod method, IObjectBinderLocator binderLocator, IDependencyResolver resolver, Dictionary <Type, object[]> attributeCache) { _attributeCache = attributeCache ?? _emptyCache; binderLocator ??= new DefaultObjectBinderLocator(); TargetType = targetType; Method = method; Binders = method.InputMembers.ToDictionary(x => x, binderLocator.GetBinder); Inputs = Binders .Select(x => new InputMember(x.Key, x.Value, x.Key.IsOptional)) .ToArray(); Resolver = resolver; }
protected AbstractMultipartFormDataCodec(ICommunicationContext context, ICodecRepository codecs, IDependencyResolver container, ITypeSystem typeSystem, IObjectBinderLocator binderLocator) { // temporary until IRequest / IResponse are moved to the container _pipeline = context.Environment; _codecs = codecs; _typeSystem = typeSystem; _container = container; BinderLocator = binderLocator; Log = NullLogger<CodecLogSource>.Instance; }
protected AbstractMultipartFormDataCodec(ICommunicationContext context, ICodecRepository codecs, IDependencyResolver container, ITypeSystem typeSystem, IObjectBinderLocator binderLocator) { // temporary until IRequest / IResponse are moved to the container _pipeline = context.PipelineData; _codecs = codecs; _typeSystem = typeSystem; _container = container; BinderLocator = binderLocator; Log = NullLogger <CodecLogSource> .Instance; }
static OperationDescriptor CreateTaskOfTDescriptor(IMethod method, IObjectBinderLocator binderLocator, IDependencyResolver resolver, IEnumerable <IOperationInterceptorAsync> asyncInterceptors) { if (!method.OutputMembers.Single().StaticType.IsTaskOfT(out var returnType)) { return(null); } return(new AsyncOperationDescriptor(method , () => ((IOperationAsync)Activator.CreateInstance( typeof(AsyncMethod <>).MakeGenericType(returnType), method, binderLocator, resolver)).Intercept(asyncInterceptors))); }
static OperationDescriptor CreateTaskDescriptor(IType declaringType, IMethod method, IObjectBinderLocator binderLocator, IDependencyResolver resolver, Func <IEnumerable <IOperationInterceptorAsync> > systemInterceptors) { if (!method.OutputMembers.Single().StaticType.IsTask()) { return(null); } var attribCache = LoadAsyncAttribCache(method); IOperationAsync factory() => new AsyncMethod(declaringType, method, binderLocator, resolver, attribCache).Intercept(systemInterceptors()); return(new AsyncOperationDescriptor(method, factory)); }
public MethodBasedOperationCreator( IObjectBinderLocator binderLocator = null, IDependencyResolver resolver = null, IMethodFilter[] filters = null, IOperationInterceptorProvider syncInterceptorProvider = null) { _resolver = resolver; _binderLocator = binderLocator ?? new DefaultObjectBinderLocator(); if (syncInterceptorProvider != null) { _syncInterceptorProvider = syncInterceptorProvider.GetInterceptors; } if (filters != null) { _filterMethod = FilterMethods(filters).Chain(); } }
public OperationModelCreator( IEnumerable <IMethodFilter> methodFilters, Func <IEnumerable <IOperationInterceptorAsync> > asyncInterceptors, IObjectBinderLocator binderLocator, IDependencyResolver resolver, IOperationInterceptorProvider syncInterceptorProvider = null) { _asyncInterceptors = asyncInterceptors; _binderLocator = binderLocator; _resolver = resolver; _methodFilters = methodFilters.DefaultIfEmpty(new TypeExclusionMethodFilter <object>()); if (syncInterceptorProvider != null) { _syncInterceptors = syncInterceptorProvider.GetInterceptors; } else { _syncInterceptors = op => Enumerable.Empty <IOperationInterceptor>(); } }
static OperationDescriptor CreateTaskOfTDescriptor(IType targetType, IMethod method, IObjectBinderLocator binderLocator, IDependencyResolver resolver, Func <IEnumerable <IOperationInterceptorAsync> > asyncInterceptors) { if (!method.OutputMembers.Single().StaticType.IsTaskOfT(out var returnType)) { return(null); } var attribCache = LoadAsyncAttribCache(method); var asyncMethodType = typeof(AsyncMethod <>).MakeGenericType(returnType); var ctor = asyncMethodType.GetConstructors().Single(); var lambdaParams = ctor .GetParameters() .Select(info => Expression.Parameter(info.ParameterType, info.Name)) .ToList(); var factoryLambda = Expression.Lambda <Func < IType, IMethod, IObjectBinderLocator, IDependencyResolver, Dictionary <Type, object[]>, IOperationAsync> >( Expression.New(ctor, lambdaParams), lambdaParams).Compile(); IOperationAsync factory() => factoryLambda(targetType, method, binderLocator, resolver, attribCache) .Intercept(asyncInterceptors()); return(new AsyncOperationDescriptor(method, factory)); }
public MethodBasedOperationCreator( IObjectBinderLocator binderLocator = null, IDependencyResolver resolver = null, IEnumerable <IMethodFilter> filters = null, IOperationInterceptorProvider syncInterceptorProvider = null, IEnumerable <IOperationInterceptorAsync> asyncInterceptors = null) { _asyncInterceptors = asyncInterceptors ?? Enumerable.Empty <IOperationInterceptorAsync>(); _resolver = resolver; _binderLocator = binderLocator ?? new DefaultObjectBinderLocator(); if (syncInterceptorProvider != null) { _syncInterceptorProvider = syncInterceptorProvider.GetInterceptors; } else { _syncInterceptorProvider = op => Enumerable.Empty <IOperationInterceptor>(); } if (filters != null) { _filterMethod = FilterMethods(filters.ToArray()).Chain(); } }
public MultipartFormDataObjectCodec(ICommunicationContext context, ICodecRepository codecs, IDependencyResolver container, ITypeSystem typeSystem, IObjectBinderLocator binderLocator) : base(context, codecs, container, typeSystem, binderLocator) { }
public MethodBasedOperationCreator(IMethodFilter[] filters, IDependencyResolver resolver, IObjectBinderLocator binderLocator) { _resolver = resolver; _binderLocator = binderLocator; _filterMethod = FilterMethods(filters).Chain(); }
public AbstractApplicationXWwwFormUrlencodedCodec(ICommunicationContext context, IObjectBinderLocator locator) { _environment = context.Environment; _binderLocator = locator; }
public AbstractApplicationXWwwFormUrlencodedCodec(ICommunicationContext context, IObjectBinderLocator locator) { _pipelineData = context.PipelineData; _binderLocator = locator; }
//// TODO: Remove when support for arrays is added to containers public MethodBasedOperationCreator(IDependencyResolver resolver, IObjectBinderLocator binderLocator) : this(resolver.ResolveAll<IMethodFilter>().ToArray(), resolver, binderLocator) { }
//// TODO: Remove when support for arrays is added to containers public MethodBasedOperationCreator(IDependencyResolver resolver, IObjectBinderLocator binderLocator) : this(resolver.ResolveAll <IMethodFilter>().ToArray(), resolver, binderLocator) { }
public AsyncMethod(IMethod method, IObjectBinderLocator binderLocator = null) : base(method, binderLocator) { }
public ApplicationXWwwFormUrlencodedObjectCodec(ICommunicationContext context, IObjectBinderLocator locator) : base(context, locator) { }
public AsyncMethod(IMethod method, IObjectBinderLocator binderLocator = null, IDependencyResolver resolver = null) : base(method, binderLocator) { Resolver = resolver; }
public SyncMethod(IType targetType, IMethod method, IObjectBinderLocator binderLocator = null, IDependencyResolver resolver = null, Dictionary <Type, object[]> attributeCache = null) : base(targetType, method, binderLocator, resolver, attributeCache) { }