public BankAccountDetails(string sortCode, string accountNumber) { accountNumber = PrepareString(accountNumber); sortCode = PrepareString(sortCode); switch (accountNumber.Length) { case 9: var chars = sortCode.ToCharArray(); chars[5] = accountNumber[0]; sortCode = new string(chars); accountNumber = accountNumber.Substring(1); break; case 10: if (SortCode.IsCooperativeBankSortCode(sortCode)) { accountNumber = accountNumber.Substring(0, 8); } else if (SortCode.IsNatWestSortCode(sortCode)) { accountNumber = accountNumber.Substring(2); } else { throw new ArgumentException(string.Format("Ten Digit Account Numbers can only come from Natwest or Coop sortcodes. {0} does not appear to be either",sortCode)); } break; } SortCode = new SortCode(sortCode); AccountNumber = AccountNumber.Parse(accountNumber); }
private void ExceptionEightPreProcessing() { if (WeightMappings.First().Exception == 8) { SortCode = new SortCode("090126"); } }
private void ExceptionEightPreProcessing(IEnumerable <ModulusWeightMapping> mappings) { if (mappings.First().Exception == 8) { SortCode = new SortCode("090126"); } }
public BankAccountDetails(string sortCode, string accountNumber) { accountNumber = PrepareString(accountNumber); sortCode = PrepareString(sortCode); switch (accountNumber.Length) { case 9: var chars = sortCode.ToCharArray(); chars[5] = accountNumber[0]; sortCode = new string(chars); accountNumber = accountNumber.Substring(1); break; case 10: if (SortCode.IsCooperativeBankSortCode(sortCode)) { accountNumber = accountNumber.Substring(0, 8); } else if (SortCode.IsNatWestSortCode(sortCode)) { accountNumber = accountNumber.Substring(2); } else { throw new ArgumentException(string.Format("Ten Digit Account Numbers can only come from Natwest or Coop sortcodes. {0} does not appear to be either", sortCode)); } break; } SortCode = new SortCode(sortCode); AccountNumber = AccountNumber.Parse(accountNumber); }
public static BankAccountDetails From(SortCode sortCode, AccountNumber accountNumber, IEnumerable <IModulusWeightMapping> weightMappings) { return(new BankAccountDetails(sortCode.ToString(), accountNumber.ToString()) { WeightMappings = weightMappings }); }
public ModulusWeightMapping( SortCode sortCodeStart, SortCode sortCodeEnd, ModulusAlgorithm modulusAlgorithm, int[] weightValues, int exception) { SortCodeStart = sortCodeStart; SortCodeEnd = sortCodeEnd; Algorithm = modulusAlgorithm; WeightValues = weightValues; Exception = exception; }
public ModulusWeightMapping( SortCode sortCodeStart, SortCode sortCodeEnd, ModulusAlgorithm modulusAlgorithm, int[] weightValues, int exception) { SortCodeStart = sortCodeStart; SortCodeEnd = sortCodeEnd; Algorithm = modulusAlgorithm; WeightValues = weightValues; Exception = exception; }
public static ModulusWeightMapping From(string row) { var weightValues = new int[14]; var items = row.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); var sortCodeStart = new SortCode(items[0]); var sortCodeEnd = new SortCode(items[1]); var algorithm = (ModulusAlgorithm) Enum.Parse(typeof(ModulusAlgorithm), items[2], true); for (var i = 3; i < 17; i++) { weightValues[i - 3] = int.Parse(items[i]); } var exception = -1; if (items.Length==18) { exception = int.Parse(items[17]); } return new ModulusWeightMapping(sortCodeStart, sortCodeEnd, algorithm, weightValues, exception); }
public ModulusWeightMapping(string row) { WeightValues = new int[14]; var items = row.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); SortCodeStart = new SortCode(items[0]); SortCodeEnd = new SortCode(items[1]); Algorithm = (ModulusAlgorithm) Enum.Parse(typeof(ModulusAlgorithm), items[2], true); for (var i = 3; i < 17; i++) { WeightValues[i - 3] = Int16.Parse(items[i]); } if (items.Length==18) { Exception = Int16.Parse(items[17]); } else { Exception = -1; } }
public static ModulusWeightMapping From(string row) { var weightValues = new int[14]; var items = row.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var sortCodeStart = new SortCode(items[0]); var sortCodeEnd = new SortCode(items[1]); var algorithm = (ModulusAlgorithm)Enum.Parse(typeof(ModulusAlgorithm), items[2], true); for (var i = 3; i < 17; i++) { weightValues[i - 3] = int.Parse(items[i]); } var exception = -1; if (items.Length == 18) { exception = int.Parse(items[17]); } return(new ModulusWeightMapping(sortCodeStart, sortCodeEnd, algorithm, weightValues, exception)); }
public ModulusWeightMapping(string row) { WeightValues = new int[14]; var items = row.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); SortCodeStart = new SortCode(items[0]); SortCodeEnd = new SortCode(items[1]); Algorithm = (ModulusAlgorithm)Enum.Parse(typeof(ModulusAlgorithm), items[2], true); for (var i = 3; i < 17; i++) { WeightValues[i - 3] = int.Parse(items[i]); } if (items.Length == 18) { Exception = int.Parse(items[17]); } else { Exception = -1; } }
private bool Equals(SortCode other) { return _doubleValue.Equals(other._doubleValue); }
public static BankAccountDetails From(SortCode sortCode, AccountNumber accountNumber, IEnumerable<IModulusWeightMapping> weightMappings) { return new BankAccountDetails(sortCode.ToString(), accountNumber.ToString()) { WeightMappings = weightMappings }; }
private void ExceptionEightPreProcessing(IEnumerable<ModulusWeightMapping> mappings) { if (mappings.First().Exception == 8) { SortCode = new SortCode("090126"); } }
private void ExceptionEightPreProcessing() { if (WeightMappings.First().Exception == 8) { SortCode = new SortCode("090126"); } }
private bool Equals(SortCode other) { return(_doubleValue.Equals(other._doubleValue)); }
public IEnumerable<IModulusWeightMapping> GetRuleMappings(SortCode sortCode) { return RuleMappings.Where(rm => sortCode.DoubleValue >= rm.SortCodeStart.DoubleValue && sortCode.DoubleValue <= rm.SortCodeEnd.DoubleValue); }
public String ToCombinedString() { return(SortCode.ToString() + AccountNumber); }
protected bool Equals(SortCode other) { return _doubleValue.Equals(other._doubleValue); }