Example #1
0
        private IEnumerable <IDirectiveMiddleware> ExtractMiddlewares(
            IDirectiveMiddlewareDescriptor[] middlewareDescriptors,
            CompiledTypes compiledTypes)
        {
            for (var i = 0; i < middlewareDescriptors.Length; i++)
            {
                string delegateName =
                    ClassSourceCodeGenerator.GetDelegateName(i);

                FieldInfo field = compiledTypes.MiddlewareType.GetField(
                    delegateName,
                    BindingFlags.Static | BindingFlags.Public);

                yield return(new DirectiveDelegateMiddleware(
                                 middlewareDescriptors[i].DirectiveName,
                                 (DirectiveMiddleware)field.GetValue(field)));
            }
        }
Example #2
0
        private IEnumerable <FieldResolver> ExtractResolvers(
            IFieldResolverDescriptor[] resolverDescriptors,
            CompiledTypes compiledTypes)
        {
            for (var i = 0; i < resolverDescriptors.Length; i++)
            {
                string delegateName =
                    ClassSourceCodeGenerator.GetDelegateName(i);

                FieldInfo field = compiledTypes.ResolverType.GetField(
                    delegateName,
                    BindingFlags.Static | BindingFlags.Public);

                yield return(new FieldResolver(
                                 resolverDescriptors[i].Field.TypeName,
                                 resolverDescriptors[i].Field.FieldName,
                                 (FieldResolverDelegate)field.GetValue(field)));
            }
        }