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


C# GetMemberBinder.IsNull方法代码示例

本文整理汇总了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);
        }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:90,代码来源:DynaXmlBuilder.cs


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