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)); }
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)); }
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); }
/// <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); } }
/// <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); }
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); } }
/// <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)); }
private void Dispose(bool disposing) { this.isDisposed = true; if (disposing) { try { if (this.outputContext != null) { this.outputContext.Dispose(); } } finally { this.outputContext = null; } } }
/// <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) { }
/// <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; }
protected ODataSerializer(ODataOutputContext outputContext) { this.outputContext = outputContext; }
protected ODataParameterWriterCore(ODataOutputContext outputContext, IEdmFunctionImport functionImport) { this.outputContext = outputContext; this.functionImport = functionImport; this.scopes.Push(ParameterWriterState.Start); }