diff --git a/src/DarkConfig/DocNode/DocNode.cs b/src/DarkConfig/DocNode/DocNode.cs index d9d7e55..5b5b6aa 100644 --- a/src/DarkConfig/DocNode/DocNode.cs +++ b/src/DarkConfig/DocNode/DocNode.cs @@ -13,8 +13,8 @@ public class DocNodeAccessException : Exception { public DocNodeAccessException(string message) : base(message) { } } - /// DocNode represents a node of a parsed document. - /// DocNode is a union type, requiring no casting but behaving differently + /// DocNode represents a node of a parsed document. + /// DocNode is a union type, requiring no casting but behaving differently /// depending on the underlying value. /// DocNode also assumes that all Dictionaries have strings as keys. public abstract class DocNode : IEquatable { @@ -50,7 +50,7 @@ public abstract class DocNode : IEquatable { /// Iterates over the values of the list public abstract IEnumerable Values { get; } - /// Iterates over a dictionary + /// Iterates over a dictionary public abstract IEnumerable> Pairs { get; } /// String describing the position and context in the source format (e.g. line number). @@ -63,7 +63,7 @@ public T As(ReificationOptions? options = null) { } /// - /// Only works on lists. Checks for the given doc node StringValue in the list. + /// Only works on lists. Checks for the given doc node StringValue in the list. /// /// String to search for /// True if the string exists in this list @@ -164,7 +164,7 @@ public int GetDeepHashCode() { /// /// Generates a new DocNode that is the result of merging two other DocNodes. - /// + /// /// lists are concatenated. /// Dictionaries are merged and values recursively DeepMerged. /// Favors rhs in the event of any unresolvable conflict. diff --git a/src/DarkConfig/Internal/TypeReifier.cs b/src/DarkConfig/Internal/TypeReifier.cs index d1cca5b..1c2c4d0 100644 --- a/src/DarkConfig/Internal/TypeReifier.cs +++ b/src/DarkConfig/Internal/TypeReifier.cs @@ -205,9 +205,11 @@ public object ReadValueOfType(Type targetType, object existing, DocNode doc, Rei if (targetType == typeof(string)) { return doc.StringValue; } #endregion + bool ignoreCase = (options & ReificationOptions.CaseSensitive) == 0; + // Enums if (targetType.IsEnum) { - return Enum.Parse(targetType, doc.StringValue, (options & ReificationOptions.CaseSensitive) == 0); + return Enum.Parse(targetType, doc.StringValue, ignoreCase); } // DocNode @@ -413,7 +415,7 @@ void ReadArray(DocNode current, int currentRank) { // Nullable if (genericTypeDef == typeof(Nullable<>)) { - var comparisonOptions = (options & ReificationOptions.CaseSensitive) == 0 ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; + var comparisonOptions = ignoreCase ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; if (doc.Type == DocNodeType.Scalar && string.Equals(doc.StringValue, "null", comparisonOptions)) { return null; } @@ -708,7 +710,6 @@ bool SetMember(Type type, ref object obj, string memberName, DocNode doc, Reific if (!allowExtra) { throw new ExtraFieldsException(doc, $"Could not find a member named {memberName} on type {type.Name}"); } - return false; } }