Ejemplo n.º 1
0
        protected void RegisterCommonCommands(Assembly InAssembly)
        {
            var TestAssembly = InAssembly;

            Type[] Types = TestAssembly.GetTypes();

            for (int ti = 0; Types != null && ti < Types.Length; ++ti)
            {
                var t = Types[ti];

                object[] Attributes = t.GetCustomAttributes(typeof(CheatCommandAttribute), true);

                if (Attributes != null)
                {
                    for (int i = 0; i < Attributes.Length; ++i)
                    {
                        // test in this type
                        CheatCommandAttribute Attr = Attributes[i] as CheatCommandAttribute;

                        if (Attr != null)
                        {
                            OnFoundClass(Attr.ID, t);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void OnFoundClass(string InID, Type InType)
        {
            CheatCommandAttribute Attribute = InType.GetCustomAttributes(typeof(CheatCommandAttribute), false)[0] as CheatCommandAttribute;

            DebugHelper.Assert(Attribute != null);

            ICheatCommand CommandHandler = Activator.CreateInstance(InType) as ICheatCommand;

            DebugHelper.Assert(CommandHandler != null);

            CommandRepositories.Add(CommandHandler);

            CheatCommandsRepository.instance.RegisterCommand(CommandHandler);
        }
Ejemplo n.º 3
0
        protected void CacheAttribute()
        {
            var Attributes = GetType().GetCustomAttributes(typeof(CheatCommandAttribute), false);

            DebugHelper.Assert(Attributes != null && Attributes.Length > 0);

            CachedAttribute = Attributes[0] as CheatCommandAttribute;

            DebugHelper.Assert(CachedAttribute != null);

            if (CachedAttribute != null)
            {
                Attributes = GetType().GetCustomAttributes(typeof(ArgumentDescriptionAttribute), false);

                if (Attributes != null)
                {
                    CachedAttribute.IndependentInitialize(Attributes);
                }
            }
        }