diff --git a/GeneratorCode/Configure/NConfig.cs b/GeneratorCode/Configure/NConfig.cs
index d9174e8..b1a5e87 100644
--- a/GeneratorCode/Configure/NConfig.cs
+++ b/GeneratorCode/Configure/NConfig.cs
@@ -11,77 +11,73 @@
//
//
// ***********************************************************************
+
+using IniParser;
+using IniParser.Model;
+using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Timers;
-using IniParser;
-using IniParser.Model;
-using JetBrains.Annotations;
namespace GeneratorCode.Configure
{
///
- /// Class NConfig.
+ /// Class NConfig.
///
public static class NConfig
{
///
- /// Delegate ConfigChangedHandle
- ///
- public delegate void ConfigChangedHandle();
-
- ///
- /// The CFG file name
+ /// The CFG file name
///
private static readonly string _cfgFileName = @".\config.ini";
///
- /// The CFG data
+ /// The CFG data
///
private static IniData _cfgData;
///
- /// Occurs when [on configuration changed].
+ /// Delegate ConfigChangedHandle
+ ///
+ public delegate void ConfigChangedHandle();
+
+ ///
+ /// Occurs when [on configuration changed].
///
public static event ConfigChangedHandle OnConfigChanged;
///
- /// Configurations the changed.
+ /// Gets the CFG value.
///
- private static void ConfigChanged()
+ ///
+ /// Name of the sec.
+ /// Name of the key.
+ /// The definition value.
+ /// T.
+ public static T GetCfgValue([NotNull] string secName, [NotNull] string keyName, T defValue = default(T))
{
- OnConfigChanged?.Invoke();
- }
+ var ret = defValue;
+
+ if (_cfgData.Equals(null)) return ret;
- ///
- /// Loads the CFG from file.
- ///
- private static void LoadCfgFromFile()
- {
try
{
- if (!File.Exists(_cfgFileName))
- {
- var fs = new FileStream(_cfgFileName, FileMode.Create, FileAccess.Write);
- var ws = new StreamWriter(fs);
- ws.WriteLine("; 应用程序配置文件\n");
- }
-
- var iniPraser = new FileIniDataParser();
- iniPraser.Parser.Configuration.CommentString = ";";
- _cfgData = iniPraser.ReadFile(_cfgFileName);
- //Trace.WriteLine(_cfgData);
+ ret = (T)Convert.ChangeType(_cfgData[secName][keyName], typeof(T));
}
catch (Exception e)
{
- Trace.WriteLine(e.Message);
+ Trace.WriteLine("[" + _cfgData[secName][keyName] + "] :" + e.Message);
+ ret = defValue;
+ throw e;
}
+
+ return ret;
}
///
- /// Initializes the configure.
+ /// Initializes the configure.
///
public static void InitConfigure()
{
@@ -102,7 +98,7 @@ namespace GeneratorCode.Configure
fw.Changed += (sender, e) =>
{
- //if (Path.GetFileName(appPath) != _cfgFileName) return;
+ if (Path.GetFileName(appPath) != _cfgFileName) return;
lock (cfgTask)
{
@@ -133,31 +129,36 @@ namespace GeneratorCode.Configure
}
///
- /// Gets the CFG value.
+ /// Configurations the changed.
///
- ///
- /// Name of the sec.
- /// Name of the key.
- /// The definition value.
- /// T.
- public static T GetCfgValue([NotNull] string secName, [NotNull] string keyName, T defValue = default(T))
+ private static void ConfigChanged()
{
- var ret = defValue;
-
- if (_cfgData.Equals(null)) return ret;
+ OnConfigChanged?.Invoke();
+ }
+ ///
+ /// Loads the CFG from file.
+ ///
+ private static void LoadCfgFromFile()
+ {
try
{
- ret = (T) Convert.ChangeType(_cfgData[secName][keyName], typeof(T));
+ if (!File.Exists(_cfgFileName))
+ {
+ var fs = new FileStream(_cfgFileName, FileMode.Create, FileAccess.Write);
+ var ws = new StreamWriter(fs);
+ ws.WriteLine("; 应用程序配置文件\n");
+ }
+
+ var iniPraser = new FileIniDataParser();
+ iniPraser.Parser.Configuration.CommentString = ";";
+ _cfgData = iniPraser.ReadFile(_cfgFileName);
+ //Trace.WriteLine(_cfgData);
}
catch (Exception e)
{
- Trace.WriteLine("[" + _cfgData[secName][keyName] + "] :" + e.Message);
- ret = defValue;
- throw e;
+ Trace.WriteLine(e.Message);
}
-
- return ret;
}
}
-}
+}
\ No newline at end of file