Exemplo n.º 1
0
        /// <summary>
        /// アセンブリを超えて型を取得する
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private Type getType(string name)
        {
            if (name.Trim().Length < 1)
            {
                return(null);
            }
            if (namespaces == null)
            {
                namespaces = new Hashtable();
                if (_assemblyList == null)
                {
                    FeatureLoader2.SetUsingClass(GetType());
                }

                foreach (Assembly a in _assemblyList.Values)
                {
                    foreach (var t in a.GetTypes())
                    {
                        var ss = a.FullName.Split(new char[] { ',' });
                        var s  = t.Namespace + ".@CLASSNAME@, " + ss[0];
                        namespaces[s] = a;
                    }
                }
            }
            Type type = null;

            foreach (string a in namespaces.Keys)
            {
                type = Type.GetType(a.Replace("@CLASSNAME@", name));
                if (type != null)
                {
                    break;
                }
            }
            System.Diagnostics.Debug.Assert(type != null, string.Format("Class '{0}' registerd in a portfolio is not in this application.", name));
            return(type);
        }
Exemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (DesignMode)
            {
                return;
            }

            // バージョン情報を収集する
            var ass = new object[3];
            ass[0] = Assembly.GetEntryAssembly();
            ass[1] = Assembly.GetCallingAssembly();
            ass[2] = Assembly.GetExecutingAssembly();
            var ex = new ArrayList();

            for (var i = 0; i < ass.Length; i++)
            {
                var isIn = false;
                foreach (var o in ex)
                {
                    if (object.ReferenceEquals(o, ass[i]))
                    {
                        isIn = true;
                        break;
                    }
                }
                if (isIn)
                {
                    continue;
                }
                var a = (Assembly)ass[i];
                if (a == null)
                {
                    continue;
                }
                var an = a.GetName();
                var li = listView.Items.Add(an.Name);
                li.SubItems.Add(an.Version.ToString());
                li.SubItems.Add(an.CodeBase);
                ex.Add(a);
            }
            var ret = FeatureLoader2.GetUsingClasses();
            for (var i = 0; i < ret.Length; i++)
            {
                var isIn = false;
                var ss = ret[i];
                var an = ss.GetName();
                foreach (ListViewItem lvi in listView.Items)
                {
                    if (lvi.Text == an.Name)
                    {
                        isIn = true;
                        break;
                    }
                }
                if (isIn)
                {
                    continue;
                }
                var li = listView.Items.Add(an.Name);
                li.SubItems.Add(an.Version.ToString());
                li.SubItems.Add(an.CodeBase);
            }
        }