Beispiel #1
0
 public override object ConvertTo(
     ITypeDescriptorContext context,
     System.Globalization.CultureInfo culture,
     object Value,
     Type destinationType)
 {
     if (destinationType.Equals(typeof(InstanceDescriptor)))
     {
         DotNetAssemblyInfo info = ( DotNetAssemblyInfo )Value;
         System.Reflection.ConstructorInfo ctor = typeof(DotNetAssemblyInfo).GetConstructor(
             new Type[] {
             typeof(string),
             typeof(string),
             typeof(string),
             typeof(string),
             typeof(string),
             typeof(AssemblyNameFlags)
         });
         return(new InstanceDescriptor(
                    ctor,
                    new object[] {
             info.Name,
             info.VersionString,
             info.RuntimeVersionString,
             info.CodeBase,
             info.FileName,
             info.Flags
         },
                    true));
     }
     return(base.ConvertTo(context, culture, Value, destinationType));
 }
Beispiel #2
0
 private void dlgScriptOptions_Load(object sender, EventArgs e)
 {
     if (myOptionsInstance != null)
     {
         foreach (DotNetAssemblyInfo info in myOptionsInstance.ReferenceAssemblies)
         {
             DotNetAssemblyInfo info2 = DotNetAssemblyInfoList.GlobalList[info.Name];
             if (info2 != null && info2.SourceStyle == info.SourceStyle)
             {
                 info.FileName       = DotNetAssemblyInfo.GetFileNameByCodeBase(info2.CodeBase);
                 info.Version        = info2.Version;
                 info.RuntimeVersion = info2.RuntimeVersion;
                 info.Flags          = info2.Flags;
                 info.CodeBase       = info2.CodeBase;
             }
             ListViewItem item = new ListViewItem(info.Name);
             item.SubItems.Add(info.VersionString);
             item.SubItems.Add(info.FileName);
             item.Tag = info;
             lvwAssembly.Items.Add(item);
         }
         System.Text.StringBuilder str = new StringBuilder();
         foreach (string item in myOptionsInstance.ImportNamespaces)
         {
             if (str.Length > 0)
             {
                 str.Append(Environment.NewLine);
             }
             str.Append(item);
         }
         this.txtImports.Text = str.ToString();
     }
 }
Beispiel #3
0
        public int AddByType(Type t)
        {
            if (t == null)
            {
                throw new ArgumentNullException("t");
            }
            DotNetAssemblyInfo info = new DotNetAssemblyInfo(t.Assembly);
            int result = this.Add(info);

            Type[] its = t.GetInterfaces();
            if (its != null && its.Length > 0)
            {
                foreach (Type it in its)
                {
                    DotNetAssemblyInfo info2 = new DotNetAssemblyInfo(it.Assembly);
                    this.Add(info2);
                }
            }
            Type st = t.BaseType;

            while (st != null)
            {
                DotNetAssemblyInfo info2 = new DotNetAssemblyInfo(st.Assembly);
                this.Add(info2);
                st = st.BaseType;
            }
            return(result);
        }
Beispiel #4
0
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (lvwAssembly.SelectedItems.Count > 0)
     {
         ListViewItem item = lvwAssembly.SelectedItems[0];
         mySelectedAssembly = (DotNetAssemblyInfo)item.Tag;
         this.DialogResult  = DialogResult.OK;
         this.Close();
     }
 }
Beispiel #5
0
        //public DotNetAssemblyInfo Search(string name)
        //{
        //    if (name == null)
        //        return null;
        //    name = name.Trim();
        //    if (name.Length == 0)
        //        return null;
        //    DotNetAssemblyInfo info = this[name];
        //    if (info != null)
        //        return info;
        //    if (name.ToLower().EndsWith(".dll"))
        //    {

        //    }
        //}

        /// <summary>
        /// add new item
        /// </summary>
        /// <param name="info">new item</param>
        /// <returns>index of new item in this list</returns>
        public int Add(DotNetAssemblyInfo info)
        {
            int index = IndexOf(info.Name);

            if (index >= 0)
            {
                this.List.RemoveAt(index);
            }
            return(this.List.Add(info));
        }
Beispiel #6
0
 public int IndexOf(string name)
 {
     for (int iCount = 0; iCount < this.Count; iCount++)
     {
         DotNetAssemblyInfo info = (DotNetAssemblyInfo)this.List[iCount];
         if (string.Compare(info.Name, name, true) == 0)
         {
             return(iCount);
         }
     }
     return(-1);
 }
Beispiel #7
0
        /// <summary>
        /// clone instance
        /// </summary>
        /// <returns>new instance</returns>
        public DotNetAssemblyInfo Clone()
        {
            DotNetAssemblyInfo info = new DotNetAssemblyInfo();

            info.strName        = this.strName;
            info.strFileName    = this.strFileName;
            info.strCodeBase    = this.strCodeBase;
            info.strFullName    = this.strFullName;
            info.myVersion      = (Version)this.myVersion.Clone();
            info.intSourceStyle = this.intSourceStyle;
            info.intFlags       = this.intFlags;
            return(info);
        }
Beispiel #8
0
 private void cmdBrowseAdd_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog dlg = new OpenFileDialog())
     {
         dlg.CheckFileExists = true;
         dlg.Filter          = ScriptStrings.AssemblyFileFilter;
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             DotNetAssemblyInfo info = DotNetAssemblyInfo.CreateByFileName(dlg.FileName);
             ListViewItem       item = new ListViewItem(info.Name);
             item.SubItems.Add(info.VersionString);
             item.SubItems.Add(info.FileName);
             item.Tag = info;
             lvwAssembly.Items.Add(item);
         }
     }
 }
Beispiel #9
0
        public static DotNetAssemblyInfo CreateByFileName(string FileName)
        {
            DotNetAssemblyInfo info = new DotNetAssemblyInfo(AssemblyName.GetAssemblyName(FileName));

            info.FileName = FileName;
            if (string.Compare(
                    System.IO.Path.GetDirectoryName(FileName),
                    DotNetAssemblyInfo.RuntimePath,
                    true) == 0)
            {
                info.intSourceStyle = AssemblySourceStyle.Standard;
            }
            else
            {
                info.intSourceStyle = AssemblySourceStyle.ThirdPart;
            }
            return(info);
        }
Beispiel #10
0
        private void cmdAddGACAssembly_Click(object sender, EventArgs e)
        {
            this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            using (dlgBrowseGACAssembly dlg = new dlgBrowseGACAssembly())
            {
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    this.Cursor = System.Windows.Forms.Cursors.Default;

                    DotNetAssemblyInfo info = dlg.SelectedAssembly;
                    ListViewItem       item = new ListViewItem(info.Name);
                    item.SubItems.Add(info.VersionString);
                    item.SubItems.Add(info.FileName);
                    item.Tag = info;
                    lvwAssembly.Items.Add(item);
                }
            }
            this.Cursor = System.Windows.Forms.Cursors.Default;
        }
Beispiel #11
0
        public int AddStandard(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            name = name.Trim();
            if (name.Length == 0)
            {
                throw new ArgumentNullException("name");
            }
            DotNetAssemblyInfo info = new DotNetAssemblyInfo();

            info.Name        = name;
            info.SourceStyle = AssemblySourceStyle.Standard;
            if (name.ToLower().EndsWith(".dll") == false)
            {
                name = name + ".dll";
            }
            info.FileName = System.IO.Path.Combine(DotNetAssemblyInfo.RuntimePath, name);
            return(this.Add(info));
        }
Beispiel #12
0
        public int AddByName(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            name = name.Trim();
            if (name.Length == 0)
            {
                throw new ArgumentNullException("name");
            }

            DotNetAssemblyInfo info = new DotNetAssemblyInfo(name);

            if (myGlobalList != null)
            {
                DotNetAssemblyInfo info2 = GlobalList[info.Name];
                if (info2 != null)
                {
                    info = info2;
                }
            }
            return(Add(info));
        }
Beispiel #13
0
 /// <summary>
 /// delete item
 /// </summary>
 /// <param name="info">item</param>
 public void Remove(DotNetAssemblyInfo info)
 {
     this.List.Remove(info);
 }