本文整理汇总了C#中Configuration.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.Save方法的具体用法?C# Configuration.Save怎么用?C# Configuration.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration.Save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var configMap = new ExeConfigurationFileMap();
configMap.ExeConfigFilename = Application.ExecutablePath + ".config";
configMap.RoamingUserConfigFilename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"LibSnesDotNet",
"LibSnesDotNet.config");
Configuration config = new Configuration(configMap);
Application.EnableVisualStyles();
Application.ThreadException += (s, e) =>
{
MessageBox.Show(e.Exception.ToString(), "Unhandled Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(-1);
};
Application.Run(new MainForm(config));
config.Save();
}
示例2: LoadChatConfiguration
public static void LoadChatConfiguration(ChatMessage msg, string chatMessage)
{
string fileName = "";
try
{
var chatTopic = msg.Chat.Topic;
if (!string.IsNullOrWhiteSpace(chatTopic))
{
fileName = System.IO.Path.GetInvalidFileNameChars().Aggregate(chatTopic, (current, c) => current.Replace(c, '_'));
Config = Configuration.LoadConfig("Configs\\" + fileName + ".config");
if (Config.ChatName.Length != 0) return;
Config.ChatName = chatTopic;
Config.Save();
return;
}
}
catch (Exception)
{
}
var chatName = msg.Chat.FriendlyName;
if (string.IsNullOrWhiteSpace(chatName))
return;
fileName = System.IO.Path.GetInvalidFileNameChars().Aggregate(chatName, (current, c) => current.Replace(c, '_'));
Config = Configuration.LoadConfig("Configs\\" + fileName + ".config");
if (Config.ChatName.Length != 0) return;
Config.ChatName = chatName;
Config.Save();
}
示例3: ToString
public override sealed string ToString()
{
Configuration config = new Configuration();
foreach (FlowItem item in _items.Values)
{
config.Items.Add(item.Config);
}
using (MemoryStream stream = new MemoryStream())
{
config.Save(stream);
stream.Seek(0, SeekOrigin.Begin);
using (StreamReader sr = new StreamReader(stream))
{
return sr.ReadToEnd();
}
}
}
示例4: SaveWebConfigHandler
public static void SaveWebConfigHandler(Configuration config)
{
config.Save(ConfigurationSaveMode.Minimal);
}
示例5: SaveConfiguration
/// <summary>
/// Saves the configuration.
/// </summary>
/// <param name="solution">The solution to save the configuration for.</param>
/// <param name="configuration">The configuration to save.</param>
/// <exception cref="ArgumentNullException">The <paramref name="solution" /> is <c>null</c>.</exception>
/// <exception cref="ArgumentNullException">The <paramref name="configuration" /> is <c>null</c>.</exception>
public static void SaveConfiguration(this Solution solution, Configuration configuration)
{
Argument.IsNotNull("solution", solution);
Argument.IsNotNull("configuration", configuration);
string configurationFileName = solution.GetConfigurationFileName();
configuration.Save(configurationFileName, SerializationMode.Xml);
}
示例6: Main
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
foreach(string arg in args)
{
if (arg == "-r")
{
int timeout = 0;
while (LauncherHelper.checkInstance())
{
if (timeout == 3)
{
if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
{
return;
}
}
Thread.Sleep(500);
timeout++;
}
}
}
Config = new Configuration();
Config.Load(Program.ConfigurationFilename);
if (File.Exists("ygopro_vs.exe") && !File.Exists("devpro.dll"))
{
File.Copy("ygopro_vs.exe", "devpro.dll");
File.Delete("ygopro_vs.exe");
Config.GameExe = "devpro.dll";
Config.Save(ConfigurationFilename);
}
LanguageManager = new LanguageManager();
//LanguageManager.Save("English");
LanguageManager.Load(Config.Language);
if (LauncherHelper.checkInstance())
if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
return;
UserInfo = new UserData();
ServerConnection = new NetClient();
if (!Config.DebugMode)
{
if (CheckUpdates())
return;
CheckServerInfo();
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
LoginService = new Authenticator(Config.DefaultUsername, Config.Password, ServerConnection, UserInfo);
if(!ServerConnection.Connect(Config.ServerAddress, Config.ServerPort))
{
MessageBox.Show(LanguageManager.Translation.pMsbErrorToServer);
}
if (Config.AutoLogin && Config.DefaultUsername.Length < 15)
{
LoginService.Authenticate();
Thread.Sleep(2000);
}
if (UserInfo.Username == "" && UserInfo.LoginKey == "")
{
LoginWindow = new Login_frm(Config, ServerConnection, LoginService);
if (LoginWindow.ShowDialog() != DialogResult.OK)
{
return;
}
}
if (!ServerConnection.IsConnected)
{
return;
}
if (UserInfo.Username != "" && UserInfo.LoginKey != "")
Application.Run(new Main_frm());
else
{
Config.AutoLogin = false;
Config.Save(ConfigurationFilename);
MessageBox.Show(LanguageManager.Translation.pMsbBadLog);
}
}
示例7: Main
public static void Main(string[] args)
{
Mode mode = Mode.None;
string key = null;
string value = null;
string updateFile = null;
OptionSet options = new OptionSet()
{
{"?|h|help", "show this message and exit", (o => {if (o != null) mode = Mode.Help;})},
{"u|update", "update the given config file", (o => { if (o != null) mode = Mode.Update; })},
{"r|remove", "remove a setting from the given config file", (o => { if (o != null) mode = Mode.Remove; })},
{"k|key=", "the key or setting name to be updated/removed", (o => key = o)},
{"v|value=", "the value to be set", (o => value = o)},
{"f|file=", "the file to update the given config file with", (o => updateFile = o)}
};
List<string> filePaths = options.Parse(args);
switch(mode)
{
case Mode.Help:
ShowHelp(options);
break;
case Mode.Update:
foreach (var filePath in filePaths)
{
var config = new Configuration(filePath);
if (updateFile != null)
if (File.Exists(updateFile))
config.UpdateWith(updateFile);
else
System.Console.WriteLine(string.Format("\nError: \"{0}\" does not exist.", updateFile));
if (key != null && value != null)
{
if (config.Settings.ContainsKey(key))
config.Settings[key] = value;
else
config.Settings.Add(key, value);
}
config.Save();
}
break;
case Mode.Remove:
foreach (var filePath in filePaths)
{
var config = new Configuration(filePath);
if (key != null)
if (config.Settings.ContainsKey(key))
config.Settings.Remove(key);
config.Save();
}
break;
default:
ShowUsage();
break;
}
}
示例8: Save
public void Save(DexterInfo dexterInfo)
{
Configuration configuration = new Configuration(new ProjectInfo(), dexterInfo);
configuration.Save(Path);
}
示例9: Generate_templates
public static string Generate_templates()
{
StringBuilder sb = new StringBuilder();
Provider.Database.Begin();
try
{
foreach (string aspxPath in System.IO.Directory.GetFiles(Provider.MapPath("/"), "*.aspx"))
{
string fileName = System.IO.Path.GetFileName(aspxPath);
Template template = (Template)Provider.Database.Read(typeof(Template), "FileName={0}", fileName);
if (template == null)
{
template = new Template();
template.FileName = fileName;
sb.AppendFormat("{0} created.\n", fileName);
}
else
sb.AppendFormat("{0} updated.\n", fileName);
string code = System.IO.File.ReadAllText(aspxPath, Encoding.UTF8);
code = code.Replace(@"<%@ Page Language=""C#"" %>", "");
code = code.Replace(@" runat=""server""", "");
code = code.Replace("</head>", "$=this.HeadSection$\r\n</head>");
Regex regexObj = new Regex(@"\<sm\:Region.+ID=""(?<id>.+?)"".+\/\>", RegexOptions.Multiline);
Match match = regexObj.Match(code);
while (match.Success)
{
code = code.Replace(match.Value, String.Format(@"<div id=""{0}"" class=""Region {0}"">$=this.{0}$</div>", match.Groups["id"].Value));
match = match.NextMatch();
}
template.HTMLCode = code;
template.Save();
}
string styles = Properties.Resources.conf_default_css;
if (System.IO.File.Exists(Provider.MapPath("/default.css")))
{
styles = System.IO.File.ReadAllText(Provider.MapPath("/default.css"), Encoding.UTF8);
sb.Append("default.css added.\n");
}
if (System.IO.File.Exists(Provider.MapPath("/CMS.conf")))
{
Configuration conf = new Configuration();
System.IO.StreamReader sr = null;
try
{
sr = new System.IO.StreamReader(Provider.MapPath("/CMS.conf"), Encoding.UTF8);
System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(Configuration));
conf = (Configuration)ser.Deserialize(sr);
sr.Close();
sb.Append("Configuration updated.\n");
}
catch
{
conf = Configuration.Read();
}
conf.Id = 1;
conf.DefaultStyleSheet = styles;
conf.Save();
}
Provider.Database.Commit();
sb.Append("\n");
sb.Append("Please check if the website is OK then delete *.aspx, default.css and CMS.conf files.");
}
catch (Exception ex)
{
Provider.Database.Rollback();
throw ex;
}
return sb.ToString();
}