Esempio n. 1
0
    public static TValue GetOrInsertNew <TKey, TValue>(this Dictionary <TKey, TValue> dict, TKey key)
        where TValue : new()
    {
        if (!dict.TryGetValue(key, out TValue result))
        {
            return(dict[key] = FastFactory <TValue> .CreateInstance());
        }

        return(result);
    }
Esempio n. 2
0
            public static T Create(DataRow row)
            {
                var result = FastFactory <T> .CreateInstance();

                foreach (var p in props)
                {
                    var col      = p.Key;
                    var accessor = p.Value.Item2;
                    var pType    = Nullable.GetUnderlyingType(p.Value.Item1) ?? p.Value.Item1;
                    accessor.SetValue(result, Convert.ChangeType(row[col], pType));
                }

                return(result);
            }