Esempio n. 1
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);
         WriteInstrumentation(string.Format("** Found referenced assembly {0} (System directory).\r\n", inputName));
         retval = true;
     }
     return retval;
 }
Esempio n. 2
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)
     {
         WriteInstrumentation(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);
             WriteInstrumentation(string.Format("** Added referenced assembly {0} to DNR.\r\n", inputName));
         }
         retval = true;
     }
     return retval;
 }
Esempio n. 3
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 = "";
 }
Esempio n. 4
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();
                WriteInstrumentation("Resolving dependencies...\r\n");
                AssemblyName[] dependencies = asm.GetReferencedAssemblies();
                foreach (AssemblyName aName in dependencies)
                {
                    ResolveDependency(aName.Name);
                }

                CheckExportedTypes(inputPath);

                foreach (string s in Directory.GetFiles(Environment.CurrentDirectory))
                {
                    if (s.ToLower().EndsWith(".xsd") || s.ToLower().EndsWith(".wsdl"))
                        File.Delete(s);
                }
                // Now check to see if you can generate the service context and wsdl
                CommandLineMonitor monitor = new CommandLineMonitor();
                monitor.StreamUpdated += new CommandLineMonitor.OnStreamUpdated(monitor_StreamUpdated);
                monitor.Initialize("svcutil.exe", inputPath + "");
                // Wait until it's done
                bool test = false;
                while (!test)
                {
                    foreach (string s in Directory.GetFiles(Environment.CurrentDirectory))
                    {
                        if (s.ToLower().EndsWith(".xsd") || s.ToLower().EndsWith(".wsdl"))
                            test = true;
                    }
                    Thread.Sleep(1000);
                }

                CaptureWsdlsAndDataContracts();

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

                }
                // }
                retval = true;
            }
            return retval;
        }
Esempio n. 5
0
 public DnrManifest()
 {
     CurrentAssembly = new DnrAssembly();
     AssemblyErrors = new List<Exception>();
     Dependencies = new List<DnrAssembly>();
     ServiceContractNamespaces = new StringCollection();
     DataContracts = new Dictionary<string, string>();
     ServiceWsdls = new Dictionary<string, string>();
     CurrentAssembly.AssemblyStream = null;
     CurrentAssembly.AssemblyName = "";
     HubName = "";
     DefaultSpoke = "";
     CurrentAssembly.AssemblyVersion = "";
     AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);
 }