本文整理汇总了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 ());
}
示例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()));
}
}