当前位置: 首页>>代码示例>>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;未经允许,请勿转载。