コード例 #1
0
        public Type Find(Type instanceof, string name)
        {
            name = name.ToLower();

            if (d_matchCache.ContainsKey(name))
            {
                return(d_matchCache[name]);
            }

            string[] parts = name.Split('.');

            foreach (Type type in Find(instanceof))
            {
                Attributes.PluginAttribute attr = GetInfo(type);
                string[] tname;

                if (attr != null && attr.Name != null)
                {
                    tname = attr.Name.ToLower().Split('.');
                }
                else
                {
                    tname = type.FullName.ToLower().Split('.');
                }

                int df = tname.Length - parts.Length;

                if (df < 0)
                {
                    continue;
                }

                bool ismatch = true;

                for (int i = 0; i < parts.Length; ++i)
                {
                    if (parts[i] != tname[df + i])
                    {
                        ismatch = false;
                        break;
                    }
                }

                if (ismatch)
                {
                    d_matchCache[name.ToLower()] = type;
                    return(type);
                }
            }

            return(null);
        }
コード例 #2
0
        public Attributes.PluginAttribute GetInfo(Type type)
        {
            object[] attrs = type.GetCustomAttributes(typeof(Attributes.PluginAttribute), true);

            if (attrs.Length != 0)
            {
                Attributes.PluginAttribute ret = (Attributes.PluginAttribute)attrs[0];

                if (ret.Name == null)
                {
                    ret.Name = type.Name;
                }

                return(ret);
            }
            else
            {
                return(null);
            }
        }