Ejemplo n.º 1
0
        private Schema TypeSchemaFactory(Type type, ISchemaRepository schemaRepository)
        {
            var schema = GetSchemaIfPrimitive(type);

            if (schema != null)
            {
                return(schema);
            }

            schema = GetSchemaIfEnumerable(type, schemaRepository);
            if (schema != null)
            {
                return(schema);
            }

            var filter = _options.PropertyFilter ?? ((_) => true);

            var propertyAndFieldMembers = type.GetProperties()
                                          .Where(filter)
                                          .Cast <MemberInfo>()
                                          .Concat(type.GetFields()).ToArray();

            return(CreateSchemaFromPropertyAndFieldMembers(schemaRepository, propertyAndFieldMembers));
        }
Ejemplo n.º 2
0
        protected override GraphQLValue GetAst(object value, ISchemaRepository schemaRepository)
        {
            if (value is bool)
            {
                value = value.ToString().ToLower();
            }

            var stringValue = value.ToString();

            if (stringValue.ParseIntOrGiveNull() != null)
            {
                return new GraphQLScalarValue(ASTNodeKind.IntValue)
                       {
                           Value = stringValue
                       }
            }
            ;

            return(new GraphQLScalarValue(ASTNodeKind.StringValue)
            {
                Value = Regex.Escape(stringValue)
            });
        }
    }
Ejemplo n.º 3
0
 public IQueryable <SchemaVersion> GetSchemaVersions(
     [Service] ISchemaRepository repository) =>
 repository.GetSchemaVersions();
Ejemplo n.º 4
0
 public IQueryable <SchemaPublishReport> GetPublishReports(
     [Parent] SchemaVersion schemaVersion,
     [Service] ISchemaRepository repository) =>
 repository.GetPublishReports().Where(t => t.SchemaVersionId == schemaVersion.Id);
Ejemplo n.º 5
0
 protected abstract GraphQLBaseType GetSchemaType(Type type, ISchemaRepository schemaRepository);
Ejemplo n.º 6
0
 public OperationFilterContext(MethodInfo method, ISchemaRepository schemaRepository, OperationAttribute operation)
 {
     Method           = method;
     SchemaRepository = schemaRepository;
     Operation        = operation;
 }
Ejemplo n.º 7
0
 public ChannelItemFilterContext(MethodInfo method, ISchemaRepository schemaRepository, ChannelAttribute channel)
 {
     Method           = method;
     SchemaRepository = schemaRepository;
     Channel          = channel;
 }
 public KnownArgumentNamesVisitor(IGraphQLSchema schema) : base(schema)
 {
     this.schemaRepository = schema.SchemaRepository;
     this.Errors           = new List <GraphQLException>();
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Generate the Channels section of the AsyncApi schema from the <see cref="ChannelAttribute"/> on classes.
        /// </summary>
        private Channels GenerateChannelsFromClasses(IEnumerable <TypeInfo> asyncApiTypes, ISchemaRepository schemaRepository)
        {
            var channels = new Channels();

            var classesWithChannelAttribute = asyncApiTypes
                                              .Select(type => new
            {
                Channel = type.GetCustomAttribute <ChannelAttribute>(),
                Type    = type,
            })
                                              .Where(cc => cc.Channel != null);

            foreach (var cc in classesWithChannelAttribute)
            {
                var channelItem = new ChannelItem
                {
                    Description = cc.Channel.Description,
                    Parameters  = cc.Channel.Parameters,
                    Publish     = GenerateOperationFromClass(cc.Type, schemaRepository, OperationType.Publish),
                    Subscribe   = GenerateOperationFromClass(cc.Type, schemaRepository, OperationType.Subscribe),
                };

                channels.Add(cc.Channel.Name, channelItem);

                var context = new ChannelItemFilterContext(cc.Type, schemaRepository, cc.Channel);
                foreach (var filter in _options.ChannelItemFilters)
                {
                    filter.Apply(channelItem, context);
                }
            }

            return(channels);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Generate the Channels section of the AsyncApi schema from the <see cref="ChannelAttribute"/> on methods.
        /// </summary>
        private Channels GenerateChannelsFromMethods(IEnumerable <TypeInfo> asyncApiTypes, ISchemaRepository schemaRepository)
        {
            var channels = new Channels();

            var methodsWithChannelAttribute = asyncApiTypes
                                              .SelectMany(type => type.DeclaredMethods)
                                              .Select(method => new
            {
                Channel = method.GetCustomAttribute <ChannelAttribute>(),
                Method  = method,
            })
                                              .Where(mc => mc.Channel != null);

            foreach (var mc in methodsWithChannelAttribute)
            {
                var channelItem = new ChannelItem
                {
                    Description = mc.Channel.Description,
                    Parameters  = mc.Channel.Parameters,
                    Publish     = GenerateOperationFromMethod(mc.Method, schemaRepository, OperationType.Publish),
                    Subscribe   = GenerateOperationFromMethod(mc.Method, schemaRepository, OperationType.Subscribe),
                };
                channels.Add(mc.Channel.Name, channelItem);

                var context = new ChannelItemFilterContext(mc.Method, schemaRepository, mc.Channel);
                foreach (var filter in _options.ChannelItemFilters)
                {
                    filter.Apply(channelItem, context);
                }
            }

            return(channels);
        }
Ejemplo n.º 11
0
        private Message GenerateMessageFromAttribute(MessageAttribute messageAttribute, ISchemaRepository schemaRepository)
        {
            if (messageAttribute?.PayloadType == null)
            {
                return(null);
            }

            var message = new Message
            {
                Payload     = _schemaGenerator.GenerateSchema(messageAttribute.PayloadType, schemaRepository),
                Name        = messageAttribute.Name ?? _options.SchemaIdSelector(messageAttribute.PayloadType),
                Title       = messageAttribute.Title,
                Summary     = messageAttribute.Summary,
                Description = messageAttribute.Description,
            };

            return(message);
        }
Ejemplo n.º 12
0
 public IQueryable <SchemaVersion> GetVersions(
     [Parent] Schema schema,
     [Service] ISchemaRepository repository) =>
 repository.GetSchemaVersions().Where(t => t.SchemaId == schema.Id);
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateAssetCommandHandler" /> class.
 /// </summary>
 /// <param name="schemaRepository">The schema repository.</param>
 /// <param name="eventBus">The event bus.</param>
 public CreateAssetCommandHandler(ISchemaRepository schemaRepository, IEventBus eventBus)
 {
     _schemaRepository = schemaRepository;
     _eventBus         = eventBus;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateSchemaTaskEventCommandHandler"/> class.
 /// </summary>
 /// <param name="repository">The repository.</param>
 public CreateSchemaTaskEventCommandHandler(ISchemaRepository repository, IEventBus eventBus)
 {
     this._repository = repository;
     this._eventBus   = eventBus;
 }
Ejemplo n.º 15
0
 public Migrator(IDatabaseConnection dbConnection, MigratorOptions options)
 {
     DbConnection     = dbConnection;
     SchemaRepository = new SchemaRepository(dbConnection);
     Options          = options;
 }
Ejemplo n.º 16
0
 public KnownTypeNamesVisitor(IGraphQLSchema schema)
 {
     this.schemaRepository = schema.SchemaRepository;
     this.Errors           = new List <GraphQLException>();
 }
 internal ComplexIntrospectedType(ISchemaRepository schemaRepository, GraphQLComplexType type)
 {
     this.schemaRepository = schemaRepository;
     this.type             = type;
 }
Ejemplo n.º 18
0
 public SchemasCacheGrain(ISchemaRepository schemaRepository)
 {
     this.schemaRepository = schemaRepository;
 }
Ejemplo n.º 19
0
 public DbScriptsService(ISchemaRepository schemaRepository)
 {
     _schemaRepository = schemaRepository ?? throw new ArgumentNullException(nameof(schemaRepository));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateTaskTransitionCommandHandler" /> class.
 /// </summary>
 /// <param name="repository">The repository.</param>
 /// <param name="eventBus">The event bus.</param>
 public CreateTaskTransitionCommandHandler(ISchemaRepository repository, IEventBus eventBus)
 {
     _repository = repository;
     _eventBus   = eventBus;
 }
Ejemplo n.º 21
0
 public SchemasController(ISchemaRepository schemaRepository)
 {
     _schemaRepository = schemaRepository;
 }
Ejemplo n.º 22
0
 public SchemaHandler(ISchemaRepository schemaRepository)
 {
     _schemaRepository = schemaRepository ?? throw new ArgumentNullException(nameof(schemaRepository));
 }
Ejemplo n.º 23
0
 public GraphQLBaseType GetGraphQLType(ISchemaRepository schemaRepository)
 {
     return(this.GetSchemaType(this.SystemType, schemaRepository));
 }
        private Message GenerateMessage(MethodInfo method, OperationAttribute operationAttribute, ISchemaRepository schemaRepository)
        {
            var message = new Message
            {
                Payload = _schemaGenerator.GenerateSchema(operationAttribute.MessagePayloadType, schemaRepository),
                // todo: all the other properties... message has a lot!
            };

            return(message);
        }
Ejemplo n.º 25
0
 public SchemasController(ICommandBus commandBus, ISchemaRepository schemaRepository)
     : base(commandBus)
 {
     this.schemaRepository = schemaRepository;
 }
Ejemplo n.º 26
0
 public CreateSchemaEventCommandHandler(ISchemaRepository repository, IEventBus eventBus)
 {
     _repository = repository;
     _eventBus   = eventBus;
 }
Ejemplo n.º 27
0
 public Task <SchemaVersion?> GetSchemaVersionByExternalIdAsync(
     string externalId,
     [Service] ISchemaRepository repository,
     CancellationToken cancellationToken) =>
 repository.GetSchemaVersionByExternalIdAsync(externalId, cancellationToken);
Ejemplo n.º 28
0
 public abstract Result GetValueFromAst(GraphQLValue astValue, ISchemaRepository schemaRepository);
 protected override GraphQLBaseType GetSchemaType(Type type, ISchemaRepository schemaRepository)
 {
     return(schemaRepository.GetSchemaTypeFor(type));
 }
Ejemplo n.º 30
0
 protected abstract GraphQLValue GetAst(object value, ISchemaRepository schemaRepository);