Beispiel #1
0
 public RequestInfo(ApiClient client) => Client = client;
Beispiel #2
0
        internal static GetImplementation <T>[] GetImplementors <T>(this CachePolicy policy, ApiClient client)
        {
            GetImplementation <T> fresh() => new GetFresh <T>(client);
            GetImplementation <T> cache() => new GetCache <T>(client, silent: true);
            GetImplementation <T> fail() => new GetFail <T>();
            GetImplementation <T> @null() => new GetNull <T>(client);

            GetImplementation <T> cacheRaise() => new GetCache <T>(client, silent: false);

            return(policy switch
            {
                CachePolicy.FreshOrNull => new[] { fresh(), @null() },
                CachePolicy.FreshOrFail => new[] { fresh(), fail() },
                CachePolicy.FreshOrCacheOrNull => new[] { fresh(), cacheRaise(), @null() },
                CachePolicy.FreshOrCacheOrFail => new[] { fresh(), cacheRaise(), fail() },
                CachePolicy.CacheOrNull => new[] { cache(), @null() },
                CachePolicy.CacheOrFail => new[] { cache(), fail() },
                CachePolicy.CacheOrFreshOrNull => new[] { cache(), fresh(), @null() },
                CachePolicy.CacheOrFreshOrFail => new[] { cache(), fresh(), fail() },
                _ => throw new Exception("Cache policy has not implemented yet!"),
            });