/// <summary> /// Converts the <see cref="IniKey.Value"/> to a list of the specified type. /// </summary> /// <param name="results">Uninitialized list of a specific type which will hold the converted values if the conversion succeeds.</param> /// <typeparam name="T">Type of the objects in list to convert the <see cref="IniKey.Value"/> to.</typeparam> /// <returns>Value that indicates whether the conversion succeeded.</returns> /// <include file='IniInternal\SharedDocumentationComments.xml' path='Comments/Comment[@name="TryParseValueSupport"]/*'/> public bool TryParseValue <T>(out List <T> results) { if (this.IsValueArray) { var listResults = new List <T>(); foreach (var value in this.Values) { T result; if (this.ParentFile.HasValueMappings && this.ParentFile.ValueMappings.TryGetResult <T>(value, out result)) { listResults.Add(result); } else if (IniValueParser <T> .TryParse(value, out result)) { listResults.Add(result); } else { results = null; return(false); } } results = listResults; return(true); } results = null; return(false); }
/// <summary> /// Converts the <see cref="IniKey.Value"/> to an instance of the specified type. /// </summary> /// <param name="result">Uninitialized instance of a specific type which will hold the converted value if the conversion succeeds.</param> /// <typeparam name="T">Type of the object to convert the <see cref="IniKey.Value"/> to.</typeparam> /// <returns>Value that indicates whether the conversion succeeded.</returns> /// <include file='IniInternal\SharedDocumentationComments.xml' path='Comments/Comment[@name="TryParseValueSupport"]/*'/> public bool TryParseValue <T>(out T result) { if (this.ParentFile.HasValueMappings && this.ParentFile.ValueMappings.TryGetResult <T>(this.Value, out result)) { return(true); } else { return(IniValueParser <T> .TryParse(this.Value, out result)); } }