/// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="jsonLightOutputContext">The output context to write to.</param>
        /// <param name="navigationSource">The navigation source we are going to write entities for.</param>
        /// <param name="entityType">The entity type for the entries in the resource set to be written (or null if the entity set base type should be used).</param>
        public ODataJsonLightDeltaWriter(ODataJsonLightOutputContext jsonLightOutputContext, IEdmNavigationSource navigationSource, IEdmEntityType entityType)
        {
            Debug.Assert(jsonLightOutputContext != null, "jsonLightOutputContext != null");

            // TODO: Replace the assertion with ODataException.
            Debug.Assert(jsonLightOutputContext.WritingResponse, "jsonLightOutputContext.WritingResponse is true");

            this.navigationSource       = navigationSource;
            this.entityType             = entityType;
            this.jsonLightOutputContext = jsonLightOutputContext;
            this.resourceWriter         = new ODataJsonLightWriter(jsonLightOutputContext, navigationSource, entityType, true, writingDelta: true);
            this.inStreamErrorListener  = resourceWriter;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="jsonLightOutputContext">The output context to write to.</param>
        /// <param name="initContextUriBuilder">Whether contextUriBuilder should be initialized.</param>
        internal ODataJsonLightSerializer(ODataJsonLightOutputContext jsonLightOutputContext, bool initContextUriBuilder = false)
            : base(jsonLightOutputContext)
        {
            Debug.Assert(jsonLightOutputContext != null, "jsonLightOutputContext != null");

            this.jsonLightOutputContext   = jsonLightOutputContext;
            this.instanceAnnotationWriter = new SimpleLazy <JsonLightInstanceAnnotationWriter>(() =>
                                                                                               new JsonLightInstanceAnnotationWriter(new ODataJsonLightValueSerializer(jsonLightOutputContext), jsonLightOutputContext.TypeNameOracle));
            this.odataAnnotationWriter = new SimpleLazy <JsonLightODataAnnotationWriter>(() =>
                                                                                         new JsonLightODataAnnotationWriter(jsonLightOutputContext.JsonWriter,
                                                                                                                            this.JsonLightOutputContext.ODataSimplifiedOptions.EnableWritingODataAnnotationWithoutPrefix));

            if (initContextUriBuilder)
            {
                // DEVNOTE: grab this early so that any validation errors are thrown at creation time rather than when Write___ is called.
                this.ContextUriBuilder = jsonLightOutputContext.CreateContextUriBuilder();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="jsonLightOutputContext">The output context to write to.</param>
        /// <param name="initContextUriBuilder">Whether contextUriBuilder should be initialized.</param>
        internal ODataJsonLightSerializer(ODataJsonLightOutputContext jsonLightOutputContext, bool initContextUriBuilder = false)
            : base(jsonLightOutputContext)
        {
            Debug.Assert(jsonLightOutputContext != null, "jsonLightOutputContext != null");

            this.jsonLightOutputContext   = jsonLightOutputContext;
            this.instanceAnnotationWriter = new SimpleLazy <JsonLightInstanceAnnotationWriter>(() =>
                                                                                               new JsonLightInstanceAnnotationWriter(new ODataJsonLightValueSerializer(jsonLightOutputContext), jsonLightOutputContext.TypeNameOracle));
            this.odataAnnotationWriter = new SimpleLazy <JsonLightODataAnnotationWriter>(() =>
                                                                                         new JsonLightODataAnnotationWriter(jsonLightOutputContext.JsonWriter,
                                                                                                                            this.JsonLightOutputContext.OmitODataPrefix, this.MessageWriterSettings.Version));

            if (initContextUriBuilder)
            {
                // DEVNOTE: grab this early so that any validation errors are thrown at creation time rather than when Write___ is called.
                this.ContextUriBuilder = ODataContextUriBuilder.Create(
                    this.jsonLightOutputContext.MessageWriterSettings.MetadataDocumentUri,
                    this.jsonLightOutputContext.WritingResponse && !(this.jsonLightOutputContext.MetadataLevel is JsonNoMetadataLevel));
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="jsonLightOutputContext">The output context to write to.</param>
 /// <param name="writingTopLevelCollection">true when writing a top-level collection that requires the 'value' wrapper object; otherwise false.</param>
 internal ODataJsonLightCollectionSerializer(ODataJsonLightOutputContext jsonLightOutputContext, bool writingTopLevelCollection)
     : base(jsonLightOutputContext, /*initContextUriBuilder*/ true)
 {
     this.writingTopLevelCollection = writingTopLevelCollection;
 }
Esempio n. 5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="jsonLightOutputContext">The output context to write to.</param>
 /// <param name="initContextUriBuilder">Whether contextUriBuilder should be initialized.</param>
 internal ODataJsonLightPropertySerializer(ODataJsonLightOutputContext jsonLightOutputContext, bool initContextUriBuilder = false)
     : base(jsonLightOutputContext, initContextUriBuilder)
 {
     this.jsonLightValueSerializer = new ODataJsonLightValueSerializer(this, initContextUriBuilder);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ODataJsonLightValueSerializer"/> class.
 /// </summary>
 /// <param name="outputContext">The output context to use.</param>
 /// <param name="initContextUriBuilder">Whether contextUriBuilder should be initialized.</param>
 internal ODataJsonLightValueSerializer(ODataJsonLightOutputContext outputContext, bool initContextUriBuilder = false)
     : base(outputContext, initContextUriBuilder)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="jsonLightOutputContext">The output context to write to.</param>
 internal ODataJsonLightBatchWriter(ODataJsonLightOutputContext jsonLightOutputContext)
     : base(jsonLightOutputContext)
 {
     this.jsonWriter = this.JsonLightOutputContext.JsonWriter;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="jsonLightOutputContext">The output context to write to.</param>
 internal ODataJsonLightEntityReferenceLinkSerializer(ODataJsonLightOutputContext jsonLightOutputContext)
     : base(jsonLightOutputContext, /*initContextUriBuilder*/ true)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="jsonLightOutputContext">The output context to write to.</param>
 internal ODataJsonLightResourceSerializer(ODataJsonLightOutputContext jsonLightOutputContext)
     : base(jsonLightOutputContext, /*initContextUriBuilder*/ true)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="jsonLightOutputContext">The output context to write to.</param>
 internal ODataJsonLightServiceDocumentSerializer(ODataJsonLightOutputContext jsonLightOutputContext)
     : base(jsonLightOutputContext, /*initContextUriBuilder*/ true)
 {
 }