Esempio n. 1
0
        /// <summary>
        /// </summary>
        public void AddScriptMembers()
        {
            this.scriptList.Clear();
            foreach (Assembly assembly in this.multipleDllList)
            {
                foreach (Type t in assembly.GetTypes())
                {
                    if (t.GetInterface("IAOScript") != null)
                    {
                        if (t.Name != "IAOScript")
                        {
                            foreach (MemberInfo mi in t.GetMembers())
                            {
                                if ((mi.Name == "GetType") || (mi.Name == ".ctor") || (mi.Name == "GetHashCode") ||
                                    (mi.Name == "ToString") || (mi.Name == "Equals"))
                                {
                                    continue;
                                }

                                if (mi.MemberType == MemberTypes.Method)
                                {
                                    if (!this.scriptList.ContainsKey(t.Namespace + "." + t.Name + ":" + mi.Name))
                                    {
                                        this.scriptList.Add(t.Namespace + "." + t.Name + ":" + mi.Name, t);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            this.chatCommands.Clear();
            Assembly wholeassembly = Assembly.GetExecutingAssembly();

            foreach (Type t in wholeassembly.GetTypes())
            {
                if (t.Namespace == "ZoneEngine.ChatCommands")
                {
                    if (t.Name != "AOChatCommand")
                    {
                        if (!this.chatCommands.ContainsKey(t.Namespace + "." + t.Name))
                        {
                            AOChatCommand aoc = (AOChatCommand)wholeassembly.CreateInstance(t.Namespace + "." + t.Name);
                            List <string> acceptedcommands = aoc.ListCommands();
                            foreach (string command in acceptedcommands)
                            {
                                this.chatCommands.Add(t.Namespace + "." + t.Name + ":" + command, t);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        public int AddScriptMembers()
        {
            this.scriptList.Clear();
            foreach (Assembly assembly in this.multipleDllList)
            {
                foreach (Type t in assembly.GetTypes())
                {
                    // returns all public types in the asembly
                    foreach (Type iface in t.GetInterfaces())
                    {
                        if (iface.FullName == typeof(IAOScript).FullName)
                        {
                            if (t.Name != "IAOScript")
                            {
                                foreach (MemberInfo mi in t.GetMembers())
                                {
                                    if ((mi.Name == "GetType") || (mi.Name == ".ctor") || (mi.Name == "GetHashCode") ||
                                        (mi.Name == "ToString") || (mi.Name == "Equals"))
                                    {
                                        continue;
                                    }

                                    if (mi.MemberType == MemberTypes.Method)
                                    {
                                        if (!this.scriptList.ContainsKey(t.Namespace + "." + t.Name + ":" + mi.Name))
                                        {
                                            this.scriptList.Add(t.Namespace + "." + t.Name + ":" + mi.Name, t);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            this.chatCommands.Clear();
            Assembly wholeassembly = Assembly.GetExecutingAssembly();
            int      chatCommands  = 0;

            foreach (Type t in wholeassembly.GetTypes().Where(x => x.IsSubclassOf(typeof(AOChatCommand))))
            {
                chatCommands++;
                AOChatCommand aoc = (AOChatCommand)wholeassembly.CreateInstance(t.FullName);
                List <string> acceptedcommands = aoc.ListCommands();
                foreach (string command in acceptedcommands)
                {
                    this.chatCommands.Add(t.FullName + ":" + command, t);
                }
            }

            return(chatCommands);
        }