private async Task <bool> AddProfile() { var fileNeme = ProfileXml.GetFullName(); NewProcess.StartInfo.Arguments = string.Format(_argumentsFileName, fileNeme); try { using (Process execute = Process.Start(NewProcess.StartInfo)) { await execute.WaitForExitAsync(); var arrNets = execute.StandardOutput.ReadToEnd().Split("\r\n".ToCharArray()); foreach (var item in arrNets) { if (!string.IsNullOrEmpty(item)) { Erros.Add(item); } } return(await ConnectProfile()); } } catch (Exception ex) { Erros.Add(ex.Message); throw; } }
/// <summary> /// Creates a new profile data. /// </summary> /// <param name="descriptor">The descriptor of the profile.</param> /// <returns>Returns the created profile data.</returns> public static ProfileData Create(ProfileXml descriptor) { ProfileData profiles = new ProfileData(); profiles.empty = descriptor.Empty; profiles.name = descriptor.Name; profiles.avatar = descriptor.Avatar; profiles.lastChapterUnlocked = descriptor.LastChapterUnlocked; profiles.lastLevelUnlocked = descriptor.LastLevelUnlocked; if (descriptor.Scores != null && descriptor.Scores.Length >= profiles.ChaptersScore.Length) { for (int i = 0; i < profiles.ChaptersScore.Length; i++) { if (i >= descriptor.Scores.Length) { break; } else if (descriptor.Scores[i].Score != null) { for (int j = 0; j < profiles.ChaptersScore[i].Scores.Length; j++) { if (j >= descriptor.Scores[i].Score.Length) { break; } else { profiles.ChaptersScore[i].Scores[j] = new Score { Steps = descriptor.Scores[i].Score[j].Steps, Seconds = descriptor.Scores[i].Score[j].Seconds }; } } } } } return(profiles); }
/// <summary> /// Creates a new profile descriptor. /// </summary> /// <param name="data">The profile.</param> /// <returns>Returns the created profile descriptor.</returns> public static ProfileXml CreateXml(ProfileData data) { ProfileXml profile = new ProfileXml(); profile.Empty = data.empty; profile.Name = data.name; profile.Avatar = data.avatar; profile.LastChapterUnlocked = data.lastChapterUnlocked; profile.LastLevelUnlocked = data.lastLevelUnlocked; Func <Score, ScoreXml> createScore = victim => { return(new ScoreXml { Steps = victim.Steps, Seconds = victim.Seconds }); }; Func <Score[], ScoresXml> createScores = victim => { var scores = new ScoresXml(); scores.Score = victim.Select(x => createScore(x)).ToArray(); return(scores); }; profile.Scores = data.ChaptersScore.Select(x => createScores(x.Scores)).ToArray(); return(profile); }