本文整理汇总了C#中ObjectDumper类的典型用法代码示例。如果您正苦于以下问题:C# ObjectDumper类的具体用法?C# ObjectDumper怎么用?C# ObjectDumper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectDumper类属于命名空间,在下文中一共展示了ObjectDumper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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();
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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();
});
}
示例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);
}
示例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));
}
示例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);
}
}
}
示例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();
});
}
示例13: Write
public static void Write(object o, int depth, TextWriter log)
{
var dumper = new ObjectDumper(depth) {_writer = log};
dumper.WriteObject(null, o);
}
示例14: Write
public static void Write(object o, int depth)
{
ObjectDumper dumper = new ObjectDumper(depth);
dumper.WriteObject(null, o);
}
示例15: Write
public static void Write(object o, int depth = 0)
{
ObjectDumper dumper = new ObjectDumper(depth, Console.Out);
dumper.WriteObject(null, o);
}