Class ScraperUtil
public static class ScraperUtil
- Inheritance
-
ScraperUtil
- Inherited Members
Fields
MAXGERMANACCTNOLENGTH
Max length of a German account number is 10 digits.
public const int MAXGERMANACCTNOLENGTH = 10
Field Value
Methods
AcctNoCompare(string, string)
Compare two account numbers, ignoring leading zeroes.
public static bool AcctNoCompare(string sAcctNo1, string sAcctNo2)
Parameters
Returns
- bool
True if account numbers match.
AppendRemittanceInformationLine(SepaTransactionDetails, string)
Appends a text line to the RemittanceInformation.
public static void AppendRemittanceInformationLine(this SepaTransactionDetails aTxn, string sRmtInfLine)
Parameters
aTxnSepaTransactionDetailsThe transaction where the remittance information line shall be added to. Must not be
null.sRmtInfLinestringThe text line to be appended. If this is
nullor empty, then this method does nothing. If the line is longer than MaxRmtInfLen, it is truncated at MaxRmtInfLen.
Remarks
If the RemittanceInformation is empty, then
the given sRmtInfLine will be set as the only content of that
property. Otherwise a Environment.NewLine is appended to separate the appended line
from the existing content.
AppendRemittanceInformationText(SepaTransactionDetails, string)
public static void AppendRemittanceInformationText(this SepaTransactionDetails aTxn, string sRmtInfText)
Parameters
aTxnSepaTransactionDetailssRmtInfTextstring
Exceptions
CoalesceSpaces(string)
public static string CoalesceSpaces(string sText)
Parameters
sTextstring
Returns
CreateFakeCreditCardNo(string, char)
Creates a fake credit card number from a masked credit card number by replacing the mask character with zeroes and fixing the Luhn check digit accordingly.
public static string CreateFakeCreditCardNo(string sMaskedCreditCardNo, char chMaskChar = '*')
Parameters
sMaskedCreditCardNostringA masked credit card number that consists solely of digits and the
chMaskChar. The length of this string must match the length of the original credit card number.chMaskCharchar
Returns
- string
If the credit card number did not contain any
chMaskChar, then it is returned as is. Otherwise a string is constructed, where all the mask characters are replaced by '0', and the last mask character is replaced with a digit that ensures that the resulting string passes the Luhn check.
Exceptions
- ArgumentNullException
The parameter
sMaskedCreditCardNowasnull.- ArgumentException
The length of
sMaskedCreditCardNois not a valid credit card number length. -or- ThesMaskedCreditCardNodid contain a character that is neither a digit nor thechMaskChar.
FormatAcctNo(string)
Remove spaces and add leading 0 up to MAXGERMANACCTNOLENGTH
public static string FormatAcctNo(string sAcctNo)
Parameters
sAcctNostring
Returns
IsMaskedCreditCardNo(string, string, char)
public static bool IsMaskedCreditCardNo(string sCreditCardNo, string sMaskedCreditCardNo, char chMaskChar = '*')
Parameters
sCreditCardNostringsMaskedCreditCardNostringchMaskCharcharThe substitution character that is used in the
sMaskedCreditCardNoas a replacement for the masked digits. By default this is '*'.
Returns
IsValidGermanAcctNo(string)
Checks whether the given account number consists of 2 to 10 digits, ignoring leading zeroes.
public static bool IsValidGermanAcctNo(string sAcctNo)
Parameters
sAcctNostring
Returns
Remarks
This method does not check any check digits that may be contained, and also does not do any other sematic checks on the given account number.
IsValidGermanBankCode(string)
Checks whether the given bank code consists of exactly eight digits.
public static bool IsValidGermanBankCode(string sBankCode)
Parameters
sBankCodestring
Returns
Remarks
This method does not check whether the bank code actually exists, and it also does not check whether the bank code begins with a digit in the range 1 through 8.
IsValidUTF8(byte[], int, int)
Determines if a buffer is a valid UTF-8 encoding.
public static bool IsValidUTF8(byte[] vbData, int nOffset, int nLength)
Parameters
Returns
- bool
If the buffer is a valid UTF-8 encoding, then
trueis returned. This includes buffers that contain solely ASCII bytes. If the buffer is not a valid UTF-8 encoding, thenfalseis returned.
NullTrim(string, int)
Trim whitespace and truncate string. Returns null when result is an empty string.
public static string NullTrim(string s, int nMaxLength = 2147483647)
Parameters
sstringThe string from which to trim leading and trailing whitespace. If this is
null, then this method also returnsnull.nMaxLengthintThe maximum length of the trimmed string. If, after trimming, the given string is longer than this, then only a sub-string with the given maximum length will be returned.
Returns
- string
If, after trimming, the resulting string is an empty string, then
nullis returned instead of an empty string.
ParseDate(string, string)
public static DateTime ParseDate(string sDate, string sOrder = "DMY")
Parameters
sDatestringDate given as a string that starts with three digits groups, separated by a non-digit character. Any characters following the last digit of the three digit groups are ignored. Possible inputs are "20.02.2013" or "2012-04-09".
sOrderstringThe order of the date elements. Must be a string containing the three characters 'D', 'M', and 'Y' in the expected order of the date elements. The default value is "DMY". If the date is given in ISO "YYYY-MM-DD" format, then it is always parsed as such, regardless of the value of this parameter.
Returns
- DateTime
The parsed date or DateTime.MinValue if the given date string was null or empty. If the date cannot be parsed an exception is thrown.
Remarks
Two digit years smaller than 80 are assumed as 2000 through 2079. All other two digit years are assumed as 1980 through 1999.
A day in the range from 28 through 31 that exceeds the maximum number of days in the given month is converted to the actual maximum day of the month. For example, a date 2017-04-31 is parsed and converted to 2017-04-30. This is done in order to cope with financial virtual date representations.
A date of 0000-00-00 is parsed as DateTime.MinValue.
Exceptions
- ArgumentNullException
The parameter sOrder was
null.- ArgumentException
The parameter sOrder did not consist of the three letters 'Y', 'M', and 'D' in any order.
- FormatException
The date could not be parsed into a valid date representation, or the year was smaller than 1000 or higher than 9999.
ParseValue(string, ScraperDecimalFormat)
public static decimal ParseValue(string sValue, ScraperDecimalFormat nFormat = ScraperDecimalFormat.Unknown)
Parameters
sValuestringThe value string that shall be parsed. This must not be
null.nFormatScraperDecimalFormatSelects the decimal number format that shall be parsed. The default value is Unknown.
Returns
- decimal
The signed decimal value of the parsed string.
Exceptions
- ArgumentNullException
The parameter sValue was
null.
Squeeze(string)
Removes any leading, trailing or interior whitespace from the given string.
public static string Squeeze(string s)
Parameters
sstring
Returns
Trim(string, int)
Trim whitespace and truncate string.
public static string Trim(string s, int nMaxLength = 2147483647)
Parameters
sstringThe string from which to trim leading and trailing whitespace. If this is
null, then this method also returnsnull.nMaxLengthintThe maximum length of the trimmed string. If, after trimming, the given string is longer than this, then only a sub-string with the given maximum length will be returned.