Exemple #1
0
        private readonly long _dataValue; // = 0;

        #region Conversion & Conversion Routing
        public static void Register(ILibrary library)
        {
            library.AddCustomDataType <IntegerValue>();
            library.AddArbitraryType(typeof(long));
            ValueConverter <IntegerValue> .AddConverterFrom(ValueConverter <long> .Router, true,
                                                            delegate(object value) { return(new IntegerValue((long)value)); });

            ValueConverter <IntegerValue> .AddConverterTo(ValueConverter <long> .Router, true,
                                                          delegate(object value) { return(((IntegerValue)value).Value); });

            //library.AddCustomDataType(new CustomDataRef(typeof(IntegerValue), ValueConverter<IntegerValue>.Router));
        }
Exemple #2
0
        private readonly double _dataValue; // = 0;

        #region Conversion & Conversion Routing
        public static void Register(ILibrary library)
        {
            library.AddCustomDataType <RealValue>();
            library.AddArbitraryType(typeof(double));
            //library.AddCustomDataType(new CustomDataRef(typeof(RealValue), ValueConverter<RealValue>.Router));
            ValueConverter <RealValue> .AddConverterFrom <IntegerValue>(true, ConvertFrom);

            ValueConverter <RealValue> .AddConverterFrom <RationalValue>(true, ConvertFrom);

            ValueConverter <RealValue> .AddConverterTo(ValueConverter <IntegerValue> .Router, false,
                                                       delegate(object value) { return(new IntegerValue((long)Math.Round(((RealValue)value).Value, 0))); });

            ValueConverter <IntegerValue> .AddConverterFrom(ValueConverter <double> .Router, true,
                                                            delegate(object value) { return(new RealValue((double)value)); });

            ValueConverter <IntegerValue> .AddConverterTo(ValueConverter <double> .Router, true,
                                                          delegate(object value) { return(((RealValue)value).Value); });
        }