Example #1
0
 /// <summary>
 /// Unregisters all the methods marked with an MDCommand of the given type
 /// </summary>
 /// <param name="ObjType">The type</param>
 /// <param name="Instance">The object to unregister for</param>
 public static void UnregisterCommandAttributes(Type ObjType, object Instance = null)
 {
     MethodInfo[] Methods = ObjType.GetMethods();
     foreach (MethodInfo Method in Methods)
     {
         MDCommand CmdAttr = Method.GetCustomAttribute(typeof(MDCommand)) as MDCommand;
         if (CmdAttr != null)
         {
             UnregisterCommand(Instance, Method);
         }
     }
 }
Example #2
0
        /// <summary>
        /// Registers all the methods marked with an MDCommand of the given type
        /// </summary>
        /// <param name="ObjType">The type</param>
        /// <param name="Instance">The object to register for</param>
        public static void RegisterCommandAttributes(Type ObjType, object Instance = null)
        {
            List <MethodInfo> Methods = ObjType.GetMethodInfos();

            foreach (MethodInfo Method in Methods)
            {
                MDCommand CmdAttr = Method.GetCustomAttribute(typeof(MDCommand)) as MDCommand;
                if (CmdAttr != null)
                {
                    RegisterCommand(Instance, Method, CmdAttr.DefaultArgs);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Unregisters all the methods marked with an MDCommand of the given type
        /// </summary>
        /// <param name="ObjType">The type</param>
        /// <param name="Instance">The object to unregister for</param>
        public static void UnregisterCommandAttributes(Type ObjType, object Instance = null)
        {
            if (MDStatics.IsInGodotNamespace(ObjType))
            {
                return;
            }
            IList <MethodInfo> Methods = ObjType.GetMethodInfos();

            foreach (MethodInfo Method in Methods)
            {
                MDCommand CmdAttr = MDReflectionCache.GetCustomAttribute <MDCommand>(Method) as MDCommand;
                if (CmdAttr != null)
                {
                    UnregisterCommand(Instance, Method);
                }
            }
        }