Exemplo n.º 1
0
        /// <summary>
        /// Adds the included files as ini configuration files
        /// </summary>
        /// <param name="sources">List of URL strings or filename strings</param>
        /// <param name="cntr">Where should we start inserting sources into the list?</param>
        private void AddIncludes(List <string> sources, ref int cntr)
        {
            int cn = cntr;

            //Where should we insert the sources into the list?
            //loop over config sources
            foreach (IConfig config in m_config.Configs)
            {
                // Look for Include-* in the key name
                string[] keys = config.GetKeys();
                foreach (string k in keys)
                {
                    if (k.StartsWith("Include-"))
                    {
                        // read the config file to be included.
                        string file = config.GetString(k);
                        if (IsUri(file))
                        {
                            if (!sources.Contains(file))
                            {
                                cn++;
                                sources.Insert(cn, file);
                            }
                        }
                        else
                        {
                            string basepath = Path.GetFullPath(Util.configDir());
                            // Resolve relative paths with wildcards
                            string chunkWithoutWildcards = file;
                            string chunkWithWildcards    = string.Empty;
                            int    wildcardIndex         = file.IndexOfAny(new char[] { '*', '?' });
                            if (wildcardIndex != -1)
                            {
                                chunkWithoutWildcards = file.Substring(0, wildcardIndex);
                                chunkWithWildcards    = file.Substring(wildcardIndex);
                            }
                            string path = Path.Combine(basepath, chunkWithoutWildcards);
                            path = Path.GetFullPath(path) + chunkWithWildcards;
                            string[] paths = Util.Glob(path);
                            foreach (string p in paths)
                            {
                                if (!sources.Contains(p))
                                {
                                    cn++;
                                    sources.Insert(cn, p);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public RegionSettings()
 {
     if (configMember == null)
     {
         try
         {
             configMember = new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS", LoadConfigurationOptions, HandleIncomingConfiguration, true);
             configMember.performConfigurationRetrieve();
         }
         catch (Exception)
         {
         }
     }
 }
Exemplo n.º 3
0
        public EstateSettings()
        {
            if (configMember == null)
            {
                try
                {
                    // Load legacy defaults
                    //
                    configMember =
                        new ConfigurationMember(Path.Combine(Util.configDir(),
                                                             "estate_settings.xml"), "ESTATE SETTINGS",
                                                loadConfigurationOptions,
                                                handleIncomingConfiguration, true);

                    l_EstateManagers.Clear();
                    configMember.performConfigurationRetrieve();
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the region configuration
        /// </summary>
        /// <param name="argvSource">Parameters passed into the process when started</param>
        /// <returns>A configuration that gets passed to modules</returns>
        public IConfigSource LoadConfigSettings(IConfigSource argvSource)
        {
            iniFilePath = "";
            bool iniFileExists = false;

            IConfig startupConfig = argvSource.Configs["Startup"];

            List <string> sources = new List <string>();

            inidbg =
                startupConfig.GetBoolean("inidbg", inidbg);

            showIniLoading =
                startupConfig.GetBoolean("inishowfileloading", showIniLoading);

            string masterFileName =
                startupConfig.GetString("inimaster", String.Empty);

            string iniGridName =
                startupConfig.GetString("inigrid", String.Empty);

            if (iniGridName == string.Empty) //Read the old name then
            {
                iniGridName =
                    startupConfig.GetString("inifile", String.Empty);
            }

            string iniSimName =
                startupConfig.GetString("inisim", defaultIniFile);

            //Be mindful of these when modifying...
            //1) When file A includes file B, if the same directive is found in both, that the value in file B wins.
            //2) That inifile may be used with or without inimaster being used.
            //3) That any values for directives pulled in via inifile (Config Set 2) override directives of the same name found in the directive set (Config Set 1) created by reading in bin/Aurora.ini and its subsequently included files or that created by reading in whatever file inimaster points to and its subsequently included files.

            if (IsUri(masterFileName))
            {
                if (!sources.Contains(masterFileName))
                {
                    sources.Add(masterFileName);
                }
            }
            else
            {
                string masterFilePath = Path.GetFullPath(
                    Path.Combine(Util.configDir(), masterFileName));

                if (masterFileName != String.Empty &&
                    File.Exists(masterFilePath) &&
                    (!sources.Contains(masterFilePath)))
                {
                    sources.Add(masterFilePath);
                }
                if (iniGridName == "") //Then it doesn't exist and we need to set this
                {
                    iniFilePath = masterFilePath;
                }
                if (iniSimName == "") //Then it doesn't exist and we need to set this
                {
                    iniFilePath = masterFilePath;
                }
            }

            if (iniGridName != "")
            {
                if (IsUri(iniGridName))
                {
                    if (!sources.Contains(iniGridName))
                    {
                        sources.Add(iniGridName);
                    }
                    iniFilePath = iniGridName;
                }
                else
                {
                    iniFilePath = Path.GetFullPath(
                        Path.Combine(Util.configDir(), iniGridName));

                    if (File.Exists(iniFilePath))
                    {
                        if (!sources.Contains(iniFilePath))
                        {
                            sources.Add(iniFilePath);
                        }
                    }
                }
            }

            if (iniSimName != "")
            {
                if (IsUri(iniSimName))
                {
                    if (!sources.Contains(iniSimName))
                    {
                        sources.Add(iniSimName);
                    }
                    iniFilePath = iniSimName;
                }
                else
                {
                    iniFilePath = Path.GetFullPath(
                        Path.Combine(Util.configDir(), iniSimName));

                    if (File.Exists(iniFilePath))
                    {
                        if (!sources.Contains(iniFilePath))
                        {
                            sources.Add(iniFilePath);
                        }
                    }
                }
            }

            string iniDirName =
                startupConfig.GetString("inidirectory", "");
            string iniDirPath =
                Path.Combine(Util.configDir(), iniDirName);

            if (Directory.Exists(iniDirPath) && iniDirName != "")
            {
                m_log.InfoFormat("Searching folder {0} for config ini files",
                                 iniDirPath);

                string[] fileEntries = Directory.GetFiles(iniDirName);
                foreach (string filePath in fileEntries)
                {
                    if (Path.GetExtension(filePath).ToLower() == ".ini")
                    {
                        if (!sources.Contains(Path.GetFullPath(filePath)))
                        {
                            sources.Add(Path.GetFullPath(filePath));
                        }
                    }
                }
            }


            m_config = new IniConfigSource();

            m_log.Info("[Config]: Reading configuration settings");

            if (sources.Count == 0)
            {
                m_log.FatalFormat("[CONFIG]: Could not load any configuration");
                m_log.FatalFormat("[CONFIG]: Did you copy the " + defaultIniFile + ".example file to " + defaultIniFile + "?");
                throw new NotSupportedException();
            }

            for (int i = 0; i < sources.Count; i++)
            {
                if (ReadConfig(sources[i], i))
                {
                    iniFileExists = true;
                }
                AddIncludes(sources, ref i);
            }

            if (!iniFileExists)
            {
                m_log.FatalFormat("[CONFIG]: Could not load any configuration");
                m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!");
                throw new NotSupportedException();
            }
            // Make sure command line options take precedence
            m_config.Merge(argvSource);

            return(m_config);
        }