/// <summary> /// Determines whether the cache contains the specified animation identifier. /// </summary> /// <param name="animationId">The animation identifier.</param> /// <returns>A <see cref="Task{System.Boolean}" /> containing true if the identifier is found; otherwise false.</returns> public async Task <bool> ContainsAsync(long animationId) { await this.InitializeAsync(); TableResult result = await this.animationsCache.ExecuteAsync(TableOperation.Retrieve <AnimationCacheEntity>((animationId / CosmosAnimationCache.partitionSize).ToString(), animationId.ToString())); AnimationCacheEntity animationEntity = result.Result as AnimationCacheEntity; return(animationEntity != null); }
/// <summary> /// Sets the animation key asynchronously. /// </summary> /// <param name="animationKey">The animation key.</param> /// <returns>An <see cref="Task{System.Int64}" /> representing the animation identifier.</returns> public async Task <string> SetAnimationKeyAsync(string animationName, string animationJSON) { await this.InitializeAsync(); AnimationCacheEntity animationEntity = new AnimationCacheEntity(CosmosAnimationCache.partitionSize, "A_" + animationName) { AnimationJSON = animationJSON, }; await this.animationsCache.ExecuteAsync(TableOperation.InsertOrReplace(animationEntity)); return(animationName); }
/// <summary> /// Gets the animation key asynchronously. /// </summary> /// <param name="animationId">The animation identifier.</param> /// <exception cref="KeyNotFoundException"></exception> /// <returns>The animation key.</returns> public async Task <string> GetAnimationKeyAsync(string animationName) { await this.InitializeAsync(); //TableResult result = await this.animationsCache.ExecuteAsync(TableOperation.Retrieve<AnimationCacheEntity>((animationId / CosmosAnimationCache.partitionSize).ToString(), animationId.ToString())); TableResult result = await this.animationsCache.ExecuteAsync(TableOperation.Retrieve <AnimationCacheEntity>("0", "A_" + animationName)); AnimationCacheEntity animationEntity = result.Result as AnimationCacheEntity; if (animationEntity != null) { return(animationEntity.AnimationJSON); } throw new KeyNotFoundException($"The {nameof(animationName)} {animationName} could not be found."); }