当前位置: 首页>>代码示例>>C#>>正文


C# CustomNodeDefinition类代码示例

本文整理汇总了C#中CustomNodeDefinition的典型用法代码示例。如果您正苦于以下问题:C# CustomNodeDefinition类的具体用法?C# CustomNodeDefinition怎么用?C# CustomNodeDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CustomNodeDefinition类属于命名空间,在下文中一共展示了CustomNodeDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PackageItemRootViewModel

 public PackageItemRootViewModel(CustomNodeDefinition def)
 {
     this.Height = 32;
     this.DependencyType = DependencyType.CustomNode;
     this.Definition = def;
     this.BuildDependencies(new HashSet<object>());
 }
开发者ID:jbenoit44,项目名称:Dynamo,代码行数:7,代码来源:PackageItemRootViewModel.cs

示例2: OnDefinitionUpdated

 protected virtual void OnDefinitionUpdated(CustomNodeDefinition obj)
 {
     var handler = DefinitionUpdated;
     if (handler != null) handler(obj);
 }
开发者ID:qingemeng,项目名称:Dynamo,代码行数:5,代码来源:CustomNodeManager.cs

示例3: TryGetFunctionDefinition

 /// <summary>
 ///     Get the function definition from a guid.
 /// </summary>
 /// <param name="id">Custom node identifier.</param>
 /// <param name="isTestMode">
 ///     Flag specifying whether or not this should operate in "test mode".
 /// </param>
 /// <param name="definition"></param>
 /// <returns></returns>
 public bool TryGetFunctionDefinition(Guid id, bool isTestMode, out CustomNodeDefinition definition)
 {
     if (Contains(id))
     {
         CustomNodeWorkspaceModel ws;
         if (IsInitialized(id) || InitializeCustomNode(id, isTestMode, out ws))
         {
             definition = loadedCustomNodes[id];
             return true;
         }
     }
     definition = null;
     return false;
 }
开发者ID:qingemeng,项目名称:Dynamo,代码行数:23,代码来源:CustomNodeManager.cs

示例4: GetAllDependenciesGuids

        internal IEnumerable<Guid> GetAllDependenciesGuids(CustomNodeDefinition def)
        {
            var idSet = new HashSet<Guid>();
            idSet.Add(def.FunctionId);

            while (true)
            {
                bool isUpdated = false;
                foreach (var d in this.LoadedDefinitions)
                {
                    if (d.Dependencies.Any(x => idSet.Contains(x.FunctionId)))
                        isUpdated = isUpdated || idSet.Add(d.FunctionId);
                }

                if (!isUpdated)
                    break;
            }

            return idSet;
        }
开发者ID:qingemeng,项目名称:Dynamo,代码行数:20,代码来源:CustomNodeManager.cs

示例5: FocusCustomNodeWorkspace

        /// <summary>
        ///     Change the currently visible workspace to a custom node's workspace
        /// </summary>
        /// <param name="symbol">The function definition for the custom node workspace to be viewed</param>
        internal void FocusCustomNodeWorkspace(CustomNodeDefinition symbol)
        {
            if (symbol == null)
            {
                throw new Exception("There is a null function definition for this node.");
            }

            if (_model.CurrentWorkspace is CustomNodeWorkspaceModel)
            {
                var customNodeWorkspace = _model.CurrentWorkspace as CustomNodeWorkspaceModel;
                if (customNodeWorkspace.CustomNodeDefinition.FunctionId
                    == symbol.WorkspaceModel.CustomNodeDefinition.FunctionId)
                {
                    return;
                }
            }

            var newWs = symbol.WorkspaceModel;

            if (!this._model.Workspaces.Contains(newWs))
                this._model.Workspaces.Add(newWs);

            CurrentSpaceViewModel.CancelActiveState();

            _model.CurrentWorkspace = newWs;
            _model.CurrentWorkspace.OnDisplayed();

            //set the zoom and offsets events
            var vm = dynSettings.Controller.DynamoViewModel.Workspaces.First(x => x.Model == newWs);
            vm.OnCurrentOffsetChanged(this, new PointEventArgs(new Point(newWs.X, newWs.Y)));
            vm.OnZoomChanged(this, new ZoomEventArgs(newWs.Zoom));
        }
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:36,代码来源:DynamoViewModel.cs

示例6: RegisterCustomNodeDefinitionWithEngine

 /// <summary>
 ///     Registers (or re-registers) a Custom Node definition with the DesignScript VM,
 ///     so that instances of the custom node can be evaluated.
 /// </summary>
 /// <param name="definition"></param>
 private void RegisterCustomNodeDefinitionWithEngine(CustomNodeDefinition definition)
 {
     EngineController.GenerateGraphSyncDataForCustomNode(
         Workspaces.OfType<HomeWorkspaceModel>().SelectMany(ws => ws.Nodes),
         definition,
         DebugSettings.VerboseLogging);
 }
开发者ID:ksobon,项目名称:Dynamo,代码行数:12,代码来源:DynamoModel.cs

示例7: OnGetDefinitionFromPath

 public void OnGetDefinitionFromPath(CustomNodeDefinition def)
 {
     if (DefinitionLoaded != null && def != null)
         DefinitionLoaded(def);
 }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:5,代码来源:CustomNodeManager.cs

示例8: GenerateGraphSyncDataForCustomNode

        /// <summary>
        /// Generate graph sync data based on the input Dynamo custom node information.
        /// Returns false if all nodes are clean.
        /// </summary>
        /// <param name="nodes"></param>
        /// <param name="definition"></param>
        /// <param name="verboseLogging"></param>
        /// <returns></returns>
        internal bool GenerateGraphSyncDataForCustomNode(IEnumerable<NodeModel> nodes, CustomNodeDefinition definition, bool verboseLogging)
        {
            lock (macroMutex)
            {
                // Any graph updates through the scheduler no longer store their 
                // GraphSyncData in 'graphSyncDataQueue' (any such entry will be 
                // withdrawn from the queue and get associated with an AsyncTask.
                // This check is to ensure that such case does not exist.
                // 
                if (graphSyncDataQueue.Count > 0)
                {
                    throw new InvalidOperationException(
                        "'graphSyncDataQueue' is not empty");
                }

                astBuilder.CompileCustomNodeDefinition(
                    definition.FunctionId,
                    definition.ReturnKeys,
                    definition.FunctionName,
                    definition.FunctionBody,
                    definition.OutputNodes,
                    definition.Parameters,
                    verboseLogging);

                if (!VerifyGraphSyncData(nodes) || (graphSyncDataQueue.Count == 0))
                    return false;

                // GraphSyncData objects accumulated through the compilation above
                // will be stored in 'pendingCustomNodeSyncData'. Entries in this 
                // queue will be used to update custom node graph prior to updating
                // the graph for the home workspace.
                // 
                while (graphSyncDataQueue.Count > 0)
                {
                    var graphSyncData = graphSyncDataQueue.Dequeue();
                    pendingCustomNodeSyncData.Enqueue(graphSyncData);
                }

                return true;
            }
        }
开发者ID:YanmengLi,项目名称:Dynamo,代码行数:49,代码来源:EngineController.cs

示例9: Function

 protected internal Function(WorkspaceModel workspace, CustomNodeDefinition def)
     : base(workspace, new CustomNodeController(workspace.DynamoModel, def))
 {
     ArgumentLacing = LacingStrategy.Disabled;
 }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:5,代码来源:Function.cs

示例10: CompileCustomNodeDefinition

        /// <summary>
        ///     Compiles a collection of Dynamo nodes into a function definition for a custom node.
        /// </summary>
        /// <param name="def"></param>
        /// <param name="funcBody"></param>
        /// <param name="outputs"></param>
        /// <param name="parameters"></param>
        public void CompileCustomNodeDefinition(
            CustomNodeDefinition def, IEnumerable<NodeModel> funcBody, List<AssociativeNode> outputs,
            IEnumerable<string> parameters)
        {
            OnAstNodeBuilding(def.FunctionId);

            var functionBody = new CodeBlockNode();
            functionBody.Body.AddRange(CompileToAstNodes(funcBody, false));

            if (outputs.Count > 1)
            {
                /* rtn_array = {};
                 * rtn_array[key0] = out0;
                 * rtn_array[key1] = out1;
                 * ...
                 * return = rtn_array;
                 */

                // return array, holds all outputs
                string rtnName = "__temp_rtn_" + def.FunctionId.ToString().Replace("-", String.Empty); 
                functionBody.Body.Add(
                    AstFactory.BuildAssignment(
                        AstFactory.BuildIdentifier(rtnName),
                        AstFactory.BuildExprList(new List<string>())));

                // indexers for each output
                IEnumerable<AssociativeNode> indexers = def.ReturnKeys != null
                    ? def.ReturnKeys.Select(AstFactory.BuildStringNode) as IEnumerable<AssociativeNode>
                    : Enumerable.Range(0, outputs.Count).Select(AstFactory.BuildIntNode);

                functionBody.Body.AddRange(
                    outputs.Zip(
                        indexers,
                        (outputId, indexer) => // for each outputId and return key
                            // pack the output into the return array
                            AstFactory.BuildAssignment(AstFactory.BuildIdentifier(rtnName, indexer), outputId)));

                // finally, return the return array
                functionBody.Body.Add(AstFactory.BuildReturnStatement(AstFactory.BuildIdentifier(rtnName)));
            }
            else
            {
                // For single output, directly return that identifier or null.
                AssociativeNode returnValue = outputs.Count == 1 ? outputs[0] : new NullNode();
                functionBody.Body.Add(AstFactory.BuildReturnStatement(returnValue));
            }

            Type allTypes = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar);

            //Create a new function definition
            var functionDef = new FunctionDefinitionNode
            {
                Name = def.FunctionName.Replace("-", string.Empty),
                Signature =
                    new ArgumentSignatureNode
                    {
                        Arguments =
                            parameters.Select(param => AstFactory.BuildParamNode(param, allTypes)).ToList()
                    },
                FunctionBody = functionBody,
                ReturnType = allTypes
            };

            OnAstNodeBuilt(def.FunctionId, new[] { functionDef });
        }
开发者ID:heegwon,项目名称:Dynamo,代码行数:72,代码来源:AstBuilder.cs

示例11: GetOwnerPackage

 public Package GetOwnerPackage(CustomNodeDefinition def)
 {
     return GetOwnerPackage(def.WorkspaceModel.FileName);
 }
开发者ID:whztt07,项目名称:Dynamo,代码行数:4,代码来源:PackageLoader.cs

示例12: IsUnderPackageControl

 public bool IsUnderPackageControl(CustomNodeDefinition def)
 {
     return IsUnderPackageControl(def.WorkspaceModel.FileName);
 }
开发者ID:whztt07,项目名称:Dynamo,代码行数:4,代码来源:PackageLoader.cs

示例13: GetDefinition

        /// <summary>
        ///     Get a CustomNodeDefinition from a guid, also stores type internally info for future instantiation.
        ///     And add the compiled node to the enviro.
        ///     As a side effect, any of its dependent nodes are also initialized.
        /// </summary>
        /// <param name="environment">The environment from which to get the </param>
        /// <param name="guid">Open a definition from a path, without instantiating the nodes or dependents</param>
        public bool GetDefinition(Guid guid, out CustomNodeDefinition result)
        {
            if (!Contains(guid))
            {
                result = null;
                return false;
            }

            if (!IsInitialized(guid))
            {
                if (!GetDefinitionFromPath(guid, out result))
                {
                    return false;
                }
            }
            else
            {
                result = LoadedCustomNodes[guid];
            }

            return true;
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:29,代码来源:CustomNodeManager.cs

示例14: GetDefinitionFromPath

        /// <summary>
        ///     Deserialize a function definition from a given path.  A side effect of this function is that
        ///     the node is added to the dictionary of loadedNodes.  
        /// </summary>
        /// <param name="funcDefGuid">The function guid we're currently loading</param>
        /// <param name="def">The resultant function definition</param>
        /// <returns></returns>
        private bool GetDefinitionFromPath(Guid funcDefGuid, out CustomNodeDefinition def)
        {
            try
            {
                var xmlPath = GetNodePath(funcDefGuid);

                #region read xml file

                var xmlDoc = new XmlDocument();
                xmlDoc.Load(xmlPath);

                string funName = null;
                string category = "";
                double cx = 0;
                double cy = 0;
                string description = "";
                string version = "";

                double zoom = 1.0;
                string id = "";

                // load the header

                // handle legacy workspace nodes called dynWorkspace
                // and new workspaces without the dyn prefix
                XmlNodeList workspaceNodes = xmlDoc.GetElementsByTagName("Workspace");
                if(workspaceNodes.Count == 0)
                    workspaceNodes = xmlDoc.GetElementsByTagName("dynWorkspace");

                foreach (XmlNode node in workspaceNodes)
                {
                    foreach (XmlAttribute att in node.Attributes)
                    {
                        if (att.Name.Equals("X"))
                            cx = double.Parse(att.Value, CultureInfo.InvariantCulture);
                        else if (att.Name.Equals("Y"))
                            cy = double.Parse(att.Value, CultureInfo.InvariantCulture);
                        else if (att.Name.Equals("zoom"))
                            zoom = double.Parse(att.Value, CultureInfo.InvariantCulture);
                        else if (att.Name.Equals("Name"))
                            funName = att.Value;
                        else if (att.Name.Equals("Category"))
                            category = att.Value;
                        else if (att.Name.Equals("Description"))
                            description = att.Value;
                        else if (att.Name.Equals("ID"))
                            id = att.Value;
                        else if (att.Name.Equals("Version"))
                            version = att.Value;
                    }
                }

                Version fileVersion = MigrationManager.VersionFromString(version);

                var currentVersion = MigrationManager.VersionFromWorkspace(dynamoModel.HomeSpace);

                if (fileVersion > currentVersion)
                {
                    bool resume = Utils.DisplayFutureFileMessage(this.dynamoModel, xmlPath, fileVersion, currentVersion);
                    if (!resume)
                    {
                        def = null;
                        return false;
                    }
                }

                var decision = MigrationManager.ShouldMigrateFile(fileVersion, currentVersion);
                if (decision == MigrationManager.Decision.Abort)
                {
                    Utils.DisplayObsoleteFileMessage(this.dynamoModel, xmlPath, fileVersion, currentVersion);
                    
                    def = null;
                    return false;
                }
                else if (decision == MigrationManager.Decision.Migrate)
                {
                    string backupPath = string.Empty;
                    bool isTesting = DynamoModel.IsTestMode; // No backup during test.
                    if (!isTesting && MigrationManager.BackupOriginalFile(xmlPath, ref backupPath))
                    {
                        string message = string.Format(
                            "Original file '{0}' gets backed up at '{1}'",
                            Path.GetFileName(xmlPath), backupPath);

                        dynamoModel.Logger.Log(message);
                    }

                    MigrationManager.Instance.ProcessWorkspaceMigrations(this.dynamoModel, xmlDoc, fileVersion);
                    MigrationManager.Instance.ProcessNodesInWorkspace(this.dynamoModel, xmlDoc, fileVersion);
                }

                // we have a dyf and it lacks an ID field, we need to assign it
                // a deterministic guid based on its name.  By doing it deterministically,
//.........这里部分代码省略.........
开发者ID:RobertiF,项目名称:Dynamo,代码行数:101,代码来源:CustomNodeManager.cs

示例15: CustomNodeController

 public CustomNodeController(CustomNodeDefinition def) : base(def) { }
开发者ID:khoaho,项目名称:Dynamo,代码行数:1,代码来源:CustomNodeController.cs


注:本文中的CustomNodeDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。