/// <inheritdoc /> public async Task <object> InitialiseCacheItemAsync( string key, CancellationToken cancellationToken) { object toReturn = null; this.loggerWrapper.Debug( $"Parsing \"{key}\" as an instance of " + $"{nameof(EnumerationKey)}..."); EnumerationKey enumerationsKey = EnumerationKey.Parse(key); this.loggerWrapper.Info( $"Parsed {enumerationsKey} from \"{key}\"."); this.loggerWrapper.Debug( $"Fetching {enumerationsKey} from storage..."); MappingsResult mappingsResult = await this.mappingsResultStorageAdapter.GetMappingsResultAsync( enumerationsKey, cancellationToken) .ConfigureAwait(false); this.loggerWrapper.Info( $"Pulled {mappingsResult} from storage for " + $"{enumerationsKey}."); toReturn = mappingsResult; return(toReturn); }
/// <inheritdoc /> public async Task <MappingsResult> GetMappingsResultAsync( EnumerationKey enumerationsKey, CancellationToken cancellationToken) { MappingsResult toReturn = null; if (enumerationsKey == null) { throw new ArgumentNullException(nameof(enumerationsKey)); } IEnumerable <EnumerationMapping> enumerationMappings = await this.GetEnumerationMappingsAsync( enumerationsKey, cancellationToken) .ConfigureAwait(false); Dictionary <string, string[]> mappings = enumerationMappings .ToDictionary( x => x.RowKey, x => MappingToArray(x.Mapping)); toReturn = new MappingsResult() { Mappings = mappings, }; return(toReturn); }
/// <inheritdoc /> public async Task <GetEnumerationMappingsResponse> GetEnumerationMappingsAsync( GetEnumerationMappingsRequest getEnumerationMappingsRequest, CancellationToken cancellationToken) { GetEnumerationMappingsResponse toReturn = null; if (getEnumerationMappingsRequest == null) { throw new ArgumentNullException( nameof(getEnumerationMappingsRequest)); } EnumerationKey enumerationsKey = getEnumerationMappingsRequest.EnumerationsKey; string enumerationsKeyStr = enumerationsKey.ExportToString(); this.loggerWrapper.Debug( $"Pulling back {nameof(MappingsResult)} for " + $"{nameof(enumerationsKey)} {enumerationsKey} " + $"(\"{enumerationsKeyStr}\") from the " + $"{nameof(ICacheManager)}..."); object unboxedMappingsResult = await this.cacheManager.GetAsync( enumerationsKeyStr, cancellationToken) .ConfigureAwait(false); MappingsResult mappingsResult = unboxedMappingsResult as MappingsResult; // Result will be non-null. this.loggerWrapper.Info( $"{nameof(MappingsResult)} pulled back from the " + $"{nameof(ICacheManager)}: {mappingsResult}."); toReturn = new GetEnumerationMappingsResponse() { MappingsResult = mappingsResult, }; return(toReturn); }