/// <summary> /// Copy constructor to create a navigation link with content scope from an existing navigation link scope. /// </summary> /// <param name="other">The navigation link scope to copy.</param> internal NavigationLinkScope(NavigationLinkScope other) : base(WriterState.NavigationLinkWithContent, other.Item, other.SkipWriting) { DebugUtils.CheckNoExternalCallers(); this.navigationPropertyType = other.navigationPropertyType; }
private void PushScope(WriterState state, ODataItem item, bool skipWriting) { Debug.Assert( state == WriterState.Error || state == WriterState.Entry && (item == null || item is ODataEntry) || state == WriterState.Feed && item is ODataFeed || state == WriterState.NavigationLink && item is ODataNavigationLink || state == WriterState.NavigationLinkWithContent && item is ODataNavigationLink || state == WriterState.Start && item == null || state == WriterState.Completed && item == null, "Writer state and associated item do not match."); Scope scope; switch (state) { case WriterState.Entry: scope = this.CreateEntryScope((ODataEntry)item, skipWriting); break; case WriterState.Feed: scope = this.CreateFeedScope((ODataFeed)item, skipWriting); break; case WriterState.NavigationLink: // fall through case WriterState.NavigationLinkWithContent: scope = new NavigationLinkScope(state, (ODataNavigationLink)item, skipWriting); break; case WriterState.Start: // fall through case WriterState.Completed: // fall through case WriterState.Error: scope = new Scope(state, item, skipWriting); break; default: string errorMessage = Strings.General_InternalError(InternalErrorCodes.ODataWriterCore_Scope_Create_UnreachableCodePath); Debug.Assert(false, errorMessage); throw new ODataException(errorMessage); } this.scopes.Push(scope); }
private void PushScope(WriterState state, ODataItem item, bool skipWriting) { Scope scope; switch (state) { case WriterState.Start: case WriterState.Completed: scope = new Scope(state, item, skipWriting); break; case WriterState.Error: scope = new Scope(state, item, skipWriting); break; case WriterState.Entry: scope = this.CreateEntryScope((ODataEntry) item, skipWriting); break; case WriterState.Feed: scope = this.CreateFeedScope((ODataFeed) item, skipWriting); break; case WriterState.NavigationLink: case WriterState.NavigationLinkWithContent: scope = new NavigationLinkScope(state, (ODataNavigationLink) item, skipWriting); break; default: throw new ODataException(Microsoft.Data.OData.Strings.General_InternalError(InternalErrorCodes.ODataWriterCore_Scope_Create_UnreachableCodePath)); } this.scopes.Push(scope); }
private void PromoteNavigationLinkScope() { Debug.Assert( this.State == WriterState.NavigationLink, "Only a NavigationLink state can be promoted right now. If this changes please review the scope replacement code below."); Debug.Assert( this.CurrentScope.Item != null && this.CurrentScope.Item is ODataNavigationLink, "Item must be a non-null navigation link."); this.ValidateTransition(WriterState.NavigationLinkWithContent); NavigationLinkScope previousScope = (NavigationLinkScope)this.scopes.Pop(); NavigationLinkScope newScope = new NavigationLinkScope(previousScope); this.scopes.Push(newScope); }
private void PromoteNavigationLinkScope() { this.ValidateTransition(WriterState.NavigationLinkWithContent); NavigationLinkScope other = (NavigationLinkScope) this.scopes.Pop(); NavigationLinkScope item = new NavigationLinkScope(other); this.scopes.Push(item); }