示例#1
0
        public void CanParseMultilineValueWithSingleGroup()
        {
            string iniContent = "[globalSettings]" + Environment.NewLine
                                + "Title:Learn painting" + Environment.NewLine
                                + "Description:\"Learn to paint" + Environment.NewLine
                                + " using oil\"" + Environment.NewLine
                                + "[post1]" + Environment.NewLine
                                + "title:Build a website" + Environment.NewLine
                                + "CreatedBy: user1";

            IniDocument document = new IniDocument(iniContent, false);
            string      title    = document.Get <string>("globalSettings", "Title");
            string      desc     = document.Get <string>("globalSettings", "Description");

            Assert.AreEqual(title, "Learn painting");
            Assert.AreEqual(desc, "Learn to paint" + Environment.NewLine + " using oil");

            Assert.AreEqual(document["post1", "title"], "Build a website");
            Assert.AreEqual(document["post1", "CreatedBy"], "user1");

            //Assert.IsTrue(groupedDict.ContainsKey("globalSettings"));
            //Assert.AreEqual(groupedDict["globalSettings"]["category"], "Art,Drawing");
            //Assert.IsTrue(groupedDict.ContainsKey("post1"));
            //Assert.AreEqual(groupedDict["post1"]["title"], "Build a website");
            //Assert.AreEqual(groupedDict["post1"]["CreatedBy"], "user1");
        }
示例#2
0
        public void CanParseWithMultiLinesAfterGroups()
        {
            string iniContent = "[globalSettings]" + Environment.NewLine
                                + "Title:Learn painting" + Environment.NewLine
                                + "Description:Learn to paint" + Environment.NewLine + Environment.NewLine + Environment.NewLine
                                + "[post1]" + Environment.NewLine
                                + "title:Build a website" + Environment.NewLine
                                + "CreatedBy: user1";

            IniDocument document = new IniDocument(iniContent, false);
            string      title    = document.Get <string>("globalSettings", "Title");
            string      desc     = document.Get <string>("globalSettings", "Description");

            Assert.AreEqual(title, "Learn painting");
            Assert.AreEqual(desc, "Learn to paint");

            Assert.AreEqual(document["post1", "title"], "Build a website");
            Assert.AreEqual(document["post1", "CreatedBy"], "user1");
        }
示例#3
0
文件: AppConfig.cs 项目: sgryjp/azuki
        /// <summary>
        /// Loads application config file.
        /// </summary>
        public static void Load()
        {
            int width, height;

            try
            {
                using (var file = new StreamReader(IniFilePath, Encoding.UTF8))
                    Ini.Load(file);

                int    fontSize = Ini.GetInt("Default", "FontSize", 1, Int32.MaxValue, FontInfo.Size);
                string fontName = Ini.Get("Default", "Font", FontInfo.Name);
                width  = Ini.GetInt("Default", "WindowWidth", 100, Int32.MaxValue, WindowSize.Width);
                height = Ini.GetInt("Default", "WindowHeight", 100, Int32.MaxValue, WindowSize.Height);

                AppConfig.FontInfo                      = new FontInfo(fontName, fontSize, FontStyle.Regular);
                AppConfig.WindowSize                    = new Size(width, height);
                AppConfig.WindowMaximized               = Ini.Get("Default", "WindowMaximized", false);
                AppConfig.TabPanelEnabled               = Ini.Get("Default", "TabPanelEnabled", false);
                AppConfig.UseScreenLineNumber           = Ini.Get("Default", "UseScreenLineNumber", false);
                AppConfig.DrawsEolCode                  = Ini.Get("Default", "DrawsEolCode", true);
                AppConfig.DrawsFullWidthSpace           = Ini.Get("Default", "DrawsFullWidthSpace", true);
                AppConfig.DrawsSpace                    = Ini.Get("Default", "DrawsSpace", true);
                AppConfig.DrawsTab                      = Ini.Get("Default", "DrawsTab", true);
                AppConfig.DrawsEofMark                  = Ini.Get("Default", "DrawsEofMark", false);
                AppConfig.HighlightsCurrentLine         = Ini.Get("Default", "HighlightsCurrentLine", true);
                AppConfig.HighlightsMatchedBracket      = Ini.Get("Default", "HighlightsMatchedBracket", true);
                AppConfig.ShowsLineNumber               = Ini.Get("Default", "ShowsLineNumber", true);
                AppConfig.ShowsHRuler                   = Ini.Get("Default", "ShowsHRuler", false);
                AppConfig.ShowsDirtBar                  = Ini.Get("Default", "ShowsDirtBar", false);
                AppConfig.TabWidth                      = Ini.GetInt("Default", "TabWidth", 0, 100, 8);
                AppConfig.LinePadding                   = Ini.GetInt("Default", "LinePadding", 1, 100, 1);
                AppConfig.LeftMargin                    = Ini.GetInt("Default", "LeftMargin", 0, 100, 1);
                AppConfig.TopMargin                     = Ini.GetInt("Default", "TopMargin", 0, 100, 1);
                AppConfig.ViewType                      = Ini.Get("Default", "ViewType", ViewType.Proportional);
                AppConfig.UsesTabForIndent              = Ini.Get("Default", "UsesTabForIndent", true);
                AppConfig.UnindentsWithBackspace        = Ini.Get("Default", "UnindentsWithBackspace", false);
                AppConfig.ConvertsFullWidthSpaceToSpace = Ini.Get("Default", "ConvertsFullWidthSpaceToSpace", false);
                AppConfig.HRulerIndicatorType           = Ini.Get("Default", "HRulerIndicatorType", HRulerIndicatorType.Segment);
                AppConfig.ScrollsBeyondLastLine         = Ini.Get("Default", "ScrollsBeyondLastLine", true);
                AppConfig.MruFiles.Load(Ini.Get("Default", "Mru", ""));

                UserPref.Antialias               = Ini.Get("Default", "Antialias", UserPref.Antialias);
                UserPref.AutoScrollMargin        = Ini.Get("Default", "AutoScrollMargin", UserPref.AutoScrollMargin);
                UserPref.CopyLineWhenNoSelection = Ini.Get("Default", "CopyLineWhenNoSelection", UserPref.CopyLineWhenNoSelection);
                UserPref.UseTextForEofMark       = Ini.Get("Default", "UseTextForEofMark", UserPref.UseTextForEofMark);
            }
            catch
            {}
        }