本文整理汇总了C#中ISettings.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# ISettings.Commit方法的具体用法?C# ISettings.Commit怎么用?C# ISettings.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISettings
的用法示例。
在下文中一共展示了ISettings.Commit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: internalMain
static void internalMain(string[] args)
{
bool success = ProgramArguments.TryParse(args, out arguments);
if (!success) {
arguments = new ProgramArguments(); // Get a new instance with default values.
}
if (arguments.CleanupUpdate || EnvironmentUtils.IsMonoRuntime()) {
if (!EnvironmentUtils.IsMonoRuntime()) {
// Wait one second to allow the other instance to exit.
Thread.Sleep(1000);
}
// Remove the old executable file.
if (File.Exists(String.Format("{0}.tmp", AssemblyUtils.GetApplicationPath()))) {
File.Delete(String.Format("{0}.tmp", AssemblyUtils.GetApplicationPath()));
}
}
if (!arguments.AllowMultipleInstances) {
var assembly = typeof(Program).Assembly;
GuidAttribute guidAttribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];
bool applicationInstanceIsNotRunning;
mutex = new Mutex(false, String.Format("{0}{1}", Application.ProductName, guidAttribute.Value), out applicationInstanceIsNotRunning);
if (!applicationInstanceIsNotRunning) {
MessageBox.Show(String.Format("An instance of this program is already running."), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
// Load settings.
String settingsFilePath = String.Format("{0}{1}{2}", Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath), Path.DirectorySeparatorChar, Program.SettingsFileName);
try {
if (!File.Exists(settingsFilePath)) {
try {
XMLSettings.CreateFile(settingsFilePath);
}
catch (Exception createSettingsFileException) {
MessageBox.Show(String.Format("Cannot create settings file {0}.\n\nError details: {1}", settingsFilePath, createSettingsFileException.Message), "uRADMonitorX", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
settings = XMLSettings.LoadFromFile(settingsFilePath);
// Fixes an issue with data log directory name on Linux due to trailing slash.
settings.DataLogDirectoryPath = settings.DataLogDirectoryPath.TrimEnd('\\');
settings.Commit();
}
catch (Exception loadSettingsFileException) {
MessageBox.Show(String.Format("Cannot load settings from file {0}.\n\nError details: {1}", settingsFilePath, loadSettingsFileException.Message), "uRADMonitorX", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var loggerFilePath = getLoggerPath(settings.LogDirectoryPath, Program.LoggerFileName, false);
var dataLoggerFilePath = getLoggerPath(settings.DataLoggingToSeparateFile ? settings.DataLogDirectoryPath : settings.LogDirectoryPath, Program.DataLoggerFileName, settings.IsLoggingEnabled && settings.IsDataLoggingEnabled && settings.DataLoggingToSeparateFile);
LoggerManager.GetInstance().Add(Program.LoggerName,
new ThreadSafeLogger(
new Logger(
new ReconfigurableFileAppender(loggerFilePath),
new DateTimeFormatter()
) {
Enabled = settings.IsLoggingEnabled
}
));
LoggerManager.GetInstance().Add(Program.DataLoggerName,
new ThreadSafeLogger(
new Logger(
new NLogDailyFileAppender(dataLoggerFilePath),
new DateTimeFormatter()
) {
Enabled = settings.IsLoggingEnabled &&
settings.IsDataLoggingEnabled &&
settings.DataLoggingToSeparateFile
}
));
logger = LoggerManager.GetInstance().GetLogger(Program.LoggerName);
IDeviceDataReaderFactory deviceDataReaderFactory = new DeviceDataHttpReaderFactory(settings);
if (!arguments.IgnoreRegisteringAtWindowsStartup && !EnvironmentUtils.IsUnix()) {
registerAtWindowsStartup();
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
FormMain formMain = new FormMain(deviceDataReaderFactory, settings, logger);
formMain.SettingsChangedEventHandler += new SettingsChangedEventHandler(formMain_SettingsChangedEventHandler);
Application.Run(formMain);
}