public override MetaObject BindGetMember(GetMemberBinder binder) {
            if (_lib.HasMember(binder.Name)) {
                Restrictions restrictions =
                    Restrictions.GetTypeRestriction(
                        Expression, typeof(ComTypeLibDesc)
                    ).Merge(
                        Restrictions.GetExpressionRestriction(
                            Expression.Equal(
                                Expression.Property(
                                    AstUtils.Convert(
                                        Expression, typeof(ComTypeLibDesc)
                                    ),
                                    typeof(ComTypeLibDesc).GetProperty("Guid")
                                ),
                                Expression.Constant(_lib.Guid)
                            )
                        )
                    );

                return new MetaObject(
                    Expression.Constant(
                        ((ComTypeLibDesc)Value).GetTypeLibObjectDesc(binder.Name)
                    ),
                    restrictions
                );
            }

            return base.BindGetMember(binder);
        }
Beispiel #2
0
 public static bool TryBindGetMember(GetMemberBinder binder, ref MetaObject instance) {
     if (TryGetMetaObject(ref instance)) {
         instance = instance.BindGetMember(binder);
         return true;
     }
     return false;
 }
        public override MetaObject BindGetMember(GetMemberBinder binder) {
            if (_desc.HasMember(binder.Name)) {
                return new MetaObject(
                    // return (.bound $arg0).GetValue("<name>")
                    Expression.Constant(((ComTypeEnumDesc)Value).GetValue(binder.Name)),
                    EnumRestrictions()
                );
            }

            throw new NotImplementedException();
        }
        public override MetaObject 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 MetaObject(
                Expression.Property(
                    AstUtils.Convert(Expression, typeof(ComTypeLibInfo)),
                    typeof(ComTypeLibInfo).GetProperty(name)
                ),
                ComTypeLibInfoRestrictions(this)
            );
        }
        public override MetaObject BindGetMember(GetMemberBinder binder) {
            ContractUtils.RequiresNotNull(binder, "binder");

            ComMethodDesc method;
            ComEventDesc @event;

            // 1. Try methods
            if (_self.TryGetMemberMethod(binder.Name, out method)) {
                return BindGetMember(method);
            }

            // 2. Try events
            if (_self.TryGetMemberEvent(binder.Name, out @event)) {
                return BindEvent(@event);
            }

            // 3. Try methods explicitly by name
            if (_self.TryGetMemberMethodExplicit(binder.Name, out method)) {
                return BindGetMember(method);
            }

            // 4. Fallback
            return base.BindGetMember(binder);
        }
 public override MetaObject BindGetMember(GetMemberBinder binder) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackGetMember(UnwrapSelf());
 }
Beispiel #7
0
            public override MetaObject BindGetMember(GetMemberBinder binder) {
                ContractUtils.RequiresNotNull(binder, "binder");

                ExpandoClass klass = Value.Class;

                int index = klass.GetValueIndex(binder.Name, binder.IgnoreCase);
                string methodName = binder.IgnoreCase ? "ExpandoGetValueIgnoreCase" : "ExpandoGetValue";

                Expression target;
                if (index == -1) {
                    // the key does not exist, report a MissingMemberException
                    target = Expression.Convert(
                        Expression.Throw(
                            Expression.New(
                                typeof(MissingMemberException).GetConstructor(new Type[] { typeof(string) }),
                                Expression.Constant(binder.Name)
                            )
                        ),
                        typeof(object)                        
                    );
                } else {
                    target = Expression.Call(
                        typeof(RuntimeOps).GetMethod(methodName),
                        GetLimitedSelf(),
                        Expression.Constant(klass),
                        Expression.Constant(index)
                    );
                }

                // add the dynamic test for the target
                return new MetaObject(
                    AddDynamicTestAndDefer(
                        binder,
                        new MetaObject[] { this },
                        klass,
                        null,
                        target
                    ),
                    GetRestrictions()
                );
            }
Beispiel #8
0
 public override MetaObject/*!*/ BindGetMember(GetMemberBinder/*!*/ binder) {
     var self = (RubyClass)Value;
     return RubyGetMemberBinder.TryBind(self.Context, binder, this) ?? binder.FallbackGetMember(this);
 }
Beispiel #9
0
 public virtual bool TryGetMember(GetMemberBinder binder, out object result) {
     throw new NotSupportedException();
 }
Beispiel #10
0
            public override MetaObject BindGetMember(GetMemberBinder binder) {
                if (IsOverridden("TryGetMember")) {
                    return CallMethodWithResult("TryGetMember", binder, NoArgs, (e) => binder.FallbackGetMember(this, e));
                }

                return base.BindGetMember(binder);
            }
Beispiel #11
0
 public virtual MetaObject BindGetMember(GetMemberBinder binder) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackGetMember(this);
 }