private JsonPropertyInfo GetPropertyWithUniqueAttribute(Type attributeType, Dictionary <string, JsonPropertyInfo> cache) { JsonPropertyInfo property = null; foreach (JsonPropertyInfo jsonPropertyInfo in cache.Values) { Attribute attribute = jsonPropertyInfo.PropertyInfo.GetCustomAttribute(attributeType); if (attribute != null) { if (property != null) { ThrowHelper.ThrowInvalidOperationException_SerializationDuplicateTypeAttribute(Type, attributeType); } property = jsonPropertyInfo; } } return(property); }
private static JsonPropertyInfo?GetPropertyWithUniqueAttribute(Type classType, Type attributeType, Dictionary <string, JsonPropertyInfo> cache) { JsonPropertyInfo?property = null; foreach (JsonPropertyInfo jsonPropertyInfo in cache.Values) { Debug.Assert(jsonPropertyInfo.MemberInfo != null); Attribute?attribute = jsonPropertyInfo.MemberInfo.GetCustomAttribute(attributeType); if (attribute != null) { if (property != null) { ThrowHelper.ThrowInvalidOperationException_SerializationDuplicateTypeAttribute(classType, attributeType); } property = jsonPropertyInfo; } } return(property); }
private JsonPropertyInfo GetPropertyThatHasAttribute(Type attributeType) { Debug.Assert(PropertyCache != null); JsonPropertyInfo property = null; foreach (JsonPropertyInfo jsonPropertyInfo in PropertyCache.Values) { Attribute attribute = jsonPropertyInfo.PropertyInfo.GetCustomAttribute(attributeType); if (attribute != null) { if (property != null) { ThrowHelper.ThrowInvalidOperationException_SerializationDuplicateTypeAttribute(Type, attributeType); } property = jsonPropertyInfo; } } return(property); }
private JsonPropertyInfo GetPropertyThatHasAttribute(Type attributeType) { Debug.Assert(_propertyRefs != null); JsonPropertyInfo property = null; for (int iProperty = 0; iProperty < _propertyRefs.Count; iProperty++) { PropertyRef propertyRef = _propertyRefs[iProperty]; JsonPropertyInfo jsonPropertyInfo = propertyRef.Info; Attribute attribute = jsonPropertyInfo.PropertyInfo.GetCustomAttribute(attributeType); if (attribute != null) { if (property != null) { ThrowHelper.ThrowInvalidOperationException_SerializationDuplicateTypeAttribute(Type, attributeType); } property = jsonPropertyInfo; } } return(property); }