public bool AssembleAlgorithmInstance(Dictionary <string, string> modelInfo) { string oldDirectory = Directory.GetCurrentDirectory(); try { Directory.SetCurrentDirectory(modelInfo["workingDirectory"]); AssemblySupport.LoadAssembly(modelInfo["workingDirectory"], modelInfo["assemblyPath"]); object obj = AssemblySupport.GetNewInstance(modelInfo["algorithm"]); if (obj is IAlgorithm) { _algorithm = (IAlgorithm)obj; } else { throw new Exception("Error occur while adding algorithm"); } return(true); } catch (Exception e) { ExceptionUtil.SendErrorEventAndLog(GetType().ToString(), e.Message); throw e; } finally { Directory.SetCurrentDirectory(oldDirectory); } }
public static bool ValidateAlgorithmClassWithFullDLLPath(string workingDirectory, string assemblyPath, string classname) { string oldDirectory = Directory.GetCurrentDirectory(); try { Directory.SetCurrentDirectory(workingDirectory); AssemblySupport.LoadAssembly(workingDirectory, assemblyPath); object obj = AssemblySupport.GetNewInstance(classname); return(obj is IAlgorithm); } catch (Exception e) { return(false); } finally { Directory.SetCurrentDirectory(oldDirectory); } }