예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }