Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleTable"></param>
        /// <param name="configureOptions"></param>
        /// <param name="getRouteTemplate"></param>
        /// <param name="getChildrenRouteTemplate"></param>
        /// <param name="findRouteTemplate"></param>
        /// <returns></returns>
        public static ModularizationModuleTable AddAdministrativeDivisionCn(this ModularizationModuleTable moduleTable,
                                                                            Action <AdministrativeDivisionModuleOptions> configureOptions,
                                                                            string getRouteTemplate         = "AD/Get",
                                                                            string getChildrenRouteTemplate = "AD/GetChildren",
                                                                            string findRouteTemplate        = "AD/Find")
        {
            moduleTable.Services.AddSingleton <AdministrativeDivisionFindMiddleware>();
            moduleTable.Services.AddSingleton <AdministrativeDivisionGetMiddleware>();
            moduleTable.Services.AddSingleton <AdministrativeDivisionGetChildrenMiddleware>();

            moduleTable.AddModule("AdministrativeDivisionModule", new[]
            {
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = findRouteTemplate,
                    HandlerType   = typeof(AdministrativeDivisionFindMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = getRouteTemplate,
                    HandlerType   = typeof(AdministrativeDivisionGetMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = getChildrenRouteTemplate,
                    HandlerType   = typeof(AdministrativeDivisionGetChildrenMiddleware),
                },
            }, configureOptions);

            return(moduleTable);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleTable"></param>
        /// <param name="configureOptions"></param>
        /// <param name="clickCodeRouteTemplate"></param>
        /// <param name="puzzleCodeRouteTemplate"></param>
        /// <param name="sliderCodeRouteTemplate"></param>
        /// <param name="arithmeticImageCodeRouteTemplate"></param>
        /// <param name="stringImageCodeRouteTemplate"></param>
        /// <returns></returns>
        public static ModularizationModuleTable AddVerificationCode(this ModularizationModuleTable moduleTable,
                                                                    Action <CaptchaModuleOptions> configureOptions,
                                                                    string clickCodeRouteTemplate           = "verificationCode/click",
                                                                    string puzzleCodeRouteTemplate          = "verificationCode/puzzle",
                                                                    string sliderCodeRouteTemplate          = "verificationCode/slider",
                                                                    string arithmeticImageCodeRouteTemplate = "verificationCode/arithmeticImage",
                                                                    string stringImageCodeRouteTemplate     = "verificationCode/stringImage")
        {
            moduleTable.Services.AddSingleton <ClickCodeMiddleware>();
            moduleTable.Services.AddSingleton <PuzzleCodeMiddleware>();
            moduleTable.Services.AddSingleton <SliderCodeMiddleware>();
            moduleTable.Services.AddSingleton <ArithmeticImageCodeMiddleware>();
            moduleTable.Services.AddSingleton <StringImageCodeMiddleware>();

            moduleTable.AddModule("VerificationCodeModule", new[]
            {
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = clickCodeRouteTemplate,
                    HandlerType   = typeof(ClickCodeMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = puzzleCodeRouteTemplate,
                    HandlerType   = typeof(PuzzleCodeMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = sliderCodeRouteTemplate,
                    HandlerType   = typeof(SliderCodeMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = arithmeticImageCodeRouteTemplate,
                    HandlerType   = typeof(ArithmeticImageCodeMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = stringImageCodeRouteTemplate,
                    HandlerType   = typeof(StringImageCodeMiddleware),
                },
            }, configureOptions);

            return(moduleTable);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleTable"></param>
        /// <param name="configureOptions"></param>
        /// <param name="routeTemplate"></param>
        /// <returns></returns>
        public static ModularizationModuleTable AddCellnumberAttributionCn(this ModularizationModuleTable moduleTable,
                                                                           Action <CellnumberAttributionModuleOptions> configureOptions,
                                                                           string routeTemplate = "CA/Find")
        {
            moduleTable.Services.AddSingleton <CellnumberAttributionMiddleware>();

            moduleTable.AddModule("CellnumberAttributionModule", new[]
            {
                new ModularizationModuleMiddleware {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = routeTemplate,
                    HandlerType   = typeof(CellnumberAttributionMiddleware),
                },
            }, configureOptions);

            return(moduleTable);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleTable"></param>
        /// <param name="configureOptions"></param>
        /// <param name="routeTemplate"></param>
        /// <returns></returns>
        public static ModularizationModuleTable AddUpload(this ModularizationModuleTable moduleTable,
                                                          Action <UploadModuleOptions> configureOptions,
                                                          string routeTemplate = "upload")
        {
            moduleTable.Services.AddSingleton <UploadMiddleware>();

            moduleTable.AddModule("UploadModule", new[]
            {
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "POST" },
                    RouteTemplate = routeTemplate,
                    HandlerType   = typeof(UploadMiddleware),
                },
            }, configureOptions);

            return(moduleTable);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleTable"></param>
        /// <param name="configureOptions"></param>
        /// <param name="combineRouteTemplate"></param>
        /// <param name="combineToGIFRouteTemplate"></param>
        /// <param name="concatenateRouteTemplate"></param>
        /// <param name="cropRouteTemplate"></param>
        /// <param name="qrcodeRouteTemplate"></param>
        /// <param name="resizeRouteTemplates"></param>
        /// <returns></returns>
        public static ModularizationModuleTable AddImage(this ModularizationModuleTable moduleTable,
                                                         Action <ImageModuleOptions> configureOptions,
                                                         string combineRouteTemplate      = "image/combine",
                                                         string combineToGIFRouteTemplate = "image/combineToGIF",
                                                         string concatenateRouteTemplate  = "image/concatenate",
                                                         string cropRouteTemplate         = "image/crop",
                                                         string qrcodeRouteTemplate       = "image/qrcode",
                                                         params string[] resizeRouteTemplates)
        {
            moduleTable.Services.AddSingleton <ImageCombineMiddleware>();
            moduleTable.Services.AddSingleton <ImageCombineToGIFMiddleware>();
            moduleTable.Services.AddSingleton <ImageConcatenateMiddleware>();
            moduleTable.Services.AddSingleton <ImageCropMiddleware>();
            moduleTable.Services.AddSingleton <ImageQRCodeMiddleware>();
            moduleTable.Services.AddSingleton <ImageResizeMiddleware>();

            var middlewares = new List <ModularizationModuleMiddleware>
            {
                new()
                {
                    HttpMethods   = new[] { "POST" },
                    RouteTemplate = combineRouteTemplate,
                    HandlerType   = typeof(ImageCombineMiddleware),
                },
                new()
                {
                    HttpMethods   = new[] { "POST" },
                    RouteTemplate = combineToGIFRouteTemplate,
                    HandlerType   = typeof(ImageCombineToGIFMiddleware),
                },
                new()
                {
                    HttpMethods   = new[] { "POST" },
                    RouteTemplate = concatenateRouteTemplate,
                    HandlerType   = typeof(ImageConcatenateMiddleware),
                },
                new()
                {
                    HttpMethods   = new[] { "POST" },
                    RouteTemplate = cropRouteTemplate,
                    HandlerType   = typeof(ImageCropMiddleware),
                },
                new()
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = qrcodeRouteTemplate,
                    HandlerType   = typeof(ImageQRCodeMiddleware),
                },
            };

            if (!resizeRouteTemplates.IsNullOrEmpty())
            {
                foreach (var routeTemplate in resizeRouteTemplates)
                {
                    middlewares.Add(new()
                    {
                        HttpMethods   = new[] { "GET" },
                        RouteTemplate = routeTemplate,
                        HandlerType   = typeof(ImageResizeMiddleware),
                    });
                }
            }

            moduleTable.AddModule("ImageModule", middlewares.ToArray(), configureOptions);

            return(moduleTable);
        }