public void FastandBlackMonsterCreateTest()
        {
            AbstractFactory fastFactory = new FastFactory();

            var fastBlackMonster = fastFactory.CreateBlackMonster(1);

            Assert.Equal(120, fastBlackMonster.GetCurrentHealth());
        }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
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);
            }