コード例 #1
0
        public static IManagedDownloaderToken AsManaged(this IDownloader @this, string managerName = DefaultManagerName)
        {
            Guards.ThrowIfNull(@this);
            Guards.ThrowIfNullOrEmpty(managerName);

            if (@this.Context == null)
            {
                throw new InvalidOperationException();
            }

            var id = @this.Context.Id;

            if (!ManagedDownloaderTokens.ContainsKey(id))
            {
                ManagedDownloaderTokens[id] = new ManagedDownloaderTokenImpl(GetFileDownloaderManager(managerName), @this);
            }

            return(ManagedDownloaderTokens[id]);
        }
コード例 #2
0
        public static Func <TInput, Task <IEnumerable <T> > > ThenAsync <TInput, TOutput, T>(
            this Func <TInput, Task <IEnumerable <TOutput> > > @this,
            Func <TOutput, T> function,
            CancellationToken cancellationToken = default)
        {
            Guards.ThrowIfNull(function);

            return(async input =>
            {
                cancellationToken.ThrowIfCancellationRequested();
                var output = await @this(input);

                return output.Select(item =>
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    return function(item);
                });
            });
        }
コード例 #3
0
        public static Func <TInput, Task <IEnumerable <T> > > ThenAsync <TInput, TOutput, T>(
            this Func <TInput, Task <IEnumerable <TOutput> > > @this,
            Func <TOutput, Task <T> > function,
            CancellationToken cancellationToken = default)
        {
            Guards.ThrowIfNull(function);

            return(async input =>
            {
                cancellationToken.ThrowIfCancellationRequested();
                var output = await @this(input);

                var result = new List <T>();
                foreach (var item in output)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    result.Add(await function(item));
                }

                return result;
            });
        }
コード例 #4
0
        public static long GetTotalSize(this IDownloader @this)
        {
            Guards.ThrowIfNull(@this);

            return(@this.Context?.TotalSize ?? 0);
        }
コード例 #5
0
        public static long GetCompletedSize(this IDownloader @this)
        {
            Guards.ThrowIfNull(@this);

            return(@this.BlockContexts?.Values.Sum(item => item.CompletedSize) ?? 0);
        }
コード例 #6
0
        public ViewModelResolver(Func<IContainerProvider> containerFactory)
        {
            Guards.ThrowIfNull(containerFactory);

            _containerFactory = containerFactory;
        }
コード例 #7
0
        public static IViewModelResolver IfInheritsFrom<TViewModel>(this IViewModelResolver @this, Action<FrameworkElement, TViewModel, IContainerProvider> configuration)
        {
            Guards.ThrowIfNull(@this, configuration);

            return @this.IfInheritsFrom(configuration);
        }
コード例 #8
0
            //.IfInheritsFrom<IAwareTabItemSelectionChanged>((view, viewModel) =>
            //{
            //    TabControlHelper.SetAwareSelectionChanged(view, true);
            //});

        public static IViewModelResolver IfInheritsFrom<TViewModel>(this IViewModelResolver @this, Action<FrameworkElement, TViewModel> configuration)
        {
            Guards.ThrowIfNull(@this, configuration);

            return @this.IfInheritsFrom<FrameworkElement, TViewModel>((view, viewModel, container) => configuration(view, viewModel));
        }
コード例 #9
0
        public UpgradeService(Func <Task <List <UpgradeInfo> > > upgradeInfosGetter)
        {
            Guards.ThrowIfNull(upgradeInfosGetter);

            _upgradeInfosGetter = upgradeInfosGetter;
        }
コード例 #10
0
 public DataTransmissionPanelViewModel(IContainerExtension container, IHouseSiteService houseSiteService) : base(container)
 {
     Guards.ThrowIfNull(container, houseSiteService);
     this.houseSiteService = houseSiteService;
 }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyMapping{TSource, TDestination}"/> class.
        /// </summary>
        /// <param name="mappingDictionary">The mapping dictionary.</param>
        public PropertyMapping(Dictionary <string, PropertyMappingValue> mappingDictionary)
        {
            Guards.ThrowIfNull(mappingDictionary);

            MappingDictionary = mappingDictionary;
        }
コード例 #12
0
        public static long GetTotalSize(this ITransferInfo <DownloadContext> @this)
        {
            Guards.ThrowIfNull(@this);

            return(@this.Context?.TotalSize ?? 0);
        }