/// <summary> /// Enables the override of a method(WARNING: The method needs to have been overridden atleast once!) /// </summary> /// <param name="method">The original method that was overridden</param> /// <returns>If the override was enabled successfully</returns> public static bool EnableOverride(MethodInfo method) { // Set the variables OverrideWrapper wrapper = OverrideManager.Overrides.First(a => a.Value.Original == method).Value; // Do the checks return(wrapper != null && wrapper.Override()); }
/// <summary> /// Loads override information for method /// </summary> /// <param name="method">Method to override another</param> public static void LoadOverride(MethodInfo method) { // Get attribute related variables OverrideAttribute attribute = (OverrideAttribute)Attribute.GetCustomAttribute(method, typeof(OverrideAttribute)); // Check if method has been overrided before if (Overrides.Count(a => a.Key.Method == attribute.Method) > 0) { return; } // Create wrapper for override OverrideWrapper wrapper = new OverrideWrapper(attribute.Method, method, attribute); // Override wrapper.Override(); // Add override to the list Overrides.Add(attribute, wrapper); }