private Result <Thumbnails.ResolveOptions, Error> FromContract(Contracts.ResolveOptions options) { var tagResult = string.IsNullOrEmpty(options.Tag) ? Result.Success <Option <Name>, Error>(Option.None <Name>()) : Name.FromString(options.Tag).MapSuccess(t => Option.Some(t)); return(tagResult.MapSuccess(t => new Thumbnails.ResolveOptions { Tag = t, MinWidth = options.MinWidth.ToOption(), MinHeight = options.MinHeight.ToOption() })); }
public async Task <Result <IReadOnlyCollection <Contracts.ResolvedThumbnail>, Contracts.Error> > ResolveAsync(string galleryName, IEnumerable <string> ids, Contracts.ResolveOptions options) { var result = await Name.FromString(galleryName) .AndThenAsync(gallery => ToIds(ids) .AndThenAsync(id => FromContract(options) .AndThenAsync(opts => _resolver.Resolve(gallery, id, opts)))); return(result.Map <IReadOnlyCollection <Contracts.ResolvedThumbnail>, Contracts.Error>(t => t.Select(ToContract).ToArray(), ErrorExtensions.ToContract)); }