本文整理汇总了C#中WriterState类的典型用法代码示例。如果您正苦于以下问题:C# WriterState类的具体用法?C# WriterState怎么用?C# WriterState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WriterState类属于命名空间,在下文中一共展示了WriterState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnWriterState
void OnWriterState(Writer writer, WriterState writerState)
{
if (writerState == WriterState.Start && correctTagCount != 0)
{
IntegrationTest.Fail();
}
if (writerState == WriterState.Pause && correctTagCount != 2)
{
IntegrationTest.Fail();
}
if (writerState == WriterState.Resume && correctTagCount != 2)
{
IntegrationTest.Fail();
}
else if (writerState == WriterState.End && correctTagCount != 4)
{
IntegrationTest.Fail();
}
if (writerState == WriterState.End)
{
if (!receivedInput)
{
IntegrationTest.Fail();
}
if (glyphCount != 6)
{
IntegrationTest.Fail();
}
IntegrationTest.Pass();
}
}
开发者ID:snozbot,项目名称:fungus,代码行数:34,代码来源:WriterSignalsTester.cs
示例2: Attribute
public Sgml.ISgmlWriter Attribute(string name, object value)
{
if (_state == WriterState.startElem) _writer.Object();
_writer.Prop("@" + name, value);
_state = WriterState.elemData;
return this;
}
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:7,代码来源:XmlJsonWriter.cs
示例3: GraphVizWriter
public GraphVizWriter(System.IO.StreamWriter streamwriter)
{
if (streamwriter == null)
{
throw new System.ArgumentNullException("streamwriter");
}
this.streamwriter = streamwriter;
this.state = WriterState.Begin;
}
开发者ID:saveenr,项目名称:saveenr,代码行数:9,代码来源:GraphVizWriter.cs
示例4: Element
public Sgml.ISgmlWriter Element(string name)
{
if (!(_tags.Count > 0 && _tags.Peek().Group && _tags.Peek().Name == name))
{
if (_state == WriterState.startElem) _writer.Object();
_writer.Prop(name);
}
_tags.Push(new Tag() { Group = false, Name = name });
_state = WriterState.startElem;
return this;
}
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:11,代码来源:XmlJsonWriter.cs
示例5: HtmlMobileTextWriter
/// <include file='doc\HtmlMobileTextWriter.uex' path='docs/doc[@for="HtmlMobileTextWriter.HtmlMobileTextWriter"]/*' />
public HtmlMobileTextWriter(TextWriter writer, MobileCapabilities device)
: base(writer, device)
{
RenderBold = device.SupportsBold;
RenderItalic = device.SupportsItalic;
RenderFontSize = device.SupportsFontSize;
RenderFontName = device.SupportsFontName;
RenderFontColor = device.SupportsFontColor;
RenderBodyColor = device.SupportsBodyColor;
RenderDivAlign = device.SupportsDivAlign;
RenderDivNoWrap = device.SupportsDivNoWrap;
RequiresNoBreakInFormatting = device.RequiresNoBreakInFormatting;
_currentState = new WriterState(this);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:15,代码来源:HtmlMobileTextWriter.cs
示例6: EnterScope
private void EnterScope(WriterState newState, ODataItem item)
{
this.InterceptException(() => this.ValidateTransition(newState));
bool skipWriting = this.SkipWriting;
Scope currentScope = this.CurrentScope;
if (((currentScope.State == WriterState.Entry) && (newState == WriterState.NavigationLink)) && !skipWriting)
{
ProjectedPropertiesAnnotation projectedProperties = currentScope.Item.GetAnnotation<ProjectedPropertiesAnnotation>();
ODataNavigationLink link = (ODataNavigationLink) item;
skipWriting = projectedProperties.ShouldSkipProperty(link.Name);
}
else if ((currentScope.State == WriterState.Feed) && (newState == WriterState.Entry))
{
FeedScope scope1 = (FeedScope) currentScope;
scope1.EntryCount++;
}
this.PushScope(newState, item, skipWriting);
}
开发者ID:nickchal,项目名称:pash,代码行数:18,代码来源:ODataWriterCore.cs
示例7: JsonLightDeltaLinkScope
/// <summary>
/// Constructor to create a new delta link scope.
/// </summary>
/// <param name="state">The writer state of this scope.</param>
/// <param name="link">The link for the new scope.</param>
/// <param name="serializationInfo">The serialization info for the current entry.</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 feed to be written (or null if the entity set base type should be used).</param>
/// <param name="writerBehavior">The <see cref="ODataWriterBehavior"/> instance controlling the behavior of the writer.</param>
/// <param name="selectedProperties">The selected properties of this scope.</param>
/// <param name="odataUri">The ODataUri info of this scope.</param>
internal JsonLightDeltaLinkScope(WriterState state, ODataItem link, ODataDeltaSerializationInfo serializationInfo, IEdmNavigationSource navigationSource, IEdmEntityType entityType, ODataWriterBehavior writerBehavior, SelectedPropertiesNode selectedProperties, ODataUri odataUri)
: base(state, link, serializationInfo, navigationSource, entityType, writerBehavior, selectedProperties, odataUri)
{
}
开发者ID:spawnadv,项目名称:msgraphodata.net,代码行数:15,代码来源:ODataJsonLightDeltaWriter.cs
示例8: DeltaEntryScope
/// <summary>
/// Constructor to create a new entry scope.
/// </summary>
/// <param name="state">The writer state of this scope.</param>
/// <param name="entry">The entry for the new scope.</param>
/// <param name="serializationInfo">The serialization info for the current entry.</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 feed to be written (or null if the entity set base type should be used).</param>
/// <param name="writerBehavior">The <see cref="ODataWriterBehavior"/> instance controlling the behavior of the writer.</param>
/// <param name="selectedProperties">The selected properties of this scope.</param>
/// <param name="odataUri">The ODataUri info of this scope.</param>
protected DeltaEntryScope(WriterState state, ODataItem entry, ODataFeedAndEntrySerializationInfo serializationInfo, IEdmNavigationSource navigationSource, IEdmEntityType entityType, ODataWriterBehavior writerBehavior, SelectedPropertiesNode selectedProperties, ODataUri odataUri)
: base(state, entry, navigationSource, entityType, selectedProperties, odataUri)
{
Debug.Assert(entry != null, "entry != null");
Debug.Assert(
state == WriterState.DeltaEntry && entry is ODataEntry ||
state == WriterState.DeltaDeletedEntry && entry is ODataDeltaDeletedEntry,
"entry must be either DeltaEntry or DeltaDeletedEntry.");
Debug.Assert(writerBehavior != null, "writerBehavior != null");
this.duplicatePropertyNamesChecker = new DuplicatePropertyNamesChecker(writerBehavior.AllowDuplicatePropertyNames, /*writingResponse*/ true);
this.serializationInfo = serializationInfo;
}
开发者ID:spawnadv,项目名称:msgraphodata.net,代码行数:24,代码来源:ODataJsonLightDeltaWriter.cs
示例9: IsErrorState
/// <summary>
/// Determines whether a given writer state is considered an error state.
/// </summary>
/// <param name="state">The writer state to check.</param>
/// <returns>True if the writer state is an error state; otherwise false.</returns>
private static bool IsErrorState(WriterState state)
{
return state == WriterState.Error;
}
开发者ID:spawnadv,项目名称:msgraphodata.net,代码行数:9,代码来源:ODataJsonLightDeltaWriter.cs
示例10: PushScope
/// <summary>
/// Create a new writer scope.
/// </summary>
/// <param name="state">The writer state of the scope to create.</param>
/// <param name="item">The item attached to the scope to create.</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 feed to be written (or null if the entity set base type should be used).</param>
/// <param name="selectedProperties">The selected properties of this scope.</param>
/// <param name="odataUri">The OdataUri info of this scope.</param>
private void PushScope(WriterState state, ODataItem item, IEdmNavigationSource navigationSource, IEdmEntityType entityType, SelectedPropertiesNode selectedProperties, ODataUri odataUri)
{
Debug.Assert(
state == WriterState.Error ||
state == WriterState.DeltaEntry && item is ODataEntry ||
state == WriterState.DeltaDeletedEntry && item is ODataDeltaDeletedEntry ||
state == WriterState.DeltaFeed && item is ODataDeltaFeed ||
state == WriterState.DeltaLink && item is ODataDeltaLink ||
state == WriterState.DeltaDeletedLink && item is ODataDeltaDeletedLink ||
state == WriterState.Start && item == null ||
state == WriterState.Completed && item == null,
"Writer state and associated item do not match.");
Scope scope;
switch (state)
{
case WriterState.DeltaEntry:
scope = this.CreateDeltaEntryScope(WriterState.DeltaEntry, item, navigationSource, entityType, selectedProperties, odataUri);
break;
case WriterState.DeltaDeletedEntry:
scope = this.CreateDeltaEntryScope(WriterState.DeltaDeletedEntry, item, navigationSource, entityType, selectedProperties, odataUri);
break;
case WriterState.DeltaFeed:
scope = this.CreateDeltaFeedScope(item, navigationSource, entityType, selectedProperties, odataUri);
break;
case WriterState.DeltaLink:
scope = this.CreateDeltaLinkScope(WriterState.DeltaLink, item, navigationSource, entityType, selectedProperties, odataUri);
break;
case WriterState.DeltaDeletedLink:
scope = this.CreateDeltaLinkScope(WriterState.DeltaDeletedLink, item, navigationSource, entityType, selectedProperties, odataUri);
break;
case WriterState.Start: // fall through
case WriterState.Completed: // fall through
case WriterState.Error:
scope = new Scope(state, item, navigationSource, entityType, selectedProperties, odataUri);
break;
default:
string errorMessage = Strings.General_InternalError(InternalErrorCodes.ODataWriterCore_Scope_Create_UnreachableCodePath);
Debug.Assert(false, errorMessage);
throw new ODataException(errorMessage);
}
this.scopes.Push(scope);
}
开发者ID:spawnadv,项目名称:msgraphodata.net,代码行数:53,代码来源:ODataJsonLightDeltaWriter.cs
示例11: JsonLightNavigationLinkScope
/// <summary>
/// Constructor to create a new JSON Light navigation link scope.
/// </summary>
/// <param name="writerState">The writer state for the new scope.</param>
/// <param name="navLink">The navigation link for the new scope.</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 feed to be written (or null if the entity set base type should be used).</param>
/// <param name="skipWriting">true if the content of the scope to create should not be written.</param>
/// <param name="selectedProperties">The selected properties of this scope.</param>
/// <param name="odataUri">The ODataUri info of this scope.</param>
internal JsonLightNavigationLinkScope(WriterState writerState, ODataNavigationLink navLink, IEdmNavigationSource navigationSource, IEdmEntityType entityType, bool skipWriting, SelectedPropertiesNode selectedProperties, ODataUri odataUri)
: base(writerState, navLink, navigationSource, entityType, skipWriting, selectedProperties, odataUri)
{
}
开发者ID:spawnadv,项目名称:msgraphodata.net,代码行数:14,代码来源:ODataJsonLightWriter.cs
示例12: Clone
/// <summary>
/// Clones this JSON Light navigation link scope and sets a new writer state.
/// </summary>
/// <param name="newWriterState">The writer state to set.</param>
/// <returns>The cloned navigation link scope with the specified writer state.</returns>
internal override NavigationLinkScope Clone(WriterState newWriterState)
{
return new JsonLightNavigationLinkScope(newWriterState, (ODataNavigationLink)this.Item, this.NavigationSource, this.EntityType, this.SkipWriting, this.SelectedProperties, this.ODataUri)
{
EntityReferenceLinkWritten = this.entityReferenceLinkWritten,
FeedWritten = this.feedWritten,
};
}
开发者ID:spawnadv,项目名称:msgraphodata.net,代码行数:13,代码来源:ODataJsonLightWriter.cs
示例13: Push
public void Push(WriterState state)
{
if (_states == null)
{
_states = new WriterState[6];
}
else if (_count == _states.Length)
{
WriterState[] items = new WriterState[_states.Length * 2];
_states.CopyTo(items, 0);
_states = items;
}
_states[_count++] = state;
}
开发者ID:db48x,项目名称:KeeFox,代码行数:15,代码来源:JsonWriterBase.cs
示例14: JsonWriterBase
protected JsonWriterBase()
{
_state = new WriterState(JsonWriterBracket.Pending);
}
开发者ID:db48x,项目名称:KeeFox,代码行数:4,代码来源:JsonWriterBase.cs
示例15: CreateNavigationLinkScope
/// <summary>
/// Creates a new JSON Light navigation link scope.
/// </summary>
/// <param name="writerState">The writer state for the new scope.</param>
/// <param name="navLink">The navigation link for the new scope.</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 feed to be written (or null if the entity set base type should be used).</param>
/// <param name="skipWriting">true if the content of the scope to create should not be written.</param>
/// <param name="selectedProperties">The selected properties of this scope.</param>
/// <param name="odataUri">The ODataUri info of this scope.</param>
/// <returns>The newly created JSON Light navigation link scope.</returns>
protected override NavigationLinkScope CreateNavigationLinkScope(WriterState writerState, ODataNavigationLink navLink, IEdmNavigationSource navigationSource, IEdmEntityType entityType, bool skipWriting, SelectedPropertiesNode selectedProperties, ODataUri odataUri)
{
return new JsonLightNavigationLinkScope(writerState, navLink, navigationSource, entityType, skipWriting, selectedProperties, odataUri);
}
开发者ID:spawnadv,项目名称:msgraphodata.net,代码行数:15,代码来源:ODataJsonLightWriter.cs
示例16: EnterScope
private void EnterScope(WriterState newState, ODataItem item)
{
this.InterceptException(() => this.ValidateTransition(newState));
// If the parent scope was marked for skipping content, the new child scope should be as well.
bool skipWriting = this.SkipWriting;
Scope currentScope = this.CurrentScope;
// When writing a navigation link, check if the link is being projected.
// If we are projecting properties, but the nav. link is not projected mark it to skip its content.
if (currentScope.State == WriterState.Entry && newState == WriterState.NavigationLink && !skipWriting)
{
Debug.Assert(currentScope.Item is ODataEntry, "If the current state is Entry the current Item must be entry as well (and not null either).");
Debug.Assert(item is ODataNavigationLink, "If the new state is NavigationLink the new item must be a navigation link as well (and not null either).");
ProjectedPropertiesAnnotation projectedProperties = currentScope.Item.GetAnnotation<ProjectedPropertiesAnnotation>();
ODataNavigationLink navigationLink = (ODataNavigationLink)item;
skipWriting = projectedProperties.ShouldSkipProperty(navigationLink.Name);
}
else if (currentScope.State == WriterState.Feed && newState == WriterState.Entry)
{
// When we're entering an entry scope on a feed, increment the count of entries on that feed.
((FeedScope)currentScope).EntryCount++;
}
this.PushScope(newState, item, skipWriting);
}
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:28,代码来源:ODataWriterCore.cs
示例17: EnterScope
/// <summary>
/// Enter a new writer scope; verifies that the transition from the current state into new state is valid
/// and attaches the item to the new scope.
/// </summary>
/// <param name="newState">The writer state to transition into.</param>
/// <param name="item">The item to associate with the new scope.</param>
private void EnterScope(WriterState newState, ODataItem item)
{
Debug.Assert(item != null, "item != null");
this.InterceptException(() => this.ValidateTransition(newState));
Scope currentScope = this.CurrentScope;
IEdmNavigationSource navigationSource = null;
IEdmEntityType entityType = null;
SelectedPropertiesNode selectedProperties = currentScope.SelectedProperties;
ODataUri odataUri = currentScope.ODataUri.Clone();
if (newState == WriterState.DeltaEntry || newState == WriterState.DeltaDeletedEntry ||
newState == WriterState.DeltaLink || newState == WriterState.DeltaDeletedLink ||
newState == WriterState.DeltaFeed)
{
navigationSource = currentScope.NavigationSource;
entityType = currentScope.EntityType;
}
WriterState currentState = currentScope.State;
if ((newState == WriterState.DeltaEntry || newState == WriterState.DeltaDeletedEntry ||
newState == WriterState.DeltaLink || newState == WriterState.DeltaDeletedLink) &&
currentState == WriterState.DeltaFeed)
{
this.CurrentDeltaFeedScope.EntryAndLinkCount++;
}
this.PushScope(newState, item, navigationSource, entityType, selectedProperties, odataUri);
}
开发者ID:spawnadv,项目名称:msgraphodata.net,代码行数:38,代码来源:ODataJsonLightDeltaWriter.cs
示例18: 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
示例19: CreateDeltaLinkScope
/// <summary>
/// Create a new delta link scope.
/// </summary>
/// <param name="state">The writer state of the scope to create.</param>
/// <param name="link">The link for the new scope.</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 feed to be written (or null if the entity set base type should be used).</param>
/// <param name="selectedProperties">The selected properties of this scope.</param>
/// <param name="odataUri">The ODataUri info of this scope.</param>
/// <returns>The newly create scope.</returns>
private DeltaLinkScope CreateDeltaLinkScope(WriterState state, ODataItem link, IEdmNavigationSource navigationSource, IEdmEntityType entityType, SelectedPropertiesNode selectedProperties, ODataUri odataUri)
{
return new JsonLightDeltaLinkScope(
state,
link,
this.GetLinkSerializationInfo(link),
navigationSource,
entityType,
this.jsonLightOutputContext.MessageWriterSettings.WriterBehavior,
selectedProperties,
odataUri);
}
开发者ID:spawnadv,项目名称:msgraphodata.net,代码行数:22,代码来源:ODataJsonLightDeltaWriter.cs
示例20: PushScope
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);
}
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:38,代码来源:ODataWriterCore.cs
注:本文中的WriterState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论