static void Main(string[] args) { AppLoader app = new AppLoader(); List<string> l = app.GetFileNames("C:\\Users\\anthony\\Desktop\\Balance"); foreach (string s in l) { string temp = Path.GetFileNameWithoutExtension(s); Console.WriteLine(temp); Console.ReadKey(); } }
public MainStack(AppLoader appLoader) { _appLoader = appLoader; var color = Mobile.Helper.Color.Blue.ToFormsColor(); NavigationPage = new NavigationPage() { BarBackgroundColor = color, BarTextColor = Mobile.Helper.Color.White.ToFormsColor(), Title = "Descubra" }; MainPage = new MasterDetailPage() { BackgroundColor = Color.Transparent, Master = BuildMenuPage(), Detail = NavigationPage, MasterBehavior = MasterBehavior.Popover, IsGestureEnabled = false }; }
private static void Main(string[] args) => AppLoader.CreateDefaultBuilder(args) .UseStartup <Startup>() .Build() .Start(new MainWindow());
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddTransient <IEmailSender, AuthMessageSender>(); services.AddTransient <ISmsSender, AuthMessageSender>(); services.AddTransient <IContextService, ContextService>(); var hostingEnvironment = services.BuildServiceProvider().GetService <IHostingEnvironment>(); services.AddOptions(); services.Configure <Weapsy.Data.Configuration.Data>(c => { c.Provider = (Data.Configuration.DataProvider)Enum.Parse( typeof(Data.Configuration.DataProvider), Configuration.GetSection("Data")["Provider"]); }); services.Configure <ConnectionStrings>(Configuration.GetSection("ConnectionStrings")); services.AddApplicationInsightsTelemetry(Configuration); services.AddEntityFramework(Configuration); services.AddLocalization(options => options.ResourcesPath = "Resources"); services.AddMvc() .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix) .AddDataAnnotationsLocalization() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }) .AddRazorOptions(options => { foreach (var assembly in AppLoader.Instance(hostingEnvironment).AppAssemblies) { var reference = MetadataReference.CreateFromFile(assembly.Location); options.AdditionalCompilationReferences.Add(reference); } }); services.Configure <RazorViewEngineOptions>(options => { foreach (var assembly in AppLoader.Instance(hostingEnvironment).AppAssemblies) { var embeddedFileProvider = new EmbeddedFileProvider(assembly, assembly.GetName().Name); options.FileProviders.Add(embeddedFileProvider); } options.ViewLocationExpanders.Add(new ViewLocationExpander()); }); services.AddAutoMapper(); foreach (var startup in AppLoader.Instance(hostingEnvironment).AppAssemblies.GetImplementationsOf <Mvc.Apps.IStartup>()) { startup.ConfigureServices(services); } var builder = new ContainerBuilder(); foreach (var module in AppLoader.Instance(hostingEnvironment).AppAssemblies.GetImplementationsOf <IModule>()) { builder.RegisterModule(module); } builder.RegisterModule(new AutofacModule()); builder.Populate(services); var container = builder.Build(); return(container.Resolve <IServiceProvider>()); }
public void Configure(IApplicationBuilder app, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory, ISiteInstallationService siteInstallationService, IThemeInstallationService themeInstallationService, ISiteRepository siteRepository, IQueryDispatcher queryDispatcher) { app.EnsureDbCreated(); app.EnsureIdentityCreatedAsync(); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseStatusCodePagesWithRedirects("~/error/{0}"); if (hostingEnvironment.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/error/500"); } app.UseTheme(); app.UseStaticFiles(); foreach (var theme in queryDispatcher.DispatchAsync <GetActiveThemes, IEnumerable <ThemeInfo> >(new GetActiveThemes()).Result) { var contentPath = Path.Combine(hostingEnvironment.ContentRootPath, "Themes", theme.Folder, "wwwroot"); if (Directory.Exists(contentPath)) { app.UseStaticFiles(new StaticFileOptions { RequestPath = "/Themes/" + theme.Folder, FileProvider = new PhysicalFileProvider(contentPath) }); } } foreach (var appDescriptor in AppLoader.Instance(hostingEnvironment).AppDescriptors) { var contentPath = Path.Combine(hostingEnvironment.ContentRootPath, "Apps", appDescriptor.Folder, "wwwroot"); if (Directory.Exists(contentPath)) { app.UseStaticFiles(new StaticFileOptions { RequestPath = "/" + appDescriptor.Folder, FileProvider = new PhysicalFileProvider(contentPath) }); } } foreach (var startup in AppLoader.Instance(hostingEnvironment).AppAssemblies.GetImplementationsOf <Mvc.Apps.IStartup>()) { startup.Configure(app); } var applicationPartManager = app.ApplicationServices.GetRequiredService <ApplicationPartManager>(); Parallel.ForEach(AppLoader.Instance(hostingEnvironment).AppAssemblies, assembly => { applicationPartManager.ApplicationParts.Add(new AssemblyPart(assembly)); }); app.UseIdentity(); themeInstallationService.EnsureThemeInstalled(new CreateTheme { Name = "Default", Description = "Default Theme", Folder = "Default" }); siteInstallationService.VerifySiteInstallation(); var site = siteRepository.GetByName("Default"); var activeLanguages = queryDispatcher.DispatchAsync <GetAllActive, IEnumerable <LanguageInfo> >(new GetAllActive { SiteId = site.Id }).Result; app.AddRoutes(); app.AddLocalisation(activeLanguages); }
/// <summary> /// Allows for a fallback loader and a Dependency Injection activator to be specified. /// </summary> /// <param name="next"></param> /// <param name="activator"></param> public DefaultLoader(AppLoader next, Func <Type, object> activator) : this(next, activator, null) { }
/// <summary> /// Allows for a fallback loader to be specified. /// </summary> /// <param name="next"></param> public DefaultLoader(AppLoader next) : this(next, null, null) { }
public void Configure(IApplicationBuilder app, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory, ISiteInstallationService siteInstallationService, IAppInstallationService appInstallationService, IMembershipInstallationService membershipInstallationService, ISiteRepository siteRepository, ILanguageFacade languageFacade, IPageFacade pageFacade) { membershipInstallationService.VerifyUserCreation(); appInstallationService.VerifyAppInstallation(); siteInstallationService.VerifySiteInstallation(); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseApplicationInsightsRequestTelemetry(); app.UseStatusCodePagesWithRedirects("~/error/{0}"); if (hostingEnvironment.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/error/500"); } app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); foreach (var appDescriptor in AppLoader.Instance(hostingEnvironment).AppDescriptors) { var contentPath = Path.Combine(hostingEnvironment.ContentRootPath, "Apps", appDescriptor.Folder, "wwwroot"); if (Directory.Exists(contentPath)) { app.UseStaticFiles(new StaticFileOptions { RequestPath = "/" + appDescriptor.Folder, FileProvider = new PhysicalFileProvider(contentPath) }); } } foreach (var startup in AppLoader.Instance(hostingEnvironment).AppAssemblies.GetTypes <Mvc.Apps.IStartup>()) { startup.Configure(app); } var applicationPartManager = app.ApplicationServices.GetRequiredService <ApplicationPartManager>(); Parallel.ForEach(AppLoader.Instance(hostingEnvironment).AppAssemblies, assembly => { applicationPartManager.ApplicationParts.Add(new AssemblyPart(assembly)); }); app.UseIdentity(); var site = siteRepository.GetByName("Default"); var activeLanguages = languageFacade.GetAllActiveAsync(site.Id).Result; app.AddRoutes(); app.AddLocalisation(activeLanguages); }
public static async Task <int> Main(string[] cmdArgs) { try { Startup.AppVersion = $"Chromium: {CefRuntime.ChromeVersion}"; Startup.GetAppHostInstructions = _ => new AppHostInstructions { ImportParams = DesktopConfig.Instance.ImportParams, }; DesktopState.AppDebug = Environment.GetEnvironmentVariable("APP_DEBUG") == "1"; DesktopState.OriginalCommandArgs = cmdArgs; DesktopState.Tool = "app"; DesktopState.ToolVersion = Startup.GetVersion(); DesktopState.ChromeVersion = CefRuntime.ChromeVersion; DesktopConfig.WindowFactory = scope => DesktopState.BrowserHandle; Startup.ConfigureScript = feature => feature.ScriptMethods.Add(new DesktopScripts()); var firstArg = cmdArgs.FirstOrDefault(); if (firstArg?.StartsWith("app:") == true || firstArg?.StartsWith("sharp:") == true || firstArg?.StartsWith("xapp:") == true) { DesktopState.FromScheme = true; var cmds = firstArg.ConvertUrlSchemeToCommands(); if (cmds.Any(x => Startup.DebugArgs.Contains(x) && !cmdArgs.Any(x => Startup.VerboseArgs.Contains(x)))) { cmds.Add("-verbose"); } cmdArgs = cmds.ToArray(); if (DesktopState.AppDebug) { NativeWin.MessageBox(0, cmdArgs.Join(","), "cmdArgs", 0); } } else { CreateRegistryEntryFor("app"); CreateRegistryEntryFor("sharp"); CreateRegistryEntryFor("xapp", "x.exe"); } var cefDebug = DesktopState.AppDebug = DesktopState.AppDebug || cmdArgs.Any(x => Startup.DebugArgs.Contains(x)); if (DesktopState.AppDebug) { Startup.DebugMode = true; } var args = DesktopState.CommandArgs = cmdArgs; var kiosk = args.Contains("-kiosk"); if (kiosk) { args = args.Where(x => x != "-kiosk").ToArray(); } string startUrl = null; string favIcon = Startup.ToolFavIcon; var startPos = Array.IndexOf(args, "start"); if (startPos >= 0) { if (startPos == args.Length - 1) { Console.WriteLine(@"Usage: app start {url}"); return(-1); } startUrl = args[startPos + 1]; if (startUrl.IndexOf("://", StringComparison.Ordinal) == -1) { Console.WriteLine(@$ "Not a valid URL: '{startUrl}'"); Console.WriteLine(@"Usage: app start {url}"); return(-2); } } if (DesktopState.FromScheme && !DesktopState.AppDebug) { var hWnd = CefPlatformWindows.GetConsoleHandle(); if (hWnd != IntPtr.Zero) { User32.ShowWindow(hWnd, User32.WindowShowStyle.SW_HIDE); } } var cts = new CancellationTokenSource(); Process process = null; CefPlatformWindows.OnExit = () => { if (Startup.Verbose) { $"OnExit".Print(); } DesktopConfig.Instance.OnExit?.Invoke(); cts?.Cancel(); process?.Close(); }; if (startUrl == null) { var host = await Startup.CreateWebHost("app", args, new WebAppEvents { CreateShortcut = Shortcut.Create, HandleUnknownCommand = ctx => Startup.PrintUsage("app"), OpenBrowser = url => CefPlatformWindows.Start(new CefConfig { StartUrl = url, Width = 1040, DevTools = false, Icon = Startup.ToolFavIcon, HideConsoleWindow = !DesktopState.AppDebug, }), RunNetCoreProcess = ctx => { var url = Environment.GetEnvironmentVariable("ASPNETCORE_URLS")?.LeftPart(';') ?? "http://localhost:5000"; var target = ctx.RunProcess; var fileName = ctx.RunProcess; var arguments = ""; if (target.EndsWith(".dll")) { fileName = "dotnet"; arguments = ctx.RunProcess; } process = Startup.PipeProcess(fileName, arguments, fn: () => CefPlatformWindows.Start(new CefConfig { StartUrl = url, Icon = ctx.FavIcon, HideConsoleWindow = !DesktopState.AppDebug })); }, }); if (host == null) { return(0); } startUrl = host.StartUrl; favIcon = host.FavIcon; cefDebug = host.DebugMode || DesktopState.AppDebug; #pragma warning disable 4014 host.Build().StartAsync(cts.Token); #pragma warning restore 4014 } var config = new CefConfig(cefDebug) { Args = args, StartUrl = DesktopState.StartUrl = startUrl, Icon = favIcon, CefSettings = { PersistSessionCookies = true, }, CefBrowserSettings = new CefBrowserSettings { DefaultEncoding = "UTF-8", FileAccessFromFileUrls = CefState.Enabled, UniversalAccessFromFileUrls = CefState.Enabled, JavaScriptCloseWindows = CefState.Enabled, JavaScriptAccessClipboard = CefState.Enabled, JavaScriptDomPaste = CefState.Enabled, JavaScript = CefState.Enabled, }, }; if ("name".TryGetAppSetting(out var name)) { config.WindowTitle = name; } if ("CefConfig".TryGetAppSetting(out var cefConfigString)) { var cefConfig = JS.eval(cefConfigString); if (cefConfig is Dictionary <string, object> objDictionary) { objDictionary.PopulateInstance(config); } } if (kiosk) { config.Kiosk = true; } if ("CefConfig.CefSettings".TryGetAppSetting(out var cefSettingsString)) { var cefSettings = JS.eval(cefSettingsString); if (cefSettings is Dictionary <string, object> objDictionary) { objDictionary.PopulateInstance(config.CefSettings); } } void allowCors(ProxyScheme proxyScheme, string origin) { proxyScheme.IgnoreHeaders.AddIfNotExists("Content-Security-Policy"); proxyScheme.AddHeaders[HttpHeaders.AllowMethods] = "GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD"; proxyScheme.AddHeaders[HttpHeaders.AllowHeaders] = "Content-Type"; proxyScheme.AddHeaders[HttpHeaders.AllowCredentials] = "true"; proxyScheme.OnResponseHeaders = headers => headers[HttpHeaders.AllowOrigin] = origin; } var i = 0; while ($"CefConfig.Schemes[{i++}]".TryGetAppSetting(out var proxyConfigString)) { var proxyScheme = new ProxyScheme(); var objDictionary = (Dictionary <string, object>)JS.eval(proxyConfigString); objDictionary.PopulateInstance(proxyScheme); if (proxyScheme.AllowCors) { allowCors(proxyScheme, startUrl); } if (objDictionary.ContainsKey("allowIFrames")) { proxyScheme.IgnoreHeaders.AddIfNotExists("Content-Security-Policy"); proxyScheme.IgnoreHeaders.Add("X-Frame-Options"); } config.Schemes.Add(proxyScheme); } foreach (var proxyConfig in DesktopConfig.Instance.ProxyConfigs) { var proxyScheme = proxyConfig.ConvertTo <ProxyScheme>(); if (proxyScheme.AllowCors) { allowCors(proxyScheme, startUrl); } config.Schemes.Add(proxyScheme); } if (config.EnableCorsScheme) { var corsScheme = CreateCorsProxy(); allowCors(corsScheme, config.StartUrl); config.SchemeFactories.Add( new SchemeFactory("cors", new CefProxySchemeHandlerFactory(corsScheme))); } var appHost = AppLoader.TryGetAppHost(); config.SchemeFactories.Add(appHost != null ? new SchemeFactory("host", new CefAppHostSchemeHandlerFactory(appHost)) : new SchemeFactory("host", new CefProxySchemeHandlerFactory(CreateCorsProxy("host", startUrl)) { RequestFilter = (webReq, request) => { webReq.Headers["X-Window-Handle"] = DesktopState.BrowserHandle.ToString(); webReq.Headers["X-Desktop-Info"] = NativeWin.GetDesktopInfo().ToJsv(); } })); if (DesktopState.AppDebug) { config.HideConsoleWindow = false; config.Verbose = true; } return(CefPlatformWindows.Start(config)); } catch (Exception ex) { DesktopConfig.Instance.OnError?.Invoke(ex); if (DesktopState.AppDebug) { NativeWin.MessageBox(0, ex.Message, "Exception", 0); } ex.HandleProgramExceptions(); return(-1); } finally { CefPlatformWindows.Provider?.ShowConsoleWindow(); } }
/// <summary> /// Loads implementation here. Change this method for loading your own implementation. /// </summary> public void Register() { AppLoader.Register(); }
void Awake() { manager = this; }
// 응용 프로그램이 비활성화(백그라운드로 전송)될 때 실행할 코드입니다. // 이 코드는 응용 프로그램이 닫힐 때는 실행되지 않습니다. private void Application_Deactivated(object sender, DeactivatedEventArgs e) { AppLoader.Deactivated(e); }
// 응용 프로그램이 활성화(포그라운드로 이동)될 때 실행할 코드입니다. // 이 코드는 응용 프로그램이 처음 시작될 때는 실행되지 않습니다. private void Application_Activated(object sender, ActivatedEventArgs e) { AppLoader.Activated(e); }
// 시작 메뉴 등에서 응용 프로그램을 시작할 때 실행할 코드입니다. // 이 코드는 응용 프로그램이 다시 활성화될 때는 실행되지 않습니다. private void Application_Launching(object sender, LaunchingEventArgs e) { AppLoader.Launching(e); }
protected override void OnStart(string[] args) { string path = @"C:\Users\narek\Source\Repos\tools\WindowsStartupTool\WindowsStartupTool.Console\bin\Debug\WindowsStartupTool.Console.exe"; AppLoader.StartProcessAndBypassUAC(path, out AppLoader.PROCESS_INFORMATION prc); }