示例#1
0
        public ISchema GenerateSchema(Type type, ISchemaRepository schemaRepository)
        {
            var schemaId = _options.SchemaIdSelector(type);

            var reference = schemaRepository.GetOrAdd(type, schemaId, () => TypeSchemaFactory(type, schemaRepository));

            return(reference);
        }
示例#2
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);
        }