コード例 #1
0
ファイル: Convert.cs プロジェクト: Xamla/graph_system
        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);
            });
        }
コード例 #2
0
        public Sort(IGraphRuntime runtime)
            : base(runtime)
        {
            this.inputPin         = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(ISequence <>)), PropertyMode.Never);
            this.sortDirectionPin = AddInputPin("SortDirection", PinDataTypeFactory.CreateEnum <SortDirection>(SortDirection.Ascending, WellKnownEditors.DropDown), 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);
                });
            });
        }
コード例 #3
0
ファイル: WriteFile.cs プロジェクト: Xamla/graph_system
 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();
 }
コード例 #4
0
ファイル: ReadableToV.cs プロジェクト: Xamla/graph_system
        public ReadableToV(IGraphRuntime runtime)
            : base(runtime)
        {
            this.targetTypePin = AddInputPin("TargetType", PinDataTypeFactory.CreateEnum <ConvertTypeCode>(ConvertTypeCode.Float64), PropertyMode.Always);
            this.outputPin     = AddOutputPin("Output", PinDataTypeFactory.FromType(typeof(V <>)));
            this.outputPin.ChangeType(CreateTargetPinDataType(ConvertTypeCode.Float64));
            this.data = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(IReadable)), PropertyMode.Allow);

            this.delimiter = AddInputPin("Delimiter", PinDataTypeFactory.FromType(typeof(char), ','), PropertyMode.Default);

            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);
                }
            });

            var del = (char)this.Properties.GetValue("Delimiter");
        }