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