public static int Register(IRegistrable registrable) { var info = registrable.GetRegistrationInfo(); if (info == null) { return(-1); } info.Id = _nextId; RegisteredList.Add(info); _nextId = RegisteredList.Count + 1; return(info.Id); }
//With BRIDGE pattern, implement Register method so it will accept both a Person and an Item public static int Register(IRegistrable registarable) { //get info from an lib object var info = registarable.GetRegistrationInfo(); if (info == null) { return(-1); } //get new id for for the registered object info.Id = _nextId; //add to registration repository _registeredList.Add(info); //store next available id _nextId = _registeredList.Count + 1; //return success return(info.Id); }