Example #1
0
 public IFrameModuleBase(IGraphRuntime runtime)
     : base(runtime, ModuleKind.Iframe, DisplayMode.Expanded)
 {
     this.AddInputPin("Caption", PinDataTypeFactory.Create <string>(), PropertyMode.Always);
     this.AddInputPin("SourceUri", PinDataTypeFactory.Create <string>(), PropertyMode.Always);
     this.AddInputPin("Size", PinDataTypeFactory.Create <Int2>(new Int2(320, 240)), PropertyMode.Always);
 }
Example #2
0
        public Take(IGraphRuntime runtime)
            : base(runtime)
        {
            this.inputPin  = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.countPin  = AddInputPin("Count", PinDataTypeFactory.CreateInt32(5), PropertyMode.Default);
            this.outputPin = AddOutputPin("Output", PinDataTypeFactory.FromType(typeof(ISequence <>)));

            this.inputPin.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.FromType(typeof(ISequence <>)), true, pinDataType =>
                {
                    var genericType = pinDataType.UnderlyingType.GenericTypeArguments.FirstOrDefault();

                    if (genericType != null)
                    {
                        genericDelegate = new GenericDelegate <Func <object, object, object> >(this, EvaluateInternalAttribute.GetMethod(GetType()).MakeGenericMethod(genericType));
                    }
                    else
                    {
                        genericDelegate = null;
                    }

                    outputPin.ChangeType(pinDataType);
                });
            });
        }
        public PythonScriptModuleBase(IGraphRuntime runtime, ILoggerFactory loggerFactory, IPythonMainThread mainThread)
            : base(runtime, ModuleKind.ScriptModule)
        {
            logger          = loggerFactory.CreateLogger <PythonScriptModuleBase>();
            this.mainThread = mainThread;

            this.captionPin       = this.AddInputPin("caption", PinDataTypeFactory.Create <string>(), PropertyMode.Always);
            this.functionNamePin  = this.AddInputPin("functionName", PinDataTypeFactory.Create <string>(DEFAULT_FUNCTION_NAME), PropertyMode.Default);
            this.useMainThreadPin = this.AddInputPin("useMainThread", PinDataTypeFactory.Create <bool>(true), PropertyMode.Always);
            this.parserErrorPin   = this.AddInputPin("parserError", PinDataTypeFactory.Create <Models.ExceptionModel>(null, WellKnownEditors.ExceptionViewer), PropertyMode.Always);
            var scriptSourcePinId = this.AddScriptSourcePin();

            this.argumentPins = new List <GenericInputPin>();
            this.resultPins   = new List <GenericOutputPin>();

            this.properties[scriptSourcePinId].WhenNodeEvent.OfType <PropertyChangedEvent>().Subscribe(evt =>
            {
                logger.LogInformation("Script source changed");
                UpdateSignatureSafe();
            });

            this.properties[functionNamePin.Id].WhenNodeEvent.OfType <PropertyChangedEvent>().Subscribe(evt =>
            {
                logger.LogInformation("Function name changed");
                UpdateSignatureSafe();
            });

            this.DynamicDisplayName = new DynamicDisplayNameFunc(FormatDisplayName);
        }
Example #4
0
        public Broadcast(IGraphRuntime runtime)
            : base(runtime)
        {
            this.inputPin         = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.dynamicOutputPin = new DynamicOutputPin(runtime, outputs, "Output", PinDataTypeFactory.FromType(typeof(ISequence <>)));

            this.inputPin.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.FromType(typeof(ISequence <>)), true, pinDataType =>
                {
                    var genericType = pinDataType.UnderlyingType.GenericTypeArguments.FirstOrDefault();

                    if (genericType != null)
                    {
                        genericDelegate = new GenericDelegate <Func <object, object[]> >(this, EvaluateInternalAttribute.GetMethod(GetType()).MakeGenericMethod(genericType));
                    }
                    else
                    {
                        genericDelegate = null;
                    }


                    foreach (var pin in dynamicOutputPin.Pins.OfType <IDataTypeChangeable>())
                    {
                        pin.ChangeType(pinDataType);
                    }
                });
            });
        }
Example #5
0
        public Convert(IGraphRuntime runtime)
            : base(runtime)
        {
            this.inputPin      = AddInputPin("Input", PinDataTypeFactory.CreateFloat64(), PropertyMode.Never);
            this.targetTypePin = AddInputPin("TargetType", PinDataTypeFactory.CreateEnum <ConvertTypeCode>(ConvertTypeCode.Float64), PropertyMode.Always);
            this.outputPin     = AddOutputPin("Output", CreateTargetPinDataType(ConvertTypeCode.Float64));
            this.inputPin.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, CreateTargetPinDataType(ConvertTypeCode.Float64), false, pinDataType =>
                {
                    var genericInputType = pinDataType.UnderlyingType;
                    BuildGenericDelegate(genericInputType, outputPin.DataType.UnderlyingType);
                });
            });


            this.properties[targetTypePin.Id].WhenNodeEvent.OfType <PropertyChangedEvent>().Subscribe(x =>
            {
                var targetTypeCode = (ConvertTypeCode)x.Value.Value;

                IPinDataType targetPinDataType = CreateTargetPinDataType(targetTypeCode);
                var errors = outputPin.ChangeType(targetPinDataType);
                if (errors.Any())
                {
                    throw new AggregateException("One or more connections could not be reestablished after a data type change.", errors);
                }
                BuildGenericDelegate(inputPin.DataType.UnderlyingType, outputPin.DataType.UnderlyingType);
            });
        }
Example #6
0
 public Range(IGraphRuntime runtime)
     : base(runtime)
 {
     this.startPin  = AddInputPin("Start", PinDataTypeFactory.CreateInt32(0), PropertyMode.Default);
     this.countPin  = AddInputPin("Count", PinDataTypeFactory.CreateInt32(10), PropertyMode.Default);
     this.outputPin = AddOutputPin("Output", PinDataTypeFactory.Create <ISequence <int> >());
 }
Example #7
0
        public Where(IGraphRuntime runtime)
            : base(runtime, false, PinDataTypeFactory.Create <bool>(), SUBGRAPH_SOURCE_PIN_ID)
        {
            this.inputPin  = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.outputPin = AddOutputPin("Output", PinDataTypeFactory.Create <ISequence <object> >());

            this.subGraphSource = ((GenericOutputPin)this.subGraphInputModule.Outputs[SUBGRAPH_SOURCE_PIN_ID]);
            this.subGraphResult = this.SubGraph.OutputModule.DefaultInputPin;

            this.inputPin.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.FromType(typeof(ISequence <>)), true, pinDataType =>
                {
                    var genericType = pinDataType.UnderlyingType.GenericTypeArguments.FirstOrDefault() ?? typeof(object);
                    subGraphSource.ChangeType(PinDataTypeFactory.FromType(genericType));

                    var outputType = PinDataTypeFactory.FromType(typeof(ISequence <>).MakeGenericType(genericType));
                    if (outputPin.DataType.UnderlyingType != outputType.UnderlyingType)
                    {
                        outputPin.ChangeType(outputType);
                    }

                    genericDelegate = new GenericDelegate <Func <object, object, object> >(this, EvaluateInternalAttribute.GetMethod(GetType()).MakeGenericMethod(genericType));
                });
            });
        }
Example #8
0
 public ZipFunc(IGraphRuntime runtime)
     : base(runtime)
 {
     this.funcPin         = AddInputPin("Function", PinDataTypeFactory.Create <Delegate>(), PropertyMode.Allow);
     this.dynamicInputPin = new DynamicInputPin(runtime, inputs, "Input", PinDataTypeFactory.Create <ISequence>());
     this.outputPin       = AddOutputPin("Output", PinDataTypeFactory.Create <ISequence <object> >());
 }
Example #9
0
 public ViewCurrent(IGraphRuntime runtime)
     : base(runtime, ModuleKind.ViewModule)
 {
     this.inputPin = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(ISequence <string>), string.Empty, WellKnownEditors.Hidden, null, null), PropertyMode.Never);
     this.data     = AddInputPin("data", PinDataTypeFactory.CreateString(), PropertyMode.Always);
     EnableVirtualOutputPin();
 }
Example #10
0
        public SelectMany(IGraphRuntime runtime)
            : base(runtime, false, PinDataTypeFactory.FromType(typeof(ISequence <>)), SUBGRAPH_SOURCE_PIN_ID)
        {
            this.inputPin          = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.sequentialPin     = AddInputPin("Sequential", PinDataTypeFactory.Create <bool>(true), PropertyMode.Default);
            this.outputPin         = AddOutputPin("Output", PinDataTypeFactory.Create <ISequence <object> >());
            this.maxConcurrencyPin = AddInputPin("MaxConcurrency", PinDataTypeFactory.Create <int>(8), PropertyMode.Default);

            this.subGraphSource = ((GenericOutputPin)this.subGraphInputModule.Outputs[SUBGRAPH_SOURCE_PIN_ID]);
            this.subGraphResult = this.SubGraph.OutputModule.DefaultInputPin;

            this.inputPin.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.FromType(typeof(ISequence <>)), true, pinDataType =>
                {
                    var genericType = pinDataType.UnderlyingType.GenericTypeArguments.FirstOrDefault() ?? typeof(object);
                    subGraphSource.ChangeType(PinDataTypeFactory.FromType(genericType));

                    BuildGenericDelegate();
                });
            });

            this.subGraphResult.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.FromType(typeof(ISequence <>)), true, pinDataType =>
                {
                    outputPin.ChangeType(pinDataType);

                    BuildGenericDelegate();
                });
            });
        }
Example #11
0
        public SequenceToArray(IGraphRuntime runtime)
            : base(runtime, ModuleKind.Module, DisplayMode.Collapsed)
        {
            this.inputPin  = AddInputPin("Sequence", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Allow);
            this.outputPin = AddOutputPin("Array", PinDataTypeFactory.FromType(typeof(object[])));

            this.inputPin.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.FromType(typeof(ISequence <>)), true, pinDataType =>
                {
                    var method = EvaluateInternalAttribute.GetMethod(GetType()).MakeGenericMethod(pinDataType.UnderlyingType);

                    var genericType = pinDataType.UnderlyingType.GenericTypeArguments.FirstOrDefault() ?? pinDataType.UnderlyingType;
                    if (genericType != null)
                    {
                        genericDelegate = new GenericDelegate <Func <object, object> >(this, EvaluateInternalAttribute.GetMethod(GetType()).MakeGenericMethod(genericType));
                    }
                    else
                    {
                        genericDelegate = null;
                    }

                    outputPin.ChangeType(PinDataTypeFactory.FromType(genericType.MakeArrayType()));
                });
            });
        }
Example #12
0
        private static IPinDataType CreateTargetPinDataType(ConvertTypeCode typeCode)
        {
            switch (typeCode)
            {
            case ConvertTypeCode.Any:
                return(PinDataTypeFactory.Create <ISequence <object> >());

            case ConvertTypeCode.Boolean:
                return(PinDataTypeFactory.Create <ISequence <bool> >());

            case ConvertTypeCode.Byte:
                return(PinDataTypeFactory.Create <ISequence <byte> >());

            case ConvertTypeCode.Int16:
                return(PinDataTypeFactory.Create <ISequence <short> >());

            case ConvertTypeCode.Int32:
                return(PinDataTypeFactory.Create <ISequence <int> >());

            case ConvertTypeCode.Int64:
                return(PinDataTypeFactory.Create <ISequence <long> >());

            case ConvertTypeCode.Float32:
                return(PinDataTypeFactory.Create <ISequence <float> >());

            case ConvertTypeCode.Float64:
                return(PinDataTypeFactory.Create <ISequence <double> >());

            case ConvertTypeCode.String:
                return(PinDataTypeFactory.Create <ISequence <string> >());
            }

            return(PinDataTypeFactory.Create <object>());
        }
Example #13
0
        private static IPinDataType CreateTargetPinDataType(ConvertTypeCode typeCode)
        {
            switch (typeCode)
            {
            case ConvertTypeCode.Any:
                return(PinDataTypeFactory.CreateAny());;

            case ConvertTypeCode.Boolean:
                return(PinDataTypeFactory.CreateBoolean());

            case ConvertTypeCode.Byte:
                return(PinDataTypeFactory.FromType(typeof(byte)));

            case ConvertTypeCode.Int16:
                return(PinDataTypeFactory.FromType(typeof(short)));

            case ConvertTypeCode.Int32:
                return(PinDataTypeFactory.CreateInt32());

            case ConvertTypeCode.Int64:
                return(PinDataTypeFactory.FromType(typeof(long)));

            case ConvertTypeCode.Float32:
                return(PinDataTypeFactory.FromType(typeof(float)));

            case ConvertTypeCode.Float64:
                return(PinDataTypeFactory.FromType(typeof(double)));

            case ConvertTypeCode.String:
                return(PinDataTypeFactory.CreateString());
            }

            return(PinDataTypeFactory.Create <object>());
        }
Example #14
0
        public Aggregate(IGraphRuntime runtime)
            : base(runtime, false, SUBGRAPH_SOURCE_PIN_ID, SUBGRAPH_ACCUMULATE_PIN_ID)
        {
            this.sourceInput = AddInputPin("Source", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.seedInput   = AddInputPin("Seed", PinDataTypeFactory.CreateAny(), PropertyMode.Allow);
            this.output      = AddOutputPin("Output", PinDataTypeFactory.CreateAny());

            this.subGraphInput      = ((GenericOutputPin)this.subGraphInputModule.Outputs[SUBGRAPH_SOURCE_PIN_ID]);
            this.subGraphAccumulate = (GenericOutputPin)this.subGraphInputModule.Outputs[SUBGRAPH_ACCUMULATE_PIN_ID];
            this.subGraphOutput     = subGraph.OutputModule.DefaultInputPin;

            this.sourceInput.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.FromType(typeof(ISequence <>)), true, pinDataType =>
                {
                    var genericType = pinDataType.UnderlyingType.GenericTypeArguments.FirstOrDefault() ?? typeof(object);
                    subGraphInput.ChangeType(PinDataTypeFactory.FromType(genericType));

                    BuildGenericDelegate();
                });
            });

            this.seedInput.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.CreateAny(), false, pinDataType =>
                {
                    subGraphAccumulate.ChangeType(pinDataType);
                    output.ChangeType(pinDataType);
                    subGraphOutput.ChangeType(pinDataType);

                    BuildGenericDelegate();
                });
            });
        }
Example #15
0
 public UnaryOperation(IGraphRuntime runtime, string moduleType, Func <double, double> operation, string resultPinName = "Result", string operandPinName = "Operand")
     : base(runtime, ModuleKind.Module, DisplayMode.Expanded, moduleType)
 {
     this.operation  = operation;
     this.operandPin = this.AddInputPin(operandPinName, PinDataTypeFactory.CreateFloat64(), PropertyMode.Never);
     this.resultPin  = this.AddOutputPin(resultPinName, PinDataTypeFactory.CreateFloat64());
 }
Example #16
0
 public SelectFunc(IGraphRuntime runtime)
     : base(runtime)
 {
     this.inputPin  = AddInputPin("Input", PinDataTypeFactory.Create <ISequence>(), PropertyMode.Never);
     this.funcPin   = AddInputPin("Function", PinDataTypeFactory.Create <Delegate>(), PropertyMode.Allow);
     this.outputPin = AddOutputPin("Output", PinDataTypeFactory.Create <ISequence <object> >());
 }
Example #17
0
        private bool OnDynamicInputAdd(string id)
        {
            dynamicInputPin.Pin(id).WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.FromType(typeof(ISequence <>)), true, pinDataType =>
                {
                    var genericType = pinDataType.UnderlyingType.GenericTypeArguments.FirstOrDefault() ?? typeof(object);

                    var pinEvent = (PinConnectionChangeEvent)evt;

                    // subgraph input
                    var pin = SubGraph.InputModule.Outputs.Where(x => x.Id == pinEvent.Source.Id).OfType <IDataTypeChangeable>().FirstOrDefault();
                    pin.ChangeType(PinDataTypeFactory.FromType(genericType));
                });
            });

            try
            {
                addingSubGraphPin = true;
                return(SubGraph.InputModule.AddModulePin(id, true, PinDataTypeFactory.CreateAny()) != null);
            }
            finally
            {
                addingSubGraphPin = false;
            }
        }
Example #18
0
        private bool OnDynamicInputAdd(string id)
        {
            return(dynamicInputPin.Pin(id).WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.FromType(typeof(ISequence <>)), true, pinDataType =>
                {
                    var genericType = pinDataType.UnderlyingType.GenericTypeArguments.FirstOrDefault();

                    if (genericType != null)
                    {
                        genericDelegate = new GenericDelegate <Func <object, object> >(this, EvaluateInternalAttribute.GetMethod(GetType()).MakeGenericMethod(genericType));
                    }
                    else
                    {
                        genericDelegate = null;
                    }


                    var pinsToChange = dynamicInputPin.Pins.Where(x => x.Id != id && x.DataType.UnderlyingType != pinDataType.UnderlyingType).OfType <IDataTypeChangeable>();
                    foreach (var pin in pinsToChange)
                    {
                        pin.ChangeType(pinDataType);
                    }

                    if (!pinsToChange.Any())
                    {
                        outputPin.ChangeType(pinDataType);
                    }
                });
            }) != null);
        }
Example #19
0
 public Fork(IGraphRuntime runtime)
     : base(runtime)
 {
     this.flowMode = FlowMode.WaitAny;
     this.AddInputPin("flowIn", PinDataTypeFactory.CreateFlow(), PropertyMode.Never);
     this.flowOutputs = new DynamicOutputPin(runtime, outputs, "Flow", PinDataTypeFactory.CreateFlow());
 }
Example #20
0
 public ShaGenerator(IGraphRuntime runtime, HashAlgorithmType type)
     : base(runtime)
 {
     this.type     = type;
     this.inputPin = AddInputPin("Input", PinDataTypeFactory.Create <object>(), PropertyMode.Never);
     this.hashPin  = AddOutputPin("Hash", PinDataTypeFactory.Create <byte[]>());
 }
 public GaussianRandomSequence(IGraphRuntime runtime)
     : base(runtime)
 {
     this.seedPin   = AddInputPin("Seed", PinDataTypeFactory.Create <int?>(null, WellKnownEditors.IntNumber), PropertyMode.Default);
     this.muPin     = AddInputPin("µ", PinDataTypeFactory.Create <double>(0, WellKnownEditors.FloatNumber), PropertyMode.Default);
     this.sigmaPin  = AddInputPin("σ", PinDataTypeFactory.Create <double>(1, WellKnownEditors.FloatNumber), PropertyMode.Default);
     this.outputPin = AddOutputPin("Output", PinDataTypeFactory.Create <ISequence <double> >());
 }
Example #22
0
 public SelectManyFunc(IGraphRuntime runtime)
     : base(runtime)
 {
     inputPin      = AddInputPin("Input", PinDataTypeFactory.Create <ISequence>(), PropertyMode.Never);
     funcPin       = AddInputPin("Function", PinDataTypeFactory.Create <Delegate>(), PropertyMode.Allow);
     sequentialPin = AddInputPin("Sequential", PinDataTypeFactory.Create <bool>(true), PropertyMode.Default);
     outputPin     = AddOutputPin("Output", PinDataTypeFactory.Create <ISequence <object> >());
 }
 public CreateArray(IGraphRuntime runtime)
     : base(runtime)
 {
     this.dynamicInputPin = new DynamicInputPin(runtime, inputs, "Input", PinDataTypeFactory.CreateAny(), OnDynamicInputAdd)
     {
         ForceAutoId = true
     };
     this.output = AddOutputPin("Output", PinDataTypeFactory.FromType(typeof(Array)));
 }
Example #24
0
 public Merge(IGraphRuntime runtime)
     : base(runtime)
 {
     this.dynamicInputPin = new DynamicInputPin(runtime, inputs, "Input", PinDataTypeFactory.FromType(typeof(ISequence <>)), OnDynamicInputAdd)
     {
         Renameable = true
     };
     this.outputPin = AddOutputPin("Output", PinDataTypeFactory.FromType(typeof(ISequence <>)));
 }
Example #25
0
        public SequenceEqual(IGraphRuntime runtime)
            : base(runtime)
        {
            this.firstInputPin  = AddInputPin("First", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.secondInputPin = AddInputPin("Second", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.outputPin      = AddOutputPin("Result", PinDataTypeFactory.CreateBoolean());

            this.firstInputPin.WhenNodeEvent.Subscribe(HandleInputPinEvent);
            this.secondInputPin.WhenNodeEvent.Subscribe(HandleInputPinEvent);
        }
Example #26
0
 public WriteFile(IGraphRuntime runtime)
     : base(runtime)
 {
     pathPin            = this.AddInputPin("fileName", PinDataTypeFactory.Create <string>(string.Empty, WellKnownEditors.FileSelector), PropertyMode.Default, flags: PinFlags.ResolvePath);
     modePin            = this.AddInputPin("mode", PinDataTypeFactory.CreateEnum(WriteFileMode.OverwriteOrCreate, WellKnownEditors.DropDown), PropertyMode.Default);
     writablePin        = this.AddInputPin("writable", PinDataTypeFactory.Create <IWritable>(), PropertyMode.Never);
     appendGuidPin      = this.AddInputPin("appendGuid", PinDataTypeFactory.CreateBoolean(false), PropertyMode.Default);
     createDirectoryPin = this.AddInputPin("createDirectory", PinDataTypeFactory.CreateBoolean(false), PropertyMode.Default);
     EnableVirtualOutputPin();
 }
Example #27
0
        public Count(IGraphRuntime runtime)
            : base(runtime)
        {
            this.inputPin  = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.outputPin = AddOutputPin("Output", PinDataTypeFactory.CreateInt32());

            this.inputPin.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.FromType(typeof(ISequence <>)), true);
            });
        }
Example #28
0
        public void BuildOutputPins(Type itemType)
        {
            if (itemType == this.itemType)
            {
                return;
            }

            // do not fall back to object when we have build pins for another type before
            // (most likely the drop back to object is due to a disconnect and we do not want to loose all existing connections)
            if (itemType == typeof(object) && itemPropertyPins.Count > 0)
            {
                return;
            }

            var oldConnections = new Dictionary <string, IPin[]>();

            // remove all outputs
            foreach (var itemPropertiesPin in itemPropertyPins)
            {
                oldConnections.Add(itemPropertiesPin.Id, itemPropertiesPin.Connections.Select(x => x.Remote).ToArray());
                itemPropertiesPin.DisconnectAll();
                outputs.Remove(itemPropertiesPin);
            }
            itemPropertyPins.Clear();

            var itemProperties = itemType.GetProperties(BINDING_FLAGS).Where(p => p.GetIndexParameters().Length == 0);

            if (itemProperties.Any())
            {
                // add one output pin for every property
                foreach (var property in itemProperties)
                {
                    if (this.itemPropertyPins.Any(p => p.Id == property.Name))
                    {
                        continue;
                    }

                    var pin = AddOutputPin(property.Name, PinDataTypeFactory.FromType(property.PropertyType));
                    this.itemPropertyPins.Add(pin);

                    // try to reestablish exsting connections
                    RestorePinConnection(pin, oldConnections);
                }
            }
            else
            {
                // add a single pin for items without properties
                this.itemPropertyPins.Add(AddOutputPin(itemType.Name, PinDataTypeFactory.FromType(itemType)));
            }

            // store current type in property
            this.ItemTypeName = itemType.AssemblyQualifiedName;
            this.itemType     = itemType;
        }
Example #29
0
        public Join(IGraphRuntime runtime)
            : base(runtime)
        {
            this.flowMode = FlowMode.WaitAllOrFirstException;

            this.flowInputs = new DynamicInputPin(runtime, inputs, "Flow", PinDataTypeFactory.CreateFlow())
            {
                MaxConnections = null,
                ForceAutoId    = true
            };
            this.flowOut = this.AddOutputPin("flowOut", PinDataTypeFactory.CreateFlow(), 1);
        }
Example #30
0
        public ForLoop(IGraphRuntime runtime)
            : base(runtime, false, (IPinDataType)null)
        {
            subGraph.InputModule.AddModulePin(SUBGRAPH_INDEX_PIN_ID, false, PinDataTypeFactory.CreateInt32());
            subGraph.OutputModule.AddModulePin("Break", PinDataTypeFactory.CreateFlow(), PinFlags.None, null);

            this.AddInputPin("startValue", PinDataTypeFactory.CreateInt32(0), PropertyMode.Default);    // Initial value for counting
            this.AddInputPin("increment", PinDataTypeFactory.CreateInt32(1), PropertyMode.Default);     // Inrement of the counter variable after each evaluation of the loop body.
            this.AddInputPin("endValue", PinDataTypeFactory.CreateInt32(100), PropertyMode.Default);    // Exit loop when the counter variable becomes greater or equal to this value.

            this.DynamicDisplayName = new DynamicDisplayNameFunc(FormatDisplayName);
        }