本文整理汇总了C#中Exceptionless.Json.Serialization.JsonProperty.SetIsSpecified方法的典型用法代码示例。如果您正苦于以下问题:C# JsonProperty.SetIsSpecified方法的具体用法?C# JsonProperty.SetIsSpecified怎么用?C# JsonProperty.SetIsSpecified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exceptionless.Json.Serialization.JsonProperty
的用法示例。
在下文中一共展示了JsonProperty.SetIsSpecified方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetPropertyValue
private bool SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, object target)
{
object currentValue;
bool useExistingValue;
JsonContract propertyContract;
bool gottenCurrentValue;
if (CalculatePropertyDetails(property, ref propertyConverter, containerContract, containerProperty, reader, target, out useExistingValue, out currentValue, out propertyContract, out gottenCurrentValue))
return false;
object value;
if (propertyConverter != null && propertyConverter.CanRead)
{
if (!gottenCurrentValue && target != null && property.Readable)
currentValue = property.ValueProvider.GetValue(target);
value = DeserializeConvertable(propertyConverter, reader, property.PropertyType, currentValue);
}
else
{
value = CreateValueInternal(reader, property.PropertyType, propertyContract, property, containerContract, containerProperty, (useExistingValue) ? currentValue : null);
}
// always set the value if useExistingValue is false,
// otherwise also set it if CreateValue returns a new value compared to the currentValue
// this could happen because of a JsonConverter against the type
if ((!useExistingValue || value != currentValue)
&& ShouldSetPropertyValue(property, value))
{
property.ValueProvider.SetValue(target, value);
if (property.SetIsSpecified != null)
{
if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose)
TraceWriter.Trace(TraceLevel.Verbose, JsonPosition.FormatMessage(reader as IJsonLineInfo, reader.Path, "IsSpecified for property '{0}' on {1} set to true.".FormatWith(CultureInfo.InvariantCulture, property.PropertyName, property.DeclaringType)), null);
property.SetIsSpecified(target, true);
}
return true;
}
// the value wasn't set be JSON was populated onto the existing value
return useExistingValue;
}