Beispiel #1
0
        /// <summary>
        /// 设置当前对象上指定名称的成员的值。
        /// </summary>
        /// <param name="instance">对象实例。</param>
        /// <param name="name">成员名称。</param>
        /// <param name="value">要设置的值。</param>
        /// <param name="ignoreCase">指定是否忽略成员名称的大小写。</param>
        public static void SetValue(this INamedAccessable instance, string name, object value, bool ignoreCase = false)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            var proxy = TypeProxy.GetProxy(instance.GetType());

            proxy.SetValue(instance, name, value, ignoreCase);
        }
Beispiel #2
0
        /// <summary>
        /// 调用当前对象上指定名称的方法。
        /// </summary>
        /// <param name="instance">对象实例。</param>
        /// <param name="name">成员名称。</param>
        /// <param name="ignoreCase">指定是否忽略成员名称的大小写。</param>
        /// <param name="args">调用方法时传入的参数列表。</param>
        /// <returns>返回该方法调用的返回结果。</returns>
        public static object Invoke(this INamedAccessable instance, string name, bool ignoreCase = false, params object[] args)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            var proxy = TypeProxy.GetProxy(instance.GetType());

            return(proxy.Invoke(instance, name, ignoreCase, args));
        }
Beispiel #3
0
        /// <summary>
        /// 判断对象是否具有指定名称的成员。
        /// </summary>
        /// <param name="instance">被搜索的对象。</param>
        /// <param name="name">要搜索的成员名称。</param>
        /// <param name="binding">指定搜索对象中那些类型的成员。</param>
        /// <param name="ignoreCase">指定是否忽略成员名称的大小写。</param>
        /// <returns>如果对象中指定类型的成员中存在指定名称的成员,返回 true;否则返回 false。</returns>
        public static object Contains(this INamedAccessable instance, string name, MemberTypeBinding binding = MemberTypeBinding.All, bool ignoreCase = false)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            var proxy = TypeProxy.GetProxy(instance.GetType());

            return(proxy.Contains(name, binding, ignoreCase));
        }
Beispiel #4
0
            internal DataMemberCollection(SimpleDataObject owner)
            {
                if (owner == null)
                {
                    throw new ArgumentNullException("owner");
                }
                var proxy = TypeProxy.GetProxy(owner.GetType());

                members = proxy.GetMemberNames(MemberTypeBinding.DataMember).Select(name => new DataMember {
                    Name = name, Type = proxy.GetDeclarationMemberType(name), Value = proxy.GetValue(owner, name)
                });
            }