• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CustomNodeDefinition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: UpdateCustomNodeDefinition

 /// <summary>
 ///     Register custom node defintion and execute all custom node
 ///     instances.
 /// </summary>
 /// <param name="definition"></param>
 private void UpdateCustomNodeDefinition(CustomNodeDefinition definition)
 {
     RegisterCustomNodeDefinitionWithEngine(definition);
     MarkAllDependenciesAsModified(definition);
 }
开发者ID:ksobon,项目名称:Dynamo,代码行数:10,代码来源:DynamoModel.cs


示例17: LoadProxyCustomNode

        private static void LoadProxyCustomNode(Guid funcId, string nickname)
        {
            var proxyDef = new CustomNodeDefinition(funcId)
            {
                WorkspaceModel =
                    new CustomNodeWorkspaceModel(nickname, "Custom Nodes") { FileName = null },
                IsProxy = true
            };

            string userMsg = "Failed to load custom node: " + nickname + ".  Replacing with proxy custom node.";

            dynSettings.DynamoLogger.Log(userMsg);

            // tell custom node loader, but don't provide path, forcing user to resave explicitly
            dynSettings.Controller.CustomNodeManager.SetFunctionDefinition(funcId, proxyDef);
        }
开发者ID:khoaho,项目名称:Dynamo,代码行数:16,代码来源:CustomNodeController.cs


示例18: MarkAllDependenciesAsModified

        /// <summary>
        /// Returns all function instances directly or indirectly depends on the
        /// specified function definition and mark them as modified so that
        /// their values will be re-queried.
        /// </summary>
        /// <param name="def"></param>
        /// <returns></returns>
        private void MarkAllDependenciesAsModified(CustomNodeDefinition def)
        {
            var homeWorkspace = Workspaces.OfType<HomeWorkspaceModel>().FirstOrDefault();
            if (homeWorkspace == null)
                return;

            var dependencies = CustomNodeManager.GetAllDependenciesGuids(def);
            var funcNodes = homeWorkspace.Nodes.OfType<Function>();
            var dirtyNodes = funcNodes.Where(n => dependencies.Contains(n.Definition.FunctionId));
            homeWorkspace.MarkNodesAsModifiedAndRequestRun(dirtyNodes);
        }
开发者ID:ksobon,项目名称:Dynamo,代码行数:18,代码来源:DynamoModel.cs


示例19: Function

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


示例20: CreateFunction

 public virtual Function CreateFunction(CustomNodeDefinition customNodeDefinition)
 {
     return new Function(customNodeDefinition);
 }
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:4,代码来源:DynamoViewModel.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CustomSqlHelper类代码示例发布时间:2022-05-24
下一篇:
C# CustomModifiers类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap