本文整理汇总了C#中ObjectDumper类的典型用法代码示例。如果您正苦于以下问题:C# ObjectDumper类的具体用法?C# ObjectDumper怎么用?C# ObjectDumper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectDumper类属于命名空间,在下文中一共展示了ObjectDumper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Write
public static void Write(object element, int depth, TextWriter log)
{
ObjectDumper dumper = new ObjectDumper(depth);
dumper.writer = log;
dumper.WriteObject(null, element);
log.WriteLine(new string('-', 20));
}
开发者ID:diamondiamon,项目名称:WeikerenUtility,代码行数:7,代码来源:ObjectDumper.cs
示例2: Write
public static string Write(object o, int depth)
{
var sw = new StringWriter();
sw.NewLine = "\r\n";
ObjectDumper dumper = new ObjectDumper(sw, depth);
dumper.WriteObject(null, o);
return sw.ToString();
}
开发者ID:taolin123,项目名称:ExpressionFutures,代码行数:8,代码来源:ObjectDumper.cs
示例3: Write
public static void Write(object element, int depth, NLog.Logger log)
{
if (log.IsTraceEnabled)
{
ObjectDumper dumper = new ObjectDumper(depth);
dumper.WriteObject(null, element);
log.Trace(dumper.builder);
}
}
开发者ID:andyhoyle,项目名称:Crucial.Framework,代码行数:9,代码来源:ObjectDumper.cs
示例4: String
/// <summary>
/// Dumps the object to a string. Added for convenience by Pete.
/// </summary>
public static string String(object element)
{
using (var w = new StringWriter())
{
var dumper = new ObjectDumper(0) { writer = w };
dumper.WriteObject(null, element);
return w.ToString();
}
}
开发者ID:jncc,项目名称:topcat,代码行数:12,代码来源:ObjectDumper.cs
示例5: ToString
public static string ToString(object o, int depth = 0)
{
using (var sw = new StringWriter())
{
ObjectDumper dumper = new ObjectDumper(depth, sw);
dumper.WriteObject(null, o);
return sw.ToString();
}
}
开发者ID:Nouser,项目名称:LolNotes,代码行数:9,代码来源:ObjectDumper.cs
示例6: DumpValueTypeInteger
public void DumpValueTypeInteger() {
var objectDumper = new ObjectDumper(1);
var xElement = objectDumper.Dump(1337, "Model");
var stringBuilder = new StringBuilder();
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
var json = stringBuilder.ToString();
var jObject = new JObject(
new JProperty("name", "Model"),
new JProperty("value", "1337"));
ComparareJsonObject(jObject, json);
}
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:14,代码来源:ObjectDumperTests.cs
示例7: Dump
/// <summary>
/// Dumps values of the specified target.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="depth">The depth of the dump.</param>
/// <returns>A string representing the object dump.</returns>
public static string Dump(object target, int depth)
{
try
{
using (var dumper = new ObjectDumper(depth))
{
dumper.WriteObject(null, target);
return dumper.ToString().TrimEnd(Environment.NewLine.ToCharArray());
}
}
catch (Exception ex)
{
return string.Format("Dump failure: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace);
}
}
开发者ID:zhangz,项目名称:Toolbox,代码行数:21,代码来源:ObjectDumper.cs
示例8: DumpObject_DepthOne
public void DumpObject_DepthOne() {
var objectDumper = new ObjectDumper(1);
var xElement = objectDumper.Dump(new TestObject
{
SomeInteger = 1337,
SomeBoolean = true,
SomeString = "Never gonna give you up"
}, "Model");
Assert.Throws(typeof (NullReferenceException), () => {
var stringBuilder = new StringBuilder();
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
var json = stringBuilder.ToString();
});
}
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:15,代码来源:ObjectDumperTests.cs
示例9: DumpContentItem_DepthSix
public void DumpContentItem_DepthSix() {
var contentItem = new ContentItem { ContentType = "TestContentType" };
var testingPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("TestingPart"), new SettingsDictionary()) };
contentItem.Weld(testingPart);
var objectDumper = new ObjectDumper(6);
var xElement = objectDumper.Dump(contentItem, "Model");
var stringBuilder = new StringBuilder();
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
var json = stringBuilder.ToString();
var jObject = new JObject(
new JProperty("name", "Model"),
new JProperty("value", "ContentItem"),
new JProperty("children", new JArray(
new JObject(
new JProperty("name", "Id"),
new JProperty("value", "0")),
new JObject(
new JProperty("name", "Version"),
new JProperty("value", "0")),
new JObject(
new JProperty("name", "ContentType"),
new JProperty("value", ""TestContentType"")),
new JObject(
new JProperty("name", "TestingPart"),
new JProperty("value", "ContentPart"),
new JProperty("children", new JArray(
new JObject(
new JProperty("name", "Id"),
new JProperty("value", "0")),
new JObject(
new JProperty("name", "TypeDefinition"),
new JProperty("value", "null")),
new JObject(
new JProperty("name", "TypePartDefinition"),
new JProperty("value", "ContentTypePartDefinition"),
new JProperty("children", new JArray(
new JObject(
new JProperty("name", "PartDefinition"),
new JProperty("value", "ContentPartDefinition"),
new JProperty("children", new JArray(
new JObject(
new JProperty("name", "Name"),
new JProperty("value", ""TestingPart"")),
new JObject(
new JProperty("name", "Fields"),
new JProperty("value", "ContentPartFieldDefinition[]")),
new JObject(
new JProperty("name", "Settings"),
new JProperty("value", "SettingsDictionary"))))),
new JObject(
new JProperty("name", "Settings"),
new JProperty("value", "SettingsDictionary")),
new JObject(
new JProperty("name", "ContentTypeDefinition"),
new JProperty("value", "null"))))),
new JObject(
new JProperty("name", "PartDefinition"),
new JProperty("value", "ContentPartDefinition"),
new JProperty("children", new JArray(
new JObject(
new JProperty("name", "Name"),
new JProperty("value", ""TestingPart"")),
new JObject(
new JProperty("name", "Fields"),
new JProperty("value", "ContentPartFieldDefinition[]")),
new JObject(
new JProperty("name", "Settings"),
new JProperty("value", "SettingsDictionary"))))),
new JObject(
new JProperty("name", "Settings"),
new JProperty("value", "SettingsDictionary")),
new JObject(
new JProperty("name", "Fields"),
new JProperty("value", "List<ContentField>"))))))));
ComparareJsonObject(jObject, json);
}
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:80,代码来源:ObjectDumperTests.cs
示例10: A
public void A()
{
var dic = new Dictionary<string, string> { { "Key 1", "Value 1" }, { "Key 2", "Value 2" } };
var x = new ObjectDumper().Dump(typeof(Object));
}
开发者ID:ByteCarrot,项目名称:Aspy,代码行数:5,代码来源:ObjectDumperTests.cs
示例11: FullDump
public void FullDump()
{
ObjectDumper dumper = new ObjectDumper(4, true, true, (System.Reflection.BindingFlags.FlattenHierarchy));
logger.Error("Dump of the spellbook of {0} : ", Character.Name);
foreach (var spell in m_spells)
{
logger.Error(" Spell {0}", spell.ToString(true));
foreach (var effectdice in spell.LevelTemplate.effects)
{
EffectBase effect = new EffectBase(effectdice);
logger.Error(" Effect {0} : {1} - {2} {3:P}", effect.Description, effectdice.diceNum <= effectdice.diceSide ? effectdice.diceNum : effectdice.diceSide, effectdice.diceNum > effectdice.diceSide ? effectdice.diceNum : effectdice.diceSide, effectdice.random == 0 ? 1.0 : effectdice.random / 100.0);
}
}
}
开发者ID:Ryuuke,项目名称:BehaviorIsManaged,代码行数:14,代码来源:SpellsBook.cs
示例12: DumpShape_DepthOne
public void DumpShape_DepthOne() {
var objectDumper = new ObjectDumper(1);
var testShape = new TestShape
{
Metadata = new ShapeMetadata()
{
Type = "TestContentType",
DisplayType = "Detail",
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
Position = "1",
ChildContent = new HtmlString("<p>Test Para</p>"),
Wrappers = new[] { "TestContentType_Wrapper" }
},
SomeInteger = 1337,
SomeBoolean = true,
SomeString = "Never gonna give you up"
};
testShape.Classes.Add("bodyClass1");
testShape.Classes.Add("bodyClass2");
testShape.Add("Child Item");
testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));
var xElement = objectDumper.Dump(testShape, "Model");
Assert.Throws(typeof(NullReferenceException), () =>
{
var stringBuilder = new StringBuilder();
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
var json = stringBuilder.ToString();
});
}
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:34,代码来源:ObjectDumperTests.cs
示例13: Write
public static void Write(object o, int depth, TextWriter log)
{
var dumper = new ObjectDumper(depth) {_writer = log};
dumper.WriteObject(null, o);
}
开发者ID:samplet,项目名称:HalfAndHalf,代码行数:5,代码来源:ObjectDumper.cs
示例14: Write
public static void Write(object o, int depth)
{
ObjectDumper dumper = new ObjectDumper(depth);
dumper.WriteObject(null, o);
}
开发者ID:CeeJay79,项目名称:aion_ext,代码行数:5,代码来源:ObjectDumper.cs
示例15: Write
public static void Write(object o, int depth = 0)
{
ObjectDumper dumper = new ObjectDumper(depth, Console.Out);
dumper.WriteObject(null, o);
}
开发者ID:Nouser,项目名称:LolNotes,代码行数:5,代码来源:ObjectDumper.cs
示例16: Write
internal static void Write(object o, int depth, TextWriter log)
{
ObjectDumper dumper = new ObjectDumper(depth);
dumper.writer = log;
dumper.WriteObject(null, o);
}
开发者ID:jaykizhou,项目名称:elinq,代码行数:6,代码来源:ObjectDumper.cs
示例17: WriteTo
public static void WriteTo(object o, Stream stream, int depth = 0)
{
ObjectDumper dumper = new ObjectDumper(depth, new StreamWriter(stream));
dumper.WriteObject(null, o);
}
开发者ID:Nouser,项目名称:LolNotes,代码行数:5,代码来源:ObjectDumper.cs
示例18: DumpShapeAndChild_DepthSix
public void DumpShapeAndChild_DepthSix() {
var objectDumper = new ObjectDumper(6);
var testShape = new TestShape
{
Metadata = new ShapeMetadata
{
Type = "TestContentType",
DisplayType = "Detail",
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
Position = "1",
ChildContent = new HtmlString("<p>Test Para</p>"),
Wrappers = new[] { "TestContentType_Wrapper" }
},
SomeInteger = 1337,
SomeBoolean = true,
SomeString = "Never gonna give you up"
};
testShape.Classes.Add("bodyClass1");
testShape.Classes.Add("bodyClass2");
testShape.Add(new TestShape
{
Metadata = new ShapeMetadata
{
Type = "TestContentChildType",
DisplayType = "Detail",
Alternates = new[] { "TestContentChildType_Detail", "TestContentChildType_Detail_2" },
Position = "1",
ChildContent = new HtmlString("<p>Test Child Para</p>"),
Wrappers = new[] { "TestContentChildType_Wrapper" }
},
SomeInteger = 1337,
SomeBoolean = true,
SomeString = "Never gonna give you up"
});
testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));
var xElement = objectDumper.Dump(testShape, "Model");
var stringBuilder = new StringBuilder();
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
var json = stringBuilder.ToString();
var jObject = new JObject(
new JProperty("name", "Model"),
new JProperty("value", "TestContentType Shape"),
new JProperty("children", new JArray(
new JObject(
new JProperty("name", "Classes"),
new JProperty("value", "List<String>"),
new JProperty("children", new JArray(
new JObject(
new JProperty("name", "[0]"),
new JProperty("value", ""bodyClass1"")),
new JObject(
new JProperty("name", "[1]"),
new JProperty("value", ""bodyClass2""))))),
new JObject(
new JProperty("name", "Attributes"),
new JProperty("value", "Dictionary<String, String>"),
new JProperty("children", new JArray(
new JObject(
new JProperty("name", "["onClick"]"),
new JProperty("value", ""dhtmlIsBad""))))),
new JObject(
new JProperty("name", "Items"),
new JProperty("value", "List<Object>"),
new JProperty("children", new JArray(
new JObject(
new JProperty("name", "[0]"),
new JProperty("value", "TestContentChildType Shape"),
new JProperty("children", new JArray(
new JObject(
new JProperty("name", "Classes"),
new JProperty("value", "List<String>")),
new JObject(
new JProperty("name", "Attributes"),
new JProperty("value", "Dictionary<String, String>")),
new JObject(
new JProperty("name", "Items"),
new JProperty("value", "List<Object>")))))))))));
ComparareJsonObject(jObject, json);
}
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:86,代码来源:ObjectDumperTests.cs
示例19: DumpIShape_DepthOne
public void DumpIShape_DepthOne() {
var objectDumper = new ObjectDumper(1);
var xElement = objectDumper.Dump(new TestIShape {
Metadata = new ShapeMetadata() {
Type = "TestContentType",
DisplayType = "Detail",
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
Position = "1",
ChildContent = new HtmlString("<p>Test Para</p>"),
Wrappers = new[] { "TestContentType_Wrapper" }
},
SomeInteger = 1337,
SomeBoolean = true,
SomeString = "Never gonna give you up"
}, "Model");
Assert.Throws(typeof(NullReferenceException), () => {
var stringBuilder = new StringBuilder();
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
var json = stringBuilder.ToString();
});
}
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:22,代码来源:ObjectDumperTests.cs
示例20: DumpShape_DepthTwo
public void DumpShape_DepthTwo() {
var objectDumper = new ObjectDumper(2);
var testShape = new TestShape
{
Metadata = new ShapeMetadata()
{
Type = "TestContentType",
DisplayType = "Detail",
Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
Position = "1",
ChildContent = new HtmlString("<p>Test Para</p>"),
Wrappers = new[] { "TestContentType_Wrapper" }
},
SomeInteger = 1337,
SomeBoolean = true,
SomeString = "Never gonna give you up"
};
testShape.Classes.Add("bodyClass1");
testShape.Classes.Add("bodyClass2");
testShape.Add("Child Item");
testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));
var xElement = objectDumper.Dump(testShape, "Model");
var stringBuilder = new StringBuilder();
ObjectDumper.ConvertToJSon(xElement, stringBuilder);
var json = stringBuilder.ToString();
var jObject = new JObject(
new JProperty("name", "Model"),
new JProperty("value", "TestContentType Shape"));
ComparareJsonObject(jObject, json);
}
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:37,代码来源:ObjectDumperTests.cs
注:本文中的ObjectDumper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论