private CodeBlockNode ImportCodeBlock(string importModuleName, string typeName, string alias, CodeBlockNode refNode) { DLLModule dllModule = null; string extension = System.IO.Path.GetExtension(importModuleName).ToLower(); if (extension == ".dll" || extension == ".exe") { try { dllModule = DLLFFIHandler.GetModule(importModuleName); } catch (DynamoServices.AssemblyBlockedException ex) { // this exception is caught upstream after displaying a failed load library warning to the user. throw ex; } catch (Exception) { _coreObj.LogSemanticError(string.Format(Resources.FailedToImport, importModuleName), _coreObj.CurrentDSFileName, curLine, curCol); } } CodeBlockNode codeBlockNode = refNode; if (null != dllModule) { codeBlockNode = dllModule.ImportCodeBlock(typeName, alias, refNode); Type type = dllModule.GetExtensionAppType(); if (type != null) { _coreObj.AddDLLExtensionAppType(type); } } else if (extension == ".ds") { string origDSFile = _coreObj.CurrentDSFileName; _coreObj.CurrentDSFileName = System.IO.Path.GetFullPath(importModuleName); codeBlockNode = ImportDesignScriptFile(_coreObj.CurrentDSFileName, typeName, alias); _coreObj.CurrentDSFileName = origDSFile; } return(codeBlockNode); }
private CodeBlockNode ImportCodeBlock(string importModuleName, string typeName, string alias, CodeBlockNode refNode) { DLLModule dllModule = null; string extension = System.IO.Path.GetExtension(importModuleName).ToLower(); if (extension == ".dll" || extension == ".exe") { try { dllModule = DLLFFIHandler.GetModule(importModuleName); } catch { _coreObj.LogSemanticError(string.Format(Resources.FailedToImport, importModuleName), _coreObj.CurrentDSFileName, curLine, curCol); } } CodeBlockNode codeBlockNode = refNode; if (null != dllModule) { codeBlockNode = dllModule.ImportCodeBlock(typeName, alias, refNode); Type type = dllModule.GetExtensionAppType(); if (type != null) { ProtoCore.RuntimeCore runtimeCore = _coreObj.__TempCoreHostForRefactoring; FFIExecutionManager.Instance.RegisterExtensionApplicationType(runtimeCore, type); } } else if (extension == ".ds") { string origDSFile = _coreObj.CurrentDSFileName; _coreObj.CurrentDSFileName = System.IO.Path.GetFullPath(importModuleName); codeBlockNode = ImportDesignScriptFile(_coreObj.CurrentDSFileName, typeName, alias); _coreObj.CurrentDSFileName = origDSFile; } return(codeBlockNode); }