public IValueParser GetParserForProperty(OptionPropertyMetadata optionProperty) { if (optionProperty.HasCustomParser) { return(CreateExternalParser(optionProperty.CustomParserType)); } return(DefaultParsers.GetValueParser(optionProperty.ParsedType)); }
private bool TryParseUnderlyingTypeValue(string rawValue, Type targetType, out object parsedValue) { var underlyingType = targetType.GetEnumUnderlyingType(); var underlyingTypeParser = DefaultParsers.GetValueParser(underlyingType); try { var numericValue = underlyingTypeParser.Parse(rawValue, targetType); if (Enum.IsDefined(targetType, numericValue)) { parsedValue = Enum.ToObject(targetType, numericValue); return(true); } } catch (Exception) { // Ignore } parsedValue = null; return(false); }
public bool HasParserForProperty(OptionPropertyMetadata propertyMetadata) { return(propertyMetadata.HasCustomParser || propertyMetadata.IsCollection || DefaultParsers.HasParser(propertyMetadata.ParsedType)); }