当前位置: 首页>>代码示例>>C#>>正文


C# IConfigSource.AddConfig方法代码示例

本文整理汇总了C#中IConfigSource.AddConfig方法的典型用法代码示例。如果您正苦于以下问题:C# IConfigSource.AddConfig方法的具体用法?C# IConfigSource.AddConfig怎么用?C# IConfigSource.AddConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IConfigSource的用法示例。


在下文中一共展示了IConfigSource.AddConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Config

        //creates a config file in the specified base path
        public Config(string base_path)
        {
            if (!Directory.Exists (base_path))
                Directory.CreateDirectory (base_path);

            string path = System.IO.Path.Combine (base_path, "fuse_settings.ini");

            if (!File.Exists (path))
                File.WriteAllText (path, "");

            source =  new IniConfigSource (path);

            bool addWindow = true;
            bool addMediaControls = true;

            foreach (IConfig config in source.Configs)
            {
                if (config.Name == "Window")
                    addWindow = false;
                else if (config.Name == "Media Controls")
                    addMediaControls = false;
            }

            if (addWindow)
                source.AddConfig ("Window");
            if (addMediaControls)
                source.AddConfig ("Media Controls");
        }
开发者ID:gsterjov,项目名称:fusemc,代码行数:29,代码来源:Config.cs

示例2: AddScriptingConfig

        private void AddScriptingConfig(IConfigSource config, XEngine.XEngine xEngine, List<object> modules)
        {
            IConfig startupConfig = config.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = config.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            modules.Add(xEngine);
        }
开发者ID:RadaSangOn,项目名称:workCore2,代码行数:15,代码来源:XEnginePersistenceTests.cs

示例3: AddCommonConfig

        private void AddCommonConfig(IConfigSource config, List<object> modules)
        {
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");

            AttachmentsModule attMod = new AttachmentsModule();
            attMod.DebugLevel = 1;
            modules.Add(attMod);
            modules.Add(new BasicInventoryAccessModule());
        }
开发者ID:RadaSangOn,项目名称:workCore2,代码行数:10,代码来源:XEnginePersistenceTests.cs

示例4: Update

 /// <summary>
 /// update the node
 /// </summary>
 /// <param name="node">name of node</param>
 public void Update(string node)
 {
     source = new IniConfigSource(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"user.ini"));
     config = source.Configs[node];
     if (config == null)
     {
         source.AddConfig(node);
         config = source.Configs[node];
     }
     RemoveKeys();
 }
开发者ID:shentianyi,项目名称:MoldSmartDevice,代码行数:15,代码来源:ConfigUtil.cs

示例5: WriteNiniConfig

        private void WriteNiniConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
                source.Configs.Remove(config);

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY);
            config.Set("Location", location);

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (m_nonphysPrimMax != 0)
                config.Set("NonphysicalPrimMax", m_nonphysPrimMax);
            if (m_physPrimMax != 0)
                config.Set("PhysicalPrimMax", m_physPrimMax);
            config.Set("ClampPrimSize", m_clampPrimSize.ToString());

            if (m_objectCapacity != 0)
                config.Set("MaxPrims", m_objectCapacity);

            if (m_agentCapacity != 0)
                config.Set("MaxAgents", m_agentCapacity);

            if (ScopeID != UUID.Zero)
                config.Set("ScopeID", ScopeID.ToString());

            if (RegionType != String.Empty)
                config.Set("RegionType", RegionType);
        }
开发者ID:justasabc,项目名称:opensim,代码行数:39,代码来源:RegionInfo.cs

示例6: ReadNiniConfig

        private void ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                    name = MainConsole.Instance.CmdPrompt("New region name", name);
                if (name == String.Empty)
                    throw new Exception("Cannot interactively create region with no name");

                source.AddConfig(name);

//                creatingNew = true;
            }

            if (name == String.Empty)
                name = source.Configs[0].Name;

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);

//                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID = new UUID(regionUUID);
            originRegionID = RegionID; // What IS this?!

            RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }

            m_internalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }
//.........这里部分代码省略.........
开发者ID:justasabc,项目名称:opensim,代码行数:101,代码来源:RegionInfo.cs

示例7: ReadNiniConfig

        //Returns true if the source should be updated. Returns false if it does not.
        public bool ReadNiniConfig(RegionInfo region, IConfigSource source, string name)
        {
            //            bool creatingNew = false;

            if (name == String.Empty || source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");
            }

            bool NeedsUpdate = false;
            if (name == String.Empty)
                name = MainConsole.Instance.CmdPrompt("New region name", name);
            if (name == String.Empty)
                throw new Exception("Cannot interactively create region with no name");

            if (source.Configs.Count == 0)
            {
                source.AddConfig(name);

                //                creatingNew = true;
                NeedsUpdate = true;
            }

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
                NeedsUpdate = true;
                //                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                NeedsUpdate = true;
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID for region " + name, newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            region.RegionID = new UUID(regionUUID);

            region.RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                NeedsUpdate = true;
                location = MainConsole.Instance.CmdPrompt("Region Location for region " + name, "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] { ',' });

            region.RegionLocX = Convert.ToInt32(locationElements[0]) * Constants.RegionSize;
            region.RegionLocY = Convert.ToInt32(locationElements[1]) * Constants.RegionSize;

            int regionSizeX = config.GetInt("RegionSizeX", 0);
            if (regionSizeX == 0 || ((region.RegionSizeX % Constants.MinRegionSize) != 0))
            {
                NeedsUpdate = true;
                while (true)
                {
                    if (int.TryParse(MainConsole.Instance.CmdPrompt("Region X Size for region " + name, "256"), out regionSizeX))
                        break;
                }
                config.Set("RegionSizeX", regionSizeX);
            }
            region.RegionSizeX = Convert.ToInt32(regionSizeX);

            int regionSizeY = config.GetInt("RegionSizeY", 0);
            if (regionSizeY == 0 || ((region.RegionSizeY % Constants.MinRegionSize) != 0))
            {
                NeedsUpdate = true;
                while(true)
                {
                    if(int.TryParse(MainConsole.Instance.CmdPrompt("Region Y Size for region " + name, "256"), out regionSizeY))
                        break;
                }
                config.Set("RegionSizeY", regionSizeY);
            }
            region.RegionSizeY = regionSizeY;

            int regionSizeZ = config.GetInt("RegionSizeZ", 1024);
            //if (regionSizeZ == String.Empty)
            //{
            //    NeedsUpdate = true;
            //    regionSizeZ = MainConsole.Instance.CmdPrompt("Region Z Size for region " + name, "1024");
            //    config.Set("RegionSizeZ", regionSizeZ);
            //}
//.........这里部分代码省略.........
开发者ID:mugginsm,项目名称:Aurora-Sim,代码行数:101,代码来源:RegionLoaderFileBasePlugin.cs

示例8: ReadNiniConfig

        private void ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                {
                    while (name.Trim() == string.Empty)
                    {
                        name = MainConsole.Instance.CmdPrompt("New region name", name);
                        if (name.Trim() == string.Empty)
                        {
                            MainConsole.Instance.Output("Cannot interactively create region with no name");
                        }
                    }
                }

                source.AddConfig(name);

//                creatingNew = true;
            }

            if (name == String.Empty)
                name = source.Configs[0].Name;

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
            }

            RegionName = name;
            IConfig config = source.Configs[name];

            // Track all of the keys in this config and remove as they are processed
            // The remaining keys will be added to generic key-value storage for
            // whoever might need it
            HashSet<String> allKeys = new HashSet<String>();
            foreach (string s in config.GetKeys())
            {
                allKeys.Add(s);
            }

            // RegionUUID
            //
            allKeys.Remove("RegionUUID");
            string regionUUID = config.GetString("RegionUUID", string.Empty);
            if (!UUID.TryParse(regionUUID.Trim(), out RegionID))
            {
                UUID newID = UUID.Random();
                while (RegionID == UUID.Zero)
                {
                    regionUUID = MainConsole.Instance.CmdPrompt("RegionUUID", newID.ToString());
                    if (!UUID.TryParse(regionUUID.Trim(), out RegionID))
                    {
                        MainConsole.Instance.Output("RegionUUID must be a valid UUID");
                    }
                }
                config.Set("RegionUUID", regionUUID);
            }

            originRegionID = RegionID; // What IS this?! (Needed for RegionCombinerModule?)

            // Location
            //
            allKeys.Remove("Location");
            string location = config.GetString("Location", String.Empty);
            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            RegionLocX = Convert.ToUInt32(locationElements[0]);
            RegionLocY = Convert.ToUInt32(locationElements[1]);

            // Region size
            // Default to legacy region size if not specified.
            allKeys.Remove("SizeX");
            string configSizeX = config.GetString("SizeX", Constants.RegionSize.ToString());
            config.Set("SizeX", configSizeX);
            RegionSizeX = Convert.ToUInt32(configSizeX);
            allKeys.Remove("SizeY");
            string configSizeY = config.GetString("SizeY", Constants.RegionSize.ToString());
            config.Set("SizeY", configSizeX);
            RegionSizeY = Convert.ToUInt32(configSizeY);
            allKeys.Remove("SizeZ");
            string configSizeZ = config.GetString("SizeZ", Constants.RegionHeight.ToString());
            config.Set("SizeZ", configSizeX);
            RegionSizeZ = Convert.ToUInt32(configSizeZ);

            DoRegionSizeSanityChecks();
//.........这里部分代码省略.........
开发者ID:SignpostMarv,项目名称:opensim,代码行数:101,代码来源:RegionInfo.cs

示例9: FormMain

		public FormMain()
		{
			// Set the resize event handler.
			resizeEventHandler = new EventHandler(FormMain_Resize);
			Resize += resizeEventHandler;

			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			// Get the window handle.
			Capture = true;
			hwnd = OpenNETCF.Win32.Win32Window.GetCapture();
			Capture = false;

			// Add a message filter.
			ApplicationEx.AddMessageFilter(this);

			// Load the configuration.
			executablePath = ApplicationEx.StartupPath;
			extensionPath = Path.Combine(executablePath, "Extensions");
			string iniFileName = Path.Combine(executablePath, "GPSProxy.ini");
			if (! File.Exists(iniFileName))
			{
				try
				{
					File.Copy(Path.Combine(executablePath, "GPSProxy.ini.default"), iniFileName, false);
				}
				catch
				{
				}
			}
			if (! File.Exists(iniFileName))
				using (File.Create(iniFileName))
				{
				}
			configSource = new IniConfigSource(iniFileName);
			configSource.Alias.AddAlias("On", true);
			configSource.Alias.AddAlias("Off", false);
			configSource.Alias.AddAlias("True", true);
			configSource.Alias.AddAlias("False", false);
			if (configSource.Configs["Settings"] == null)
				configSource.AddConfig("Settings");

			configSettings = configSource.Configs["Settings"];
			settings["autoStart"].Value = configSettings.GetBoolean("Start Proxy Automatically on Launch", (bool)settings["autoStart"].Value);
			settings["runExternalApp"].Value = configSettings.GetBoolean("Run External App after Proxy Startup", (bool)settings["runExternalApp"].Value);
			settings["externalApp"].Value = configSettings.GetString("External Application", (string)settings["externalApp"].Value);
			settings["autoReconnect"].Value = configSettings.GetBoolean("Reconnect after Power-on", (bool)settings["autoReconnect"].Value);
			settings["reconnectDelay"].Value = configSettings.GetInt("Power-on Reconnect Delay", (int)settings["reconnectDelay"].Value);

			// Create the main and page menu panels.
			mainMenuPanel = new ScrollablePanel();
			mainMenuPanel.Visible = false;
			Controls.Add(mainMenuPanel);
			mainMenuPanel.Size = pluginPanel.ClientSize;
			mainMenuPanel.BringToFront();

			pageMenuPanel = new ScrollablePanel();
			pageMenuPanel.Visible = false;
			Controls.Add(pageMenuPanel);
			pageMenuPanel.Size = pluginPanel.ClientSize;
			pageMenuPanel.BringToFront();

			// Add the main menu buttons.
			AboutButton = AddMenuButton(mainMenuPanel, "About...",
				new EventHandler(AboutButton_Click));
			SettingsButton = AddMenuButton(mainMenuPanel, "Settings...",
				new EventHandler(SettingsButton_Click), true);
			ExtensionsButton = AddMenuButton(mainMenuPanel, "Extensions...",
				new EventHandler(ExtensionsButton_Click));
			VirtualComPortsButton = AddMenuButton(mainMenuPanel, "Virtual COM Ports...",
				new EventHandler(VirtualComPortsButton_Click));
			ExitButton = AddMenuButton(mainMenuPanel, "Exit",
				new EventHandler(ExitButton_Click), true);

			// Load the extension DLLs.
			LoadExtensions();

			// Activate extensions according to the configuration file.
			ActivateExtensions();

			// NOTE: do not attempt to show an message boxes before this point, as this triggers
			// other form events that expect the activeExtensions array to have been created.

			// Load the virtual COM port drivers.
			virtualComPortRootKey = Registry.LocalMachine.CreateSubKey(@"Drivers\GPSProxyVirtualCOMPorts");
			if (virtualComPortRootKey == null)
			{
				MessageBox.Show(@"Unable to open/create registry key: " + virtualComPortRootKey.Name,
					"Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
			}
			else
			{
				LoadVirtualComPortDrivers();
			}

			// Create and populate the extensions dialog.
			extensionsDialog = new FormExtensions();
//.........这里部分代码省略.........
开发者ID:JeffreyZksun,项目名称:gpstranslator,代码行数:101,代码来源:FormMain.cs

示例10: ReadNiniConfig

        //Returns true if the source should be updated. Returns false if it does not.
        private bool ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (name == String.Empty || source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");
            }

            bool NeedsUpdate = false;
            if (name == String.Empty)
                name = MainConsole.Instance.CmdPrompt("New region name", name);
            if (name == String.Empty)
                throw new Exception("Cannot interactively create region with no name");

            if (source.Configs.Count == 0)
            {
                source.AddConfig(name);

//                creatingNew = true;
                NeedsUpdate = true;
            }

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
                NeedsUpdate = true;
//                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                NeedsUpdate = true;
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID = new UUID(regionUUID);
            
            RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                NeedsUpdate = true;
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                NeedsUpdate = true;
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                NeedsUpdate = true;
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }

            m_internalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
//.........这里部分代码省略.........
开发者ID:shangcheng,项目名称:Aurora,代码行数:101,代码来源:RegionInfo.cs

示例11: WriteNiniConfig

        private void WriteNiniConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
                source.Configs.Remove(RegionName);

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY);
            config.Set("Location", location);

            if (DataStore != String.Empty)
                config.Set("Datastore", DataStore);

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (MasterAvatarAssignedUUID != UUID.Zero)
            {
                config.Set("MasterAvatarUUID", MasterAvatarAssignedUUID.ToString());
            }
            else if (MasterAvatarFirstName != String.Empty && MasterAvatarLastName != String.Empty)
            {
                config.Set("MasterAvatarFirstName", MasterAvatarFirstName);
                config.Set("MasterAvatarLastName", MasterAvatarLastName);
            }
            if (MasterAvatarSandboxPassword != String.Empty)
            {
                config.Set("MasterAvatarSandboxPassword", MasterAvatarSandboxPassword);
            }

            if (m_nonphysPrimMax != 0)
                config.Set("NonphysicalPrimMax", m_nonphysPrimMax);
            if (m_physPrimMax != 0)
                config.Set("PhysicalPrimMax", m_physPrimMax);
            config.Set("ClampPrimSize", m_clampPrimSize.ToString());

            if (m_objectCapacity != 0)
                config.Set("MaxPrims", m_objectCapacity);

            if (ScopeID != UUID.Zero)
                config.Set("ScopeID", ScopeID.ToString());

            if (RegionType != String.Empty)
                config.Set("RegionType", RegionType);
        }
开发者ID:dirkhusemann,项目名称:opensim,代码行数:53,代码来源:RegionInfo.cs

示例12: ReadNiniConfig

        private void ReadNiniConfig(IConfigSource source, string name)
        {
            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                    name = MainConsole.Instance.CmdPrompt("New region name", name);
                if (name == String.Empty)
                    throw new Exception("Cannot interactively create region with no name");

                source.AddConfig(name);

                creatingNew = true;
            }

            if (name == String.Empty)
                name = source.Configs[0].Name;

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);

                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID = new UUID(regionUUID);
            originRegionID = RegionID; // What IS this?!

            
            // Region name
            //
            RegionName = name;

            
            // Region location
            //
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);


            // Datastore (is this implemented? Omitted from example!)
            //
            DataStore = config.GetString("Datastore", String.Empty);


            // Internal IP
            //
            IPAddress address;
            
            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
//.........这里部分代码省略.........
开发者ID:dirkhusemann,项目名称:opensim,代码行数:101,代码来源:RegionInfo.cs

示例13: CreateIConfig

        public void CreateIConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
                source.Configs.Remove(config);

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX / 256, m_regionLocY / 256);
            config.Set("Location", location);

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (m_objectCapacity != 0)
                config.Set("MaxPrims", m_objectCapacity);

            if (ScopeID != UUID.Zero)
                config.Set("ScopeID", ScopeID.ToString());

            if (RegionType != String.Empty)
                config.Set("RegionType", RegionType);

            config.Set("AllowPhysicalPrims", AllowPhysicalPrims);
            config.Set("AllowScriptCrossing", AllowScriptCrossing);
            config.Set("TrustBinariesFromForeignSims", TrustBinariesFromForeignSims);
            config.Set("SeeIntoThisSimFromNeighbor", SeeIntoThisSimFromNeighbor);
            config.Set("RegionSizeX", RegionSizeX);
            config.Set ("RegionSizeY", RegionSizeY);
            config.Set ("RegionSizeZ", RegionSizeZ);

            config.Set ("StartupType", Startup.ToString());

            config.Set("NeighborPassword", Password.ToString());
        }
开发者ID:RevolutionSmythe,项目名称:Aurora-Sim,代码行数:42,代码来源:RegionInfo.cs

示例14: AddScriptingConfig

        private void AddScriptingConfig(IConfigSource config, List<object> modules)
        {
            IConfig startupConfig = config.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = config.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            modules.Add(new XEngine());

            // Necessary to stop serialization complaining
            // FIXME: Stop this being necessary if at all possible
//            modules.Add(new WorldCommModule());
        }
开发者ID:Belxjander,项目名称:Asuna,代码行数:19,代码来源:AttachmentsModuleTests.cs

示例15: frmMain

        public frmMain()
        {
            #if (DEBUG_1||DEBUG_2||DEBUG_3)
            debugLogger = new DebugLogger("frmMain.log");
            #endif
            debugLogger.WriteDebug_3("Begin Method: frmMain.frmMain()");

            InitializeComponent();

            Directory.SetCurrentDirectory(Directory.GetParent(Application.ExecutablePath).FullName);
            debugLogger.WriteDebug_2("Set Current Directory to " + Directory.GetParent(Application.ExecutablePath).FullName);

            // TODO: Determine why this is a double nested try/catch to load some INI settings
            try
            {
                inifile = new IniConfigSource(Directory.GetCurrentDirectory() + "\\settings.ini");
                DBString = inifile.Configs["Files"].GetString("dbfile","");
                LogFile = inifile.Configs["Files"].GetString("logfile","");
                OutputDirectory = inifile.Configs["Files"].GetString("outdir","");
                DKPTax = inifile.Configs["Other"].GetDouble("tax",0.0);
                MinDKP = inifile.Configs["Other"].GetDouble("mindkp", 0);
                TierAPct = inifile.Configs["Other"].GetDouble("tierapct", 0.6);
                TierBPct = inifile.Configs["Other"].GetDouble("tierbpct", 0.3);
                TierCPct = inifile.Configs["Other"].GetDouble("tiercpct", 0.0);
                GuildNames = inifile.Configs["Other"].GetString("GuildNames", "Eternal Sovereign");
                debugLogger.WriteDebug_1("Read settings from INI: DBFile=" + DBString + ", LogFile=" + LogFile + ", OutputDirectory="
                    + OutputDirectory + ", DKPTax=" + DKPTax + ", GuildNames=" + GuildNames);

                StatusMessage ="Read settings from INI...";
                try
                {
                    parser = new LogParser(this,LogFile);
                    debugLogger.WriteDebug_3("Created log parser");
                }
                catch (Exception ex) {
                    debugLogger.WriteDebug_1("Failed to create log parser: " + ex.Message);
                }
            }
            catch (FileNotFoundException ex)
            {
                debugLogger.WriteDebug_3("settings.ini not found, creating");

                FileStream a = File.Create(Directory.GetCurrentDirectory() + "\\settings.ini");
                a.Close();
                sbpMessage.Text = "settings.ini not found... Loading defaults";
                try
                {
                    inifile = new IniConfigSource(Directory.GetCurrentDirectory() + "\\settings.ini");
                    inifile.AddConfig("Files");
                    inifile.AddConfig("Other");
                    LogFile = inifile.Configs["Files"].GetString("logfile","");
                    DBString = inifile.Configs["Files"].GetString("dbfile","");
                    OutputDirectory = inifile.Configs["Files"].GetString("outdir","");
                    DKPTax = inifile.Configs["Other"].GetDouble("tax",0.0);
                    MinDKP = inifile.Configs["Other"].GetDouble("mindkp", 0);
                    TierAPct = inifile.Configs["Other"].GetDouble("tierapct", 0.6);
                    TierBPct = inifile.Configs["Other"].GetDouble("tierbpct", 0.3);
                    TierCPct = inifile.Configs["Other"].GetDouble("tiercpct", 0.0);
                    GuildNames = inifile.Configs["Other"].GetString("GuildNames", "Eternal Sovereign");
                    inifile.Save();
                    debugLogger.WriteDebug_1("Read settings from INI: dbFile=" + DBString + ", logFile=" + LogFile
                        + ", outDir=" + OutputDirectory + ", tax=" + DKPTax + ", mindkp=" + MinDKP + ", GuildNames=" + GuildNames);
                }
                catch (Exception exc)
                {
                    debugLogger.WriteDebug_1("Failed to create new settings.ini: " + exc.Message);
                    MessageBox.Show("Error opening settings.ini","Error");
                    Environment.Exit(1);
                }
            }
            catch (Exception ex)
            {
                debugLogger.WriteDebug_1("Failed to load settings.ini: " + ex.Message);
                MessageBox.Show("Error opening settings.ini","Error");
                Environment.Exit(1);
            }
            UITimer = new Timer();
            UITimer.Interval = 100;
            UITimer.Tick += new EventHandler(UITimer_Tick);
            UITimer.Start();

            debugLogger.WriteDebug_3("End Method: frmMain.frmMain()");
        }
开发者ID:esdkp,项目名称:esdkp,代码行数:83,代码来源:MainClass.cs


注:本文中的IConfigSource.AddConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。