private ISBN(ISBN_Prefix prefix, int groupIdentifier, string publisherCode, string catalogueNumber) { _prefix = prefix; _groupIdentifier = groupIdentifier; _publisherCode = publisherCode.PadLeft(2, '0'); int catalogueNumberLength = ISBN_LENGTH - ((short)_prefix).ToString().Length - _groupIdentifier.ToString().Length - _publisherCode.Length - 1; // Check Digit _catalogueNumber = catalogueNumberLength > 0 ? catalogueNumber.PadLeft(catalogueNumberLength, '0') : catalogueNumber; StringBuilder sb; try { sb = new StringBuilder($"{(short)_prefix}{_groupIdentifier}{_publisherCode}{_catalogueNumber}X", ISBN_LENGTH); } catch (ArgumentOutOfRangeException) { throw new ArgumentException( $"Length of ISBN must be exactly {ISBN_LENGTH - 1} (without check digit). ISBN: {ToString()}"); } _checkDigit = CalcCheckDigit(sb); sb[sb.Length - 1] = char.Parse(_checkDigit.ToString()); _value = ulong.Parse(sb.ToString()); }
private void SetISBNGroupItemsSource(ISBN_Prefix prefix) { switch (prefix) { case ISBN_Prefix.ISBN_978: cboISBNGroup.ItemsSource = Enum.GetValues(typeof(ISBN_978_GroupIdentifier)); break; case ISBN_Prefix.ISBN_979: cboISBNGroup.ItemsSource = Enum.GetValues(typeof(ISBN_979_GroupIdentifier)); break; default: break; } }
private void SetISBNGroupFilterItemsSource(ISBN_Prefix prefix) { switch (prefix) { case ISBN_Prefix.ISBN_978: cboISBNGroupFilter.ItemsSource = Entities .Where(i => i.ISBN.Prefix == prefix) .Select(i => (ISBN_978_GroupIdentifier)i.ISBN.GroupIdentifier).Distinct(); break; case ISBN_Prefix.ISBN_979: cboISBNGroupFilter.ItemsSource = Entities .Where(i => i.ISBN.Prefix == prefix) .Select(i => (ISBN_979_GroupIdentifier)i.ISBN.GroupIdentifier).Distinct(); break; default: break; } }