コード例 #1
0
ファイル: Function.cs プロジェクト: thomas-gale/Dynamo
        protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
        {
            List <XmlNode> childNodes = nodeElement.ChildNodes.Cast <XmlNode>().ToList();

            if (!Controller.IsInSyncWithNode(this))
            {
                Controller.SyncNodeWithDefinition(this);
                OnNodeModified();
            }
            else if (Controller.Definition == null || Controller.Definition.IsProxy)
            {
                foreach (XmlNode subNode in childNodes)
                {
                    if (subNode.Name.Equals("Outputs"))
                    {
                        var data =
                            subNode.ChildNodes.Cast <XmlNode>()
                            .Select(
                                (outputNode, i) =>
                                new
                        {
                            data = new PortData(outputNode.Attributes[0].Value, Properties.Resources.ToolTipOutput + (i + 1)),
                            idx  = i
                        });

                        foreach (var dataAndIdx in data)
                        {
                            if (OutPorts.Count > dataAndIdx.idx)
                            {
                                OutPorts[dataAndIdx.idx] = new PortModel(PortType.Output, this, dataAndIdx.data);
                            }
                            else
                            {
                                OutPorts.Add(new PortModel(PortType.Output, this, dataAndIdx.data));
                            }
                        }
                    }
                    else if (subNode.Name.Equals("Inputs"))
                    {
                        var data =
                            subNode.ChildNodes.Cast <XmlNode>()
                            .Select(
                                (inputNode, i) =>
                                new
                        {
                            data = new PortData(inputNode.Attributes[0].Value, Properties.Resources.ToolTipInput + (i + 1)),
                            idx  = i
                        });

                        foreach (var dataAndIdx in data)
                        {
                            if (InPorts.Count > dataAndIdx.idx)
                            {
                                InPorts[dataAndIdx.idx] = new PortModel(PortType.Input, this, dataAndIdx.data);
                            }
                            else
                            {
                                InPorts.Add(new PortModel(PortType.Input, this, dataAndIdx.data));
                            }
                        }
                    }

                    #region Legacy output support

                    else if (subNode.Name.Equals("Output"))
                    {
                        var data = new PortData(subNode.Attributes[0].Value, Properties.Resources.ToolTipFunctionOutput);

                        if (OutPorts.Any())
                        {
                            OutPorts[0] = new PortModel(PortType.Output, this, data);
                        }
                        else
                        {
                            OutPorts.Add(new PortModel(PortType.Output, this, data));
                        }
                    }

                    #endregion
                }

                RegisterAllPorts();
            }

            base.DeserializeCore(nodeElement, context); //Base implementation must be called

            XmlNode nameNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("Name"));
            if (nameNode != null && nameNode.Attributes != null)
            {
                NickName = nameNode.Attributes["value"].Value;
            }

            XmlNode descNode = childNodes.LastOrDefault(subNode => subNode.Name.Equals("Description"));
            if (descNode != null && descNode.Attributes != null)
            {
                Description = descNode.Attributes["value"].Value;
            }
        }
コード例 #2
0
        private void ProcessFormula()
        {
            Expression e;

            try
            {
                e = new Expression(
                    FormulaString.ToLower()
                    .Replace(" and ", "+").Replace("&&", "+")
                    .Replace(" or ", "+").Replace("||", "+"),
                    EvaluateOptions.IgnoreCase);
            }
            catch (Exception ex)
            {
                Error(ex.Message);
                return;
            }

            if (e.HasErrors())
            {
                Error(e.Error);
                return;
            }

            var parameters = new List <string>();
            var paramSet   = new HashSet <string>();

            e.EvaluateParameter += delegate(string name, ParameterArgs args)
            {
                if (!paramSet.Contains(name) && !reservedParamNames.Contains(name))
                {
                    paramSet.Add(name);
                    parameters.Add(name);
                }

                args.Result = 0;
            };

            e.EvaluateFunction += delegate(string name, FunctionArgs args)
            {
                foreach (var p in args.Parameters)
                {
                    p.Evaluate();
                }

                args.Result = 0;
            };

            try
            {
                e.Evaluate();
            }
            catch { }

            InPorts.Clear();

            foreach (var p in parameters)
            {
                InPorts.Add(new PortModel(PortType.Input, this, new PortData(p, "variable")));
            }

            ClearRuntimeError();
        }
コード例 #3
0
 public PythonStringNode()
 {
     InPorts.Add(new PortModel(PortType.Input, this, new PortData("script", Properties.Resources.PythonStringPortDataScriptToolTip)));
     AddInput();
     RegisterAllPorts();
 }
コード例 #4
0
 public DerivedTestNode()
 {
     InPorts.Add(new PortModel(PortType.Input, this, new PortData("input B", "This is input B.")));
 }
コード例 #5
0
ファイル: RevitDropDown.cs プロジェクト: ziter05/DynamoRevit
 public FamilyInstanceParameters()
     : base(outputName)
 {
     InPorts.Add(new PortModel(PortType.Input, this, new PortData("f", Properties.Resources.PortDataFamilySymbolToolTip)));
     PropertyChanged += OnPropertyChanged;
 }
コード例 #6
0
 public TestNode()
 {
     InPorts.Add(new PortModel(PortType.Input, this, new PortData("input A", "This is input A.")));
     OutPorts.Add(new PortModel(PortType.Output, this, new PortData("output A", "This is output A.")));
     RegisterAllPorts();
 }
コード例 #7
0
ファイル: Elements.cs プロジェクト: Revitcivil/DynamoRevit
 public ElementsOfType()
 {
     InPorts.Add(new PortModel(PortType.Input, this, new PortData("element class", Properties.Resources.PortDataElementTypeToolTip)));
     OutPorts.Add(new PortModel(PortType.Output, this, new PortData("elements", Properties.Resources.PortDataAllElementsInDocumentToolTip)));
     RegisterAllPorts();
 }
コード例 #8
0
ファイル: TestUINodes.cs プロジェクト: zhoufan1987/Expressior
 public NodeWithFailingASTOutput()
 {
     InPorts.Add(new PortModel(PortType.Input, this, new PortData("input", "dummy input")));
     OutPorts.Add(new PortModel(PortType.Output, this, new PortData("result", "dummy result")));
     RegisterAllPorts();
 }
コード例 #9
0
ファイル: JsonObjectUI.cs プロジェクト: chuongmep/JsonData
 public ByKeysAndValues() : base()
 {
     InPorts.Add(new PortModel(PortType.Input, this, new PortData("keys", Properties.Resources.JsonObject_Keys_Set)));
     InPorts.Add(new PortModel(PortType.Input, this, new PortData("values", Properties.Resources.JsonObject_Values_Set)));
     OutPorts.Add(new PortModel(PortType.Output, this, new PortData("jsonObject", Properties.Resources.JsonObject_Json_Get)));
 }
コード例 #10
0
        public UnPack()
        {
            InPorts.Add(new PortModel(PortType.Input, this, new PortData("In", "Dictionary")));

            ArgumentLacing = LacingStrategy.Longest;
        }