Exemple #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.RegisterServiceType?.Invoke(typeof(AdministrativeDivisionFindMiddleware), "Singleton");
            moduleTable.RegisterServiceType?.Invoke(typeof(AdministrativeDivisionGetChildrenMiddleware), "Singleton");
            moduleTable.RegisterServiceType?.Invoke(typeof(AdministrativeDivisionGetMiddleware), "Singleton");

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

            return(moduleTable);
        }
        /// <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.RegisterServiceType?.Invoke(typeof(CellnumberAttributionMiddleware), "Singleton");

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

            return(moduleTable);
        }
Exemple #3
0
        /// <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);
        }
        /// <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);
        }
        /// <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="arithmeticSpeechCodeRouteTemplate"></param>
        /// <param name="stringImageCodeRouteTemplate"></param>
        /// <param name="stringSpeechCodeRouteTemplate"></param>
        /// <returns></returns>
        public static ModularizationModuleTable AddCaptcha(this ModularizationModuleTable moduleTable,
                                                           Action <CaptchaModuleOptions> configureOptions,
                                                           string clickCodeRouteTemplate            = "captcha/click",
                                                           string puzzleCodeRouteTemplate           = "captcha/puzzle",
                                                           string sliderCodeRouteTemplate           = "captcha/slider",
                                                           string arithmeticImageCodeRouteTemplate  = "captcha/arithmeticImage",
                                                           string arithmeticSpeechCodeRouteTemplate = "captcha/arithmeticSpeech",
                                                           string stringImageCodeRouteTemplate      = "captcha/stringImage",
                                                           string stringSpeechCodeRouteTemplate     = "captcha/stringSpeech")
        {
            moduleTable.Services.AddSingleton <ClickCaptchaMiddleware>();
            moduleTable.Services.AddSingleton <PuzzleCaptchaMiddleware>();
            moduleTable.Services.AddSingleton <SliderCaptchaMiddleware>();
            moduleTable.Services.AddSingleton <ArithmeticImageCaptchaMiddleware>();
            moduleTable.Services.AddSingleton <ArithmeticSpeechCaptchaMiddleware>();
            moduleTable.Services.AddSingleton <StringImageCaptchaMiddleware>();
            moduleTable.Services.AddSingleton <StringSpeechCaptchaMiddleware>();

            moduleTable.AddModule("Captcha(Module", new[]
            {
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = clickCodeRouteTemplate,
                    HandlerType   = typeof(ClickCaptchaMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = puzzleCodeRouteTemplate,
                    HandlerType   = typeof(PuzzleCaptchaMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = sliderCodeRouteTemplate,
                    HandlerType   = typeof(SliderCaptchaMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = arithmeticImageCodeRouteTemplate,
                    HandlerType   = typeof(ArithmeticImageCaptchaMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = arithmeticSpeechCodeRouteTemplate,
                    HandlerType   = typeof(ArithmeticSpeechCaptchaMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = stringImageCodeRouteTemplate,
                    HandlerType   = typeof(StringImageCaptchaMiddleware),
                },
                new ModularizationModuleMiddleware
                {
                    HttpMethods   = new[] { "GET" },
                    RouteTemplate = stringSpeechCodeRouteTemplate,
                    HandlerType   = typeof(StringSpeechCaptchaMiddleware),
                },
            }, configureOptions);

            return(moduleTable);
        }