Beispiel #1
0
        public static T ConvertNMSType <T, S>(S value)
        {
            ConversionKey          key       = ConversionKey.GetKey(typeof(T), value.GetType());
            ConversionEntry <T, S> converter = (ConversionEntry <T, S>)NMSTypeConversionTable[key];

            if (converter == null)
            {
                throw new NMSTypeConversionException("Cannot convert between type : " + (typeof(T)).Name + ", and type: " + value.GetType().Name);
            }
            return(converter.ConvertInstance(value));
        }
Beispiel #2
0
        public static T ConvertNMSType <T>(object value)
        {
            ConversionKey key = ConversionKey.GetKey(typeof(T), value.GetType());

            NMSTypeConversionTable.TryGetValue(key, out ConversionEntry converter);
            if (converter == null)
            {
                throw new NMSTypeConversionException("Cannot convert between type : " + (typeof(T)).Name + ", and type: " + value.GetType().Name);
            }
            return((T)converter.Convert(value));
        }
Beispiel #3
0
        public static bool CanConvertNMSType <T>(object value)
        {
            ConversionKey key = ConversionKey.GetKey(typeof(T), value.GetType());

            return(NMSTypeConversionSet.Contains(key));
        }