本文整理汇总了C#中Nini.Config.IniConfigSource.Save方法的典型用法代码示例。如果您正苦于以下问题:C# IniConfigSource.Save方法的具体用法?C# IniConfigSource.Save怎么用?C# IniConfigSource.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nini.Config.IniConfigSource
的用法示例。
在下文中一共展示了IniConfigSource.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: saveZigFile
private bool saveZigFile()
{
bool retVal = false;
try
{
IniConfigSource source = new IniConfigSource();
string appDataPath = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ZigGIS";
if (!System.IO.Directory.Exists(appDataPath))
{
System.IO.Directory.CreateDirectory(appDataPath);
}
IConfig config = source.AddConfig("connection");
config.Set("server", this.txtServer.Text);
config.Set("port", this.txtSchema.Text);
config.Set("database", this.txtDatabase.Text);
config.Set("user", this.txtUserName.Text);
config.Set("password", this.txtPassword.Text);
config = source.AddConfig("logging");
config.Set("configfile", this.txtLogFile.Text);
string zigFileName = this.txtServer.Text + "." + this.txtDatabase.Text + "." + this.txtUserName.Text + "." + System.Guid.NewGuid().ToString() + ".zig";
source.Save(appDataPath + "\\" + zigFileName);
return retVal;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
return false;
}
}
示例2: EmptyConstructor
public void EmptyConstructor()
{
string filePath = "EmptyConstructor.ini";
IniConfigSource source = new IniConfigSource ();
IConfig config = source.AddConfig ("Pets");
config.Set ("cat", "Muffy");
config.Set ("dog", "Rover");
config.Set ("bird", "Tweety");
source.Save (filePath);
Assert.AreEqual (3, config.GetKeys ().Length);
Assert.AreEqual ("Muffy", config.Get ("cat"));
Assert.AreEqual ("Rover", config.Get ("dog"));
Assert.AreEqual ("Tweety", config.Get ("bird"));
source = new IniConfigSource (filePath);
config = source.Configs["Pets"];
Assert.AreEqual (3, config.GetKeys ().Length);
Assert.AreEqual ("Muffy", config.Get ("cat"));
Assert.AreEqual ("Rover", config.Get ("dog"));
Assert.AreEqual ("Tweety", config.Get ("bird"));
File.Delete (filePath);
}
示例3: SetAndSave
public void SetAndSave ()
{
string filePath = "Test.ini";
StreamWriter writer = new StreamWriter (filePath);
writer.WriteLine ("; some comment");
writer.WriteLine ("[new section]");
writer.WriteLine (" dog = Rover");
writer.WriteLine (""); // empty line
writer.WriteLine ("; a comment");
writer.WriteLine (" cat = Muffy");
writer.Close ();
IniConfigSource source = new IniConfigSource (filePath);
IConfig config = source.Configs["new section"];
Assert.AreEqual ("Rover", config.Get ("dog"));
Assert.AreEqual ("Muffy", config.Get ("cat"));
config.Set ("dog", "Spots");
config.Set ("cat", "Misha");
config.Set ("DoesNotExist", "SomeValue");
Assert.AreEqual ("Spots", config.Get ("dog"));
Assert.AreEqual ("Misha", config.Get ("cat"));
Assert.AreEqual ("SomeValue", config.Get ("DoesNotExist"));
source.Save ();
source = new IniConfigSource (filePath);
config = source.Configs["new section"];
Assert.AreEqual ("Spots", config.Get ("dog"));
Assert.AreEqual ("Misha", config.Get ("cat"));
Assert.AreEqual ("SomeValue", config.Get ("DoesNotExist"));
File.Delete (filePath);
}
示例4: UpdateMooegeIni
internal static void UpdateMooegeIni(Repository repository)
{
var repoIniPath = new IniConfigSource(Paths.GetMooegeIniPath(repository));
//For each selection we set the correct MPQ storage path & PacketLog|ServerLog settings on the config INI, this is the best way I could think to have the paths updated at everytime
//We CANNOT call variable Compile.mooegeINI because that variable only saves latest compiled ini path for INSTANT writting after compiling a repository.
//WE do not need to write different IPS / PORTS for this since its LOCAL function, We do that over RepositorySelectionSERVER.
#region SetSettings
repoIniPath.Configs["Storage"].Set("MPQRoot", MadCow.MpqServer);
repoIniPath.Configs["ServerLog"].Set("Enabled", Mooege.FileLogging);
repoIniPath.Configs["PacketLog"].Set("Enabled", Mooege.PacketLogging);
repoIniPath.Configs["Storage"].Set("EnableTasks", Mooege.Tasks);
repoIniPath.Configs["Storage"].Set("LazyLoading", Mooege.LazyLoading);
repoIniPath.Configs["Authentication"].Set("DisablePasswordChecks", Mooege.PasswordCheck);
//We set the server variables:
//MooNet-Server IP
repoIniPath.Configs["MooNet-Server"].Set("BindIP", MadCow.CurrentProfile.MooNetServerIp);
//Game-Server IP
repoIniPath.Configs["Game-Server"].Set("BindIP", MadCow.CurrentProfile.GameServerIp);
//Public IP
repoIniPath.Configs["NAT"].Set("PublicIP", MadCow.CurrentProfile.NatIp);
//MooNet-Server Port
repoIniPath.Configs["MooNet-Server"].Set("Port", MadCow.CurrentProfile.MooNetServerPort);
//Game-Server Port
repoIniPath.Configs["Game-Server"].Set("Port", MadCow.CurrentProfile.GameServerPort);
//MOTD
repoIniPath.Configs["MooNet-Server"].Set("MOTD", MadCow.CurrentProfile.MooNetServerMotd);
//NAT
repoIniPath.Configs["NAT"].Set("Enabled", MadCow.CurrentProfile.NatEnabled);
repoIniPath.Save();
#endregion
Console.WriteLine("Current Profile: " + MadCow.CurrentProfile);
Console.WriteLine("Set Mooege config.ini according to your profile " + MadCow.CurrentProfile);
Console.WriteLine(repository + " is ready to go.");
}
示例5: InitialiseSomerBlinkConfigFileAtPath
/// <summary>
/// Initialises the somer blink configuration file at path.
/// </summary>
/// <param name="path">The path.</param>
public static void InitialiseSomerBlinkConfigFileAtPath(string path)
{
var source = new IniConfigSource();
source.AddConfig("Credentials");
source.Configs["Credentials"].Set("Username", "");
source.Configs["Credentials"].Set("Password", "");
source.AddConfig("Settings");
source.Configs["Settings"].Set("MinWaitTime", "2000");
source.Configs["Settings"].Set("MaxWaitTime", "60000");
source.Configs["Settings"].Set("MinBlinkBidIsk", "2500000");
source.Configs["Settings"].Set("MaxBlinkBidIsk", "10000000");
source.Configs["Settings"].Set("DownTime", "4");
source.Configs["Settings"].Set("RunTime", "4");
source.AddConfig("Extra");
source.Configs["Settings"].Set("DebugMode", "0");
source.Configs["Settings"].Set("proxyIp", "x.x.x.x");
source.Configs["Settings"].Set("proxyPort", "8080");
source.Configs["Settings"].Set("proxyUser", "");
source.Configs["Settings"].Set("proxyPass", "");
source.Configs["Settings"].Set("useProxy", "false");
source.Save(path);
SaveToDesktop(path);
Logger.LogMessage();
Logger.LogMessage("--------------------");
Logger.LogMessage("ConfigFile shortcut created on desktop");
}
示例6: AugmentConfigFile
/// <summary>
/// Augments the configuration file.
/// </summary>
/// <param name="path">The path.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">path</exception>
public static bool AugmentConfigFile(string path)
{
if (path.IsNullOrBlank())
{
throw new ArgumentNullException("path");
}
var changed = false;
var source = new IniConfigSource(path);
var configs = source.Configs["Settings"];
var proxyType = configs.Get("proxyType");
if (proxyType.IsNullOrBlank())
{
configs.Set("proxyType", 0);
changed = true;
}
source.Save(path);
return changed;
}
示例7: ReloadConfigFile
public static void ReloadConfigFile()
{
if(System.IO.File.Exists (FullConfigPath))
{
ConfigSource = new IniConfigSource (FullConfigPath);
ConfigSource.Reload ();
}
else
{
logger.Warn ("Конфигурационный фаил {0} не найден. Конфигурация не загружена.");
ConfigSource = new IniConfigSource ();
ConfigSource.Save (FullConfigPath);
}
}
示例8: btnRefresh_Click
private void btnRefresh_Click(object sender, EventArgs e)
{
// Write config file settings for [ToonItems]
IConfigSource source = new IniConfigSource("config.ini");
IConfig config = source.Configs["ToonItems"];
config.Set("Head", lblHead.Text);
config.Set("Chest", lblChest.Text);
config.Set("Feet", lblFeet.Text);
config.Set("Hands", lblHands.Text);
config.Set("Weapon1", lblWeapon1.Text);
config.Set("Weapon2", lblWeapon2.Text);
config.Set("Shoulders", lblShoulders.Text);
config.Set("Legs", lblLegs.Text);
source.Save();
var main = new Program(); // startup.
main.StartupServers();
}
示例9: btnSave_Click
private void btnSave_Click(object sender, EventArgs e)
{
#if (DEBUG)
IConfigSource source = new IniConfigSource("C:\\UDK\\Gladiator2_2012022322222222\\UDKGame\\Config\\UDKEngine.ini");
#else
IConfigSource source = new IniConfigSource(Application.StartupPath + "UDKGame\\Config\\UDKEngine.ini");
#endif
source.Configs["SystemSettings"].Set("ResX", cmbResolution.Text.Split('x').ElementAt(0));
source.Configs["SystemSettings"].Set("ResY", cmbResolution.Text.Split('x').ElementAt(1));
source.Configs["SystemSettings"].Set("Fullscreen", (chkEnableWindowedMode.Checked == true) ? "False" : "True");
source.Configs["SystemSettings"].Set("AmbientOcclusion", (chkEnableAmbientOcclusion.Checked == true) ? "True" : "False");
source.Save();
Properties.Settings.Default.Resolution = cmbResolution.Text.Trim();
Properties.Settings.Default.AmbientOcc = chkEnableAmbientOcclusion.Checked;
Properties.Settings.Default.EnableWindowedMode = !chkEnableWindowedMode.Checked;
Properties.Settings.Default.ServerLog = chkLog.Checked;
this.Close();
}
示例10: SaveChangesFile
private void SaveChangesFile(RegionInfo regionInfo)
{
string regionConfigPath = Path.Combine(Util.configDir(), "Regions");
try
{
IConfig config = m_config.Configs["RegionStartup"];
if (config != null)
{
regionConfigPath = config.GetString("RegionsDirectory", regionConfigPath).Trim();
}
}
catch (Exception)
{
// No INI setting recorded.
}
if (!Directory.Exists(regionConfigPath))
return;
string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
foreach (string file in iniFiles)
{
IConfigSource source = new IniConfigSource(file, Nini.Ini.IniFileType.AuroraStyle);
IConfig cnf = source.Configs[regionInfo.RegionName];
if (cnf != null)
{
cnf.Set("Location", regionInfo.RegionLocX + "," + regionInfo.RegionLocY);
cnf.Set("RegionType", regionInfo.RegionType);
cnf.Name = regionInfo.RegionName;
source.Save();
break;
}
}
}
示例11: SaveFigureTools
public static void SaveFigureTools()
{
IniConfigSource source = new IniConfigSource();
WorkBookUtils.WriteDapToConfig(dapPolyline, source.AddConfig(POLYLINE_SECT));
WorkBookUtils.WriteDapToConfig(dapRect, source.AddConfig(RECT_SECT));
WorkBookUtils.WriteDapToConfig(dapEllipse, source.AddConfig(ELLIPSE_SECT));
WorkBookUtils.WriteDapToConfig(dapTextBox, source.AddConfig(TEXTBOX_SECT));
WorkBookUtils.WriteDapToConfig(dapText, source.AddConfig(TEXT_SECT));
WorkBookUtils.WriteDapToConfig(dapClock, source.AddConfig(CLOCK_SECT));
WorkBookUtils.WriteDapToConfig(dapTriangle, source.AddConfig(TRIANGLE_SECT));
WorkBookUtils.WriteDapToConfig(dapRightAngleTriangle, source.AddConfig(RIGHTANGLETRIANGLE_SECT));
WorkBookUtils.WriteDapToConfig(dapDiamond, source.AddConfig(DIAMOND_SECT));
WorkBookUtils.WriteDapToConfig(dapPentagon, source.AddConfig(PENTAGON_SECT));
WorkBookUtils.WriteDapToConfig(dapLine, source.AddConfig(LINE_SECT));
source.Save(IniFile);
}
示例12: CreateNewFile
/// <summary>
/// Creates a new config file.
/// </summary>
private void CreateNewFile()
{
string type = null;;
if (IsArg ("set-type")) {
type = GetArg ("set-type").ToLower ();
} else {
ThrowError ("You must supply a type (--set-type)");
}
switch (type)
{
case "ini":
IniConfigSource iniSource = new IniConfigSource ();
iniSource.Save (configPath);
break;
case "xml":
XmlConfigSource xmlSource = new XmlConfigSource ();
xmlSource.Save (configPath);
break;
case "config":
DotNetConfigSource dotnetSource = new DotNetConfigSource ();
dotnetSource.Save (configPath);
break;
default:
ThrowError ("Unknown type");
break;
}
}
示例13: SaveRegionToFile
public void SaveRegionToFile(string description, string filename)
{
if (filename.ToLower().EndsWith(".ini"))
{
IniConfigSource source = new IniConfigSource();
try
{
source = new IniConfigSource(filename); // Load if it exists
}
catch (Exception)
{
}
WriteNiniConfig(source);
source.Save(filename);
return;
}
else if (filename.ToLower().EndsWith(".xml"))
{
configMember = new ConfigurationMember(filename, description, loadConfigurationOptionsFromMe,
ignoreIncomingConfiguration, false);
configMember.performConfigurationRetrieve();
RegionFile = filename;
}
else
throw new Exception("Invalid file type for region persistence.");
}
示例14: RegionInfo
public RegionInfo(string description, string filename, bool skipConsoleConfig, IConfigSource configSource, string configName)
{
// m_configSource = configSource;
if (filename.ToLower().EndsWith(".ini"))
{
if (!File.Exists(filename)) // New region config request
{
IniConfigSource newFile = new IniConfigSource();
ReadNiniConfig(newFile, configName);
newFile.Save(filename);
RegionFile = filename;
return;
}
IniConfigSource source = new IniConfigSource(filename);
bool saveFile = false;
if (source.Configs[configName] == null)
saveFile = true;
ReadNiniConfig(source, configName);
if (configName != String.Empty && saveFile)
source.Save(filename);
RegionFile = filename;
return;
}
try
{
// This will throw if it's not legal Nini XML format
// and thereby toss it to the legacy loader
//
IConfigSource xmlsource = new XmlConfigSource(filename);
ReadNiniConfig(xmlsource, configName);
RegionFile = filename;
return;
}
catch (Exception)
{
}
configMember =
new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig);
configMember.performConfigurationRetrieve();
RegionFile = filename;
}
示例15: button1_Click
private void button1_Click(object sender, EventArgs e)
{
if (File.Exists(Program.madcowINI))
{
try
{
IConfigSource source = new IniConfigSource(Program.madcowINI);
String Src = source.Configs["ShortCut"].Get("Shortcut");
if (Src.Contains("1"))
{
source.Configs["ShortCut"].Set("Shortcut", 0);
source.Save();
SrtCutStatusLabel.ResetText();
SrtCutStatusLabel.Text = "Disabled";
SrtCutStatusLabel.ForeColor = Color.DimGray;
}
else
{
source.Configs["ShortCut"].Set("Shortcut", 1);
source.Save();
SrtCutStatusLabel.ResetText();
SrtCutStatusLabel.Text = "Enabled";
SrtCutStatusLabel.ForeColor = Color.SeaGreen;
}
}
catch
{
Console.WriteLine("[Error] At ShortCut Disabler.");
}
}
}