本文整理汇总了C#中Newtonsoft.Json.Serialization.JsonProperty.LoadFrom方法的典型用法代码示例。如果您正苦于以下问题:C# JsonProperty.LoadFrom方法的具体用法?C# JsonProperty.LoadFrom怎么用?C# JsonProperty.LoadFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Serialization.JsonProperty
的用法示例。
在下文中一共展示了JsonProperty.LoadFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateProperties
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
var properties = base.CreateProperties(type, memberSerialization);
foreach (var p in properties.ToArray())
{
// ICopyFrom properties are always Writable, and should not attempt to set the value directly.
if (typeof(ICopyFrom).IsAssignableFrom(p.PropertyType))
{
p.Writable = true;
p.ValueProvider = new DeserializeToExistingValueProvider(p.ValueProvider);
p.ObjectCreationHandling = ObjectCreationHandling.Reuse;
}
// Fixable properties need to have a second 'virtual' property to support #prefix.
if (p.PropertyType.IsConstructedGenericType &&
p.PropertyType.GetGenericTypeDefinition() == typeof(Fixable<>))
{
// ShouldSerialize for Fixable<> properties is smuggled in via the
// ShouldDeserialize delegate. (trying to think of a workaround)
var newp = new JsonProperty();
newp.LoadFrom(p);
newp.PropertyName = $"#{p.PropertyName}";
newp.ShouldSerialize = p.ShouldDeserialize;
// should always deserialize (fix smuggling)
newp.ShouldDeserialize = o => true;
p.ShouldDeserialize = o=>true;
// add the virtual property
properties.Add(newp);
}
}
return properties;
}