internal static Type GetPropertyType(object resource, string propertyName) { IDelta delta = resource as IDelta; if (delta != null) { Type type; delta.TryGetPropertyType(propertyName, out type); return(type); } else { PropertyInfo property = resource.GetType().GetProperty(propertyName); return(property == null ? null : property.PropertyType); } }
internal static Type GetPropertyType(object resource, string propertyName) { IDelta delta = resource as IDelta; if (delta != null) { Type type; delta.TryGetPropertyType(propertyName, out type); return(type); } PropertyInfo property = resource.GetType().GetProperty(propertyName); if (!(property == (PropertyInfo)null)) { return(property.PropertyType); } return((Type)null); }
internal static Type GetPropertyType(object resource, string propertyName, bool isDelta) { Contract.Assert(resource != null); Contract.Assert(propertyName != null); if (isDelta) { IDelta delta = resource as IDelta; Contract.Assert(delta != null); Type type; delta.TryGetPropertyType(propertyName, out type); return(type); } else { PropertyInfo property = resource.GetType().GetProperty(propertyName); return(property == null ? null : property.PropertyType); } }
private void SetDeltaPropertyValue(ODataSerializerContext writeContext, List <ODataProperty> properties, IDelta delta, string propertyName) { object propertyValue; if (delta.TryGetPropertyValue(propertyName, out propertyValue)) { Type propertyType; IEdmStructuredTypeReference expectedPropType = null; if (propertyValue == null) { // We need expected property type only if property value is null, else it will get from the value if (delta.TryGetPropertyType(propertyName, out propertyType)) { expectedPropType = writeContext.GetEdmType(propertyValue, propertyType) as IEdmStructuredTypeReference; } } SetPropertyValue(writeContext, properties, expectedPropType, propertyName, propertyValue); } }