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


C# GetMemberBinder.FallbackGetMember方法代码示例

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


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

示例1: BindGetMember

            public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
                var binderDefault = binder.FallbackGetMember(this);

                var expression = Expression.Convert(GetMemberAccessExpression(binder.Name), typeof(object));

                var dynamicSuggestion = new DynamicMetaObject(expression, BindingRestrictions.GetTypeRestriction(Expression, LimitType)
                                                                                             .Merge(binderDefault.Restrictions));

                return binder.FallbackGetMember(this, dynamicSuggestion);
            }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:10,代码来源:DynamicWrapper.cs

示例2: BindGetMember

        public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
            ContractUtils.RequiresNotNull(binder, "binder");
            string name = binder.Name;

            if (name == _info.Name) {
                name = "TypeLibDesc";
            } else if (name != "Guid" &&
                name != "Name" &&
                name != "VersionMajor" &&
                name != "VersionMinor") {

                return binder.FallbackGetMember(this);
            }

            return new DynamicMetaObject(
                Expression.Convert(
                    Expression.Property(
                        AstUtils.Convert(Expression, typeof(ComTypeLibInfo)),
                        typeof(ComTypeLibInfo).GetProperty(name)
                    ),
                    typeof(object)
                ),
                ComTypeLibInfoRestrictions(this)
            );
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:25,代码来源:TypeLibInfoMetaObject.cs

示例3: BindGetMember

 public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackGetMember(UnwrapSelf());
 }
开发者ID:jschementi,项目名称:iron,代码行数:4,代码来源:ComFallbackMetaObject.cs

示例4: BindGetMember

            public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
                if (IsOverridden("TryGetMember")) {
                    return CallMethodWithResult("TryGetMember", binder, NoArgs, (e) => binder.FallbackGetMember(this, e));
                }

                return base.BindGetMember(binder);
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:DynamicObject.cs

示例5: BindGetMember

 public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
     var flags = BindingFlags.IgnoreCase | BindingFlags.Static | 
                 BindingFlags.Public;
     // consider BindingFlags.Instance if want to return wrapper for
     // inst members that is callable.
     var members = ReflType.GetMember(binder.Name, flags);
     if (members.Length == 1) {
         return new DynamicMetaObject(
             // We always access static members for type model objects, so the
             // first argument in MakeMemberAccess should be null.
             RuntimeHelpers.EnsureObjectResult(
                 Expression.MakeMemberAccess(
                     null,
                     members[0])),
             // Don't need restriction test for name since this
             // rule is only used where binder is used, which is
             // only used in sites with this binder.Name.
             this.Restrictions.Merge(
                 BindingRestrictions.GetInstanceRestriction(
                     this.Expression,
                     this.Value)
             )
         );
     } else {
         return binder.FallbackGetMember(this);
     }
 }
开发者ID:TerabyteX,项目名称:main,代码行数:27,代码来源:Sympl.cs

示例6: BindGetMember

 /// <summary>
 /// Performs the binding of the dynamic get member operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="GetMemberBinder"/> that represents the details of the dynamic operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindGetMember(GetMemberBinder binder) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackGetMember(this);
 }
开发者ID:joshholmes,项目名称:ironruby,代码行数:9,代码来源:DynamicMetaObject.cs

示例7: BindGetMember

 public override DynamicMetaObject/*!*/ BindGetMember(GetMemberBinder/*!*/ binder) {
     var self = (IRubyObject)Value;
     return RubyGetMemberBinder.TryBind(self.Class.Context, binder, this) ?? binder.FallbackGetMember(this);
 }
开发者ID:joshholmes,项目名称:ironruby,代码行数:4,代码来源:RubyObject.Meta.cs

示例8: BindGetMember

            public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
            {
                var prop = _type.GetProperty(binder.Name);

                if (prop != null && prop.Methods != null && prop.CompiledMethods == null)
                    prop.CompiledMethods = _type.MakeCompileMethods(binder.Name);

                if (prop != null && prop.CompiledMethods != null)
                {
                    var ret = prop.CompiledMethods(this);
                    if (ret != null)
                        return ret;
                }

                if (prop != null && prop.Getters != null)
                {
                    foreach (var getter in prop.Getters)
                    {
                        var ret = getter(this);
                        if (ret != null)
                        {
                            return ret;
                        }
                    }
                }

                ITotemProperty totemProp;
                if(_type._customProperties.TryGetValue(binder.Name, out totemProp))
                {
                    return new DynamicMetaObject(
                        AstUtils.SimpleCallHelper(
                            Expression.Constant(totemProp, typeof(ITotemProperty)),
                            typeof(ITotemProperty).GetMethod("Get"),
                            Expression
                        ),
                        BindingRestrictions.GetTypeRestriction(Expression, LimitType)
                    );
                }

                DynamicMetaObject result;
                if (_type.HandleGetMember(binder, this, out result))
                    return result;

                var fallback = binder.FallbackGetMember(this, result);
                BindingRestrictions restrictions = fallback.Restrictions.Merge(BindingRestrictions.GetTypeRestriction(Expression, LimitType));

                return new DynamicMetaObject(
                    AssertImplemented(
                        Expression.Call(
                            Expression.Constant(_type, typeof(TotemType)),
                            TotemType.GetMissingPropertyInfo,
                            Expression,
                            Expression.Constant(binder.Name, typeof(string))
                        ),
                        fallback.Expression
                    ),
                    restrictions
                );
            }
开发者ID:Alxandr,项目名称:IronTotem,代码行数:59,代码来源:TotemType.cs

示例9: BindGetMember

            public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
                ContractUtils.RequiresNotNull(binder, "binder");
                DynamicMetaObject memberValue = GetDynamicMetaObjectForMember(
                    binder.Name, 
                    binder.IgnoreCase,
                    binder.FallbackGetMember(this)
                );

                return AddDynamicTestAndDefer(
                    binder,
                    new DynamicMetaObject[] { this },
                    Value.Class,
                    null,
                    memberValue
                );
            }
开发者ID:octavioh,项目名称:ironruby,代码行数:16,代码来源:ExpandoObject.cs

示例10: BindGetMember

 public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
 {
     return DynamicTryGetMember(binder.Name,
         binder.FallbackGetMember(this).Expression,
         (tmp) => tmp
     );
 }
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:StringDictionaryExpando.cs

示例11: typeof

            public override DynamicMetaObject BindGetMember
                    (GetMemberBinder binder)
            {
                var self = this.Expression;
                var bag = (FastNBag)base.Value;

                int index = bag.GetFastIndex(binder.Name);

                Expression target;

                // If match found in fast array:
                if (index != -1)
                {
                    // Fetch result from fast array.
                    target =
                        Expression.Call(
                            Expression.Convert(self, typeof(FastNBag)),
                            typeof(FastNBag).GetMethod("GetFastValue"),
                            Expression.Constant(index)
                        );
                }
                // Else, if no match found in fast array, but fast array is full:
                else if (bag.fastTable.Count == bag.fastCount)
                {
                    // Fetch result from dictionary.
                    var keyExpr = Expression.Constant(binder.Name);
                    var valueExpr = Expression.Variable(typeof(object));

                    var dictCheckExpr =
                        Expression.Call(
                            Expression.Convert(self, typeof(FastNBag)),
                            typeof(FastNBag).GetMethod("TryGetValue"),
                            keyExpr,
                            valueExpr
                        );
                    var dictFailExpr =
                        Expression.Block(
                            binder.FallbackGetMember(this).Expression,
                            Expression.Default(typeof(object))
                        );

                    target =
                        Expression.Block(
                            new[] { valueExpr },
                            Expression.Condition(
                                dictCheckExpr,
                                valueExpr,
                                dictFailExpr
                            )
                        );
                }
                // Else, no match found in fast array, fast array is not yet full:
                else
                {
                    // Fail binding, but only until fast array is updated.
                    var versionCheckExpr =
                        Expression.Call(
                            Expression.Convert(self, typeof(FastNBag)),
                            typeof(FastNBag).GetMethod("CheckVersion"),
                            Expression.Constant(bag.Version)
                        );
                    var versionMatchExpr =
                        binder.FallbackGetMember(this).Expression;
                    var updateExpr =
                        binder.GetUpdateExpression(versionMatchExpr.Type);

                    target =
                        Expression.Condition(
                            versionCheckExpr,
                            versionMatchExpr,
                            updateExpr
                        );
                }

                var restrictions = BindingRestrictions
                                       .GetInstanceRestriction(self, bag);

                return new DynamicMetaObject(target, restrictions);
            }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:79,代码来源:Program.cs

示例12: BindGetMember

 public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
 {
     Fallback fallback = null;
     if (!this.IsOverridden("TryGetMember"))
     {
         return base.BindGetMember(binder);
     }
     if (fallback == null)
     {
         fallback = e => binder.FallbackGetMember(this, e);
     }
     return this.CallMethodWithResult("TryGetMember", binder, NoArgs, fallback);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:DynamicObject.cs

示例13: TryGetMember

        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            if (this.UseFallbackMethod)
            {
                DynamicMetaObject target = new DynamicMetaObject(Expression.Parameter(this.GetType()), BindingRestrictions.Empty);
                DynamicMetaObject errorSuggestion = null;

                if (this.UseErrorSuggestion)
                {
                    errorSuggestion = new DynamicMetaObject(Expression.Throw(Expression.Constant(new TestDynamicObjectException())), BindingRestrictions.Empty);
                }

                DynamicMetaObject metaObj = binder.FallbackGetMember(target, errorSuggestion);
                Expression<Action> lambda = Expression.Lambda<Action>(metaObj.Expression, new ParameterExpression[] { });
                lambda.Compile().Invoke();
            }

            return _values.TryGetValue(binder.Name, out result);
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:19,代码来源:AnyInstance.cs

示例14: BindGetMember

 public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
     var tmp = Expression.Parameter(typeof(object));
     return new DynamicMetaObject(
         Expression.Block(
             new[] { tmp },
             Expression.Condition(
                 Expression.NotEqual(
                     Expression.Assign(
                         tmp,
                         Expression.Invoke(
                             Expression.Constant(new Func<object, SymbolId, object>(AttributesAdapter.TryGetMember)),
                             Expression,
                             Expression.Constant(SymbolTable.StringToId(binder.Name))
                         )
                     ),
                     Expression.Constant(_getFailed)
                 ),
                 tmp,
                 Expression.Convert(binder.FallbackGetMember(this).Expression, typeof(object))
             )
         ),
         GetRestrictions()
     );
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:24,代码来源:Scope.cs

示例15: BindGetMember

 public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
 {
     return binder.FallbackGetMember(UnwrapSelf());
 }
开发者ID:40a,项目名称:PowerShell,代码行数:4,代码来源:ComFallbackMetaObject.cs


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