Пример #1
0
        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            result = null;
            int index = (int)indexes[0];
            var value = this.TheObject[index];

            result = new LookingGlass(value);
            return(true);
        }
Пример #2
0
        public virtual bool TryInvokeMember(string name, object[] args, out object result)
        {
            result = null;
            var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod;
            var value = this.TheObjectType.InvokeMember(name, flags, Type.DefaultBinder, this.TheObject, args);

            if (value != null)
            {
                result = new LookingGlass(value);
            }
            return(true);
        }
Пример #3
0
        public virtual bool TryGetMember(string name, out object result)
        {
            result = null;

            var field = GetField(name);

            if (field != null)
            {
                var value = field.GetValue(this.TheObject);
                result = new LookingGlass(value);
                return(true);
            }

            var prop = GetProperty(name);

            if (prop != null)
            {
                var value = prop.GetValue(this.TheObject, null);
                result = new LookingGlass(value);
                return(true);
            }

            return(false);
        }