Beispiel #1
0
        public static async Task <QueryBANResponse> RunAsync(
            QueryBANRequest request,
            GetCacheKey getCacheKey,
            GetCacheAsync getCache,
            SetCacheAsync setCache
            )
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (!request.IsValid)
            {
                throw new ArgumentException(nameof(request));
            }

            string content = await getCache?.Invoke(getCacheKey?.Invoke(request));

            if (string.IsNullOrEmpty(content))
            {
                content
                    = request.Coordinates == null
                    ? await LookupAddressAsync(request.Address)
                    : await LookupLocationAsync(request.Coordinates);

                await setCache?.Invoke(getCacheKey?.Invoke(request), content);
            }

            return(GetAddressInfos(content));
        }
Beispiel #2
0
 public static async Task <QueryBANResponse> RunAsync(QueryBANRequest request)
 {
     return(await RunAsync(
                request,
                GetLocalCacheKey,
                GetLocalCacheAsync,
                SetLocalCacheAsync
                ));
 }
Beispiel #3
0
 public static string GetLocalCacheKey(QueryBANRequest request) =>
 $"ban_{HashUtils.ToMD5(request.Coordinates?.ToString() ?? request.Address)}.json";