本文整理汇总了C#中ObjectWriter.Write方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectWriter.Write方法的具体用法?C# ObjectWriter.Write怎么用?C# ObjectWriter.Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectWriter
的用法示例。
在下文中一共展示了ObjectWriter.Write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJS
public override void WriteJS(IndentedTextWriter writer)
{
writer.Write("model.select('{0}', {1}, \"{2}\"", this.type, this.number, this.name);
if (this.optional || this.filter != null)
{
writer.Write(", ");
using (ObjectWriter ow = new ObjectWriter(writer))
{
if (this.optional) { ow.Write("optional", this.optional); }
if (this.filter != null)
{
ow.WritePrefix("filter", "function(model, element) { return ");
this.filter.WriteJS(writer);
writer.Write("; }");
}
}
}
writer.WriteLine(");");
}
示例2: WriteJS
public void WriteJS(IndentedTextWriter textWriter)
{
using (ObjectWriter writer = new ObjectWriter(textWriter))
{
writer.Write("name", this.name);
writer.Write("type", this.type);
writer.Write("id", this.id);
if (this.source != null) { writer.Write("source", this.source); }
string url = CompendiumUrl;
if (url != null) { writer.Write("compendiumUrl", url); }
if (Specifics.Count > 0)
{
writer.WritePrefix("specifics", "");
textWriter.Indent++;
using(ObjectWriter specificWriter = new ObjectWriter(textWriter))
{
foreach(KeyValuePair<string, string> specific in Specifics)
{
specificWriter.Write(specific.Key, specific.Value);
}
}
textWriter.Indent--;
}
if (Categories.Count > 0)
{
writer.WritePrefix("categories", "[");
Identifier[] categories = Categories.ToArray();
for (int i = 0; i < categories.Length; i++)
{
if (i != 0) { textWriter.Write(", "); }
textWriter.Write("\"{0}\"", Converter.QuoteString(categories[i]));
}
textWriter.Write("]");
}
if (Rules.Count > 0)
{
writer.WritePrefix("rules", "function(model) {");
textWriter.Indent++;
textWriter.WriteLine();
foreach (Rule rule in Rules)
{
rule.WriteJS(textWriter);
}
textWriter.Indent -= 1;
textWriter.Write("}");
}
}
}