public static bool EnableOverride(MethodInfo method)
    {
        OverrideManager manager = new OverrideManager();
        OverrideWrapper value   = manager.Overrides.First((KeyValuePair <OverrideAttribute, OverrideWrapper> a) => a.Value.Original == method).Value;

        return(value != null && value.Override());
    }
Esempio n. 2
0
        /// <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());
        }
Esempio n. 3
0
    public void LoadOverride(MethodInfo method)
    {
        OverrideAttribute attribute = (OverrideAttribute)Attribute.GetCustomAttribute(method, typeof(OverrideAttribute));
        bool flag = Overrides.Count((KeyValuePair <OverrideAttribute, OverrideWrapper> a) => a.Key.Method == attribute.Method) > 0;

        if (!flag)
        {
            OverrideWrapper overrideWrapper = new OverrideWrapper(attribute.Method, method, attribute, null);
            overrideWrapper.Override();
            Overrides.Add(attribute, overrideWrapper);
        }
    }
Esempio n. 4
0
        /// <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);
        }