Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="next"></param>
        /// <param name="provider"></param>
        /// <param name="options"></param>
        /// <param name="routeTemplate"></param>
        public ApiExplorerGeneratorMiddleware(
            RequestDelegate next,
            IGenerateProvider provider,
            IOptions <ApiExplorerGeneratorOptions> options,
            string routeTemplate)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            if (string.IsNullOrWhiteSpace(routeTemplate))
            {
                throw new ArgumentNullException(nameof(routeTemplate));
            }

            this.next          = next;
            this.provider      = provider;
            this.basePath      = options?.Value?.BasePath;
            this.routeTemplate = routeTemplate;
        }
Пример #2
0
        private IFileProvider GetFileProvider()
        {
            IGenerateProvider generateProvider = GetGenerateProvider();
            IFilePathProvider filePathProvider = GetFilePathProvider();

            return(new FileProvider(generateProvider, new List <IFilePathProvider>()
            {
                filePathProvider
            }));
        }
Пример #3
0
        private NoteService GetNoteService()
        {
            IRepository <Models.Note, Guid> res = GetRepository();
            ILoggerFactory loggerFactory        = new LoggerFactory();
            IUnitOfWork    uow      = GetUnitOfWork();
            IMapper        mapper   = GetMapper();
            EventBus       eventBus = GetEventBus();
            IEventHandler <PersistentImg> eventHandler     = GetEventHandler();
            IGenerateProvider             generateProvider = GetGenerateProvider();

            return(new NoteService(loggerFactory, uow, res, mapper, eventBus, eventHandler, generateProvider));
        }
Пример #4
0
        public NoteService(ILoggerFactory loggerFactory,
                           IUnitOfWork unitOfWork,
                           IRepository <Models.Note, Guid> repository,
                           IMapper mapper,
                           EventBus eventBus,
                           IEventHandler <PersistentImg> eventHandler,
                           IGenerateProvider generateProvider)
            : base(unitOfWork, repository, mapper)
        {
            _eventBus         = eventBus;
            _eventHandler     = eventHandler;
            _logger           = loggerFactory.CreateLogger <NoteService>();
            _generateProvider = generateProvider;

            eventBus.Subscribe(_eventHandler);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="options"></param>
        /// <param name="routeTemplate"></param>
        public ApiExplorerGeneratorMiddleware(
            IGenerateProvider provider,
            ApiExplorerGeneratorOptions options,
            string routeTemplate)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            if (string.IsNullOrWhiteSpace(routeTemplate))
            {
                throw new ArgumentNullException(nameof(routeTemplate));
            }

            this.provider      = provider;
            this.basePath      = options?.BasePath;
            this.routeTemplate = routeTemplate;
        }
Пример #6
0
        /// <summary>
        /// 注册ApiExplorer生成服务
        /// </summary>
        /// <param name="app"></param>
        /// <param name="configureOptions"></param>
        /// <param name="apiExplorerGenerateProvider"></param>
        /// <returns></returns>
        public static HttpApplication AddApiExplorerGenerator(this HttpApplication app, Action <ApiExplorerGeneratorOptions> configureOptions, IGenerateProvider apiExplorerGenerateProvider = null)
        {
            configureOptions?.Invoke(generatorOptions);

            if (apiExplorerGenerateProvider == null)
            {
                var apiExplorer            = GlobalConfiguration.Configuration.Services.GetApiExplorer();
                var jsonSerializerSettings = new Newtonsoft.Json.JsonSerializerSettings();
                var xmlDocmentationReader  = new DefaultXmlDocmentationReader(generatorOptions);
                var typeRegister           = new DefaultTypeRegister(jsonSerializerSettings, xmlDocmentationReader);
                var apiResolver            = new ApiResolver(apiExplorer, jsonSerializerSettings, generatorOptions, typeRegister, xmlDocmentationReader);
                var apiSerializer          = new DefaultApiSerializer();

                apiExplorerGenerateProvider = new GenerateProvider(apiResolver, apiSerializer, typeRegister, xmlDocmentationReader);
            }

            generateProvider = apiExplorerGenerateProvider;

            return(app);
        }
 /// <summary>
 /// 注册ApiExplorer服务
 /// </summary>
 /// <param name="app"></param>
 /// <param name="configure"></param>
 /// <param name="apiExplorerGenerateProvider"></param>
 /// <returns></returns>
 public static HttpApplication AddApiExplorer(this HttpApplication app, Action <ApiExplorerGeneratorOptions> configure, IGenerateProvider apiExplorerGenerateProvider = null)
 {
     return(app.AddApiExplorerGenerator(configure));
 }
Пример #8
0
 public FileProvider(IGenerateProvider generateProvider, ICollection <IFilePathProvider> filePathProviders)
 {
     _generateProvider  = generateProvider;
     _filePathProviders = filePathProviders;
 }