public IDAlreadyExistsException(ID id) : base($"The ID {id} already exists in this ID pool") { }
public UnresolvedContextException(ID id) : base($"The contextual ID {id} was passed to the ID pool without expanding its context") { }
public MissingIDException(ID id) : base($"The ID {id} does not exist") { }
/// <summary> /// Ensures that the provided ID is mapped to an object. Will /// throw appropriate exceptions if not. /// </summary> /// <returns>The `id` parameter.</returns> /// <param name="id">The contextless ID.</param> public ID ValidateExisting(ID id) { CheckContext(id); Get(id); return(id); }
/// <summary> /// Checks if this ID pool contains the specified ID. /// </summary> /// <returns>`true` if the ID is mapped, `false` if not.</returns> /// <param name="id">The contextless ID.</param> public bool Contains(ID id) { CheckContext(id); return(_Storage.ContainsKey(id)); }
/// <summary> /// Maps the specified ID to the specified object. Will throw an /// exception if the namespace is locked. /// </summary> /// <param name="id">The contextless ID.</param> public void Set(ID id, T val) { CheckContext(id); CheckNamespace(id); _Storage[id] = val; }
/// <summary> /// Retrieves an object with the specified ID. Sets `val` if the object /// exists. /// </summary> /// <returns>`true` if the object exists and `val` has been set, /// `false` otherwise.</returns> /// <param name="id">The contextless ID.</param> /// /// <param name="val">Output parameter for the object.</param> public bool TryGet(ID id, out T val) { CheckContext(id); return(_Storage.TryGetValue(id, out val)); }