public ConversionFactory(NumericWordsConversionOptions options, string[] ones, string[] tens, string[] scale) { _options = options; _ones = ones; _tens = tens; _scale = scale; }
/// <summary> /// Output resources for words conversion as per the specified options /// </summary> /// <param name="ones">Output parameter for ones digit</param> /// <param name="tens">Output parameter for tens digit</param> /// <param name="scale">Output parameter for scale of specified culture</param> /// <param name="options">Options used for resources output</param> internal static void ManageSuitableResources(out string[] ones, out string[] tens, out string[] scale, NumericWordsConversionOptions options) { switch (options.Culture) { case Culture.Nepali: switch (options.OutputFormat) { case OutputFormat.English: ones = WordResources.OnesEnglish; tens = WordResources.TensEnglish; scale = WordResources.ScaleNepEnglish; break; case OutputFormat.Unicode: ones = WordResources.OnesNep; tens = WordResources.TensNep; scale = WordResources.ScaleNep; break; case OutputFormat.Devnagari: ones = WordResources.OnesDevnagari; tens = WordResources.TensDevnagari; scale = WordResources.ScaleDevnagari; break; default: throw new ArgumentOutOfRangeException(); } break; case Culture.International: scale = WordResources.ScaleEng; ones = WordResources.OnesEnglish; tens = WordResources.TensEnglish; break; case Culture.Hindi: switch (options.OutputFormat) { case OutputFormat.English: ones = WordResources.OnesEnglish; tens = WordResources.TensEnglish; scale = WordResources.ScaleNepEnglish; break; case OutputFormat.Unicode: ones = WordResources.OnesHindi; tens = WordResources.TensHindi; scale = WordResources.ScaleHindi; break; case OutputFormat.Devnagari: throw new NotSupportedException("Devnagari Output is not currently supported for Hindi Numeric System"); default: throw new ArgumentOutOfRangeException(); } break; default: throw new ArgumentOutOfRangeException(nameof(options.Culture), options.Culture, "Invalid Culture in Conversion Options"); } }
/// <summary> /// Used to initialize the conversion factory as per the specified options /// </summary> /// <param name="options"></param> internal static ConversionFactory InitializeConversionFactory(NumericWordsConversionOptions options) { ManageSuitableResources(out string[] ones, out string[] tens, out string[] scale, options); return(new ConversionFactory(options, ones, tens, scale)); }
/// <summary> /// Creates an instance of NumberConverter with specified options /// </summary> public NumericWordsConverter(NumericWordsConversionOptions options) { this._options = options; _conversionFactory = Utilities.InitializeConversionFactory(_options); }
/// <summary> /// Creates an instance of NumberConverter with default options /// <br/> Culture: International, OutputFormat: English, DecimalPlaces : 2 /// </summary> public NumericWordsConverter() { this._options = GlobalOptions.NumericWordsOptions; _conversionFactory = Utilities.InitializeConversionFactory(_options); }
/// <summary> /// Configures default options to be used while converting numeric to words. /// Uses default options if assigned null /// </summary> /// <param name="numericWordsOptions">Options for Numeric Words Conversion</param> public void SetDefaultNumericWordsOptions(NumericWordsConversionOptions numericWordsOptions) { GlobalOptions.NumericWordsOptions = numericWordsOptions ?? new NumericWordsConversionOptions(); GlobalOptions.NumericWordsConverter = new NumericWordsConverter(GlobalOptions.NumericWordsOptions); }
public ConversionFactory(NumericWordsConversionOptions options) { _options = options; Utilities.ManageSuitableResources(out _ones, out _tens, out _scale, options); }