From 427b92f33aef497d2ff90029cfd0e859e8111550 Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Thu, 29 Oct 2020 15:18:27 +0100 Subject: [PATCH] Make UseCaseSensitiveFieldNames opt-in. --- src/YouTrackSharp/Issues/Issue.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/YouTrackSharp/Issues/Issue.cs b/src/YouTrackSharp/Issues/Issue.cs index 2d49882..36f8928 100644 --- a/src/YouTrackSharp/Issues/Issue.cs +++ b/src/YouTrackSharp/Issues/Issue.cs @@ -19,7 +19,18 @@ namespace YouTrackSharp.Issues public class Issue : DynamicObject { - private readonly IDictionary _fields = new Dictionary(StringComparer.Ordinal); + /// + /// Use case-sensitive field names? Defaults to false. + /// + /// + /// When set to true, fields like "assignee" and "Assignee" can be used. + /// + public static bool UseCaseSensitiveFieldNames { get; set; } + + private readonly IDictionary _fields = new Dictionary( + UseCaseSensitiveFieldNames + ? StringComparer.Ordinal + : StringComparer.OrdinalIgnoreCase); /// /// Creates an instance of the class. @@ -86,12 +97,12 @@ public bool IsMarkdown { } /// - /// Issue fields. + /// Get all issue fields. /// public ICollection Fields => _fields.Values; /// - /// Get all field names + /// Get all issue field names. /// public ICollection FieldNames => _fields.Keys; @@ -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 }; } }