/// <summary> /// The get test suites file from assembly. /// </summary> /// <param name="loadingAssemblyName"> /// The assembly path. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public static EhResourceCollection GetTestSuitesFileFromAssembly(string loadingAssemblyName) { var seperateAppDomainAssemblyLoader = new AppDomainAssemblyLoader(); var tempFile = Path.GetTempFileName(); EhResourceCollection resourceCollection; try { var resultList = seperateAppDomainAssemblyLoader.LoadAssemblyXmlResources(new FileInfo(loadingAssemblyName)); resultList.Save(tempFile); resourceCollection = new EhResourceCollection(); resourceCollection.Load(tempFile); } finally { seperateAppDomainAssemblyLoader.UnloadAppDomain(); } return(resourceCollection); }
/// <summary> /// The get xml resources. /// </summary> /// <param name="fileinfo"> /// The fileinfo. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> internal EhResourceCollection GetXmlResources(FileInfo fileinfo) { var streamList = new EhResourceCollection(); var directory = new DirectoryInfo(fileinfo.Directory.FullName); ResolveEventHandler resolveEventHandler = (s, e) => { return(this.OnReflectionOnlyResolve(e, directory)); }; AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += resolveEventHandler; Assembly reflectionOnlyAssembly = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies().First(); foreach (string resourceName in reflectionOnlyAssembly.GetManifestResourceNames()) { if (resourceName.EndsWith(".xml")) { var stream = reflectionOnlyAssembly.GetManifestResourceStream(resourceName); var fileName = Path.Combine(Path.GetTempPath(), resourceName); using (var output = new FileStream(fileName, FileMode.Create)) { var resourc = new EhResourceInfo { ResourceNameFullPath = fileName, ResourceName = resourceName }; if (!streamList.Contains(resourc)) { if (stream != null) { stream.CopyTo(output); streamList.Add(resourc); } } } } } AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= resolveEventHandler; return(streamList); }