public bool HasObject <T>(string fullName) { if (ObjectIdentifierLookup.ContainsKey(typeof(T))) { return(ObjectIdentifierLookup[typeof(T)].ContainsKey(fullName)); } return(false); }
public T GetObject <T>(string fullName) where T : ToffeeObject { if (ObjectIdentifierLookup.ContainsKey(typeof(T))) { if (ObjectIdentifierLookup[typeof(T)].ContainsKey(fullName)) { return((T)ObjectIdentifierLookup[typeof(T)][fullName]); } } return(null); }
private void AddObject(ToffeeObject tObject) { if (tObject.Network != this) { throw new ToffeeException("Tried to add object to network '{0}' but object belongs to '{1}'", Name, tObject.Network.Name); } if (Objects.ContainsKey(tObject.GetType())) { Objects[tObject.GetType()].Add(tObject); ObjectIdentifierLookup[tObject.GetType()].Add(tObject.FullName, tObject); ObjectLookup[tObject.GetType()].Add(tObject.ObjectId, tObject); } else { Objects.Add(tObject.GetType(), new List <ToffeeObject>()); ObjectIdentifierLookup.Add(tObject.GetType(), new Dictionary <string, ToffeeObject>()); ObjectLookup.Add(tObject.GetType(), new Dictionary <uint, ToffeeObject>()); Objects[tObject.GetType()].Add(tObject); ObjectIdentifierLookup[tObject.GetType()].Add(tObject.FullName, tObject); ObjectLookup[tObject.GetType()].Add(tObject.ObjectId, tObject); } }