Skip to content

Commit

Permalink
Update WorkflowInfo.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Jul 23, 2024
1 parent 7ca9b59 commit 6c258f6
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 12 deletions.
8 changes: 7 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ dotnet_diagnostic.CA1863.severity = silent

dotnet_diagnostic.CA1859.severity = silent

dotnet_diagnostic.IDE0046.severity = silent

[*.cs]
#### Styles de nommage ####

Expand Down Expand Up @@ -139,6 +141,8 @@ csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_space_around_binary_operators = before_and_after
csharp_indent_labels = one_less_than_current

[*.vb]
#### Styles de nommage ####
Expand Down Expand Up @@ -190,4 +194,6 @@ dotnet_naming_style.casse_pascal.capitalization = pascal_case

[*.{cs,vb}]
tab_width = 4
indent_size = 4
indent_size = 4
dotnet_style_operator_placement_when_wrapping = beginning_of_line
end_of_line = crlf
1 change: 0 additions & 1 deletion Wexflow.sln
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wexflow.Scripts.LiteDB", "s
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{CBF733C9-E197-44FA-837B-1FE4F5923FD9}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\azure-pipelines.yml = .github\azure-pipelines.yml
EndProjectSection
EndProject
Expand Down
8 changes: 2 additions & 6 deletions src/net/Wexflow.Server/Contracts/WorkflowInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public enum LaunchType
Cron
}

public class WorkflowInfo : IComparable
public class WorkflowInfo : IComparable<WorkflowInfo>
{
public string DbId { get; set; }

Expand Down Expand Up @@ -95,10 +95,6 @@ public WorkflowInfo(string dbId,
RetryTimeout = retryTimeout;
}

public int CompareTo(object obj)
{
var wfi = (WorkflowInfo)obj;
return wfi.Id.CompareTo(Id);
}
public int CompareTo(WorkflowInfo other) => other.Id.CompareTo(Id);
}
}
61 changes: 57 additions & 4 deletions src/netcore/Wexflow.Server/Contracts/WorkflowInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public enum LaunchType
Cron
}

public class WorkflowInfo : IComparable
public class WorkflowInfo : IComparable<WorkflowInfo>
{
public string DbId { get; set; }

Expand Down Expand Up @@ -95,10 +95,63 @@ public WorkflowInfo(string dbId,
RetryTimeout = retryTimeout;
}

public int CompareTo(object obj)
public int CompareTo(WorkflowInfo other) => other.Id.CompareTo(Id);

public override bool Equals(object obj)
{
var wfi = obj as WorkflowInfo;

if (wfi == null)
{
return false;
}

if (ReferenceEquals(this, obj))
{
return true;
}

return wfi.Id.Equals(Id);
}

public override int GetHashCode()
{
return Id.GetHashCode();
}

public static bool operator ==(WorkflowInfo left, WorkflowInfo right)
{
if (left is null)
{
return right is null;
}

return left.Equals(right);
}

public static bool operator !=(WorkflowInfo left, WorkflowInfo right)
{
return !(left == right);
}

public static bool operator <(WorkflowInfo left, WorkflowInfo right)
{
return left is null ? right is not null : left.CompareTo(right) < 0;
}

public static bool operator <=(WorkflowInfo left, WorkflowInfo right)
{
return left is null || left.CompareTo(right) <= 0;
}

public static bool operator >(WorkflowInfo left, WorkflowInfo right)
{
return left is not null && left.CompareTo(right) > 0;
}

public static bool operator >=(WorkflowInfo left, WorkflowInfo right)
{
var wfi = (WorkflowInfo)obj;
return wfi.Id.CompareTo(Id);
return left is null ? right is null : left.CompareTo(right) >= 0;
}
}
}

0 comments on commit 6c258f6

Please sign in to comment.