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))); } }
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))); } }
public object this[MemberInfo key] { get { return(ReflectionTool.GetMemberValue(key, target)); } set { ReflectionTool.SetMemberValue(key, target, value); } }
public object this[KeyValuePair <MemberInfo, object> key] { get { return(ReflectionTool.GetMemberValue(key.Key, target)); } set { ReflectionTool.SetMemberValue(key.Key, target, value); } }
public bool TryGetValue(string key, out object value) { if (ContainsKey(key)) { value = ReflectionTool.GetValue(target, key); return(true); } value = null; return(false); }
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); })); }
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); } }
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(); }
public static MemberInfo[] GetFieldsAndProperties(this Type t) { return(ReflectionTool.FieldsAndPropertiesOf(t)); }
public static bool DerivesFromGeneric(this Type t, Type ancestorType) { return(ReflectionTool.TypeDerivesFromGeneric(t, ancestorType)); }
public static bool Implements(this Type t, Type interfaceType) { return(ReflectionTool.TypeImplements(t, interfaceType)); }