/// <summary> /// Load the assembly object only /// </summary> /// <param name="assemblyPath"></param> /// <returns></returns> public NetAssembly LoadAssembly(string assemblyPath) { // get the cecil assembly AssemblyDefinition AsmToProfile = CecilHelper.GetAssembly(assemblyPath); if (AsmToProfile == null) { return(null); } return(new NetAssembly(AsmToProfile) { Name = AsmToProfile.Name.Name, FilePath = assemblyPath, Version = AsmToProfile.Name.Version.ToString(), Culture = AsmToProfile.Name.Culture, PublicKey = ByteHelper.ByteToHexString(AsmToProfile.Name.PublicKey), PublicKeyToken = ByteHelper.ByteToHexString(AsmToProfile.Name.PublicKeyToken), Hash = ByteHelper.ByteToHexString(AsmToProfile.Name.Hash), HashAlgorithm = AsmToProfile.Name.HashAlgorithm.ToString(), EntryPoint = AsmToProfile.EntryPoint != null?AsmToProfile.EntryPoint.ToString() : string.Empty, Kind = AsmToProfile.Kind != null?AsmToProfile.Kind.ToString() : string.Empty //IsProgram = (AsmToProfile.EntryPoint.ToString() != string.Empty && AsmToProfile.Kind.ToString() != string.Empty) }); }
/// <summary> /// Refresh an assembly and all subtypes if loaded /// </summary> /// <param name="assembly"></param> public void RefreshAssembly(NetAssembly assembly) { //reload cecil assembly definition assembly.Tag = CecilHelper.GetAssembly(assembly.FilePath); //for each type in cecil assembly, refresh or load it foreach (TypeDefinition modulType in ((AssemblyDefinition)assembly.Tag).MainModule.Types) { if (modulType.Name == CecilHelper.CecilModul) { continue; } if (modulType.IsClass) { if (!RefreshClass(assembly.Children, modulType)) { AddClass(assembly, modulType); } } } }