当前位置: 首页>>代码示例>>C#>>正文


C# WriterState.ToString方法代码示例

本文整理汇总了C#中WriterState.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# WriterState.ToString方法的具体用法?C# WriterState.ToString怎么用?C# WriterState.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WriterState的用法示例。


在下文中一共展示了WriterState.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateTransition

        /// <summary>
        /// Verify that the transition from the current state into new state is valid .
        /// </summary>
        /// <param name="newState">The new writer state to transition into.</param>
        private void ValidateTransition(WriterState newState)
        {
            if (!IsErrorState(this.State) && IsErrorState(newState))
            {
                // we can always transition into an error state if we are not already in an error state
                return;
            }

            switch (this.State)
            {
                case WriterState.Start:
                    if (newState != WriterState.DeltaFeed)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromStart(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.DeltaEntry:
                case WriterState.DeltaDeletedEntry:
                case WriterState.DeltaLink:
                case WriterState.DeltaDeletedLink:
                    if (this.CurrentScope.Item == null)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromNullEntry(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.DeltaFeed:
                    if (newState != WriterState.DeltaEntry && newState != WriterState.DeltaDeletedEntry &&
                        newState != WriterState.DeltaLink && newState != WriterState.DeltaDeletedLink)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromFeed(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.Completed:
                    // we should never see a state transition when in state 'Completed'
                    throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromCompleted(this.State.ToString(), newState.ToString()));
                case WriterState.Error:
                    if (newState != WriterState.Error)
                    {
                        // No more state transitions once we are in error state except for the fatal error
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromError(this.State.ToString(), newState.ToString()));
                    }

                    break;
                default:
                    throw new ODataException(Strings.General_InternalError(InternalErrorCodes.ODataWriterCore_ValidateTransition_UnreachableCodePath));
            }
        }
开发者ID:spawnadv,项目名称:msgraphodata.net,代码行数:54,代码来源:ODataJsonLightDeltaWriter.cs

示例2: ValidateTransition

        private void ValidateTransition(WriterState newState)
        {
            if (!IsErrorState(this.State) && IsErrorState(newState) && 
                !(this.State == WriterState.Completed && newState == WriterState.Error))
            {
                // we can always transition into an error state if we are not already in an error state
                // unless we're in a completed state trying to write an error (we can't write error after the payload
                // was finished as it might introduce another top-level element in XML)
                return;
            }

            switch (this.State)
            {
                case WriterState.Start:
                    if (newState != WriterState.Feed && newState != WriterState.Entry)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromStart(this.State.ToString(), newState.ToString()));
                    }

                    if (newState == WriterState.Feed && !this.writingFeed)
                    {
                        throw new ODataException(Strings.ODataWriterCore_CannotWriteTopLevelFeedWithEntryWriter);
                    }

                    if (newState == WriterState.Entry && this.writingFeed)
                    {
                        throw new ODataException(Strings.ODataWriterCore_CannotWriteTopLevelEntryWithFeedWriter);
                    }

                    break;
                case WriterState.Entry:
                    if (newState != WriterState.Link)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromEntry(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.Feed:
                    if (newState != WriterState.Entry)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromFeed(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.Link:
                    if (newState != WriterState.ExpandedLink)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidStateTransition(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.ExpandedLink:
                    if (newState != WriterState.Feed && newState != WriterState.Entry)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromExpandedLink(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.Completed:
                    // we should never see a state transition when in state 'Completed'
                    throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromCompleted(this.State.ToString(), newState.ToString()));
                case WriterState.ODataExceptionThrown:
                    if (!IsErrorState(newState))
                    {
                        // once an exception has been thrown we only allow clients to write an error (or we detect a fatal exception)
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromODataExceptionThrown(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.Error:
                    // No more state transitions once we are in error state except for the fatal error
                    if (newState != WriterState.FatalExceptionThrown)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromError(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.FatalExceptionThrown:
                    if (newState != WriterState.FatalExceptionThrown)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromFatalExceptionThrown(this.State.ToString(), newState.ToString()));
                    }

                    break;
                default:
                    throw new ODataException(Strings.General_InternalError(InternalErrorCodes.ODataWriterCore_ValidateTransition_UnreachableCodePath));
            }
        }
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:88,代码来源:ODataWriterCore.cs

示例3: ValidateTransition

        private void ValidateTransition(WriterState newState)
        {
            if (!IsErrorState(this.State) && IsErrorState(newState))
            {
                // we can always transition into an error state if we are not already in an error state
                return;
            }

            switch (this.State)
            {
                case WriterState.Start:
                    if (newState != WriterState.Feed && newState != WriterState.Entry)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromStart(this.State.ToString(), newState.ToString()));
                    }

                    if (newState == WriterState.Feed && !this.writingFeed)
                    {
                        throw new ODataException(Strings.ODataWriterCore_CannotWriteTopLevelFeedWithEntryWriter);
                    }

                    if (newState == WriterState.Entry && this.writingFeed)
                    {
                        throw new ODataException(Strings.ODataWriterCore_CannotWriteTopLevelEntryWithFeedWriter);
                    }

                    break;
                case WriterState.Entry:
                    {
                        if (this.CurrentScope.Item == null)
                        {
                            throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromNullEntry(this.State.ToString(), newState.ToString()));
                        }

                        if (newState != WriterState.NavigationLink)
                        {
                            throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromEntry(this.State.ToString(), newState.ToString()));
                        }
                    }

                    break;
                case WriterState.Feed:
                    if (newState != WriterState.Entry)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromFeed(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.NavigationLink:
                    if (newState != WriterState.NavigationLinkWithContent)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidStateTransition(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.NavigationLinkWithContent:
                    if (newState != WriterState.Feed && newState != WriterState.Entry)
                    {
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromExpandedLink(this.State.ToString(), newState.ToString()));
                    }

                    break;
                case WriterState.Completed:
                    // we should never see a state transition when in state 'Completed'
                    throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromCompleted(this.State.ToString(), newState.ToString()));
                case WriterState.Error:
                    if (newState != WriterState.Error)
                    {
                        // No more state transitions once we are in error state except for the fatal error
                        throw new ODataException(Strings.ODataWriterCore_InvalidTransitionFromError(this.State.ToString(), newState.ToString()));
                    }

                    break;
                default:
                    throw new ODataException(Strings.General_InternalError(InternalErrorCodes.ODataWriterCore_ValidateTransition_UnreachableCodePath));
            }
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:77,代码来源:ODataWriterCore.cs

示例4: ValidateTransition

        private void ValidateTransition(WriterState newState)
        {
            if (IsErrorState(this.State) || !IsErrorState(newState))
            {
                switch (this.State)
                {
                    case WriterState.Start:
                        if ((newState != WriterState.Feed) && (newState != WriterState.Entry))
                        {
                            throw new ODataException(Microsoft.Data.OData.Strings.ODataWriterCore_InvalidTransitionFromStart(this.State.ToString(), newState.ToString()));
                        }
                        if ((newState == WriterState.Feed) && !this.writingFeed)
                        {
                            throw new ODataException(Microsoft.Data.OData.Strings.ODataWriterCore_CannotWriteTopLevelFeedWithEntryWriter);
                        }
                        if ((newState != WriterState.Entry) || !this.writingFeed)
                        {
                            break;
                        }
                        throw new ODataException(Microsoft.Data.OData.Strings.ODataWriterCore_CannotWriteTopLevelEntryWithFeedWriter);

                    case WriterState.Entry:
                        if (this.CurrentScope.Item == null)
                        {
                            throw new ODataException(Microsoft.Data.OData.Strings.ODataWriterCore_InvalidTransitionFromNullEntry(this.State.ToString(), newState.ToString()));
                        }
                        if (newState != WriterState.NavigationLink)
                        {
                            throw new ODataException(Microsoft.Data.OData.Strings.ODataWriterCore_InvalidTransitionFromEntry(this.State.ToString(), newState.ToString()));
                        }
                        break;

                    case WriterState.Feed:
                        if (newState != WriterState.Entry)
                        {
                            throw new ODataException(Microsoft.Data.OData.Strings.ODataWriterCore_InvalidTransitionFromFeed(this.State.ToString(), newState.ToString()));
                        }
                        break;

                    case WriterState.NavigationLink:
                        if (newState != WriterState.NavigationLinkWithContent)
                        {
                            throw new ODataException(Microsoft.Data.OData.Strings.ODataWriterCore_InvalidStateTransition(this.State.ToString(), newState.ToString()));
                        }
                        break;

                    case WriterState.NavigationLinkWithContent:
                        if ((newState != WriterState.Feed) && (newState != WriterState.Entry))
                        {
                            throw new ODataException(Microsoft.Data.OData.Strings.ODataWriterCore_InvalidTransitionFromExpandedLink(this.State.ToString(), newState.ToString()));
                        }
                        break;

                    case WriterState.Completed:
                        throw new ODataException(Microsoft.Data.OData.Strings.ODataWriterCore_InvalidTransitionFromCompleted(this.State.ToString(), newState.ToString()));

                    case WriterState.Error:
                        if (newState != WriterState.Error)
                        {
                            throw new ODataException(Microsoft.Data.OData.Strings.ODataWriterCore_InvalidTransitionFromError(this.State.ToString(), newState.ToString()));
                        }
                        break;

                    default:
                        throw new ODataException(Microsoft.Data.OData.Strings.General_InternalError(InternalErrorCodes.ODataWriterCore_ValidateTransition_UnreachableCodePath));
                }
            }
        }
开发者ID:nickchal,项目名称:pash,代码行数:68,代码来源:ODataWriterCore.cs


注:本文中的WriterState.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。