Пример #1
0
        public static Dictionary <TKeyOut, TValueOut> To <TKeyOut, TValueOut>(MapType <TKey, TValue> obj)
        {
            //Check to make sure we can convert
            if (KeyType.CreateInstance().CanConvertFrom(typeof(TKeyOut)) && ValueType.CreateInstance().CanConvertFrom(typeof(TValueOut)))
            {
                return(obj.ToDictionary(k => k.Key.GetValue <TKeyOut>(), v => v.Value.GetValue <TValueOut>()));
            }

            throw new ArgumentException(string.Format("can't convert MapType of type {0},{1} to Dictionary of type {2},{3}", typeof(TKey), typeof(TValue), typeof(TKeyOut), typeof(TValueOut)));
        }
Пример #2
0
        public static MapType <TKey, TValue> From <TKeyIn, TValueIn>(IDictionary <TKeyIn, TValueIn> obj)
        {
            //Check to make sure we can convert
            if (KeyType.CreateInstance().CanConvertFrom(typeof(TKeyIn)) && ValueType.CreateInstance().CanConvertFrom(typeof(TValueIn)))
            {
                return(new MapType <TKey, TValue>(obj.ToDictionary(
                                                      k => (TKey)CassandraObject.GetCassandraObjectFromObject(k.Key, KeyType),
                                                      v => (TValue)CassandraObject.GetCassandraObjectFromObject(v.Value, ValueType))));
            }

            throw new ArgumentException(string.Format("can't convert IDictionary of type {0},{1} to MapType of type {2},{3}", typeof(TKeyIn), typeof(TValueIn), typeof(TKey), typeof(TValue)));
        }
Пример #3
0
 public override IMember Index(IPythonInstance instance, IArgumentSet args) => ValueType.CreateInstance(args);