當前位置: 首頁>>代碼示例>>C#>>正文


C# IniConfigSource.ToString方法代碼示例

本文整理匯總了C#中Nini.Config.IniConfigSource.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# IniConfigSource.ToString方法的具體用法?C# IniConfigSource.ToString怎麽用?C# IniConfigSource.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nini.Config.IniConfigSource的用法示例。


在下文中一共展示了IniConfigSource.ToString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ToStringTest

        public void ToStringTest()
        {
            StringWriter writer = new StringWriter ();
            writer.WriteLine ("[Test]");
            writer.WriteLine (" cat = muffy");
            writer.WriteLine (" dog = rover");
            writer.WriteLine (" bird = tweety");
            IniConfigSource source =
                new IniConfigSource (new StringReader (writer.ToString ()));

            string eol = Environment.NewLine;

            string compare = "[Test]" + eol
                             + "cat = muffy" + eol
                             + "dog = rover" + eol
                             + "bird = tweety" + eol;
            Assert.AreEqual (compare, source.ToString ());
        }
開發者ID:rwhitworth,項目名稱:nini,代碼行數:18,代碼來源:IniConfigSourceTests.cs

示例2: Save

 public static void Save(string fileName, IList<DEngine> engines, DPoint pageSize, BackgroundFigure bf, Dictionary<string, byte[]> extraEntries)
 {
     System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
     using (ZipOutputStream zipOut = new ZipOutputStream(File.Create(fileName)))
     {
         IniConfigSource source = new IniConfigSource();
         // write each page
         int i = 0;
         Dictionary<string, byte[]> images = new Dictionary<string, byte[]>();
         foreach (DEngine de in engines)
         {
             IConfig config = source.AddConfig(string.Format("page{0}", i));
             config.Set(PAGESIZE, DPoint.FormatToString(de.PageSize));
             if (de.PageName != null)
                 config.Set(PAGENAME, de.PageName);
             string figureListName = string.Format("figureList{0}.xml", i);
             byte[] data = encoding.GetBytes(FigureSerialize.FormatToXml(de.Figures, images));
             config.Set(FIGURELIST, figureListName);
             Write(zipOut, figureListName, data);
             if (de.CustomBackgroundFigure)
             {
                 string backgroundFigureName = string.Format("backgroundFigure{0}.xml", i);
                 config.Set(BACKGROUNDFIGURE, backgroundFigureName);
                 data = encoding.GetBytes(FigureSerialize.FormatToXml(de.BackgroundFigure, images));
                 Write(zipOut, backgroundFigureName, data);
             }
             i += 1;
         }
         // write background figure
         if (bf != null)
         {
             // store page size to background figure
             if (pageSize != null)
             {
                 bf.Width = pageSize.X;
                 bf.Height = pageSize.Y;
             }
             else
             {
                 DPoint sz = PageTools.FormatToSize(PageFormat.Default);
                 bf.Width = sz.X;
                 bf.Height = sz.Y;
             }
             byte[] data = encoding.GetBytes(FigureSerialize.FormatToXml(bf, images));
             Write(zipOut, GENBKGNDFIGURE, data);
         }
         // write images
         foreach (KeyValuePair<string, byte[]> kvp in images)
             if (kvp.Key != null && kvp.Key.Length > 0)
                 Write(zipOut, IMAGES_DIR + Path.DirectorySeparatorChar + Path.GetFileName(kvp.Key), kvp.Value);
         // write extra entries
         if (extraEntries != null)
             foreach (string name in extraEntries.Keys)
                 Write(zipOut, name, extraEntries[name]);
         // write pages ini
         Write(zipOut, PAGES_INI, encoding.GetBytes(source.ToString()));
     }
 }
開發者ID:djpnewton,項目名稱:ddraw,代碼行數:58,代碼來源:FileHelper.cs


注:本文中的Nini.Config.IniConfigSource.ToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。