本文整理汇总了C#中Serializer.WriteDefinitions方法的典型用法代码示例。如果您正苦于以下问题:C# Serializer.WriteDefinitions方法的具体用法?C# Serializer.WriteDefinitions怎么用?C# Serializer.WriteDefinitions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Serializer
的用法示例。
在下文中一共展示了Serializer.WriteDefinitions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanWriteTypeStack
public void CanWriteTypeStack()
{
Serializer serializer = new Serializer(new[] {"InternalUse"});
Stack<Type> typeStack = new Stack<Type>();
typeStack.Push(typeof (SampleService.CompositeType));
string models = serializer.WriteDefinitions(typeStack);
var obj = JObject.Parse(HttpUtility.UrlDecode(models));
Assert.AreEqual(2, obj.Count);
Assert.IsNotNull(obj["SampleService.CompositeType"]);
}
示例2: CanHideTaggedTypes
public void CanHideTaggedTypes()
{
var typeStack = new Stack<Type>();
typeStack.Push(typeof (ModelSampleA));
typeStack.Push(typeof (ModelSampleB));
//gets the Secret property when it's tag isn't configured
var serializerAll = new Serializer(null);
string modelAll = serializerAll.WriteDefinitions(typeStack);
Assert.IsFalse(string.IsNullOrEmpty(modelAll));
var objAll = JObject.Parse(modelAll) as JObject;
Assert.AreEqual(2, objAll.Count);
Assert.AreEqual(0, typeStack.Count);
var serializerTags = new Serializer(new[] {"Test"});
typeStack.Push(typeof (ModelSampleA));
typeStack.Push(typeof (ModelSampleB));
string modelHidden = serializerTags.WriteDefinitions(typeStack);
Assert.IsFalse(string.IsNullOrEmpty(modelHidden));
var objHidden = JObject.Parse(modelHidden) as JObject;
Assert.AreEqual(1, objHidden.Count);
}