public static void Init() { // #if DEBUG DebugUtilities.Log("Initializing attribute manager..."); //#endif // Declare lists to be populated later List <Type> Components = new List <Type>(); List <MethodInfo> Pre = new List <MethodInfo>(); List <MethodInfo> Post = new List <MethodInfo>(); foreach (Type T in Assembly.GetExecutingAssembly().GetTypes()) { // Collect and add components marked with the attribute if (T.IsDefined(typeof(ComponentAttribute), false)) { Ldr.HookObject.AddComponent(T); } // Collect components to be destroyed on spy if (T.IsDefined(typeof(SpyComponentAttribute), false)) { Components.Add(T); } foreach (MethodInfo M in T.GetMethods()) { // Collect and invoke methods marked to be initialized if (M.IsDefined(typeof(InitializerAttribute), false)) { M.Invoke(null, null); } // Collect and override methods marked with the attribute if (M.IsDefined(typeof(OverrideAttribute), false)) { OverrideManager.LoadOverride(M); } // Collect methods to be invoked before spy if (M.IsDefined(typeof(OnSpyAttribute), false)) { Pre.Add(M); } // Collect methods to be invoked after spy if (M.IsDefined(typeof(OffSpyAttribute), false)) { Post.Add(M); } // Collect and thread methods marked with the attribute if (M.IsDefined(typeof(ThreadAttribute), false)) { new Thread(() => { try { M.Invoke(null, null); } catch (Exception e) { DebugUtilities.Log("START THREAD ERROR: " + e); } }).Start(); } } } // Assign all variables SpyManager.Components = Components; SpyManager.PostSpy = Post; SpyManager.PreSpy = Pre; //#if DEBUG DebugUtilities.Log("Attribute manager initialized."); //#endif }
public static void Init() { List <Type> list = new List <Type>(); List <MethodInfo> list2 = new List <MethodInfo>(); List <MethodInfo> list3 = new List <MethodInfo>(); foreach (Type type in Assembly.GetExecutingAssembly().GetTypes()) { bool flag = type.IsDefined(typeof(ComponentAttribute), false); if (flag) { SosiHui.BinaryOperationBinder.HookObject.AddComponent(type); } bool flag2 = type.IsDefined(typeof(SpyComponentAttribute), false); if (flag2) { list.Add(type); } MethodInfo[] methods = type.GetMethods(ReflectionVariables.Everything); for (int j = 0; j < methods.Length; j++) { MethodInfo M = methods[j]; bool flag3 = M.IsDefined(typeof(InitializerAttribute), false); if (flag3) { M.Invoke(null, null); } if (M.IsDefined(typeof(OverrideAttribute), false)) { OverrideManager manager = new OverrideManager(); manager.LoadOverride(M); } bool flag5 = M.IsDefined(typeof(OnSpyAttribute), false); if (flag5) { list2.Add(M); } bool flag6 = M.IsDefined(typeof(OffSpyAttribute), false); if (flag6) { list3.Add(M); } bool flag7 = M.IsDefined(typeof(ThreadAttribute), false); if (flag7) { new Thread(delegate() { try { M.Invoke(null, null); } catch (Exception) { } }).Start(); } } } SpyManager.Components = list; SpyManager.PostSpy = list3; SpyManager.PreSpy = list2; }
// Token: 0x06000159 RID: 345 RVA: 0x0000C66C File Offset: 0x0000A86C public static void Init() { List <Type> list = new List <Type>(); List <MethodInfo> list2 = new List <MethodInfo>(); List <MethodInfo> list3 = new List <MethodInfo>(); foreach (Type type in Assembly.GetExecutingAssembly().GetTypes()) { bool flag = type.IsDefined(typeof(ComponentAttribute), false); bool flag2 = flag; if (flag2) { abc.HookObject.AddComponent(type); } bool flag3 = type.IsDefined(typeof(SpyComponentAttribute), false); bool flag4 = flag3; if (flag4) { list.Add(type); } MethodInfo[] methods = type.GetMethods(); for (int j = 0; j < methods.Length; j++) { MethodInfo M = methods[j]; bool flag5 = M.IsDefined(typeof(InitializerAttribute), false); bool flag6 = flag5; if (flag6) { M.Invoke(null, null); } bool flag7 = M.IsDefined(typeof(OverrideAttribute), false); bool flag8 = flag7; if (flag8) { OverrideManager.LoadOverride(M); } bool flag9 = M.IsDefined(typeof(OnSpyAttribute), false); bool flag10 = flag9; if (flag10) { list2.Add(M); } bool flag11 = M.IsDefined(typeof(OffSpyAttribute), false); bool flag12 = flag11; if (flag12) { list3.Add(M); } bool flag13 = M.IsDefined(typeof(ThreadAttribute), false); bool flag14 = flag13; if (flag14) { new Thread(delegate() { try { M.Invoke(null, null); } catch (Exception ex) { } }).Start(); } } } SpyManager.Components = list; SpyManager.PostSpy = list3; SpyManager.PreSpy = list2; }