/// <summary> /// Annotates the given payload based on the metadata in the given uri /// </summary> /// <param name="rootElement">The payload to annotate with metadata information</param> /// <param name="uri">The uri that corresponds to the given payload</param> public void ResolveMetadata(ODataPayloadElement rootElement, ODataUri uri) { ExceptionUtilities.CheckArgumentNotNull(rootElement, "rootElement"); ExceptionUtilities.CheckArgumentNotNull(uri, "uri"); this.InitializeMetadataStack(uri); this.InitialStackSize = this.MetadataStack.Count; rootElement.Add(new ExpectedPayloadElementTypeAnnotation() { ExpectedType = uri.GetExpectedPayloadType() }); // if the uri did not contain any metadata, do nothing if (this.InitialStackSize > 0) { // if this is the result of service operation or action, the root element needs to have the function itself and its return type var serviceOperation = this.MetadataStack.OfType <Function>().FirstOrDefault(); if (serviceOperation != null) { rootElement.AddAnnotationIfNotExist(new FunctionAnnotation() { Function = serviceOperation }); rootElement.AddAnnotationIfNotExist(new DataTypeAnnotation() { DataType = serviceOperation.ReturnType }); } this.Recurse(rootElement); } }
/// <summary> /// Annotates the given payload based on the metadata in the given uri /// </summary> /// <param name="rootElement">The payload to annotate with metadata information</param> /// <param name="uri">The uri that corresponds to the given payload</param> public void ResolveMetadata(ODataPayloadElement rootElement, ODataUri uri) { ExceptionUtilities.CheckArgumentNotNull(rootElement, "rootElement"); ExceptionUtilities.CheckArgumentNotNull(uri, "uri"); this.InitializeMetadataStack(uri); this.InitialStackSize = this.MetadataStack.Count; rootElement.Add(new ExpectedPayloadElementTypeAnnotation() { ExpectedType = uri.GetExpectedPayloadType() }); // if the uri did not contain any metadata, do nothing if (this.InitialStackSize > 0) { // if this is the result of service operation or action, the root element needs to have the function itself and its return type var serviceOperation = this.MetadataStack.OfType<Function>().FirstOrDefault(); if (serviceOperation != null) { rootElement.AddAnnotationIfNotExist(new FunctionAnnotation() { Function = serviceOperation }); rootElement.AddAnnotationIfNotExist(new DataTypeAnnotation() { DataType = serviceOperation.ReturnType }); } this.Recurse(rootElement); } }