示例#1
0
 private TResult WriteToOutput <TResult>(ODataPayloadKind payloadKind, Action verifyHeaders, Func <ODataOutputContext, TResult> writeFunc)
 {
     this.SetOrVerifyHeaders(payloadKind);
     if (verifyHeaders != null)
     {
         verifyHeaders();
     }
     this.outputContext = ODataOutputContext.CreateOutputContext(this.format, this.message, this.encoding, this.settings, this.writingResponse, this.model, this.urlResolver);
     return(writeFunc(this.outputContext));
 }
示例#2
0
 protected ODataWriterCore(ODataOutputContext outputContext, bool writingFeed)
 {
     this.outputContext = outputContext;
     this.writingFeed   = writingFeed;
     if (this.writingFeed && this.outputContext.Model.IsUserModel())
     {
         this.feedValidator = new FeedWithoutExpectedTypeValidator();
     }
     this.scopes.Push(new Scope(WriterState.Start, null, false));
 }
示例#3
0
 private void WriteToOutput(ODataPayloadKind payloadKind, Action verifyHeaders, Action <ODataOutputContext> writeAction)
 {
     this.SetOrVerifyHeaders(payloadKind);
     if (verifyHeaders != null)
     {
         verifyHeaders();
     }
     this.outputContext = ODataOutputContext.CreateOutputContext(this.format, this.message, this.encoding, this.settings, this.writingResponse, this.model, this.urlResolver);
     writeAction(this.outputContext);
 }
示例#4
0
 protected ODataWriterCore(ODataOutputContext outputContext, bool writingFeed)
 {
     this.outputContext = outputContext;
     this.writingFeed = writingFeed;
     if (this.writingFeed && this.outputContext.Model.IsUserModel())
     {
         this.feedValidator = new FeedWithoutExpectedTypeValidator();
     }
     this.scopes.Push(new Scope(WriterState.Start, null, false));
 }
示例#5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="outputContext">The output context to write to.</param>
        /// <param name="expectedItemType">The type reference of the expected item type or null if no expected item type exists.</param>
        /// <param name="listener">If not null, the writer will notify the implementer of the interface of relevant state changes in the writer.</param>
        protected ODataCollectionWriterCore(ODataOutputContext outputContext, IEdmTypeReference expectedItemType, IODataReaderWriterListener listener)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(outputContext != null, "outputContext != null");

            this.outputContext    = outputContext;
            this.expectedItemType = expectedItemType;
            this.listener         = listener;
            this.scopes.Push(new Scope(CollectionWriterState.Start, null));
        }
 protected ODataCollectionWriterCore(ODataOutputContext outputContext, IEdmTypeReference expectedItemType, IODataReaderWriterListener listener)
 {
     this.outputContext = outputContext;
     this.expectedItemType = expectedItemType;
     this.listener = listener;
     this.scopes.Push(new Scope(CollectionWriterState.Start, null));
     if (this.expectedItemType == null)
     {
         this.collectionValidator = new CollectionWithoutExpectedTypeValidator(null);
     }
 }
示例#7
0
 protected ODataCollectionWriterCore(ODataOutputContext outputContext, IEdmTypeReference expectedItemType, IODataReaderWriterListener listener)
 {
     this.outputContext    = outputContext;
     this.expectedItemType = expectedItemType;
     this.listener         = listener;
     this.scopes.Push(new Scope(CollectionWriterState.Start, null));
     if (this.expectedItemType == null)
     {
         this.collectionValidator = new CollectionWithoutExpectedTypeValidator(null);
     }
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="outputContext">The output context to write to.</param>
        /// <param name="functionImport">The function import whose parameters will be written.</param>
        protected ODataParameterWriterCore(ODataOutputContext outputContext, IEdmFunctionImport functionImport)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(outputContext != null, "outputContext != null");
            Debug.Assert(
                outputContext.MessageWriterSettings.Version.HasValue && outputContext.MessageWriterSettings.Version.Value >= ODataVersion.V3,
                "Parameter writer only writes to V3 or above.");

            this.outputContext  = outputContext;
            this.functionImport = functionImport;
            this.scopes.Push(ParameterWriterState.Start);
        }
示例#9
0
 private Task WriteToOutputAsync(ODataPayloadKind payloadKind, Action verifyHeaders, Func <ODataOutputContext, Task> writeAsyncAction)
 {
     this.SetOrVerifyHeaders(payloadKind);
     if (verifyHeaders != null)
     {
         verifyHeaders();
     }
     return(ODataOutputContext.CreateOutputContextAsync(this.format, this.message, this.encoding, this.settings, this.writingResponse, this.model, this.urlResolver).FollowOnSuccessWithTask <ODataOutputContext>(delegate(Task <ODataOutputContext> createOutputContextTask) {
         this.outputContext = createOutputContextTask.Result;
         return writeAsyncAction(this.outputContext);
     }));
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="outputContext">The output context to write to.</param>
        /// <param name="expectedItemType">The type reference of the expected item type or null if no expected item type exists.</param>
        /// <param name="listener">If not null, the writer will notify the implementer of the interface of relevant state changes in the writer.</param>
        protected ODataCollectionWriterCore(ODataOutputContext outputContext, IEdmTypeReference expectedItemType, IODataReaderWriterListener listener)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(outputContext != null, "outputContext != null");

            this.outputContext = outputContext;
            this.expectedItemType = expectedItemType;
            this.listener = listener;
            this.scopes.Push(new Scope(CollectionWriterState.Start, null));

            if (this.expectedItemType == null)
            {
                this.collectionValidator = new CollectionWithoutExpectedTypeValidator(/*expectedItemTypeName*/ null);
            }
        }
示例#11
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="outputContext">The output context to write to.</param>
        /// <param name="writingFeed">True if the writer is created for writing a feed; false when it is created for writing an entry.</param>
        protected ODataWriterCore(ODataOutputContext outputContext, bool writingFeed)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(outputContext != null, "outputContext != null");

            this.outputContext = outputContext;
            this.writingFeed = writingFeed;

            // create a collection validator when writing a top-level feed and a user model is present
            if (this.writingFeed && this.outputContext.Model.IsUserModel())
            {
                this.feedValidator = new FeedWithoutExpectedTypeValidator();
            }

            this.scopes.Push(new Scope(WriterState.Start, null, false));
        }
示例#12
0
 private void Dispose(bool disposing)
 {
     this.isDisposed = true;
     if (disposing)
     {
         try
         {
             if (this.outputContext != null)
             {
                 this.outputContext.Dispose();
             }
         }
         finally
         {
             this.outputContext = null;
         }
     }
 }
示例#13
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="outputContext">The output context to write to.</param>
 /// <param name="itemTypeReference">The item type of the collection being written or null if no metadata is available.</param>
 protected ODataCollectionWriterCore(ODataOutputContext outputContext, IEdmTypeReference itemTypeReference)
     : this(outputContext, itemTypeReference, null)
 {
 }
示例#14
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="outputContext">The output context to write to.</param>
        protected ODataSerializer(ODataOutputContext outputContext)
        {
            Debug.Assert(outputContext != null, "outputContext != null");

            this.outputContext = outputContext;
        }
示例#15
0
 protected ODataSerializer(ODataOutputContext outputContext)
 {
     this.outputContext = outputContext;
 }
示例#16
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="outputContext">The output context to write to.</param>
        protected ODataSerializer(ODataOutputContext outputContext)
        {
            Debug.Assert(outputContext != null, "outputContext != null");

            this.outputContext = outputContext;
        }
示例#17
0
 protected ODataParameterWriterCore(ODataOutputContext outputContext, IEdmFunctionImport functionImport)
 {
     this.outputContext  = outputContext;
     this.functionImport = functionImport;
     this.scopes.Push(ParameterWriterState.Start);
 }
示例#18
0
 protected ODataSerializer(ODataOutputContext outputContext)
 {
     this.outputContext = outputContext;
 }