Skip to content

Commit

Permalink
Make UseCaseSensitiveFieldNames opt-in.
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenba committed Oct 29, 2020
1 parent 314cc8c commit 427b92f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/YouTrackSharp/Issues/Issue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ namespace YouTrackSharp.Issues
public class Issue
: DynamicObject
{
private readonly IDictionary<string, Field> _fields = new Dictionary<string, Field>(StringComparer.Ordinal);
/// <summary>
/// Use case-sensitive field names? Defaults to false.
/// </summary>
/// <remarks>
/// When set to true, fields like "assignee" and "Assignee" can be used.
/// </remarks>
public static bool UseCaseSensitiveFieldNames { get; set; }

private readonly IDictionary<string, Field> _fields = new Dictionary<string, Field>(
UseCaseSensitiveFieldNames
? StringComparer.Ordinal
: StringComparer.OrdinalIgnoreCase);

/// <summary>
/// Creates an instance of the <see cref="Issue" /> class.
Expand Down Expand Up @@ -86,12 +97,12 @@ public bool IsMarkdown {
}

/// <summary>
/// Issue fields.
/// Get all issue fields.
/// </summary>
public ICollection<Field> Fields => _fields.Values;

/// <summary>
/// Get all field names
/// Get all issue field names.
/// </summary>
public ICollection<string> FieldNames => _fields.Keys;

Expand Down Expand Up @@ -131,7 +142,7 @@ public void SetField(string fieldName, object value)
}
else
{
_fields.Add(fieldName, new Field { Name = fieldName, Value = value });
_fields[fieldName] = new Field { Name = fieldName, Value = value };
}
}

Expand Down

0 comments on commit 427b92f

Please sign in to comment.