public object GetService(Type serviceType) { var res = default(object); if (serviceType == typeof(ITrimmable <KeyValuePair <T, R> >)) { res = Trimmable.Create <KeyValuePair <T, R> >(shouldTrim => TrimBy(kv => kv, shouldTrim)); } // // NB: No trim by key or value; those types could unify to the same ITrimmable<>. // The drawback is that users of N-ary function need to use Args<> types. // return(res); }
public object GetService(Type serviceType) { var res = default(object); if (serviceType == typeof(ITrimmable <KeyValuePair <T, R> >)) { res = Trimmable.Create <KeyValuePair <T, R> >(shouldTrim => TrimBy(kv => kv.Value.Kind == ValueOrErrorKind.Value, kv => new KeyValuePair <T, R>(kv.Key, kv.Value.Value), shouldTrim)); } else if (serviceType == typeof(ITrimmable <KeyValuePair <T, IValueOrError <R> > >) && _cacheError) { res = Trimmable.Create <KeyValuePair <T, IValueOrError <R> > >(shouldTrim => TrimBy(kv => true, kv => new KeyValuePair <T, IValueOrError <R> >(kv.Key, kv.Value), shouldTrim)); } // // NB: No trim by key or value; those types could unify to the same ITrimmable<>. // The drawback is that users of N-ary function need to use Args<> types. // return(res); }