public void Setup() { this.WebClient = new TestWebClient(new WebClient(WebTimeout), MaxRetry); this.Client = new MegaApiClient(this.WebClient); if (this._options.HasFlag(Options.AsyncWrapper)) { this.Client = new MegaApiClientAsyncWrapper(this.Client); } if (this._options.HasFlag(Options.LoginAuthenticated)) { this.Client.Login(Username, Password); } if (this._options.HasFlag(Options.LoginAnonymous)) { this.Client.LoginAnonymous(); } if (this._options.HasFlag(Options.Clean)) { Policy .Handle <ApiException>(ex => ex.ApiResultCode == ApiResultCode.BadSessionId && this._options.HasFlag(Options.LoginAuthenticated)) .Or <NotSupportedException>(ex => this._options.HasFlag(Options.LoginAuthenticated)) .WaitAndRetry(MaxRetry, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), this.ReconnectOnException) .Execute(this.SanitizeStorage); } }
internal MegaSource(IMegaApiClient client, Uri uri, INodeInfo node, IArchiveHandler handler) { this.client = client; this.uri = uri; this.node = node; this.handler = handler; }
public void Execute(IMegaApiClient megaApiClient, IMegaNzItemCollection megaNzItemCollection, IFileManager fileManager, IProgress <double> progressNotifier) { var nodeToDelete = megaNzItemCollection.GetByPath(PathToDelete); megaApiClient.Delete(nodeToDelete); megaNzItemCollection.RemoveItemByExactPath(PathToDelete); }
private static IEnumerable <MegaNzItem> GenerateListFromMegaNz(IMegaApiClient megaApiClient) { logger.Trace("Reading nodes from MegaNZ"); var remoteNodeList = megaApiClient .GetNodes() .ToList(); var generator = new MegaNzItemListGenerator(); return(generator.Generate(remoteNodeList)); }
public void Execute(IMegaApiClient megaApiClient, IMegaNzItemCollection megaNzItemCollection, IFileManager fileManager, IProgress <double> progressNotifier) { // Find the MegaNZ node related to the parent folder var parent = megaNzItemCollection.GetByPath(ParentPath); // Create the new folder var newNode = megaApiClient.CreateFolder(Name, parent); // Update the item collection megaNzItemCollection.Add(newNode); }
public void Execute(IMegaApiClient megaApiClient, IMegaNzItemCollection megaNzItemCollection, IFileManager fileManager, IProgress <double> progressNotifier) { using (var filestream = fileManager.GetStreamToReadFile(SourcePath)) { var sourceFileName = System.IO.Path.GetFileName(SourcePath); var remoteFileName = NameHandler.BuildRemoteFileName(sourceFileName, LastModifiedDate); var parentMegaNzNode = megaNzItemCollection.GetByPath(DestinationPath); var newMegaNzNode = megaApiClient.UploadAsync(filestream, remoteFileName, parentMegaNzNode, progressNotifier).Result; megaNzItemCollection.Add(newMegaNzNode); } }
protected override void ConnectClient(IMegaApiClient client) { Assert.False(string.IsNullOrEmpty(Password), $"Environment variable {MegaApiClientPasswordEnvironment} not set."); client.Login(Inputs.UsernameAccount, Password); }
protected abstract void ConnectClient(IMegaApiClient client);
public static async Task <long> GetFolderSizeAsync(this INodeInfo node, IMegaApiClient client) { var allNodes = await client.GetNodesAsync(); return(await node.GetFolderSizeAsync(allNodes)); }
public static long GetFolderSize(this INodeInfo node, IMegaApiClient client) { var allNodes = client.GetNodes(); return(node.GetFolderSize(allNodes)); }
/// <summary> /// Constructor method. /// </summary> /// <param name="window"><see cref="MainWindow"/> where are placed GUI elements to be updated to show progress.</param> /// <param name="url">mega.nz link to download a .zip including the .exe to be launched and all the files needed.</param> public MegaDownloader(MainWindow window, string url) : base(window, url) { client = new MegaApiClient(); }
protected override void ConnectClient(IMegaApiClient client) { client.LoginAnonymous(); }
private static INode GetRootFolderMega(IMegaApiClient client) { return(client.GetNodes().Single(n => n.Type == NodeType.Root)); }
private static void LoginMega(IMegaApiClient client, Account account) { client.Login(account.UserName, account.Password); }
// Token: 0x060008B7 RID: 2231 RVA: 0x0003BB7C File Offset: 0x00039D7C public static long GetFolderSize(this INodeInfo node, IMegaApiClient client) { IEnumerable <INode> nodes = client.GetNodes(); return(node.GetFolderSize(nodes)); }
public MegaApiClientAsyncWrapper(IMegaApiClient client) { this.client = client; }
protected override void ConnectClient(IMegaApiClient client) { client.Login(Username, Password); }
public MegaApiClientAsyncWrapper(IMegaApiClient client) { _client = client; _client.ApiRequestFailed += OnApiRequestFailed; }
protected override void ConnectClient(IMegaApiClient client) { }
public MegaApiClientAsyncWrapper(IMegaApiClient client) { this.client = client; this.client.ApiRequestFailed += this.OnApiRequestFailed; }
public CommandExecutor(IMegaApiClient megaApiClient, ILogger logger) { _megaApiClient = megaApiClient; _logger = logger; }