예제 #1
0
        public void UpdatePorts()
        {
            if (string.IsNullOrEmpty(GetFunctionName()))
            {
                return;
            }
            var ctx           = Context.GetContext();
            var function      = ctx.GetFunction(GetFunctionName());
            var existingNames = new HashSet <string>(InstancePorts.Select(p => p.fieldName));

            foreach (var input in function?.Inputs ?? Array.Empty <Element.PortInfo>())
            {
                // TODO: Different types for different Element types
                var type = typeof(ElementNodeValue);
                if (existingNames.Remove(input.Name))
                {
                    GetPort(input.Name).ValueType = type;
                }
                else
                {
                    AddInstanceInput(type, ConnectionType.Multiple, input.Name);
                }
            }
            if (function != null && function.Inputs == null)
            {
                for (int i = 0; i < GetVaradicCount(); i++)
                {
                    AddInstanceInput(typeof(object), ConnectionType.Multiple, $"${i}");
                }
            }
            foreach (var name in existingNames)
            {
                RemoveInstancePort(name);
            }
        }
예제 #2
0
        public override object GetValue(NodePort port)
        {
            var ctx   = Context.GetContext();
            var info  = new CompilerInfo {
            };
            var iface = ctx.GetType(Type, info);
            int idx   = 0;
            Func <Expression> getNextValue = () => idx < TestValue.Length
                                ? new Constant(TestValue[idx++]) : Constant.Zero;

            return(new ElementNodeValue {
                Value = iface.Deserialize(getNextValue)
            });
        }