Exemplo n.º 1
0
        public First(IGraphRuntime runtime)
            : base(runtime)
        {
            this.inputPin  = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.outputPin = AddOutputPin("Output", PinDataTypeFactory.Create <object>());

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

                    if (genericType != null)
                    {
                        genericDelegate = new GenericDelegate <Func <object, object, Task <object> > >(this, method.MakeGenericMethod(genericType));
                    }
                    else
                    {
                        genericDelegate = null;
                        genericType     = typeof(object);
                    }

                    outputPin.ChangeType(PinDataTypeFactory.FromType(genericType));
                });
            });
        }
Exemplo n.º 2
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> >());
 }
Exemplo n.º 3
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));
                });
            });
        }
Exemplo n.º 4
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>());
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
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> >());
 }
Exemplo n.º 7
0
        public Repeat(IGraphRuntime runtime)
            : base(runtime)
        {
            this.inputPin  = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.countPin  = AddInputPin("Count", PinDataTypeFactory.Create <int?>(null, WellKnownEditors.IntNumber), PropertyMode.Default);
            this.outputPin = AddOutputPin("Output", PinDataTypeFactory.FromType(typeof(ISequence <object>)));

            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));
                        outputPin.ChangeType(pinDataType);
                    }
                    else
                    {
                        genericDelegate = null;
                        outputPin.ChangeType(PinDataTypeFactory.FromType(typeof(ISequence <object>)));
                    }
                });
            });
        }
Exemplo n.º 8
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);
 }
Exemplo n.º 9
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();
                });
            });
        }
Exemplo n.º 10
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>());
        }
Exemplo n.º 11
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> >());
 }
Exemplo n.º 12
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[]>());
 }
Exemplo n.º 13
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> >());
 }
Exemplo n.º 14
0
 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> >());
 }
Exemplo n.º 15
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();
 }
Exemplo n.º 16
0
        public GetValuesFromArray(IGraphRuntime runtime)
            : base(runtime)
        {
            this.AddInputPin(COUNT_PIN_NAME, PinDataTypeFactory.FromType(typeof(int)), PropertyMode.Always);
            this.AddInputPin("array", PinDataTypeFactory.FromType(typeof(Array)), PropertyMode.Never);

            this.AddOutputPin("OutputRemainings", PinDataTypeFactory.FromType(typeof(Array)));
            this.dynamicOutputPin = new DynamicOutputPin(runtime, outputs, "Output", PinDataTypeFactory.Create <object>());

            this.properties[COUNT_PIN_NAME]
            .WhenNodeEvent
            .OfType <PropertyChangedEvent>()
            .Subscribe(x => UpdateOutputs((int)x.Value.Value));
        }
Exemplo n.º 17
0
        public Return(IGraphRuntime runtime)
            : base(runtime)
        {
            this.inputPin  = AddInputPin("Value", PinDataTypeFactory.CreateAny(), PropertyMode.Allow);
            this.outputPin = AddOutputPin("Sequence", PinDataTypeFactory.Create <ISequence <object> >());

            this.inputPin.WhenNodeEvent.Subscribe(evt =>
            {
                PinConnectionChangeEventHandler.ConnectionSensitivePinDataType(evt, PinDataTypeFactory.CreateAny(), false, pinDataType =>
                {
                    var method      = EvaluateInternalAttribute.GetMethod(GetType()).MakeGenericMethod(pinDataType.UnderlyingType);
                    genericDelegate = new GenericDelegate <Func <object, object> >(this, method);

                    outputPin.ChangeType(PinDataTypeFactory.FromType(typeof(ISequence <>).MakeGenericType(pinDataType.UnderlyingType)));
                });
            });
        }
Exemplo n.º 18
0
        public Any(IGraphRuntime runtime)
            : base(runtime, false, PinDataTypeFactory.Create <bool>(), SUBGRAPH_SOURCE_PIN_ID)
        {
            this.input  = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.output = AddOutputPin("Output", PinDataTypeFactory.CreateBoolean());

            this.subGraphInput = ((GenericOutputPin)this.subGraphInputModule.Outputs[SUBGRAPH_SOURCE_PIN_ID]);

            this.input.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();
                });
            });
        }
Exemplo n.º 19
0
        public PropertyAccessorModule(IGraphRuntime runtime)
            : base(runtime)
        {
            this.itemPin         = AddInputPin("Item", PinDataTypeFactory.Create <object>(), PropertyMode.Never);
            this.itemTypeNamePin = AddInputPin("ItemType", PinDataTypeFactory.Create <string>(OBJECT_TYPE_NAME), PropertyMode.Invisible);

            this.itemPropertyPins = new List <GenericOutputPin>();

            this.itemPin.WhenNodeEvent.Subscribe(evt =>
            {
                if (itemPin.Connections.Any())
                {
                    BuildOutputPins(itemPin.Connections.Single().Remote.DataType.UnderlyingType);
                }
                else
                {
                    BuildOutputPins(OBJECT_TYPE);
                }
            });
        }
Exemplo n.º 20
0
 protected override string AddScriptSourcePin()
 {
     pathPin = AddInputPin("path", PinDataTypeFactory.Create <string>(null, WellKnownEditors.SingleLineText), PropertyMode.Always, false, false, PinFlags.ResolvePath);
     return(pathPin.Id);
 }
Exemplo n.º 21
0
 public Catch(IGraphRuntime runtime)
     : base(runtime)
 {
     this.AddOutputPin("OnError", PinDataTypeFactory.CreateFlow(), 1);
     this.AddOutputPin("Exception", PinDataTypeFactory.Create <Exception>());
 }
Exemplo n.º 22
0
 public Interval(IGraphRuntime runtime)
     : base(runtime)
 {
     this.periodPin = AddInputPin("Period", PinDataTypeFactory.CreateTimeSpan(), PropertyMode.Default);
     this.outputPin = AddOutputPin("Output", PinDataTypeFactory.Create <ISequence <long> >());
 }
Exemplo n.º 23
0
 public VideoCommentModule(IGraphRuntime runtime)
     : base(runtime)
 {
     this.AddInputPin("Autoplay", PinDataTypeFactory.Create <bool>(), PropertyMode.Always);
 }
Exemplo n.º 24
0
 public Empty(IGraphRuntime runtime)
     : base(runtime)
 {
     this.outputPin = AddOutputPin("Output", PinDataTypeFactory.Create <ISequence <object> >());
 }
Exemplo n.º 25
0
 public VectorInput(IGraphRuntime runtime)
     : base(runtime, null, PinDataTypeFactory.Create <string>(), PinDataTypeFactory.Create <V <double> >(), WellKnownEditors.MultiLineText)
 {
 }
Exemplo n.º 26
0
 public ReadableToString(IGraphRuntime runtime)
     : base(runtime)
 {
     this.readablePin = AddInputPin("Readable", PinDataTypeFactory.Create <IReadable>(), PropertyMode.Allow);
     this.stringPin   = AddOutputPin("String", PinDataTypeFactory.Create <string>());
 }
Exemplo n.º 27
0
 protected override string AddScriptSourcePin()
 {
     scriptPin = AddInputPin("Script", PinDataTypeFactory.Create <string>(DEFAULT_SCRIPT, WellKnownEditors.Python), PropertyMode.Always);
     return(scriptPin.Id);
 }
Exemplo n.º 28
0
 public Throw(IGraphRuntime runtime)
     : base(runtime)
 {
     this.messagePin = AddInputPin("Message", PinDataTypeFactory.Create <string>(string.Empty, WellKnownEditors.MultiLineText), PropertyMode.Default);
     this.outputPin  = AddOutputPin("Output", PinDataTypeFactory.Create <ISequence <object> >());
 }
Exemplo n.º 29
0
 public ImageDecoderBase(IGraphRuntime runtime)
     : base(runtime)
 {
     this.readablePin = this.AddInputPin("Readable", PinDataTypeFactory.Create <IReadable>(), PropertyMode.Never);
     this.imagePin    = this.AddOutputPin("Image", PinDataTypeFactory.Create <IImageBuffer>());
 }
Exemplo n.º 30
0
 public Func(IGraphRuntime runtime)
     : base(runtime, true)
 {
     funcPin = AddOutputPin("Function", PinDataTypeFactory.Create <Delegate>());
 }