ALFA.SystemInfo.GetModuleResourceName C# (CSharp) Метод

GetModuleResourceName() публичный статический Метод

This routine gets the resource name of the module that was passed on the server command line. Note that if the server did not have a module argument then null is returned.
public static GetModuleResourceName ( ) : string
Результат string
        public static string GetModuleResourceName()
        {
            string[] Args = Environment.GetCommandLineArgs();

            for (int i = 0; i < Args.Length; i += 1)
            {
                if (((Args[i] == "-module") || (Args[i] == "-moduledir")) && i + 1 < Args.Length)
                    return Args[i + 1];
            }

            return null;
        }

Usage Example

Пример #1
0
        /// <summary>
        /// This method performs demand loading of resource repositories.
        /// </summary>
        /// <param name="ModuleOnly">If true, only load the module core
        /// resources.</param>
        private void LoadResourceRepositories(bool ModuleOnly)
        {
            string HomeDirectory    = SystemInfo.GetHomeDirectory();
            string InstallDirectory = SystemInfo.GetGameInstallationDirectory();
            string ModPath;
            string DataPath;

            //
            // Create a dummy resource manager to keep OEIShared happy.  We do
            // not use it explicitly, but some OEIShared code uses
            // ResourceManager.Instance and hopes to get something back.
            //

            if (OEIShared.IO.ResourceManager.Instance == null)
            {
                new DummyOEIResourceManager();
            }

            if (ModuleResourceName == null)
            {
                ModuleResourceName = SystemInfo.GetModuleResourceName();
            }

            if (ModuleResourceName == null)
            {
                throw new ApplicationException("Cannot determine module resource name.");
            }

            Repositories = new List <ResourceRepository>();

            ModPath = String.Format("{0}\\modules\\{1}.mod", HomeDirectory, ModuleResourceName);

            if (File.Exists(ModPath))
            {
                Repositories.Add(new ALFAERFResourceRepository(ModPath));
            }
            else
            {
                ModPath = String.Format("{0}\\modules\\{1}\\", HomeDirectory, ModuleResourceName);

                Repositories.Add(new DirectoryResourceRepository(ModPath));
            }

            if (!ModuleOnly)
            {
                GFFFile ModuleIfo = OpenModuleIfo();

                AddModuleHaks(ModuleIfo, HomeDirectory, InstallDirectory);
                AddModuleCampaign(ModuleIfo, HomeDirectory, InstallDirectory);

                foreach (string PathName in new string[] { HomeDirectory, InstallDirectory })
                {
                    string overrideFolder = String.Format("{0}\\override", PathName);
                    if (Directory.Exists(overrideFolder))
                    {
                        Repositories.Add(new DirectoryResourceRepository(overrideFolder));
                    }
                }

                DataPath = String.Format("{0}\\Data", InstallDirectory);

                foreach (string ZipPath in Directory.EnumerateFiles(DataPath, "*.zip"))
                {
                    Repositories.Add(new ZIPResourceRepository(ZipPath));
                }
            }

            //
            // Finally, populate all of the repositories, which may take time.
            //

            foreach (ResourceRepository Repository in Repositories)
            {
                Repository.PopulateRepository();
            }
        }