/// <summary>Initializes the converter with an attribute</summary> public override void Initialize(CsvConverterAttribute attribute, IDefaultTypeConverterFactory defaultFactory) { base.Initialize(attribute, defaultFactory); if (!(attribute is CsvConverterNumberAttribute oneAttribute)) { throw new CsvConverterAttributeException( $"Please use the {nameof(CsvConverterNumberAttribute)} " + $"attribute with the {nameof(CsvConverterPercentage)} converter."); } if (string.IsNullOrWhiteSpace(oneAttribute.StringFormat)) { int precession = oneAttribute.NumberOfDecimalPlaces - 2; if (precession < 0) { precession = 0; } oneAttribute.StringFormat = $"P{precession}"; } _decimalConverter = defaultFactory.CreateConverter(typeof(decimal)); _decimalConverter.Initialize(oneAttribute, defaultFactory); }
/// <summary>Initializes the converter with an attribute</summary> public override void Initialize(CsvConverterAttribute attribute, IDefaultTypeConverterFactory defaultFactory) { base.Initialize(attribute, defaultFactory); if (attribute is CsvConverterStringTrimAttribute oneAttribute) { TrimAction = oneAttribute.TrimAction; } }
/// <summary>Initializes the converter with an attribute</summary> public override void Initialize(CsvConverterAttribute attribute, IDefaultTypeConverterFactory defaultFactory) { base.Initialize(attribute, defaultFactory); if (attribute != null) { if (attribute is CsvConverterNumberAttribute settings) { StringFormat = settings.StringFormat; } } }
/// <summary>Initializes the converter with an attribute</summary> public override void Initialize(CsvConverterAttribute attribute, IDefaultTypeConverterFactory defaultFactory) { base.Initialize(attribute, defaultFactory); if (attribute != null) { if (attribute is CsvConverterDateTimeAttribute settings) { DateFormat = settings.StringFormat; DateStyle = settings.DateStyle; } } }
/// <summary>Initializes the converter with an attribute</summary> public override void Initialize(CsvConverterAttribute attribute, IDefaultTypeConverterFactory defaultFactory) { base.Initialize(attribute, defaultFactory); if (attribute != null) { if (attribute is CsvConverterBooleanAttribute settings) { TrueValue = settings.TrueValue; FalseValue = settings.FalseValue; } } }
/// <summary>Initializes the converter with an attribute</summary> public override void Initialize(CsvConverterAttribute attribute, IDefaultTypeConverterFactory defaultFactory) { base.Initialize(attribute, defaultFactory); if (attribute != null) { if (attribute is CsvConverterNumberAttribute settings) { StringFormat = settings.StringFormat; AllowRounding = settings.AllowRounding; NumberOfDecimalPlaces = settings.NumberOfDecimalPlaces; Mode = settings.Mode; } } }
/// <summary>Initializes the converter with an attribute</summary> public override void Initialize(CsvConverterAttribute attribute, IDefaultTypeConverterFactory defaultFactory) { base.Initialize(attribute, defaultFactory); if (!(attribute is CsvConverterStringOldAndNewAttribute oneAttribute)) { throw new CsvConverterAttributeException( $"Please use the {nameof(CsvConverterStringOldAndNewAttribute)} " + $"attribute with the {nameof(CsvConverterStringReplaceTextExactMatch)} converter."); } _newValue = oneAttribute.NewValue; }
/// <summary>Initializes the converter with an attribute</summary> public override void Initialize(CsvConverterAttribute attribute, IDefaultTypeConverterFactory defaultFactory) { base.Initialize(attribute, defaultFactory); if (!(attribute is CsvConverterStringOldAndNewAttribute oneAttribute)) { throw new CsvConverterAttributeException( $"Please use the {nameof(CsvConverterStringOldAndNewAttribute)} " + $"attribute with the {nameof(CsvConverterStringReplaceTextExactMatch)} converter."); } _newValue = oneAttribute.NewValue; _oldValue = oneAttribute.OldValue; _oldValueCannotBeProcessByStringReplace = _oldValue == null || _oldValue.Length == 0; _regexOptions = oneAttribute.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase; }
/// <summary>Initializes the converter with an attribute</summary> public override void Initialize(CsvConverterAttribute attribute, IDefaultTypeConverterFactory defaultFactory) { base.Initialize(attribute, defaultFactory); if (!(attribute is CsvConverterNumberAttribute oneAttribute)) { throw new CsvConverterAttributeException( $"Please use the {nameof(CsvConverterNumberAttribute)} " + $"attribute with the {nameof(CsvConverterDecimalToInt)} converter."); } _oneAttribute = oneAttribute; _writeDecimalConverter = defaultFactory.CreateConverter(typeof(decimal)); _writeDecimalConverter.Initialize(oneAttribute, defaultFactory); oneAttribute.NumberOfDecimalPlaces = 0; _readDecimalConverter = defaultFactory.CreateConverter(typeof(decimal)); _readDecimalConverter.Initialize(oneAttribute, defaultFactory); }
/// <summary>Initializes the converter with an attribute</summary> public virtual void Initialize(CsvConverterAttribute attribute, IDefaultTypeConverterFactory defaultFactory) { }