/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Class != null) { hashCode = hashCode * 59 + Class.GetHashCode(); } if (AssignedLabels != null) { hashCode = hashCode * 59 + AssignedLabels.GetHashCode(); } if (Mode != null) { hashCode = hashCode * 59 + Mode.GetHashCode(); } if (NodeDescription != null) { hashCode = hashCode * 59 + NodeDescription.GetHashCode(); } if (NodeName != null) { hashCode = hashCode * 59 + NodeName.GetHashCode(); } hashCode = hashCode * 59 + NumExecutors.GetHashCode(); if (Description != null) { hashCode = hashCode * 59 + Description.GetHashCode(); } if (Jobs != null) { hashCode = hashCode * 59 + Jobs.GetHashCode(); } if (PrimaryView != null) { hashCode = hashCode * 59 + PrimaryView.GetHashCode(); } hashCode = hashCode * 59 + QuietingDown.GetHashCode(); hashCode = hashCode * 59 + SlaveAgentPort.GetHashCode(); if (UnlabeledLoad != null) { hashCode = hashCode * 59 + UnlabeledLoad.GetHashCode(); } hashCode = hashCode * 59 + UseCrumbs.GetHashCode(); hashCode = hashCode * 59 + UseSecurity.GetHashCode(); if (Views != null) { hashCode = hashCode * 59 + Views.GetHashCode(); } return(hashCode); } }
protected override async Task Save() { try { var labels = AssignedLabels.With(x => x.Select(y => y.Name).ToArray()); var milestone = AssignedMilestone.With(x => (int?)x.Number); var user = AssignedUser.With(x => x.Login); var request = _applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues .Create(Subject, Content, user, milestone, labels); var data = await _applicationService.Client.ExecuteAsync(request); _createdIssueSubject.OnNext(data.Data); } catch (Exception e) { throw new Exception("Unable to save new issue! Please try again.", e); } }
/// <summary> /// Returns true if Hudson instances are equal /// </summary> /// <param name="other">Instance of Hudson to be compared</param> /// <returns>Boolean</returns> public bool Equals(Hudson other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Class == other.Class || Class != null && Class.Equals(other.Class) ) && ( AssignedLabels == other.AssignedLabels || AssignedLabels != null && other.AssignedLabels != null && AssignedLabels.SequenceEqual(other.AssignedLabels) ) && ( Mode == other.Mode || Mode != null && Mode.Equals(other.Mode) ) && ( NodeDescription == other.NodeDescription || NodeDescription != null && NodeDescription.Equals(other.NodeDescription) ) && ( NodeName == other.NodeName || NodeName != null && NodeName.Equals(other.NodeName) ) && ( NumExecutors == other.NumExecutors || NumExecutors.Equals(other.NumExecutors) ) && ( Description == other.Description || Description != null && Description.Equals(other.Description) ) && ( Jobs == other.Jobs || Jobs != null && other.Jobs != null && Jobs.SequenceEqual(other.Jobs) ) && ( PrimaryView == other.PrimaryView || PrimaryView != null && PrimaryView.Equals(other.PrimaryView) ) && ( QuietingDown == other.QuietingDown || QuietingDown.Equals(other.QuietingDown) ) && ( SlaveAgentPort == other.SlaveAgentPort || SlaveAgentPort.Equals(other.SlaveAgentPort) ) && ( UnlabeledLoad == other.UnlabeledLoad || UnlabeledLoad != null && UnlabeledLoad.Equals(other.UnlabeledLoad) ) && ( UseCrumbs == other.UseCrumbs || UseCrumbs.Equals(other.UseCrumbs) ) && ( UseSecurity == other.UseSecurity || UseSecurity.Equals(other.UseSecurity) ) && ( Views == other.Views || Views != null && other.Views != null && Views.SequenceEqual(other.Views) )); }
protected IssueModifyViewModel( IApplicationService applicationService, IAlertDialogFactory alertDialogFactory) { GoToAssigneesCommand = ReactiveCommand.Create(); GoToLabelsCommand = ReactiveCommand.Create(); GoToMilestonesCommand = ReactiveCommand.Create(); Assignees = new IssueAssigneeViewModel( () => applicationService.GitHubClient.Issue.Assignee.GetForRepository(RepositoryOwner, RepositoryName), () => Task.FromResult(AssignedUser), x => Task.FromResult(AssignedUser = x)); Milestones = new IssueMilestonesViewModel( () => applicationService.GitHubClient.Issue.Milestone.GetForRepository(RepositoryOwner, RepositoryName), () => Task.FromResult(AssignedMilestone), x => Task.FromResult(AssignedMilestone = x)); var assignedLabels = new ReactiveList <Octokit.Label>(); AssignedLabels = assignedLabels.CreateDerivedCollection(y => y); Labels = new IssueLabelsViewModel( () => applicationService.GitHubClient.Issue.Labels.GetForRepository(RepositoryOwner, RepositoryName), () => Task.FromResult(new ReadOnlyCollection <Octokit.Label>(AssignedLabels.ToList()) as IReadOnlyList <Octokit.Label>), x => { assignedLabels.Reset(x); return(Task.FromResult(0)); }); Labels.SelectedLabels.Changed .Select(_ => new ReadOnlyCollection <Octokit.Label>(Labels.SelectedLabels.ToList())) .Subscribe(x => assignedLabels.Reset(x)); var canSave = this.WhenAnyValue(x => x.Subject).Select(x => !string.IsNullOrEmpty(x)); SaveCommand = ReactiveCommand.CreateAsyncTask(canSave, async _ => { using (alertDialogFactory.Activate("Saving...")) { await Save(); // This is because the stupid ReactiveUI issue with the tableview :( await Task.Delay(400); } Dismiss(); }); LoadCommand = ReactiveCommand.CreateAsyncTask(async t => { try { IsCollaborator = await applicationService.GitHubClient.Repository.RepoCollaborators .IsCollaborator(RepositoryOwner, RepositoryName, applicationService.Account.Username); } catch { IsCollaborator = false; } }); }