Пример #1
0
        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);
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
        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;
        }
Пример #5
0
        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);
            }
        }
Пример #6
0
        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);
        }
Пример #7
0
 private static String getObserverCreator( MethodObserver os )
 {
     return string.Format( "{0}.Create<{1}>()", typeof( ObjectContext ).FullName, os.GetType().FullName );
 }
Пример #8
0
        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);
        }
Пример #9
0
 private static String getObserverCreator(MethodObserver os)
 {
     return(string.Format("{0}.Create<{1}>()", typeof(ObjectContext).FullName, os.GetType().FullName));
 }