// Pass a reference back to the requested assembly (library) public static void GetAssembly(LIB_TYPE lib, out AssemblyDefinition outAssembly) { if (_thisObject == null) { throw new InvalidOperationException("The class AssemblyStore has not been initialised!"); } // Assemblies are loaded on first retrieval if (Get()._libsLoaded != true) { Get().LoadAssemblies(); } // Try to fetch the correct definition from the map. The returned value (from the map) will be put // into this variable. AssemblyDefinition assemblyDefinition; Get()._assemblies.TryGetValue(lib, out assemblyDefinition); // If lib is invalid, null is returned. Escalate the issue. if (assemblyDefinition == null) { throw new ArgumentOutOfRangeException("Parameter lib must be a valid value of LIB_TYPE!"); } // Pass the definition back in the same paradigm outAssembly = assemblyDefinition; }
// Get the full path to the file of the requested library public static string GetAssemblyPath(LIB_TYPE lib) { if (_thisObject == null) { throw new InvalidOperationException("The class AssemblyStore has not been initialised!"); } int fileNameIdx = (int)lib; // Prevent IndexOutOfBounds by testing the value of lib if (fileNameIdx < 1 || fileNameIdx >= _assemblyFileNames.Length) { throw new ArgumentOutOfRangeException("Parameter lib must be a valid value of LIB_TYPE!"); } // Construct the full path for the requested assembly. This requires prepending the path // recorded on initialisation. string fullPath = Path.Combine(_dataPath, _assemblyFileNames[fileNameIdx]); return(fullPath); }