public Duck Get(DuckId id)
 {
     if (!_duckDictionary.ContainsKey(id.ToString()))
     {
         throw new NoDuckWithIdException(id.ToString());
     }
     return(_converter.Convert(_duckDictionary[id.ToString()]));
 }
Beispiel #2
0
 public Duck Convert(DuckRecord record)
 {
     return(new ReflectionBuilder <Duck>()
            .SetAutoPropety("Id", DuckId.FromExisiting(record.Id))
            .SetField("_name", record.Name)
            .SetField("_age", record.Age)
            .Instance);
 }
Beispiel #3
0
 public static Duck Create(string name, int age) => new Duck(DuckId.Generate(), name, age);
Beispiel #4
0
 private Duck(DuckId id, string name, int age)
 {
     Id    = id;
     _name = name;
     _age  = age;
 }