private static ObservedMethod addNewObserverMethod(MethodObserver objObserver, MethodInfo method) { ObservedMethod om = new ObservedMethod(); om.Method = method; om.Observer = new List <MethodObserver>(); om.Observer.Add(objObserver); return(om); }
private static void addType(Dictionary <Type, ObservedType> results, MethodObserver obj) { Dictionary <Type, String> dic = obj.GetRelatedMethods(); foreach (KeyValuePair <Type, String> kv in dic) { List <MethodInfo> methods = getMethods(kv.Value, kv.Key); foreach (MethodInfo method in methods) { addTypeSingle(results, obj, kv.Key, method); } } }
private static void addObserverToMethodSingle(ObservedMethod m, MethodObserver obj) { if (m.Observer == null) { m.Observer = new List <MethodObserver>(); } if (m.Observer.Contains(obj)) { return; } m.Observer.Add(obj); }
private static void addTypeSingle(Dictionary <Type, ObservedType> results, MethodObserver obj, Type t, MethodInfo method) { ObservedType oType; results.TryGetValue(t, out oType); if (oType == null) { oType = new ObservedType(); } oType.Type = t; populateMethodList(oType, obj, method); results[t] = oType; }
private static void populateMethodList(ObservedType oType, MethodObserver obj, MethodInfo method) { if (oType.MethodList == null) { oType.MethodList = new List <ObservedMethod>(); } if (hasAddMethod(oType, method)) { oType.MethodList = addObserverToMethodList(oType.MethodList, method, obj); } else { ObservedMethod om = addNewObserverMethod(obj, method); om.ObservedType = oType; oType.MethodList.Add(om); } }
private static Dictionary <Type, ObservedType> loadObservers() { Dictionary <Type, ObservedType> results = new Dictionary <Type, ObservedType>(); Dictionary <String, Type> typeList = ObjectContext.Instance.TypeList; foreach (KeyValuePair <String, Type> kv in typeList) { Type type = kv.Value; if (type.IsSubclassOf(typeof(MethodObserver))) { MethodObserver obj = rft.GetInstance(type) as MethodObserver; addType(results, obj); } } return(results); }
private static String getObserverCreator( MethodObserver os ) { return string.Format( "{0}.Create<{1}>()", typeof( ObjectContext ).FullName, os.GetType().FullName ); }
private static List <ObservedMethod> addObserverToMethodList(List <ObservedMethod> list, MethodInfo method, MethodObserver obj) { foreach (ObservedMethod m in list) { if (m.Method == method) { addObserverToMethodSingle(m, obj); } } return(list); }
private static String getObserverCreator(MethodObserver os) { return(string.Format("{0}.Create<{1}>()", typeof(ObjectContext).FullName, os.GetType().FullName)); }