/// <summary>
 /// Injects the appropriate metadata builder based on the metadata level.
 /// </summary>
 /// <param name="entry">The entry to inject the builder.</param>
 /// <param name="builder">The metadata builder to inject.</param>
 internal virtual void InjectMetadataBuilder(ODataEntry entry, ODataEntityMetadataBuilder builder)
 {
     entry.MetadataBuilder = builder;
 }
        /// <summary>
        /// Injects the appropriate metadata builder based on the metadata level.
        /// </summary>
        /// <param name="entry">The entry to inject the builder.</param>
        /// <param name="builder">The metadata builder to inject.</param>
        internal override void InjectMetadataBuilder(ODataEntry entry, ODataEntityMetadataBuilder builder)
        {
            base.InjectMetadataBuilder(entry, builder);

            // Inject to the Media Resource.
            var mediaResource = entry.NonComputedMediaResource;
            if (mediaResource != null)
            {
                mediaResource.SetMetadataBuilder(builder, /*propertyName*/null);
            }

            // Inject to named stream property values
            if (entry.NonComputedProperties != null)
            {
                foreach (ODataProperty property in entry.NonComputedProperties)
                {
                    var streamReferenceValue = property.ODataValue as ODataStreamReferenceValue;
                    if (streamReferenceValue != null)
                    {
                        streamReferenceValue.SetMetadataBuilder(builder, property.Name);
                    }
                }
            }

            // Inject to operations
            IEnumerable<ODataOperation> operations = ODataUtilsInternal.ConcatEnumerables((IEnumerable<ODataOperation>)entry.NonComputedActions, (IEnumerable<ODataOperation>)entry.NonComputedFunctions);
            if (operations != null)
            {
                foreach (ODataOperation operation in operations)
                {
                    operation.SetMetadataBuilder(builder, this.NonNullMetadataDocumentUri);
                }
            }
        }
 /// <summary>
 /// Sets the metadata builder for this stream reference value.
 /// </summary>
 /// <param name="builder">The metadata builder used to compute values from model annotations.</param>
 /// <param name="propertyName">The property name for the named stream; null for the default media resource.</param>
 internal void SetMetadataBuilder(ODataEntityMetadataBuilder builder, string propertyName)
 {
     this.metadataBuilder = builder;
     this.edmPropertyName = propertyName;
     this.computedEditLink = null;
     this.computedReadLink = null;
 }
Esempio n. 4
0
        /// <summary>
        /// Sets the metadata builder for this operation.
        /// </summary>
        /// <param name="builder">The metadata builder used to compute values from model annotations.</param>
        /// <param name="metadataDocumentUri">The metadata document Uri.</param>
        internal void SetMetadataBuilder(ODataEntityMetadataBuilder builder, Uri metadataDocumentUri)
        {
            Debug.Assert(metadataDocumentUri != null, "metadataDocumentUri != null");
            Debug.Assert(metadataDocumentUri.IsAbsoluteUri, "metadataDocumentUri.IsAbsoluteUri");

            ODataJsonLightValidationUtils.ValidateOperation(metadataDocumentUri, this);
            this.metadataBuilder = builder;
            this.operationFullName = ODataJsonLightUtils.GetFullyQualifiedOperationName(metadataDocumentUri, UriUtils.UriToString(this.Metadata), out this.parameterNames);
            this.computedTitle = null;
            this.computedTarget = null;
        }
 internal static void GetOperationTitleShouldValidateArguments(ODataEntityMetadataBuilder builder)
 {
     Action<string> action = (value) => builder.GetOperationTitle(value);
     action.ShouldThrowOnNullOrEmptyStringArgument("operationName");
 }
 internal static void GetAssociationLinkUriShouldValidateArguments(ODataEntityMetadataBuilder builder)
 {
     Action<string> action = (value) => builder.GetAssociationLinkUri(value, null, false);
     action.ShouldThrowOnNullOrEmptyStringArgument("navigationPropertyName");
 }
 internal static void GetStreamReadLinkShouldValidateArguments(ODataEntityMetadataBuilder builder)
 {
     Action<string> action = (value) => builder.GetStreamReadLink(value);
     action.ShouldThrowOnEmptyStringArgument("streamPropertyName");
 }
 /// <summary>
 /// Injects the appropriate metadata builder based on the metadata level.
 /// </summary>
 /// <param name="entry">The entry to inject the builder.</param>
 /// <param name="builder">The metadata builder to inject.</param>
 internal override void InjectMetadataBuilder(ODataEntry entry, ODataEntityMetadataBuilder builder)
 {
     // For minimal metadata we don't want to change the metadata builder that's currently on the entry because the entry might come from a JSON light
     // reader and it would contain the metadata builder from the reader.  Until we give the user the ability to choose whether to write what was reported
     // by the reader versus what was on the wire, we no-op here so the writer will just write what's on the OM for now.
 }