Beispiel #1
0
 public static void Shutdown()
 {
     ArchiveManager.a();
     ComponentManager.Unload();
     Initialized = false;
 }
Beispiel #2
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="logFileName">日志文件</param>
        /// <param name="correctCurrentDirectory">!</param>
        /// <param name="specialExecutableDirectoryPath">程序目录</param>
        /// <param name="specialResourceDirectoryPath">资源目录</param>
        /// <param name="specialUserDirectoryPath">用户目录</param>
        /// <param name="specialNativeLibrariesDirectoryPath">DLL目录</param>
        /// <returns></returns>
        public static bool Init(string logFileName, bool correctCurrentDirectory, string specialExecutableDirectoryPath, string specialResourceDirectoryPath, string specialUserDirectoryPath, string specialNativeLibrariesDirectoryPath)
        {
            logFileName = NormalizePath(logFileName);
            specialExecutableDirectoryPath      = NormalizePath(specialExecutableDirectoryPath);
            specialResourceDirectoryPath        = NormalizePath(specialResourceDirectoryPath);
            specialUserDirectoryPath            = NormalizePath(specialUserDirectoryPath);
            specialNativeLibrariesDirectoryPath = NormalizePath(specialNativeLibrariesDirectoryPath);

            NativeLibraryManager.specialNativeLibrariesDirectoryPath = specialNativeLibrariesDirectoryPath;
            if (Initialized)
            {
                Log.Fatal("VirtualFileSystem: Init: File system already initialized.");
                return(false);
            }

            if (!string.IsNullOrEmpty(specialExecutableDirectoryPath) && !Path.IsPathRooted(specialExecutableDirectoryPath))
            {
                Log.Fatal("VirtualFileSystem: Init: Special executable directory path must be rooted.");
                return(false);
            }

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            executableDirectoryPath             = specialExecutableDirectoryPath;
            if (string.IsNullOrEmpty(executableDirectoryPath))
            {
                executableDirectoryPath = PlatformNative.Get().GetExecutableDirectoryPath();
            }
            resourceDirectoryPath = specialResourceDirectoryPath;

            if (string.IsNullOrEmpty(resourceDirectoryPath))
            {
                resourceDirectoryPath = Path.Combine(executableDirectoryPath, "Data");
            }

            if (!string.IsNullOrEmpty(specialUserDirectoryPath))
            {
                userDirectoryPath = specialUserDirectoryPath;
            }
            bool flag = Type.GetType("Mono.Runtime", false) != null;

            if (flag)
            {
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolveAssembly);
            }
            if (PlatformInfo.Platform == PlatformInfo.PlanformType.MacOSX)
            {
                NativeLibraryManager.PreLoadLibrary("MacAppNativeWrapper");
            }
            if (correctCurrentDirectory)
            {
                _CorrectCurrentDirectory();
            }

            ComponentManager.Init();
            if (!ArchiveManager.A())
            {
                Shutdown();
                return(false);
            }
            Initialized = true;
            InitDeployment();
            string dumpRealFileName = null;

            if (!string.IsNullOrEmpty(logFileName))
            {
                dumpRealFileName = GetRealPathByVirtual(logFileName);
            }
            Log._Init(Thread.CurrentThread, dumpRealFileName);
            InitCachingExtensions();
            return(true);
        }