Example #1
0
        /// <summary>
        /// Place where derived writers can perform custom steps before the entry is writen, at the begining of WriteStartEntryImplementation.
        /// </summary>
        /// <param name="entry">Entry to write.</param>
        /// <param name="typeContext">The context object to answer basic questions regarding the type of the entry or feed.</param>
        /// <param name="selectedProperties">The selected properties of this scope.</param>
        protected override void PrepareEntryForWriteStart(ODataEntry entry, ODataFeedAndEntryTypeContext typeContext, SelectedPropertiesNode selectedProperties)
        {
            if (this.jsonLightOutputContext.MessageWriterSettings.AutoComputePayloadMetadataInJson)
            {
                EntryScope entryScope = (EntryScope)this.CurrentScope;
                Debug.Assert(entryScope != null, "entryScope != null");

                ODataEntityMetadataBuilder builder = this.jsonLightOutputContext.MetadataLevel.CreateEntityMetadataBuilder(
                    entry,
                    typeContext,
                    entryScope.SerializationInfo,
                    entryScope.EntityType,
                    selectedProperties,
                    this.jsonLightOutputContext.WritingResponse,
                    this.jsonLightOutputContext.MessageWriterSettings.UseKeyAsSegment,
                    this.jsonLightOutputContext.MessageWriterSettings.ODataUri);

                if (builder is ODataConventionalEntityMetadataBuilder)
                {
                    builder.ParentMetadataBuilder = this.FindParentEntryMetadataBuilder();
                }

                this.jsonLightOutputContext.MetadataLevel.InjectMetadataBuilder(entry, builder);
            }
        }
Example #2
0
        /// <summary>
        /// Find instance of the metadata builder which belong to the parent odata entry
        /// </summary>
        /// <returns>
        /// The metadata builder of the parent odata entry
        /// Or null if there is no parent odata entry
        /// </returns>
        private ODataEntityMetadataBuilder FindParentEntryMetadataBuilder()
        {
            EntryScope parentEntryScope = this.GetParentEntryScope();

            if (parentEntryScope != null)
            {
                ODataEntry entry = parentEntryScope.Item as ODataEntry;
                if (entry != null)
                {
                    return(entry.MetadataBuilder);
                }
            }

            return(null);
        }
Example #3
0
        /// <summary>
        /// Place where derived writers can perform custom steps before the entry is writen, at the begining of WriteStartEntryImplementation.
        /// </summary>
        /// <param name="entry">Entry to write.</param>
        /// <param name="typeContext">The context object to answer basic questions regarding the type of the entry or feed.</param>
        /// <param name="selectedProperties">The selected properties of this scope.</param>
        protected override void PrepareEntryForWriteStart(ODataEntry entry, ODataFeedAndEntryTypeContext typeContext, SelectedPropertiesNode selectedProperties)
        {
            if (this.jsonLightOutputContext.MessageWriterSettings.AutoComputePayloadMetadataInJson)
            {
                EntryScope entryScope = (EntryScope)this.CurrentScope;
                Debug.Assert(entryScope != null, "entryScope != null");

                ODataEntityMetadataBuilder builder = this.jsonLightOutputContext.MetadataLevel.CreateEntityMetadataBuilder(
                    entry,
                    typeContext,
                    entryScope.SerializationInfo,
                    entryScope.EntityType,
                    selectedProperties,
                    this.jsonLightOutputContext.WritingResponse,
                    this.jsonLightOutputContext.MessageWriterSettings.AutoGeneratedUrlsShouldPutKeyValueInDedicatedSegment);
                this.jsonLightOutputContext.MetadataLevel.InjectMetadataBuilder(entry, builder);
            }
        }