Exemple #1
0
        /// <summary>
        ///     Creates a new Custom Node Instance.
        /// </summary>
        /// <param name="id">Identifier referring to a custom node definition.</param>
        /// <param name="name">
        ///     Name for the custom node to be instantiated, used for error recovery if
        ///     the given id could not be found.
        /// </param>
        /// <param name="def">
        ///     Custom node definition data
        /// </param>
        /// <param name="info">
        ///     Custom node information data
        /// </param>
        /// <returns>Custom Node Instance</returns>
        public EFunction CreateCustomNodeInstance(
            Guid id,
            string name,
            CustomNodeDefinition def,
            CustomNodeInfo info)
        {
            if (info == null)
            {
                // Couldn't find the workspace at all, prepare for a late initialization.
                Log(Properties.Resources.UnableToCreateCustomNodeID + id + "\"",
                    WarningLevel.Moderate);
                info = new CustomNodeInfo(id, name ?? "", "", "", "");
            }

            if (def == null)
            {
                def = CustomNodeDefinition.MakeProxy(id, info.Name);
            }

            var node = new EFunction(def, info.Name, info.Description, info.Category);

            CustomNodeWorkspaceModel workspace = null;

            if (loadedWorkspaceModels.TryGetValue(id, out workspace))
            {
                RegisterCustomNodeInstanceForUpdates(node, workspace);
            }
            else
            {
                RegisterCustomNodeInstanceForLateInitialization(node, id, name);
            }

            return(node);
        }
Exemple #2
0
        /// <summary>
        ///     Creates a new Custom Node Instance.
        /// </summary>
        /// <param name="id">Identifier referring to a custom node definition.</param>
        /// <param name="nickname">
        ///     Nickname for the custom node to be instantiated, used for error recovery if
        ///     the given id could not be found.
        /// </param>
        /// <param name="isTestMode">
        ///     Flag specifying whether or not this should operate in "test mode".
        /// </param>
        public Function CreateCustomNodeInstance(
            Guid id, string nickname = null, bool isTestMode = false)
        {
            CustomNodeWorkspaceModel workspace;
            CustomNodeDefinition     def;
            CustomNodeInfo           info;

            // Try to get the definition, initializing the custom node if necessary
            if (TryGetFunctionDefinition(id, isTestMode, out def))
            {
                // Got the definition, proceed as planned.
                info = NodeInfos[id];
            }
            else
            {
                // Couldn't get the workspace with the given ID, try a nickname lookup instead.
                if (nickname != null && TryGetNodeInfo(nickname, out info))
                {
                    return(CreateCustomNodeInstance(info.FunctionId, nickname, isTestMode));
                }

                // Couldn't find the workspace at all, prepare for a late initialization.
                Log(
                    Properties.Resources.UnableToCreateCustomNodeID + id + "\"",
                    WarningLevel.Moderate);
                info = new CustomNodeInfo(id, nickname ?? "", "", "", "");
            }

            if (def == null)
            {
                def = CustomNodeDefinition.MakeProxy(id, info.Name);
            }

            var node = new Function(def, info.Name, info.Description, info.Category);

            if (loadedWorkspaceModels.TryGetValue(id, out workspace))
            {
                RegisterCustomNodeInstanceForUpdates(node, workspace);
            }
            else
            {
                RegisterCustomNodeInstanceForLateInitialization(node, id, nickname, isTestMode);
            }

            return(node);
        }