Example #1
0
        public static IManagedTransporterToken AsManaged(this IDownloader @this, string managerName = FileTransferService.DefaultManagerName)
        {
            Guards.ThrowIfNull(@this);
            Guards.ThrowIfNullOrEmpty(managerName);

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

            var id = @this.Id;

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

            return(ManagedDownloaderTokens[id]);
        }