コード例 #1
0
        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()
            }));
        }
コード例 #2
0
        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));
        }