public ConverterModule(IGraphRuntime runtime) : base(runtime) { converterByName.Add("None", null); foreach (var c in runtime.TypeConverters) { string sourceTypeName = GetShortTypeName(c.SourceType); string destinationTypeName = GetShortTypeName(c.DestinationType); var converterName = string.Concat(sourceTypeName, " -> ", destinationTypeName); if (!converterByName.ContainsKey(converterName)) { converterByName.Add(converterName, c); } } this.inputPin = AddInputPin("Input", PinDataTypeFactory.FromType(typeof(object)), PropertyMode.Never); this.converterPin = AddInputPin("Converter", PinDataTypeFactory.CreateDynamicEnum(converterByName.Keys.ToArray(), "None"), PropertyMode.Always); this.outputPin = AddOutputPin("Output", PinDataTypeFactory.FromType(typeof(object))); this.properties[converterPin.Id].WhenNodeEvent.OfType <PropertyChangedEvent>().Subscribe(x => { var converterName = (string)x.Value.Value; converterByName.TryGetValue(converterName, out typeConverter); IPinDataType sourceType, destinationType; if (typeConverter == null) { sourceType = PinDataTypeFactory.CreateAny(); destinationType = PinDataTypeFactory.CreateAny(); } else { sourceType = typeConverter.SourceType != null ? PinDataTypeFactory.FromType(typeConverter.SourceType) : PinDataTypeFactory.CreateAny(); destinationType = typeConverter.DestinationType != null ? PinDataTypeFactory.FromType(typeConverter.DestinationType) : PinDataTypeFactory.CreateAny(); } var errors = inputPin.ChangeType(sourceType).Concat(outputPin.ChangeType(destinationType)); if (errors.Any()) { throw new AggregateException("One or more connections could not be reestablished after a data type change.", errors); } }); }