/// <summary> /// Checks whether the <paramref name="id"/> is already contained. /// </summary> private bool IsContainingId(AssetId id) { if (ExistingIds.Contains(id)) { return(true); } return(ContainsAssetWithId?.Invoke(id) ?? false); }
/// <summary> /// Default delegate for ids. /// </summary> private bool DefaultContainsId(Guid guid) { if (ExistingIds.Contains(guid)) { return(true); } if (ContainsAssetWithId != null) { return(ContainsAssetWithId(guid)); } return(false); }
/// <summary> /// Registers an asset identifier for usage. /// </summary> /// <param name="assetId">The asset identifier.</param> /// <param name="newGuid">The new unique identifier if an asset has already been registered with the same id.</param> /// <returns><c>true</c> if the asset id is already in used. <paramref name="newGuid" /> contains a new guid, <c>false</c> otherwise.</returns> public bool RegisterId(AssetId assetId, out AssetId newGuid) { newGuid = assetId; var result = AlwaysCreateNewId || IsContainingId(assetId); if (result) { newGuid = AssetId.New(); } ExistingIds.Add(newGuid); return(result); }
/// <summary> /// Registers an asset identifier for usage. /// </summary> /// <param name="assetId">The asset identifier.</param> /// <param name="newGuid">The new unique identifier if an asset has already been registered with the same id.</param> /// <returns><c>true</c> if the asset id is already in used. <paramref name="newGuid" /> contains a new guid, <c>false</c> otherwise.</returns> public bool RegisterId(Guid assetId, out Guid newGuid) { newGuid = assetId; var result = AlwaysCreateNewId || containsId(assetId); if (result) { newGuid = Guid.NewGuid(); } ExistingIds.Add(newGuid); return(result); }