Пример #1
0
 public IEnumerator <KeyValuePair <MemberInfo, object> > GetEnumerator()
 {
     foreach (var a in ReflectionTool.FieldsAndPropertiesOf(target.GetType()))
     {
         yield return(new KeyValuePair <MemberInfo, object>(a, ReflectionTool.GetMemberValue(a, target)));
     }
 }
Пример #2
0
 IEnumerator <KeyValuePair <string, object> > IEnumerable <KeyValuePair <string, object> > .GetEnumerator()
 {
     foreach (var a in ReflectionTool.FieldsAndPropertiesOf(target.GetType()))
     {
         yield return(new KeyValuePair <string, object>(a.Name, ReflectionTool.GetMemberValue(a, target)));
     }
 }
Пример #3
0
 public object this[MemberInfo key] {
     get {
         return(ReflectionTool.GetMemberValue(key, target));
     }
     set {
         ReflectionTool.SetMemberValue(key, target, value);
     }
 }
Пример #4
0
 public object this[KeyValuePair <MemberInfo, object> key] {
     get {
         return(ReflectionTool.GetMemberValue(key.Key, target));
     }
     set {
         ReflectionTool.SetMemberValue(key.Key, target, value);
     }
 }
Пример #5
0
 public bool TryGetValue(string key, out object value)
 {
     if (ContainsKey(key))
     {
         value = ReflectionTool.GetValue(target, key);
         return(true);
     }
     value = null;
     return(false);
 }
Пример #6
0
        public static IEnumerable <MemberInfo> AttributedMembersWhere <T>(this Type type, Func <MemberInfo, T, bool> act) where T : Attribute
        {
            var members = ReflectionTool.FieldsAndPropertiesOf(type);

            if (act == null)
            {
                return(new List <MemberInfo>());
            }
            return(members.Where(m => {
                var vatt = m.GetCustomAttribute <T>();
                return vatt != null && act.Invoke(m, vatt);
            }));
        }
Пример #7
0
 public object this[String key] {
     get {
         if (target is IDictionary <String, object> )
         {
             var t = (IDictionary <String, object>)target;
             if (t.ContainsKey(key))
             {
                 return(((Dictionary <String, object>)target)[key]);
             }
         }
         return(ReflectionTool.GetValue(target, key));
     }
     set {
         if (target is IDictionary <String, object> )
         {
             var t = (IDictionary <String, object>)target;
             ((IDictionary <String, object>)target)[key] = value;
             return;
         }
         ReflectionTool.SetValue(target, key, value);
     }
 }
Пример #8
0
 private void RefreshKeysAndValues()
 {
     keys   = ReflectionTool.FieldsAndPropertiesOf(target.GetType()).Select(x => x.Name).ToArray();
     values = ReflectionTool.FieldsAndPropertiesOf(target.GetType()).Select(x => ReflectionTool.GetMemberValue(x, target)).ToArray();
 }
Пример #9
0
 public static MemberInfo[] GetFieldsAndProperties(this Type t)
 {
     return(ReflectionTool.FieldsAndPropertiesOf(t));
 }
Пример #10
0
 public static bool DerivesFromGeneric(this Type t, Type ancestorType)
 {
     return(ReflectionTool.TypeDerivesFromGeneric(t, ancestorType));
 }
Пример #11
0
 public static bool Implements(this Type t, Type interfaceType)
 {
     return(ReflectionTool.TypeImplements(t, interfaceType));
 }