public static IApplicationBuilder UseGraphQL(
     this IApplicationBuilder applicationBuilder,
     IServiceProvider serviceProvider)
 {
     return(applicationBuilder
            .UseGraphQL(serviceProvider, new QueryMiddlewareOptions()));
 }
예제 #2
0
        private static AppBuilder UseYOYOFx(this AppBuilder app, Action <IRouteBuilder> routebuilderFunc = null, Action <YOYOFxOptions> configuration = null)
        {
            if (Application.CurrentApplication.ServiceProvider == null)
            {
                IServiceCollection sc = new ServiceCollection();
                sc.AddYOYOFx();
            }

            YOYOFxOptions options = new YOYOFxOptions();

            if (configuration != null)
            {
                configuration(options);
            }

            Application.CurrentApplication.SetOptions(options);

            IRouteBuilder routeBuilder = RouteBuilder.Builder;

            //default route role
            routeBuilder.Map("/{controller}/{action}/{id}/");

            if (routebuilderFunc != null)
            {
                routebuilderFunc(RouteBuilder.Builder);
            }

            return(app);
        }
        // This method is required by Katana:
        public void Configuration(Owin.IAppBuilder app)
        {
            var webApiConfiguration = ConfigureWebApi();

            // Use the extension method provided by the WebApi.Owin library:
            app.UseWebApi(webApiConfiguration);
        }
예제 #4
0
        /// <summary>
        /// IMPORTANT: Please note that each enum in your project
        /// IMPORTANT: should be included below in a call to <see cref="AgoRapide.Core.PropertyKeyMapper.MapEnum"/> (See mapper1)
        /// </summary>
        /// <param name="appBuilder"></param>
        public void Configuration(Owin.IAppBuilder appBuilder)
        {
            try {
                var logPath = @"c:\p\Logfiles\AgoRapideSample\AgoRapideLog_[DATE_HOUR].txt";

                /// Note how we set AgoRapide.Core.Util.Configuration twice,
                /// First in order to set <see cref="AgoRapide.Core.ConfigurationAttribute.LogPath"/> (so we can call <see cref="AgoRapide.Core.Util.Log"/>),
                /// Second in order to set <see cref="AgoRapide.Core.ConfigurationAttribute.RootUrl"/>
                AgoRapide.Core.Util.Configuration = new AgoRapide.Core.Configuration(new AgoRapide.Core.ConfigurationAttribute(
                                                                                         logPath: logPath,
                                                                                         rootUrl: AgoRapide.Core.Util.Configuration.C.RootUrl,
                                                                                         databaseGetter: type => throw new NullReferenceException(nameof(AgoRapide.Core.ConfigurationAttribute.DatabaseGetter) + " not yet set")
                                                                                         ));

                Log(null, "");
                var environment = GetEnvironment();
                Log(null, "rootUrl: " + environment.rootUrl); // Necessary because System.Web.HttpContext.Current.Request.Url not available now.
                Log(null, "environment: " + environment.environment);

                // Note how we set AgoRapide.Core.Util.Configuration twice, first in order to be able to log, second in order to set rootUrl, rootPath and databaseGetter
                AgoRapide.Core.Util.Configuration = new AgoRapide.Core.Configuration(new AgoRapide.Core.ConfigurationAttribute(
                                                                                         logPath: logPath,
                                                                                         rootUrl: environment.rootUrl,
                                                                                         databaseGetter: ownersType => BaseController.GetDatabase(ownersType)
                                                                                         )
                {
                    // Change to different version of JQuery by adding this line:
                    // ScriptRelativePaths = new List<string> { "Scripts/AgoRapide-0.1.js", "Scripts/jquery-3.1.1.min.js" },

                    Environment = environment.environment,
                    SuperfluousStackTraceStrings = new List <string>()
                    {
                        @"c:\git\AgoRapide",
                        @"C:\git\AgoRapide\",
                        @"C:\AgoRapide2\trunk\",
                        @"C:\diggerout\trunk\DAPI\DAPI"
                    },
                });

                /// Include all assemblies in which your controllers and <see cref="AgoRapide.BaseEntity"/>-derived classes resides.
                var assemblies = new List <System.Reflection.Assembly> {
                    typeof(HomeController).Assembly, /// Strictly speaking only needed for call to <see cref="AgoRapide.Core.CoreStartup.Initialize"/>, not <see cref="AgoRapide.API.APIMethod.FindAndSetAllBaseEntityDerivedTypes"/>
                };

                AgoRapide.API.APIMethod.FindAndSetAllBaseEntityDerivedTypes(
                    assemblies,
                    typesToExclude: new List <Type>() /// Exclude <see cref="AgoRapide.Person"/> now if you do not want to use that class in your project.
                    );

                AgoRapide.Core.PropertyKeyMapper.MapKnownEnums(s => Log("MapEnums", nameof(AgoRapide.Core.PropertyKeyMapper.MapKnownEnums) + ": " + s)); /// TODO: Move into <see cref="AgoRapide.Core.Startup"/> somehow

                /// Mapping must be done now because of a lot of static properties which calls one of <see cref="AgoRapide.Core.Extensions.A"/>
                void mapper1 <T>() where T : struct, IFormattable, IConvertible, IComparable => AgoRapide.Core.PropertyKeyMapper.MapEnum <T>(s => Log("MapEnums", nameof(AgoRapide.Core.PropertyKeyMapper.MapEnum) + ": " + s)); // What we really would want is "where T : Enum"
        public static IApplicationBuilder UseGraphQL(
            this IApplicationBuilder applicationBuilder,
            IServiceProvider serviceProvider,
            PathString path)
        {
            var options = new QueryMiddlewareOptions
            {
                Path = path.HasValue ? path : new PathString("/")
            };

            return(applicationBuilder
                   .UseGraphQL(serviceProvider, options));
        }
 public static Owin.IAppBuilder UseOpenIdConnectAuthenticationPatched(this Owin.IAppBuilder app, Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationOptions openIdConnectOptions)
 {
     if (app == null)
     {
         throw new System.ArgumentNullException("app");
     }
     if (openIdConnectOptions == null)
     {
         throw new System.ArgumentNullException("openIdConnectOptions");
     }
     System.Type type     = typeof(OpenIdConnectAuthenticationPatchedMiddleware);
     object[]    objArray = new object[] { app, openIdConnectOptions };
     return(app.Use(type, objArray));
 }
        public static IApplicationBuilder UseGraphQL(
            this IApplicationBuilder applicationBuilder,
            IServiceProvider serviceProvider,
            QueryMiddlewareOptions options)
        {
            if (applicationBuilder == null)
            {
                throw new ArgumentNullException(nameof(applicationBuilder));
            }

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

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

            return(applicationBuilder
                   .UseGraphQLHttpPost(serviceProvider,
                                       new HttpPostMiddlewareOptions
            {
                Path = options.Path,
                ParserOptions = options.ParserOptions,
                MaxRequestSize = options.MaxRequestSize
            })
                   .UseGraphQLHttpGet(serviceProvider,
                                      new HttpGetMiddlewareOptions
            {
                Path = options.Path
            })
                   .UseGraphQLHttpGetSchema(serviceProvider,
                                            new HttpGetSchemaMiddlewareOptions
            {
                Path = options.Path.Add(new PathString("/schema"))
            }));
        }
예제 #8
0
        protected override void SetupThrottling(Owin.IAppBuilder app)
        {
            MemoryCacheRepository cache = new MemoryCacheRepository();

            cache.Clear();
            app.Use(typeof(CustomThrottlingMiddleware), new ThrottlePolicy(perHour: 600)
            {
                IpThrottling     = false,
                ClientThrottling = true,
                ClientRules      = new Dictionary <string, RateLimits>
                {
                    { CustomThrottlingMiddleware.IS_AUTHENTICATE, new RateLimits {
                          PerHour = 4000
                      } }
                },
                EndpointThrottling = true,
                EndpointRules      = new Dictionary <string, RateLimits>()
                {
                    { "api/ip", new RateLimits {
                          PerMinute = 2
                      } }
                }
            }, new PolicyMemoryCacheRepository(), cache, new ThrottlingLogger());
        }
예제 #9
0
 public static AppBuilder UseWorkFolder(this AppBuilder app, string path)
 {
     HostingEnvronment.SetRootPath(path);
     return(app);
 }
예제 #10
0
 public static AppBuilder UseYOYOFxCore(this AppBuilder app, Action <IRouteBuilder> routebuilderFunc = null, Action <YOYOFxOptions> configuration = null)
 {
     UseYOYOFx(app, routebuilderFunc, configuration);
     app.UseOwin(p => p(next => Invoke));
     return(app);
 }
        public static IAppBuilder UseDashboardSamples(this IAppBuilder app)
        {
            var assembly = typeof(DashboardExtensions).GetTypeInfo().Assembly;
            var contentFolderNamespace = GetContentFolderNamespace();

            //AspNetCore.StaticFiles.FileExtensionContentTypeProvider f; f.TryGetContentType()
            app.UseMapDashboard("/Dashboard", routes =>
            {
                routes.Add("", new RedirectDispatcher((uriMatch) => uriMatch.Value + "/"));
                //routes.Add("/aaaa", new RedirectDispatcher((uriMatch) => uriMatch.Value + "/"));

                routes.Add("/", new EmbeddedResourceDispatcher(System.Net.Mime.MediaTypeNames.Text.Html, assembly, GetContentResourceName("index.html")));
                //routes.Add("/", new PhysicalFileDispatcher(System.Net.Mime.MediaTypeNames.Text.Html, "Content/index.html"));
                //routes.Add("/aaaa/", new EmbeddedResourceDispatcher(System.Net.Mime.MediaTypeNames.Text.Html, assembly, GetContentResourceName("index.html")));
                ////app.UseStaticFiles(new StaticFileOptions { RequestPath = "/aa/bb", ServeUnknownFileTypes = true, DefaultContentType = "application/x-msdownload", FileProvider = new EmbeddedFileProvider(assembly, "AspNetCoreDashboardLibraryTest") });
                //routes.AddEmbeddedResource(assembly, "/(?<path>.+\\.css)", "text/css", GetContentFolderNamespace());
                //routes.AddEmbeddedResource(assembly, "/(?<path>.+\\.js)", "application/javascript", GetContentFolderNamespace());
                //routes.AddEmbeddedResource(assembly, "/(?<path>.+\\.png)", "image/png", GetContentFolderNamespace());
                //routes.AddEmbeddedResource(assembly, "/(?<path>.+\\.gif)", System.Net.Mime.MediaTypeNames.Image.Gif, GetContentFolderNamespace());
                //routes.AddEmbeddedResource(assembly, "/(?<path>.+\\.jpg)", System.Net.Mime.MediaTypeNames.Image.Jpeg, GetContentFolderNamespace());
                //routes.AddEmbeddedResource(assembly, "/(?<path>.+\\.woff2)", "font/woff2", GetContentFolderNamespace());
                //routes.AddEmbeddedResource(assembly, "/(?<path>.+\\.woff)", "application/font-woff", GetContentFolderNamespace());
                //routes.AddEmbeddedResource(assembly, "/(?<path>.+\\.png)", "image/png", GetContentFolderNamespace());
                //routes.AddEmbeddedDefaultResource(assembly, GetContentFolderNamespace(),"");

                routes.AddCommand("/FlowStatistics", async context =>
                {
                    try
                    {
                        var filter  = context.Request.Method == "POST" ? await context.Request.GetFormValueAsync("filter") : context.Request.GetQuery("filter");
                        var orderBy = context.Request.Method == "POST" ? await context.Request.GetFormValueAsync("orderBy") : context.Request.GetQuery("orderBy");
                        //var start = (context.Request.Method == "POST" ? await context.Request.GetFormValueAsync("start") : context.Request.GetQuery("start")).AsInt32();
                        //var length = (context.Request.Method == "POST" ? await context.Request.GetFormValueAsync("length") : context.Request.GetQuery("length")).AsInt32();
                        //var draw = (context.Request.Method == "POST" ? await context.Request.GetFormValueAsync("draw") : context.Request.GetQuery("draw"))?.AsInt32();

                        //var _accessInfoServices = app.ApplicationServices.GetService<AccessInfoServices>();

                        //var data = _accessInfoServices.GetAccessRecord().Where(filter).OrderBy(orderBy);

                        //var d = Newtonsoft.Json.JsonConvert.SerializeObject(new
                        //{
                        //    Data = data.Skip(start).Take(length).ToArray(),
                        //    Total = data.Count(),
                        //    Draw = draw,
                        //});
                        await context.Response.WriteAsync("aaa");
                    }
                    catch (System.Exception ex)
                    {
                        //var d = Newtonsoft.Json.JsonConvert.SerializeObject(new { IsSuccess = false, ErrorMsg = ex.DetailMessage() });
                        await context.Response.WriteAsync(ex.Message);
                    }
                    return(true);
                });
                routes.AddEmbeddedResource(assembly, "/(?<path>.*)", string.Empty, GetContentFolderNamespace());
                //routes.AddEmbeddedResource("/libs/(?<path>.+\\.json)", "application/json", GetExecutingAssembly(), GetContentFolderNamespace("RichFilemanager.libs"));
                //routes.AddEmbeddedResource("/libs/(?<path>.+\\.js)", "application/javascript", GetExecutingAssembly(), GetContentFolderNamespace("RichFilemanager.libs"));
                //routes.AddEmbeddedResource("/libs/(?<path>.+\\.css)", "text/css", GetExecutingAssembly(), GetContentFolderNamespace("RichFilemanager.libs"));
                //routes.AddEmbeddedResource("/libs/(?<path>.+\\.png)", "image/png", GetExecutingAssembly(), GetContentFolderNamespace("RichFilemanager.libs"));
                //routes.AddEmbeddedResource("/libs/(?<path>.+\\.gif)", "image/gif", GetExecutingAssembly(), GetContentFolderNamespace("RichFilemanager.libs"));
                //routes.AddEmbeddedResource("/themes/(?<path>.+\\.css)", "text/css", GetExecutingAssembly(), GetContentFolderNamespace("RichFilemanager.themes"));
                //routes.AddEmbeddedResource("/themes/(?<path>.+\\.png)", "image/png", GetExecutingAssembly(), GetContentFolderNamespace("RichFilemanager.themes"));
                //routes.AddEmbeddedResource("/src/templates/(?<path>.+\\.html)", System.Net.Mime.MediaTypeNames.Text.Html, GetExecutingAssembly(), GetContentFolderNamespace("RichFilemanager.src.templates"));
                //routes.AddEmbeddedResource("/languages/(?<path>.+\\.json)", "application/json", GetExecutingAssembly(), GetContentFolderNamespace("RichFilemanager.languages"));
                //routes.Add("/config/filemanager.init.js", new EmbeddedResourceDispatcher("application/javascript", GetExecutingAssembly(), GetContentResourceName("RichFilemanager.config", "filemanager.init.js")));
                //routes.Add("/config/filemanager.config.json", new EmbeddedResourceDispatcher("application/json", GetExecutingAssembly(), GetContentResourceName("RichFilemanager.config", "filemanager.config.json")));
                //routes.Add("/config/filemanager.config.default.json", new EmbeddedResourceDispatcher("application/json", GetExecutingAssembly(), GetContentResourceName("RichFilemanager.config", "filemanager.config.default.json")));
                //routes.AddCommand("", context=> { context.Response.r});
            }, null);
            return(app);
        }
예제 #12
0
 public CustomOpenIdConnectAuthenticationMiddleware(OwinMiddleware next, Owin.IAppBuilder app,
                                                    OpenIdConnectAuthenticationOptions options)
     : base(next, app, options)
 {
     _logger = app.CreateLogger <CustomOpenIdConnectAuthenticationMiddleware>();
 }
예제 #13
0
 public OpenIdConnectAuthenticationPatchedMiddleware(Microsoft.Owin.OwinMiddleware next, Owin.IAppBuilder app, Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationOptions options)
     : base(next, app, options)
 {
     this._logger = Microsoft.Owin.Logging.AppBuilderLoggerExtensions.CreateLogger <OpenIdConnectAuthenticationPatchedMiddleware>(app);
 }
예제 #14
0
 public InitializeOwinMiddlewareArgs(IAppBuilder app)
 {
     this.App = app;
 }
 public override void ConfigureMiddleware(Owin.IAppBuilder appBuilder, Microsoft.WindowsAzure.Mobile.Service.ServiceSettingsDictionary settings)
 {
     return;
 }