/// <summary> /// Checks whether reflection over the property is allowed or not. /// </summary> /// <param name="property">The property to check.</param> /// <param name="model">The model containing annotations.</param> /// <returns>true if reflection over the property is allowed; otherwise false.</returns> public static bool GetCanReflectOnInstanceTypeProperty(this IEdmProperty property, IEdmModel model) { ExceptionUtils.CheckArgumentNotNull(property, "property"); ExceptionUtils.CheckArgumentNotNull(model, "model"); ODataQueryEdmPropertyAnnotation annotation = model.GetAnnotationValue <ODataQueryEdmPropertyAnnotation>(property); return(annotation == null ? false : annotation.CanReflectOnProperty); }
/// <summary> /// Sets whether reflection over the property is allowed or not. /// </summary> /// <param name="property">The property to check.</param> /// <param name="model">The model containing annotations.</param> /// <param name="canReflect">true if reflection over the property is allowed; otherwise false.</param> public static void SetCanReflectOnInstanceTypeProperty(this IEdmProperty property, IEdmModel model, bool canReflect) { ExceptionUtils.CheckArgumentNotNull(property, "property"); ExceptionUtils.CheckArgumentNotNull(model, "model"); ODataQueryEdmPropertyAnnotation annotation = model.GetAnnotationValue<ODataQueryEdmPropertyAnnotation>(property); if (annotation == null) { if (canReflect) { annotation = new ODataQueryEdmPropertyAnnotation { CanReflectOnProperty = true }; model.SetAnnotationValue(property, annotation); } } else { annotation.CanReflectOnProperty = canReflect; } }
/// <summary> /// Sets whether reflection over the property is allowed or not. /// </summary> /// <param name="property">The property to check.</param> /// <param name="model">The model containing annotations.</param> /// <param name="canReflect">true if reflection over the property is allowed; otherwise false.</param> public static void SetCanReflectOnInstanceTypeProperty(this IEdmProperty property, IEdmModel model, bool canReflect) { ExceptionUtils.CheckArgumentNotNull(property, "property"); ExceptionUtils.CheckArgumentNotNull(model, "model"); ODataQueryEdmPropertyAnnotation annotation = model.GetAnnotationValue <ODataQueryEdmPropertyAnnotation>(property); if (annotation == null) { if (canReflect) { annotation = new ODataQueryEdmPropertyAnnotation { CanReflectOnProperty = true }; model.SetAnnotationValue(property, annotation); } } else { annotation.CanReflectOnProperty = canReflect; } }