private static StaticFileMiddleware CreateStaticFileMiddleware( RequestDelegate next, IWebHostEnvironment hostingEnv, GraftOptions options, ILoggerFactory loggerFactory ) { var staticFileOptions = new StaticFileOptions { RequestPath = string.IsNullOrEmpty(options.RoutePrefix) ? string.Empty : $"/{options.RoutePrefix}", FileProvider = new ManifestEmbeddedFileProvider(typeof(GraftMiddleware).GetTypeInfo().Assembly), }; return(new StaticFileMiddleware(next, hostingEnv, Options.Create(staticFileOptions), loggerFactory)); }
public GraftMiddleware( RequestDelegate next, IWebHostEnvironment webHostEnvironment, ILoggerFactory loggerFactory, GraftOptions options ) { _options = options ?? new GraftOptions(); _staticFileMiddleware = CreateStaticFileMiddleware(next, webHostEnvironment, _options, loggerFactory); _jsonSerializerOptions = new(); #if NET6_0 _jsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; #else _jsonSerializerOptions.IgnoreNullValues = true; #endif _jsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; _jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase, false)); }
public static IApplicationBuilder UseGraft(this IApplicationBuilder app, GraftOptions options) { return(app.UseMiddleware <GraftMiddleware>(options)); }
static void Main(string[] args) { /** * * Layout: * Repo/ * Repo/<WorkSpace> * Repo/.ExtGit/ * Repo/.ExtGit/<ExtGitWorkLoad> * Repo/.ExtGit/.extgitconfigs/ - ExtGit Configurations * Repo/.ExtGit/.git/... * **/ GraftOptions options = new GraftOptions(); for (int i = 0; i < args.Length; i++) { switch (args[i].ToUpper()) { case "--GRAFT-LOSE-GIT-HISTORY": options.KeepGitHistory = false; break; case "--GRAFT-HOLD-COMMIT": options.CommitAfterGraft = false; break; case "--KEEP-ORIGINAL-GIT-REPO": options.KeepOriginalGitRepo = false; break; case "-C": case "COMMIT": CurrentOperation = Operation.Commit; break; case "-O": case "CHECKOUT": CurrentOperation = Operation.Checkout; break; case "-H": case "-?": case "--?": case "-HELP": case "--HELP": case "HELP": CurrentOperation = Operation.Help; break; case "-V": case "--V": case "VERSION": case "-VERSION": case "--VERSION": case "VER": case "-VER": case "--VER": CurrentOperation = Operation.Version; break; case "NEW": case "INIT": case "-INIT": case "--I": case "--N": CurrentOperation = Operation.Create; break; case "TEST": case "-TEST": case "--T": case "-T": CurrentOperation = Operation.FunctionTest; break; case "GRAFT": case "-G": case "--G": CurrentOperation = Operation.Graft; break; case "--LOG-LEVEL": case "-LOG-LEVEL": case "-L": case "--L": { var logLevel = args[i + 1]; i++; switch (logLevel.ToUpper()) { case "FULL": Debugger.MinLogLevel = LogLevel.Development; break; case "STANDARD": case "STD": Debugger.MinLogLevel = LogLevel.Normal; break; case "WARNING": Debugger.MinLogLevel = LogLevel.Warning; break; case "ERROR": Debugger.MinLogLevel = LogLevel.Error; break; default: break; } } break; case "--FEATURE": case "-FEATURE": case "FEATURE": case "--F": case "-F": { var FEATURE = args[i + 1]; i++; switch (FEATURE.ToUpper()) { case "COMPRESS": Features.CompressLargeFiles = true; break; default: break; } } break; default: Console.WriteLine("Unknown parameter:" + args[i]); break; } } Console.WriteLine(Language.CurrentLanguage.Get("TITLE0", "ExtGit - Designed for commit large file without GIT-LFS to host platforms.")); Console.WriteLine(Language.CurrentLanguage.Get("PREVIEW00", "This software still in an early preview")); Console.WriteLine(""); Console.WriteLine(Language.CurrentLanguage.Get("TITLE1", "Designed for What Happened to Site-13?")); switch (CurrentOperation) { case Operation.Commit: { try { double prog = 0.0; Repo r = new Repo(new DirectoryInfo("./").FullName); r.Commit(ref prog); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.Write(Language.CurrentLanguage.Get("FATAL", "Fatal:")); Console.ForegroundColor = ConsoleColor.White; Debugger.CurrentDebugger.Log(e.Message, LogLevel.Error); } } break; case Operation.Checkout: { try { double prog = 0.0; Repo r = new Repo(new DirectoryInfo("./").FullName); r.Checkout(ref prog); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.Write(Language.CurrentLanguage.Get("FATAL", "Fatal:")); Console.ForegroundColor = ConsoleColor.White; Debugger.CurrentDebugger.Log(e.Message, LogLevel.Error); } } break; case Operation.None: case Operation.Help: ShowHelp(); break; case Operation.FunctionTest: { Tester.Test00(); } break; case Operation.Graft: { Repo.Graft(new DirectoryInfo(".").FullName, options, ShellVersion); } break; case Operation.Version: ShowVersion(); break; case Operation.Create: { Repo repo = new Repo(); repo.ExtGitVer = ShellVersion; repo.ExtGitVerCore = CoreLib.CurrentCore.CoreVersion; Repo.Create(repo, new DirectoryInfo("./").FullName); } break; default: break; } }