コード例 #1
0
 private void initializeCacher()
 {
     CacherSettings.Load();
     // Print rules if file not exist.
     if (CacherSettings.Current.PrintGraphList &&
         !File.Exists(CacherSettings.Current.CacheFolder + "\\GraphList.txt"))
     {
         GraphList.AppendRule();
     }
     FiddlerRules.Initialize();
 }
コード例 #2
0
 public CacheCore()
 {
     set = CacherSettings.Current;
     VersionChecker.Load();
     myCacheFolder = set.CacheFolder;
 }
コード例 #3
0
ファイル: Settings.cs プロジェクト: rubygba/HoppoPlugin
        /// <summary>
        /// 加载插件设置
        /// </summary>
        public static void Load()
        {
            var switch_on = 0;

SwitchCase:
            switch (switch_on)
            {
            case 0:
                goto SetPath1;

            //第一次读取失败
            case 1:
                goto SetPath2;

            //第二次读取失败
            case 2:
                goto Failed;
            }
            goto Failed;


SetPath1:
            filePath = Directory.GetCurrentDirectory() + @"\Plugins\HoppoCacher.xml";

            switch_on = 1;
            goto ReadFile;


SetPath2:
            filePath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                "grabacr.net",
                "KanColleViewer",
                "HoppoCacher.xml"
                );
            switch_on = 2;
            goto ReadFile;


ReadFile:
            if (File.Exists(filePath))
            {
                try
                {
                    Current = filePath.ReadXml <CacherSettings>();
                    goto Succeed;
                }
                catch (Exception ex)
                {
                    Log.Exception(ex.InnerException, ex, "读取设置文件时出现异常");
                }
            }
            goto SwitchCase;


Failed:
            Current = new CacherSettings();
            return;


Succeed:
            if (!Directory.Exists(Current.CacheFolder))
            {
                try
                {
                    Directory.CreateDirectory(Current.CacheFolder);
                }
                catch (Exception ex)
                {
                    Current.CacheFolder = Directory.GetCurrentDirectory() + @"\HoppoPlugin\KanColleCache";
                    Log.Exception(ex.InnerException, ex, "设置文件中CacheFolder不存在,试图创建时发生异常");
                }
            }
            return;
        }