Ejemplo n.º 1
0
        internal void LoadAssembly()
        {
            var pluginLocation = AssemblyFile.ExistsOrThrow().FullName;

            AssemblyObj = Assembly.LoadFrom(AssemblyFile.ExistsOrThrow().FullName);

            ControllerType = AssemblyObj.GetType(ControllerName);

            if (ControllerType == null) // Maybe no namespace?
            {
                ControllerType = AssemblyObj.GetTypes().FirstOrDefault(x => x.Name == ControllerName)
                                 ?? throw new Exception(ControllerName + " was not found.");
            }

            ControllerName = ControllerType.FullName; // Ensure it has full namespace

            ActionMethods = ControllerType
                            .GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public)
                            .Select(x => new MethodGenerator(x, ControllerType))
                            .ToArray();

            if (ActionMethods.Length == 0)
            {
                throw new Exception("This controller has no action method.");
            }
        }
Ejemplo n.º 2
0
 private static void FillFiles(Database database, string connectionString)
 {
     if (database.Options.Ignore.FilterAssemblies)
     {
         using (SqlConnection conn = new SqlConnection(connectionString))
         {
             using (SqlCommand command = new SqlCommand(GetSQLFiles(), conn))
             {
                 conn.Open();
                 command.CommandTimeout = 0;
                 using (SqlDataReader reader = command.ExecuteReader())
                 {
                     while (reader.Read())
                     {
                         if (((int)reader["FileId"]) != 1)
                         {
                             Assembly     assem = database.Assemblies[reader["Name"].ToString()];
                             AssemblyFile file  = new AssemblyFile(assem, reader["FileName"].ToString(), ToHex((byte[])reader["FileContent"]));
                             assem.Files.Add(file);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((base.GetHashCode() * 397) ^ AssemblyFile.GetHashCode());
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Registers an Assembly into the IO Embedding Process
        /// </summary>
        /// <param name="asm"></param>
        public static void RegisterAssembly(Assembly asm)
        {
            if (_loadedAssemblies.Contains(asm))
            {
                return;
            }

            _loadedAssemblies.Add(asm);
            string[] files = asm.GetManifestResourceNames();
            Logger.Log(LogType.Log, "Adding Assembly: " + asm.GetName().Name, 10);
            for (int i = 0; i < files.Length; i++)
            {
                string file = files[i].Remove(0, (asm.GetName().Name + ".").Length);
                if (_assemblyFiles.ContainsKey(file))
                {
                    Logger.Log(LogType.Log,
                               "Overwriting File: " + file + " with version from assembly: " + asm.GetName().Name,
                               8);
                    _assemblyFiles[file] = new AssemblyFile(false, files[i], asm);
                }
                else
                {
                    _assemblyFiles.Add(file, new AssemblyFile(false, files[i], asm));
                }
            }

            PrepareManifestFiles(asm);
        }
Ejemplo n.º 5
0
        private string Process(string fileName, IInstanceResourceContext instance, AssemblyFile defaultAssembly)
        {
            var actualAssemblies = instance.SitecoreInfo.Assemblies;
            var key = actualAssemblies.Keys.FirstOrDefault(x => fileName.Equals(x, StringComparison.OrdinalIgnoreCase)) ?? actualAssemblies.Keys.FirstOrDefault(x => fileName.EndsWith(x, StringComparison.OrdinalIgnoreCase));

            if (key == null)
            {
                return("missing");
            }

            var actualAssembly = actualAssemblies[key];

            Assert.IsNotNull(actualAssembly, "assembly");

            var actualFileVersion = actualAssembly.FileVersion;

            if (!string.Equals(defaultAssembly.FileVersion, actualFileVersion, StringComparison.Ordinal))
            {
                return(actualFileVersion);
            }

            var actualHash = actualAssembly.HashSum;

            if (defaultAssembly.HashSum != actualHash)
            {
                return("[wrong checksum]");
            }

            return(null);
        }
Ejemplo n.º 6
0
        public AssemblyFile DiassembleCompiledFile(string inputFile, ILogger loggerInput)
        {
            AssemblyFile asmFile = new AssemblyFile();

            try
            {
                string tmpPath = DisassembleToTemporaryFile(inputFile, loggerInput);

                using (var fileStream = new FileStream(tmpPath, FileMode.Open))
                {
                    using (var reader = new StreamReader(fileStream))
                    {
                        string fileTxt = reader.ReadToEnd();
                        asmFile.FileText = fileTxt;// fileTxt.Replace("\n", Environment.NewLine);
                    }
                }

                File.Delete(tmpPath);
            }
            catch (Exception ex)
            {
                loggerInput.Log(LogLevel.Critical, "Failed to disassemble file: " + ex.Message);
            }

            return(asmFile);
        }
Ejemplo n.º 7
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(AssemblyFile.GetHashCode());
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles the Completed event of the Package control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RunWorkerCompletedEventArgs"/> instance containing the event data.</param>
        private void Package_Completed(object sender, RunWorkerCompletedEventArgs e)
        {
            AssemblyFile versionFile = this.Files.FirstOrDefault(x => x.Name == APP_VER_FILE) as AssemblyFile;

            if (this.IsAssemblyPackage)
            {
                this.Info = new assembly_patch()
                {
                    app_name    = APP_NAME,
                    description = Comments,
                    version     = versionFile.GetVersion().ToString()
                }
            }
            ;
            else
            {
                this.Info = new full_patch()
                {
                }
            };
            if (e.Result is Exception)
            {
                Console.WriteLine((e.Result as Exception).Message);
            }
            else
            {
                Console.WriteLine(e.Result as String);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creatings the package work.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param>
        private void CreatingPackageWork(object sender, DoWorkEventArgs e)
        {
            IEnumerable <InstalledFile> files = (IEnumerable <InstalledFile>)e.Argument;
            AssemblyFile versionFile          = files.FirstOrDefault(x => x.Name == APP_VER_FILE) as AssemblyFile;
            String       tmpDir  = Path.Combine(TABALIM_APP_DIR, TMP);
            String       package = Path.Combine(TABALIM_APP_DIR, String.Format(this.IsAssemblyPackage ? PACKAGE_NAME : FULL_PACKAGE_NAME, versionFile.GetVersion().ToString()));

            try
            {
                //1: Se realiza la limpieza del directorio temporal
                if (Directory.Exists(tmpDir))
                {
                    new DirectoryInfo(tmpDir).GetFiles().ToList().ForEach(x => x.Delete());
                }
                else
                {
                    Directory.CreateDirectory(tmpDir);
                }
                (sender as BackgroundWorker).ReportProgress(0, "Copiando archivos del paquete...");
                //2: Copiamos los archivos al directorio temporal
                foreach (var file in files)
                {
                    File.Copy(file.GetPath(), Path.Combine(tmpDir, file.EntryName));
                }
                (sender as BackgroundWorker).ReportProgress(50, "Archivos copiados");
                //3: Se crea el archivo zip
                (sender as BackgroundWorker).ReportProgress(50, "Generando paquete...");
                ZipFile.CreateFromDirectory(tmpDir, package);
                e.Result = String.Format("Paquete creado en {0}", package);
            }
            catch (Exception exc)
            {
                e.Result = exc;
            }
        }
Ejemplo n.º 10
0
 public AssemblyFileViewModel(AssemblyFile file)
 {
     m_AreAnyChangesUnsaved = false;
     m_UnderlyingFile       = file;
     m_LoggerVm             = new LoggerViewModel();
     m_FileErrors           = new ObservableCollection <AssemblyException>();
 }
Ejemplo n.º 11
0
        private unsafe InternalManifestResourceInfo GetInternalManifestResourceInfo(string resourceName)
        {
            InternalManifestResourceInfo     result            = new InternalManifestResourceInfo();
            ManifestResourceHandleCollection manifestResources = MetadataReader.ManifestResources;

            foreach (var resourceHandle in manifestResources)
            {
                ManifestResource resource = MetadataReader.GetManifestResource(resourceHandle);
                if (MetadataReader.StringComparer.Equals(resource.Name, resourceName))
                {
                    result.Found = true;
                    if (resource.Implementation.IsNil)
                    {
                        checked
                        {
                            // Embedded data resource
                            result.ResourceLocation = ResourceLocation.Embedded | ResourceLocation.ContainedInManifestFile;
                            PEReader pe = PEReader;

                            PEMemoryBlock resourceDirectory = pe.GetSectionData(pe.PEHeaders.CorHeader.ResourcesDirectory.RelativeVirtualAddress);
                            BlobReader    reader            = resourceDirectory.GetReader((int)resource.Offset, resourceDirectory.Length - (int)resource.Offset);
                            uint          length            = reader.ReadUInt32();
                            result.PointerToResource = reader.CurrentPointer;

                            // Length check the size of the resource to ensure it fits in the PE file section, note, this is only safe as its in a checked region
                            if (length + sizeof(Int32) > reader.Length)
                            {
                                throw new BadImageFormatException();
                            }
                            result.SizeOfResource = length;
                        }
                    }
                    else
                    {
                        if (resource.Implementation.Kind == HandleKind.AssemblyFile)
                        {
                            // Get file name
                            result.ResourceLocation = default(ResourceLocation);
                            AssemblyFile file = MetadataReader.GetAssemblyFile((AssemblyFileHandle)resource.Implementation);
                            if (file.ContainsMetadata)
                            {
                                result.ResourceLocation = ResourceLocation.Embedded;
                                throw new PlatformNotSupportedException(); // Support for multi-module assemblies is not implemented on this platform
                            }
                            result.FileName = MetadataReader.GetString(file.Name);
                        }
                        else if (resource.Implementation.Kind == HandleKind.AssemblyReference)
                        {
                            // Resolve assembly reference
                            result.ResourceLocation = ResourceLocation.ContainedInAnotherAssembly;
                            RuntimeAssemblyName destinationAssemblyName = ((AssemblyReferenceHandle)resource.Implementation).ToRuntimeAssemblyName(MetadataReader);
                            result.ReferencedAssembly = RuntimeAssembly.GetRuntimeAssemblyIfExists(destinationAssemblyName);
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 12
0
 public FileEntry(PEFile module, AssemblyFileHandle handle)
 {
     this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
     this.module         = module;
     this.metadata       = module.Metadata;
     this.handle         = handle;
     this.assemblyFile   = metadata.GetAssemblyFile(handle);
 }
Ejemplo n.º 13
0
        public bool Load(string Path, bool AssemblyOnly = false)
        {
            try
            {
                // 구성 파일 로드
                if (!AssemblyOnly)
                {
                    LoadConfig(Path);
                }

                if (AssemblyFile.Equals("local"))
                {
                    // 내부 어셈블리 사용
                    switch (AssemblyEntry)
                    {
                    case "WebView":
                        BorderContent.Background = Brushes.Black;
                        ChromiumWebBrowser WebView = new ChromiumWebBrowser();
                        WebView.Address     = AssemblyArgument;
                        BorderContent.Child = WebView;
                        break;
                    }
                }
                else
                {
                    // 외부 어셈블리 참조
                    Assembly WidgetAssembly = Assembly.LoadFrom(AssemblyFile);
                    Type[]   TypeList       = WidgetAssembly.GetTypes();
                    foreach (Type Target in TypeList)
                    {
                        if (Target.Name == AssemblyEntry)
                        {
                            // 어셈블리 진입점 검색 및 인스턴스 생성
                            _WidgetTarget  = Target;
                            _WidgetControl = Activator.CreateInstance(Target) as UserControl;

                            // 어셈블리에 전달할 인자가 존재하는 경우 메소드 호출
                            if (AssemblyArgument.Length > 0)
                            {
                                CallMethod("SetArgument", AssemblyArgument);
                            }

                            break;
                        }
                    }
                    ;

                    // 검색된 컨트롤을 현재 컨트롤에 추가
                    BorderContent.Child = WidgetControl;
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 14
0
        public virtual void Upload(Site site, string fileName, Stream stream)
        {
            AssemblyFile assemblyFile = new AssemblyFile(site, fileName);

            //assemblyFile.
            assemblyFile.Save(stream);
            DeleteFromBin(fileName);
            EnsureAssembliesExistsInBin(site);
        }
Ejemplo n.º 15
0
 public static void SaveFile(AssemblyFile file)
 {
     using (var fileStream = new FileStream(file.FilePath, FileMode.Create))
     {
         using (var writer = new StreamWriter(fileStream))
         {
             writer.Write(file.FileText);
         }
     }
 }
Ejemplo n.º 16
0
        public virtual void Delete(Site site, string fileName)
        {
            AssemblyFile assemblyFile = new AssemblyFile(site, fileName);

            if (assemblyFile.Exists())
            {
                assemblyFile.Delete();
            }
            DeleteFromBin(fileName);
            EnsureAssembliesExistsInBin(site);
        }
Ejemplo n.º 17
0
        internal void LoadAssembly()
        {
            var pluginLocation = AssemblyFile.ExistsOrThrow().FullName;

            AssemblyObj = Assembly.LoadFrom(AssemblyFile.ExistsOrThrow().FullName);

            CommandType = AssemblyObj.GetType(CommandName) ??
                          AssemblyObj.GetTypes().FirstOrDefault(x => x.Name == CommandName && x.BaseType == typeof(EventBusCommandMessage)) ??
                          throw new Exception($"No type in the assembly {AssemblyFile.FullName} is named: {CommandName}.");

            CommandName = CommandType.FullName; // Ensure it has full namespace
        }
Ejemplo n.º 18
0
        private bool CheckIfLibraryInstalled(AssemblyFile ass)
        {
            foreach (var assembly in Assemblies)
            {
                if (ass.FileName == assembly.Value.FileName && ass.FileVersion == assembly.Value.FileVersion)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 19
0
        public override int GetHashCode()
        {
            int hashCode = 0;

            unchecked {
                if (AssemblyFile != null)
                {
                    hashCode += 1000000007 * AssemblyFile.GetHashCode();
                }
                hashCode += 1000000009 * Type.GetHashCode();
            }
            return(hashCode);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Converts a file info to an installed file
        /// </summary>
        /// <param name="file">The file to convert.</param>
        /// <returns>The installed file</returns>
        private InstalledFile ToInstalledFile(FileInfo file)
        {
            InstalledFile iFile;

            if (file.Extension.ToUpper() == ".DLL")
            {
                iFile = new AssemblyFile(file);
            }
            else
            {
                iFile = new AssetFile(file);
            }
            return(iFile);
        }
Ejemplo n.º 21
0
        private static IEnumerable <AssemblyFile> GetBinaries([NotNull] string rootPath)
        {
            Assert.ArgumentNotNull(rootPath, nameof(rootPath));
            try
            {
                // in 9.0 sitecore.kernel.dll is always present in support package, so check Client.dll
                var kernel = FindFile(rootPath, "Sitecore.Client.dll");
                if (kernel == null)
                {
                    var assemblyInfoPath = FindFile(rootPath, "AssemblyInfo.xml");
                    if (assemblyInfoPath != null && File.Exists(assemblyInfoPath))
                    {
                        var xml = new XmlDocument().TryLoadFile(assemblyInfoPath);
                        return(xml.SelectElements("/assemblies/assembly").Select(ParseAssembly).GroupBy(x => x.FileName).ToDictionary(x => x.Key, x => x.First()).Values); // GroupBy to bypass duplication issues
                    }

                    return(null);
                }

                var binPath = Path.GetDirectoryName(kernel);
                var files   = Directory.GetFiles(binPath, "*.dll", SearchOption.AllDirectories);

                var binaries = new Dictionary <string, AssemblyFile>();
                foreach (var file in files)
                {
                    try
                    {
                        var name     = file.Substring(binPath.Length).TrimStart("\\/".ToCharArray());
                        var assembly = new AssemblyFile(new FileInfo(file));
                        if (name != null)
                        {
                            Log.Info("Assembly detected: " + file);
                            binaries.Add(name, assembly);
                        }
                    }
                    catch (Exception exception)
                    {
                        Log.Error(exception, $"Error happened during parsing assembly. Skipping: {file}");
                    }
                }

                return(binaries.Values);
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"Unhandled error happened during parsing binaries: {rootPath}");

                return(null);
            }
        }
Ejemplo n.º 22
0
        public virtual IEnumerable <AssemblyFile> GetFiles(Site site)
        {
            List <AssemblyFile> files = new List <AssemblyFile>();

            AssemblyFile dummy = new AssemblyFile(site, "dummy.dll");

            if (Directory.Exists(dummy.BasePhysicalPath))
            {
                foreach (var file in Directory.EnumerateFiles(dummy.BasePhysicalPath, "*.dll"))
                {
                    files.Add(new AssemblyFile(site, Path.GetFileName(file)));
                }
            }

            return(files);
        }
Ejemplo n.º 23
0
    bool ImportDll(MBDirectory dir, FileInfo dll)
    {
        string[] pieces = dll.Name.Split('_');

        if (pieces.Length != 2)
        {
            log.Error(9999, "Invalid bundle filename (expected exactly one underscore): " + dll.Name, null);
            return(true);
        }

        // pieces[1] is <version>.dll, so strip off the .dll part
        string shortname = pieces[0].Substring(BundleManager.MBuildPrefix.Length);
        string version   = pieces[1].Substring(0, pieces[1].Length - 4);

        AssemblyName aname = BundleManager.MakeName(shortname, version);

        if (bm.LoadBundle(aname, log) == false)
        {
            Console.WriteLine(" + Bundle {0}/{1} already imported", shortname, version);
            return(false);
        }

        if (dry_run)
        {
            Console.WriteLine(" + Would import {0}/{1}", shortname, version);
            return(false);
        }

        Console.WriteLine(" + Importing {0}/{1}", shortname, version);

        AssemblyFile assy = new AssemblyFile();

        assy.Dir  = dir;
        assy.Name = dll.Name;

        // FIXME
        //if (gacprog.InstallAssembly (assy, root, MBImport.Config.CompatCode, false, ctxt))
        if (gacprog.InstallAssembly(assy, root, "mbuild-0.0", false, ctxt))
        {
            return(true);
        }

        num_imported++;
        return(false);
    }
Ejemplo n.º 24
0
        public static IEnumerable <object[]> FileInstances()
        {
            var other    = new AssemblyFile(1);
            var version1 = "1.0.0";
            var version2 = "1.0.2";

            yield return(new object[] { new VersionedFile(other, version1), new VersionedFile(other, version1), true });

            yield return(new object[] { new VersionedFile(new AssemblyFile(1), version1), new VersionedFile(new AssemblyFile(1), version1), true });

            yield return(new object[] { new VersionedFile(new AssemblyFile(2), version1), new VersionedFile(new AssemblyFile(1), version1), false });

            yield return(new object[] { new VersionedFile(new AssemblyFile(1), version1), new VersionedFile(new AssemblyFile(1), version2), false });

            yield return(new object[] { new VersionedFile(new AssemblyFile(1), "0.1"), new VersionedFile(new AssemblyFile(1), "0.1"), true });

            yield return(new object[] { new VersionedFile(new AssemblyFile(1), "0.1-Pre"), new VersionedFile(new AssemblyFile(1), "0.1-pre"), true });
        }
Ejemplo n.º 25
0
        protected sealed override IEnumerable <AssemblyFileInfo> GetAssemblyFileInfosFromManifest(bool includeManifestModule, bool includeResourceModules)
        {
            MetadataReader reader = Reader;

            if (includeManifestModule)
            {
                yield return(new AssemblyFileInfo(reader.GetModuleDefinition().Name.GetString(reader), true, 0));
            }

            foreach (AssemblyFileHandle h in reader.AssemblyFiles)
            {
                AssemblyFile af = h.GetAssemblyFile(reader);
                if (includeResourceModules || af.ContainsMetadata)
                {
                    yield return(new AssemblyFileInfo(af.Name.GetString(reader), af.ContainsMetadata, h.GetToken().GetTokenRowNumber()));
                }
            }
        }
        private Mapping <AssemblyFileHandle> MapAssemblyFileImpl(AssemblyFileHandle handle)
        {
            AssemblyFile assemblyFile = _sourceMetadata.GetAssemblyFile(handle);
            string       name         = _sourceMetadata.GetString(assemblyFile.Name);

            foreach (var targetHandle in _targetMetadata.AssemblyFiles)
            {
                AssemblyFile target = _targetMetadata.GetAssemblyFile(targetHandle);
                if (!_targetMetadata.StringComparer.Equals(target.Name, name))
                {
                    continue;
                }

                return(new Mapping <AssemblyFileHandle>(targetHandle));
            }

            return(new Mapping <AssemblyFileHandle>());
        }
Ejemplo n.º 27
0
        public static AssemblyFile LoadFile(string filePath)
        {
            var file = new AssemblyFile();

            file.FilePath = filePath;

            using (var readStream = new FileStream(filePath, FileMode.Open))
            {
                using (var reader = new StreamReader(readStream))
                {
                    string rawFileData = reader.ReadToEnd();
                    file.FileText = rawFileData;

                    // text box expects this to be a specific new line, let's give it what it wants.
                    //file.FileText = rawFileData.Replace("\n", Environment.NewLine);
                }
            }

            return(file);
        }
Ejemplo n.º 28
0
        public void Execute(IResponseWriter writer, string[] arguments)
        {
            if (arguments.Length != 2)
            {
                writer.Write("error|The handler needs the full path to the reference. " +
                             "Usage: reference {assembly/project} {project to add reference to");
                return;
            }

            var   fullpath = getFile(arguments[0]);
            IFile file;

            if (new VSProjectFile().SupportsExtension(fullpath))
            {
                file = new VSProjectFile().New(fullpath);
            }
            else
            {
                file = new AssemblyFile().New(fullpath);
            }
            var projectFile = getFile(arguments[1]);

            if (!File.Exists(projectFile))
            {
                writer.Write("error|The project to add this reference to does not exist. " +
                             "Usage: reference {assembly/project} {project to add reference to");
                return;
            }

            if (!_project.Read(projectFile, _provider))
            {
                return;
            }
            _project.Reference(file);
            _project.Write();

            writer.Write("comment|Added reference {0} to {1}", file, projectFile);
        }
Ejemplo n.º 29
0
        public void Execute(IResponseWriter writer, string[] arguments)
        {
            if (arguments.Length != 2)
            {
                writer.Write("error|The handler needs the full path to the reference. " +
                             "Usage: dereference {assembly/project} {project to remove reference from}");
                return;
            }

            var   fullpath = getFile(arguments[0]);
            IFile file;

            if (new VSProjectFile().SupportsExtension(fullpath))
            {
                file = new VSProjectFile().New(fullpath);
            }
            else
            {
                file = new AssemblyFile().New(fullpath);
            }
            var projectFile = getFile(arguments[1]);

            if (!File.Exists(projectFile))
            {
                writer.Write("error|The project to remove this reference for does not exist. " +
                             "Usage: dereference {assembly/project} {project to remove reference from}");
                return;
            }

            if (!_project.Read(projectFile, _getTypesProviderByLocation))
            {
                return;
            }
            _project.Dereference(file);
            _project.Write();

            writer.Write("comment|Rereferenced {0} from {1}", file, projectFile);
        }
Ejemplo n.º 30
0
        public ModuleReferenceTreeNode(AssemblyTreeNode parentAssembly, ModuleReferenceHandle r, MetadataReader module)
        {
            this.parentAssembly = parentAssembly ?? throw new ArgumentNullException(nameof(parentAssembly));
            if (r.IsNil)
            {
                throw new ArgumentNullException(nameof(r));
            }
            this.metadata   = module;
            this.handle     = r;
            this.reference  = module.GetModuleReference(r);
            this.moduleName = metadata.GetString(reference.Name);

            foreach (var h in module.AssemblyFiles)
            {
                var file = module.GetAssemblyFile(h);
                if (module.StringComparer.Equals(file.Name, moduleName))
                {
                    this.file             = file;
                    this.fileHandle       = h;
                    this.containsMetadata = file.ContainsMetadata;
                    break;
                }
            }
        }
Ejemplo n.º 31
0
	bool ImportDll (MBDirectory dir, FileInfo dll) {
		string[] pieces = dll.Name.Split ('_');

		if (pieces.Length != 2) {
			log.Error (9999, "Invalid bundle filename (expected exactly one underscore): " + dll.Name, null);
			return true;
		}

		// pieces[1] is <version>.dll, so strip off the .dll part
		string shortname = pieces[0].Substring (BundleManager.MBuildPrefix.Length);
		string version = pieces[1].Substring (0, pieces[1].Length - 4);

		AssemblyName aname = BundleManager.MakeName (shortname, version);

		if (bm.LoadBundle (aname, log) == false) {
			Console.WriteLine (" + Bundle {0}/{1} already imported", shortname, version);
			return false;
		}

		if (dry_run) {
			Console.WriteLine (" + Would import {0}/{1}", shortname, version);
			return false;
		}

		Console.WriteLine (" + Importing {0}/{1}", shortname, version);

		AssemblyFile assy = new AssemblyFile ();
		assy.Dir = dir;
		assy.Name = dll.Name;

		// FIXME
		//if (gacprog.InstallAssembly (assy, root, MBImport.Config.CompatCode, false, ctxt))
		if (gacprog.InstallAssembly (assy, root, "mbuild-0.0", false, ctxt))
			return true;

		num_imported++;
		return false;
	}