コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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
                {
                    compileState.BuildStatus.LogSemanticError(string.Format("Failed to import {0}", importModuleName), compileState.CurrentDSFileName, curLine, curCol);
                }
            }


            CodeBlockNode codeBlockNode = refNode;

            if (null != dllModule)
            {
                codeBlockNode = dllModule.ImportCodeBlock(typeName, alias, refNode);
                Type type = dllModule.GetExtensionAppType();
                if (type != null)
                {
                    FFIExecutionManager.Instance.RegisterExtensionApplicationType(compileState, type);
                }
            }
            else if (extension == ".ds")
            {
                string origDSFile = compileState.CurrentDSFileName;
                compileState.CurrentDSFileName = System.IO.Path.GetFullPath(importModuleName);
                codeBlockNode = ImportDesignScriptFile(importModuleName, typeName, alias);
                compileState.CurrentDSFileName = origDSFile;
            }


            return(codeBlockNode);
        }