Esempio n. 1
0
        /// <summary>
        /// Set the member's instances value
        /// </summary>
        /// <returns></returns>
        public static object GetMemberValue(this object instance, string propertyName)
        {
            var member = ReflectionCache.Get(instance.GetType()).GetMember(propertyName);

            if (member == null)
            {
                return(null);
            }

            if (member is MethodInfo)
            {
                return(((MethodInfo)member).Invoke(instance, null));
            }
            if (member is PropertyInfo)
            {
                return(((PropertyInfo)member).GetValue(instance, null));
            }

            return(((FieldInfo)member).GetValue(instance));
        }
Esempio n. 2
0
 /// <summary>
 /// Get Member
 /// </summary>
 /// <param name="t"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public static MemberInfo GetRuntimeMember(this Type t, string name)
 {
     return(ReflectionCache.Get(t).GetMember(name));
 }
Esempio n. 3
0
 /// <summary>
 /// Get all Members
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public static MemberInfo[] GetRuntimeMembers(this Type t)
 {
     return(ReflectionCache.Get(t).Members);
 }