Пример #1
0
 public DnrManifest()
 {
     CurrentAssembly = new DnrAssembly();
     AssemblyErrors = new List<Exception>();
     Dependencies = new List<DnrAssembly>();
     CurrentAssembly.AssemblyStream = null;
     CurrentAssembly.AssemblyName = "";
     HubName = "";
     DefaultSpoke = "";
     CurrentAssembly.AssemblyVersion = "";
     AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);
 }
Пример #2
0
 public DnrManifest(string AssemblyPath, string assemblyName, string hubName, string defaultSpoke)
 {
     Dependencies = new List<DnrAssembly>();
     AssemblyErrors = new List<Exception>();
     this.Add(AssemblyPath);
     CurrentAssembly = new DnrAssembly();
     CurrentAssembly.AssemblyName = assemblyName;
     HubName = hubName;
     DefaultSpoke = defaultSpoke;
     CurrentAssembly.AssemblyVersion = "";
 }
Пример #3
0
 private bool IsInCurrentDirectory(string inputName)
 {
     bool retval = false;
     string SysPath = currentDirectory;
     AppDomain.CurrentDomain.SetData("APPBASE", currentDirectory);
     string[] match = System.IO.Directory.GetFiles(SysPath, inputName + ".dll", SearchOption.TopDirectoryOnly);
     if (match.Length > 0)
     {
         OutputMessages.Append(string.Format("** Found referenced assembly {0} (Current directory).\r\n", inputName));
         foreach (string s in match)
         {
             DnrAssembly dep = new DnrAssembly();
             dep.InitialAssemblyLoadPath = s;
             dep.Name = inputName;
             dep.AssemblyStream = ProcessBinary(dep.InitialAssemblyLoadPath);
             Assembly asm = Assembly.Load(dep.AssemblyStream);
             dep.AssemblyName = asm.GetName().Name;
             dep.AssemblyType = DnrAssemblyTypes.Local;
             dep.AssemblyVersion = asm.GetName().Version.ToString();
             AssemblyRef.Add(inputName);
             Dependencies.Add(dep);
             OutputMessages.Append(string.Format("** Added referenced assembly {0} to DNR.\r\n", inputName));
         }
         retval = true;
     }
     return retval;
 }
Пример #4
0
 private bool IsInSystem32(string inputName)
 {
     bool retval = false;
     string SysPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
     string[] match = System.IO.Directory.GetFiles(SysPath, inputName + ".dll", SearchOption.TopDirectoryOnly);
     if (match.Length > 0)
     {
         DnrAssembly dep = new DnrAssembly();
         dep.InitialAssemblyLoadPath = match[0];
         dep.Name = inputName;
         dep.AssemblyType = DnrAssemblyTypes.System;
         //_domain.Load(inputName);
         Dependencies.Add(dep);
         OutputMessages.Append(string.Format("** Found referenced assembly {0} (System directory).\r\n", inputName));
         retval = true;
     }
     return retval;
 }
Пример #5
0
        public bool Add(string inputPath)
        {
            bool retval = false;
            //bool HasValidService = false;
            if (!(inputPath == string.Empty) && !(inputPath == null) &&
                Path.GetExtension(inputPath) == ".dll")
            {
                AppDomain.CurrentDomain.SetData("APPBASE", inputPath);
                this.Name = System.IO.Path.GetFileNameWithoutExtension(inputPath);
                currentDirectory = System.IO.Path.GetDirectoryName(inputPath);
                CurrentAssembly = new DnrAssembly();
                CurrentAssembly.AssemblyType = DnrAssemblyTypes.Primary;
                CurrentAssembly.Name = System.IO.Path.GetFileName(inputPath);
                CurrentAssembly.AssemblyStream = ProcessBinary(inputPath);
                Assembly asm = Assembly.Load(CurrentAssembly.AssemblyStream);
                //_domain.Load(inputPath);
                CurrentAssembly.AssemblyName = asm.GetName().Name;
                CurrentAssembly.AssemblyVersion = asm.GetName().Version.ToString();
                OutputMessages.Append("Resolving dependencies...\r\n");
                AssemblyName[] dependencies = asm.GetReferencedAssemblies();
                foreach (AssemblyName aName in dependencies)
                {
                    ResolveDependency(aName.Name);
                }

                CheckExportedTypes(inputPath);
                //if (HasValidService)
                //{
                // Now loop through and find the dependencies

                if (AssemblyErrors.Count > 0)
                {
                    OutputMessages.Append(string.Format("Errors creating manifest--{0} error(s) found.\r\n", AssemblyErrors.Count));
                }
                else
                {
                    OutputMessages.Append("Dependencies resolved and manifest generated.\r\n");

                }
                // }
                retval = true;
            }
            return retval;
        }