Ejemplo n.º 1
0
        private void RegisterCustomNodeInstanceForLateInitialization(
            EFunction node,
            Guid id,
            string name)
        {
            var disposed = false;
            Action <CustomNodeInfo> infoUpdatedHandler = null;

            infoUpdatedHandler = newInfo =>
            {
                if (newInfo.FunctionId == id || newInfo.Name == name)
                {
                    CustomNodeWorkspaceModel foundWorkspace;
                    if (TryGetFunctionWorkspace(newInfo.FunctionId, out foundWorkspace))
                    {
                        node.ResyncWithDefinition(foundWorkspace.CustomNodeDefinition);
                        RegisterCustomNodeInstanceForUpdates(node, foundWorkspace);
                        InfoUpdated -= infoUpdatedHandler;
                        disposed     = true;
                    }
                }
            };
            InfoUpdated   += infoUpdatedHandler;
            node.Disposed += (args) =>
            {
                if (!disposed)
                {
                    InfoUpdated -= infoUpdatedHandler;
                }
            };
        }
Ejemplo n.º 2
0
        private static void RegisterCustomNodeInstanceForUpdates(EFunction node, CustomNodeWorkspaceModel workspace)
        {
            Action defUpdatedHandler = () =>
            {
                node.ResyncWithDefinition(workspace.CustomNodeDefinition);
            };

            workspace.DefinitionUpdated += defUpdatedHandler;

            Action infoChangedHandler = () =>
            {
                var info = workspace.CustomNodeInfo;
                node.Name        = info.Name;
                node.Description = info.Description;
                node.Category    = info.Category;
            };

            workspace.InfoChanged += infoChangedHandler;
            node.Disposed         += (args) =>
            {
                workspace.DefinitionUpdated -= defUpdatedHandler;
                workspace.InfoChanged       -= infoChangedHandler;
            };
        }