// Access the one and only instance of this class public static AssemblyStore Get(String dataPath = null) { if (_thisObject == null) { if (dataPath == null) { throw new ArgumentNullException("Parameter dataPath must be a valid string"); } _thisObject = new AssemblyStore(); // Save the dataPath for future reference _dataPath = dataPath; } return(_thisObject); }
public static void Save(this AssemblyStore.LIB_TYPE lib) { // Get the assembly AssemblyDefinition assDefinition; AssemblyStore.GetAssembly(lib, out assDefinition); // Put the patch mark on the assembly ! important assDefinition.AddPatchMark(); // Load the default out path string assOutPath = GetPathOut(lib); // Add our datapath to the resolve process (assDefinition.MainModule.AssemblyResolver as BaseAssemblyResolver).AddSearchDirectory(AssemblyStore.DataPath); // Store the assembly assDefinition.Write(assOutPath); }
// Constructs an backup path string for the given assembly // An optional directory can be provided where the assembly file will be stored. The resulting path // will be next to the original file if no path is given. public static string GetPathBackup(this AssemblyStore.LIB_TYPE lib, string directory = null) { if (directory != null && !Directory.Exists(directory)) { throw new ArgumentException("Argument path '{0}' does not exist!", directory); } string fullPath = AssemblyStore.GetAssemblyPath(lib); // Construct a new filename for the manipulated assembly string file = Path.GetFileNameWithoutExtension(fullPath); // We know for sure that the extension is .dll string newFileName = file + AssemblyStore.AssemblyBackupAffix + ".dll"; string dir = (directory != null) ? directory : Path.GetDirectoryName(fullPath); // Construct a new full path for the manipulated assembly string newFullPath = Path.Combine(dir, newFileName); return(newFullPath); }
// Fetch the original location of the given library public static string GetPath(this AssemblyStore.LIB_TYPE lib) { return(AssemblyStore.GetAssemblyPath(lib)); }