本文整理汇总了C#中System.Dynamic.GetMemberBinder.IsNull方法的典型用法代码示例。如果您正苦于以下问题:C# GetMemberBinder.IsNull方法的具体用法?C# GetMemberBinder.IsNull怎么用?C# GetMemberBinder.IsNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Dynamic.GetMemberBinder
的用法示例。
在下文中一共展示了GetMemberBinder.IsNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetMember
/// <inheritdoc />
/// This method handles property gets.
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
// A binder must have been supplied, the runtime will always do this.
if (binder.IsNull())
{
throw new ArgumentNullException("binder");
}
// This is an "interface flowing" construct, so the result is always this.
result = this;
// Starts a Literal block
if (binder.Name == "l" && !this.IsLiteratState)
{
switch (this.State)
{
// If we are in an Attribute List builder, we push state.
case DynaXmlBuilderState.AttributeListBuilder:
this.context.PushState(DynaXmlBuilderState.LiteralAttributeBuilder);
break;
// If we are in a single attribute builder we change state (so the pop takes
// us out of the attribute building)
case DynaXmlBuilderState.AttributeBuilder:
this.context.ChangeState(DynaXmlBuilderState.LiteralAttributeBuilder);
break;
// If we are in an Element or an Element List builder we push state.
case DynaXmlBuilderState.ElementListBuilder:
this.context.PushState(DynaXmlBuilderState.LiteralElementBuilder);
break;
}
return true;
}
// Starts an Attribute block which allows for an attribute to be added.
if (binder.Name == "at" && !this.IsLiteratState)
{
this.context.PushState(DynaXmlBuilderState.AttributeBuilder);
return true;
}
if (binder.Name == "xmlns" && !this.IsLiteratState)
{
this.context.PushState(DynaXmlBuilderState.NamespaceBuilder);
return true;
}
// Starts a list (which is multiple elements or attributes in a row)
if (binder.Name == "b")
{
if (this.State == DynaXmlBuilderState.ElementListBuilder)
{
// Enter a child list of the parent.
this.context.PushState(DynaXmlBuilderState.ElementListBuilder);
return true;
}
if (this.State == DynaXmlBuilderState.AttributeBuilder)
{
// Change state to attribute list builder.
this.context.ChangeState(DynaXmlBuilderState.AttributeListBuilder);
return true;
}
}
// Ends a list (multiple elements or attributes in a row).
if (binder.Name == "d" &&
(this.State == DynaXmlBuilderState.ElementListBuilder ||
this.State == DynaXmlBuilderState.AttributeListBuilder))
{
this.context.Pop();
return true;
}
switch (this.State)
{
case DynaXmlBuilderState.NamespaceBuilder:
return this.NamespaceBuilderGetMember(binder.Name);
case DynaXmlBuilderState.ElementListBuilder:
case DynaXmlBuilderState.LiteralElementBuilder:
return this.ElementBuilderGetMember(binder.Name);
case DynaXmlBuilderState.AttributeBuilder:
case DynaXmlBuilderState.LiteralAttributeBuilder:
case DynaXmlBuilderState.AttributeListBuilder:
return this.AttributeBuilderGetMember(binder.Name);
}
// Otherwise call into base.
// Base currently does nothing (but returns false and fails), but a new class could be interposed.
return base.TryGetMember(binder, out result);
}