當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。