Exemplo n.º 1
0
 void GetPreviouslyOpenedAssemblies()
 {
     foreach (string assembly in PreviouslyOpenedAssemblies)
     {
         List.Add(PreviouslyOpenedAssembly.ConvertFromString(assembly));
     }
 }
		public void Remove(PreviouslyOpenedAssembly assembly)
		{
			if (List.Contains(assembly)) {
				List.Remove(assembly);
				UpdateProperties();
			}
		}
Exemplo n.º 3
0
 public void Remove(PreviouslyOpenedAssembly assembly)
 {
     if (List.Contains(assembly))
     {
         List.Remove(assembly);
         UpdateProperties();
     }
 }
Exemplo n.º 4
0
 void UpdateProperties()
 {
     string[] items = new string[List.Count];
     for (int i = 0; i < Count; ++i)
     {
         PreviouslyOpenedAssembly assembly = (PreviouslyOpenedAssembly)List[i];
         items[i] = assembly.ConvertToString();
     }
     PreviouslyOpenedAssemblies = items;
 }
Exemplo n.º 5
0
 int IndexOf(string codeBase)
 {
     for (int i = 0; i < Count; ++i)
     {
         PreviouslyOpenedAssembly assembly = (PreviouslyOpenedAssembly)List[i];
         if (assembly.CodeBase == codeBase)
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 6
0
 public void Add(PreviouslyOpenedAssembly assembly)
 {
     List.Add(assembly);
     UpdateProperties();
 }
Exemplo n.º 7
0
        // Restore the assemblies that were previously loaded
        public static void RestoreAssemblies()
        {
            AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(AssemblyLoadHandler);
            if (_assemblies.Count == 0)
            {
                return;
            }
            ProgressDialog progressDialog = new ProgressDialog();

            progressDialog.Setup(StringParser.Parse("${res:ComponentInspector.ProgressDialog.LoadingPreviouslyOpenedAssembliesDialogTitle}"),
                                 StringParser.Parse("${res:ComponentInspector.ProgressDialog.LoadingPreviouslyOpenedAssembliesMessage}"),
                                 _assemblies.Count,
                                 ProgressDialog.HAS_PROGRESS_TEXT,
                                 ProgressDialog.FINAL);
            progressDialog.ShowIfNotDone();
            TraceUtil.WriteLineInfo(null, DateTime.Now + " Assembly Restore start ");
            try {
                for (int i = _assemblies.Count - 1; i >= 0; --i)
                {
                    PreviouslyOpenedAssembly assembly = _assemblies[i];
                    try {
                        AssemblyName aName = new AssemblyName();
                        aName.CodeBase = assembly.CodeBase;
                        TraceUtil.WriteLineInfo(null, DateTime.Now + " restore assy: " + assembly.CodeBase);
                        progressDialog.UpdateProgressText(assembly.CodeBase);
                        // Tell the TypeLibrary code the assembly
                        // belongs to some type library
                        Guid guid = Guid.Empty;
                        // Don't mess with assemblies that came from
                        // typelibs if the typelib is not there
                        if (assembly.TypeLibGuid.Length > 0)
                        {
                            guid = new Guid(assembly.TypeLibGuid);
                            TypeLibrary lib          = TypeLibrary.GetTypeLibOpened(guid, assembly.TypeLibVersion);
                            String      assyFileName = new Uri(assembly.CodeBase).LocalPath;
                            if (lib == null ||
                                !TypeLibrary.IsAssyCurrent(assyFileName, lib.FileName))
                            {
                                TraceUtil.WriteLineInfo
                                    (null, DateTime.Now +
                                    " skipped assy (typelib not opened "
                                    + "or current): "
                                    + assembly.CodeBase);
                                // Forget it
                                _assemblies.Remove(assembly);
                                progressDialog.UpdateProgress(1);
                                continue;
                            }
                        }
                        // The load event that happens under here causes the
                        // assembly to appear in the tree
                        Assembly assy = Assembly.Load(aName);
                        // Tell the TypeLibrary code the assembly
                        // belongs to some type library
                        if (assembly.TypeLibGuid.Length > 0)
                        {
                            TypeLibrary.RestoreAssembly(assy, guid, assembly.TypeLibVersion);
                        }
                        TraceUtil.WriteLineInfo(null, DateTime.Now + " loaded assy: " + assembly.CodeBase);
                        progressDialog.UpdateProgress(1);
                    } catch (Exception ex) {
                        TraceUtil.WriteLineWarning(null,
                                                   "Assemblies - deleting bad assemblies entry: "
                                                   + assembly.CodeBase + " " + ex);
                        _assemblies.Remove(assembly);
                        progressDialog.UpdateProgress(1);
                    }
                }
                // This depends on having all of the assemblies restored
                TraceUtil.WriteLineInfo(null, DateTime.Now + " Assembly Restore end ");
                _assyRootNode.Expand();
            } catch (Exception ex) {
                TraceUtil.WriteLineError(null, "Unexpected exception restoring assemblies: " + ex);
            }
            progressDialog.Finished();
        }
		public void Add(PreviouslyOpenedAssembly assembly)
		{
			List.Add(assembly);
			UpdateProperties();
		}