/// <summary> /// Sets the value of the CustomState for the specified annotatable. /// </summary> /// <param name="annotatable">The annotatable instance to set the CustomState for.</param> /// <param name="value">The value of the CustomState to set, will overwrite any existing value.</param> internal static void SetCustomState(this ODataAnnotatable annotatable, object value) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(annotatable != null, "annotatable != null"); CustomStateAnnotation annotation = annotatable.GetAnnotation<CustomStateAnnotation>(); if (annotation == null) { annotation = new CustomStateAnnotation(); } annotation.Value = value; annotatable.SetAnnotation(annotation); }
/// <summary> /// Sets the value of the CustomState for the specified annotatable. /// </summary> /// <param name="annotatable">The annotatable instance to set the CustomState for.</param> /// <param name="value">The value of the CustomState to set, will overwrite any existing value.</param> internal static void SetCustomState(this ODataAnnotatable annotatable, object value) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(annotatable != null, "annotatable != null"); CustomStateAnnotation annotation = annotatable.GetAnnotation <CustomStateAnnotation>(); if (annotation == null) { annotation = new CustomStateAnnotation(); } annotation.Value = value; annotatable.SetAnnotation(annotation); }
/// <summary> /// Returns the value of the CustomState for the specified annotatable. /// </summary> /// <param name="annotatable">The annotatable instance to get the CustomState for.</param> /// <returns>The value of the CustomState.</returns> internal static object GetCustomState(this ODataAnnotatable annotatable) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(annotatable != null, "annotatable != null"); CustomStateAnnotation annotation = annotatable.GetAnnotation <CustomStateAnnotation>(); if (annotation == null) { return(null); } else { return(annotation.Value); } }