// Create the window. No assemblies will be displayed. public DependenciesForm(LoadAssemblyInfo lai) { m_lai = new LoadAssemblyInfo(); m_lai.LoadAs(lai.LoadAs()); m_lai.AppPath(lai.AppPath()); m_lai.RelPath(lai.RelPath()); InitializeComponent(); }
// Create a LoadAssembly object based on ``i''. // // If ``i.LoadAs()'' doesn't return a value from the AssemblyLoadAs // enumeration, then an exception is thrown. public static LoadAssembly CreateLoader(LoadAssemblyInfo i) { Trace.WriteLine("Creating Assembly Loader for:"); Trace.WriteLine(" LoadAs: " + i.LoadAs().ToString()); Trace.WriteLine(" AppBasePath: " + i.AppPath()); Trace.WriteLine(" RelativeSearchPath: " + i.RelPath()); _creator c = (_creator)m_tbl[i.LoadAs()]; if (c == null) { throw new Exception("Internal error: Invalid AssemblyLoadAs specified"); } return(c(i)); }
// Create a new AppDomain to load the assembly ``an''. protected static AppDomain CreateAppDomain(AssemblyName an, LoadAssemblyInfo info) { Trace.WriteLine("Loading a custom assembly for: " + an.FullName); String fname = String.Format(Localization.FMT_APPDOMAIN_NAME, an.FullName); Trace.WriteLine(" -- Friendly Name of new AppDomain: " + fname); Debug.Assert(an.CodeBase != null, "The AssemblyName CodeBase must be set!"); /* * The Application Base Path used to create the domain should be the * directory that the Assembly is located in. If AppPath() is null, * then we should consult use the AssemblyName's CodeBase as the App * Base Path. */ String appbase = info.AppPath(); if (appbase == null) { appbase = _furi_to_dir(an.CodeBase); } AppDomain ad = AppDomain.CreateDomain( fname, // friendlyName null, // securityInfo appbase, // appBasePath info.RelPath(), // relativeSearchPath false // shadowCopyFiles ); Trace.WriteLine(" -- created AppDomain"); return(ad); }
// For the given manifest, build a tree of its dependant assembiles/ // modules, and display them in the TreeView. private void _create_manifest(ICollection manifests) { Trace.WriteLine("Loading up manifests..."); Trace.WriteLine(" LoadAs: " + m_lai.LoadAs().ToString()); Trace.WriteLine(" AppP: " + m_lai.AppPath()); Trace.WriteLine(" RelP: " + m_lai.RelPath()); StringBuilder sb = new StringBuilder(); foreach (String manifest in manifests) { try { Trace.WriteLine(" manifest: " + manifest); AssemblyDependencies ad = new AssemblyDependencies(manifest, m_lai); DependenciesForm f = this; // if this window already contains a dependency list, create // a new window. if (f.m_ad != null) { f = new DependenciesForm(m_lai); f.Size = Size; f._set_assembly_load(f.m_lai.LoadAs()); f.BringToFront(); f.Show(); } f._set_dependencies(ad); f.m_file = manifest; f.m_menu.ViewRefresh.Enabled = true; f.m_menu.FileSaveConfig.Enabled = true; // set the infopanel to the root node. f.TreeView.SelectedNode = f.TreeView.Nodes[0]; } catch (System.ArgumentNullException e) { Trace.WriteLine("_create_manifest: arg null exception: " + e.ToString()); sb.Append(String.Format(Localization.FMT_INVALID_MANIFEST, manifest, Localization.INVALID_ASSEMBLY_MANIFEST)); _reset_interface(); } catch (System.Exception e) { Trace.WriteLine("_create_manifest: exception: " + e.ToString()); sb.Append(String.Format(Localization.FMT_INVALID_MANIFEST, manifest, e.Message)); _reset_interface(); } } if (sb.Length > 0) { // some of the files couldn't be opened; alert the user. MessageBox.Show(this, String.Format(Localization.FMT_INVALID_FILE_LIST, Localization.UNOPENED_FILES, sb.ToString()), Localization.GUI_WINDOW_TITLE, MessageBoxButtons.OK); } }
// Parse the command line given by ``args''. public ParseOptions(string[] args) { /* * if someone actually wants to list the dependancies of a file named * "--help", they don't want ``--help'' to be interpreted as a program * argument. To disable parsing of program arguments, use ``--'', e.g. * adepends -- --help */ bool parse_opts = true; for (int i = 0; i < args.Length; i++) { string arg = args[i]; if (parse_opts) { if (_help_message(arg)) { m_help = true; } else if (_use_console(arg)) { m_gui = false; } else if (_use_gui(arg)) { m_gui = true; } else if (_use_current_process(arg)) { m_cur = true; } else if (_load(arg)) { string s = _next(args, ref i, arg); try { m_lai.LoadAs((AssemblyLoadAs)Enum.Parse( typeof(AssemblyLoadAs), s, true)); } catch { throw new BadParameterException( String.Format(Localization.FMT_BAD_PARAMETER, arg, s)); } } else if (_app_base(arg)) { m_lai.AppPath(_next(args, ref i, arg)); } else if (_rels(arg)) { m_lai.RelPath(_next(args, ref i, arg)); } else if (_config(arg)) { m_config = _next(args, ref i, arg); } else if (arg == "--") { parse_opts = false; } else { m_files.Add(arg); } } else { m_files.Add(arg); } } }