public void Test1() { var fs = new FileSystem2(); fs.Mkdir("/goowmfn"); fs.AddContentToFile("/goowmfn/c", "shetopcy"); fs.Ls("/goowmfn/c").Should().Equal("c"); }
public void OneTimeSetUp() { // TODO: Add code here that is run before // all tests in the assembly are run FileSystem2.InitFileSystem(); if (!DI.IsInit) { DI.Init(ConfigureServices); } }
static int Main(string[] args) { try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13; } catch (NotSupportedException) { } #if WINDOWS_DESKTOP_BRIDGE if (!DesktopBridgeHelper.Init()) { return(0); } DesktopBridgeHelper.OnActivated(ref args); #elif !__MOBILE__ #if MAC AppDelegate.Init(/*args*/); FileSystemDesktopMac.InitFileSystem(); #elif LINUX FileSystemDesktopXDG.InitFileSystem(); #elif WINDOWS FileSystemDesktopWindows.InitFileSystem(); #else FileSystem2.InitFileSystem(); #endif #endif #if StartupTrace StartupTrace.Restart(); #endif // 目前桌面端默认使用 SystemTextJson 如果出现兼容性问题可取消下面这行代码 // Serializable.DefaultJsonImplType = Serializable.JsonImplType.NewtonsoftJson; IsMainProcess = args.Length == 0; IsCLTProcess = !IsMainProcess && args.FirstOrDefault() == "-clt"; IApplication.InitLogDir(); #if StartupTrace StartupTrace.Restart("InitLogDir"); #endif //void InitCefNetApp() => CefNetApp.Init(AppHelper.LogDirPath, args); Startup.InitGlobalExceptionHandler(); try { string[] args_clt; if (IsCLTProcess) // 命令行模式 { args_clt = args.Skip(1).ToArray(); if (args_clt.Length == 1 && args_clt[0].Equals(command_main, StringComparison.OrdinalIgnoreCase)) { return(default);
// Avalonia configuration, don't remove; also used by visual designer. static AppBuilder BuildAvaloniaApp() { #if DEBUG // 设计器模式不会执行 Main 函数所以以此区分来初始化文件系统 if (Assembly.GetCallingAssembly() != Assembly.GetExecutingAssembly()) { FileSystem2.InitFileSystem(); } #endif SettingsHost.Load(); var builder = AppBuilder.Configure <App>() .UsePlatformDetect() .LogToTrace() .UseReactiveUI(); var useGpu = !IApplication.DisableGPU && GeneralSettings.UseGPURendering.Value; #if MAC builder.With(new AvaloniaNativePlatformOptions { UseGpu = useGpu }); #elif LINUX builder.With(new X11PlatformOptions { UseGpu = useGpu }); #elif WINDOWS var useWgl = IApplication.UseWgl || GeneralSettings.UseWgl.Value; var options = new Win32PlatformOptions { UseWgl = useWgl, AllowEglInitialization = useGpu, }; builder.With(options); #else throw new PlatformNotSupportedException(); #endif RenderingSubsystemName = builder.RenderingSubsystemName; return(builder); }
//#if DEBUG //RefWatcher? _refWatcher; //void SetupLeakCanary() //{ // // “A small leak will sink a great ship.” - Benjamin Franklin // if (LeakCanaryXamarin.IsInAnalyzerProcess(this)) // { // // This process is dedicated to LeakCanary for heap analysis. // // You should not init your app in this process. // return; // } // _refWatcher = LeakCanaryXamarin.Install(this); //} //#endif public override void OnCreate() { base.OnCreate(); //#if DEBUG // //SetupLeakCanary(); //#endif var stopwatch = Stopwatch.StartNew(); var startTrace = new StringBuilder(); FileSystem2.InitFileSystem(); stopwatch.Stop(); startTrace.AppendFormatLine("init FileSystem {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); IApplication.InitLogDir(); stopwatch.Stop(); startTrace.AppendFormatLine("init NLog {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); Startup.InitGlobalExceptionHandler(); stopwatch.Stop(); startTrace.AppendFormatLine("init ExceptionHandler {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); VisualStudioAppCenterSDK.Init(); stopwatch.Stop(); startTrace.AppendFormatLine("init AppCenter {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); XEFileProvider.TemporaryLocation = FileProviderLocation.Internal; XEPlatform.Init(this); // 初始化 Xamarin.Essentials.Platform.Init XEPlatform.ActivityStateChanged += OnActivityStateChanged; stopwatch.Stop(); startTrace.AppendFormatLine("init Essentials {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); bool GetIsMainProcess() { // 注意:进程名可以自定义,默认是包名,如果自定义了主进程名,这里就有误,所以不要自定义主进程名! var name = this.GetCurrentProcessName(); return(name == PackageName); } IsMainProcess = GetIsMainProcess(); stopwatch.Stop(); startTrace.AppendFormatLine("init IsMainProcess {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); SettingsHost.Load(); stopwatch.Stop(); startTrace.AppendFormatLine("init SettingsHost {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); InitSettingSubscribe(); stopwatch.Stop(); startTrace.AppendFormatLine("init SettingSubscribe {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); var level = DILevel.Min; if (IsMainProcess) { level = DILevel.MainProcess; } Startup.Init(level); stopwatch.Stop(); startTrace.AppendFormatLine("init Startup {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); if (IsMainProcess) { XEVersionTracking.Track(); stopwatch.Stop(); startTrace.AppendFormatLine("init VersionTracking {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); if (XEVersionTracking.IsFirstLaunchForCurrentVersion) { // 当前版本第一次启动时,清除存放升级包缓存文件夹的目录 IApplicationUpdateService.ClearAllPackCacheDir(); stopwatch.Stop(); startTrace.AppendFormatLine("init ClearAllPackCacheDir {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); } } UISettings.Language.Subscribe(x => R.ChangeLanguage(x)); stopwatch.Stop(); startTrace.AppendFormatLine("init Language.Subscribe {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); Startup.OnStartup(IsMainProcess); stopwatch.Stop(); startTrace.AppendFormatLine("init OnStartup {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); if (IsMainProcess) { var vmService = IViewModelManager.Instance; vmService.InitViewModels(); stopwatch.Stop(); startTrace.AppendFormatLine("init ViewModels {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); #if __XAMARIN_FORMS__ Forms.Init(this, null); FormsMaterial.Init(this, null); ImageCircleRenderer.Init(); stopwatch.Stop(); startTrace.AppendFormatLine("init XF {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); _Current = new(RealTheme); stopwatch.Stop(); startTrace.AppendFormatLine("init XFApp {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); #endif vmService.MainWindow.Initialize(); } stopwatch.Stop(); StartupTrack = startTrace.ToString(); #if DEBUG Log.Warn("Application", $"OnCreate Complete({stopwatch.ElapsedMilliseconds}ms"); #endif }