Class ScraperUtil
Inheritance
Inherited Members
Namespace: Subsembly.Scraper
Assembly: Subsembly.Scraper.dll
Syntax
public static class ScraperUtil
Fields
MAXGERMANACCTNOLENGTH
Max length of a German account number is 10 digits.
Declaration
public const int MAXGERMANACCTNOLENGTH = 10
Field Value
Type | Description |
---|---|
System.Int32 |
Methods
AcctNoCompare(String, String)
Compare two account numbers, ignoring leading zeroes.
Declaration
public static bool AcctNoCompare(string sAcctNo1, string sAcctNo2)
Parameters
Type | Name | Description |
---|---|---|
System.String | sAcctNo1 | |
System.String | sAcctNo2 |
Returns
Type | Description |
---|---|
System.Boolean | True if account numbers match. |
AppendRemittanceInformationLine(SepaTransactionDetails, String)
Appends a text line to the RemittanceInformation.
Declaration
public static void AppendRemittanceInformationLine(this SepaTransactionDetails aTxn, string sRmtInfLine)
Parameters
Type | Name | Description |
---|---|---|
SepaTransactionDetails | aTxn | The transaction where the remittance information line shall be added to.
Must not be |
System.String | sRmtInfLine | The text line to be appended. If this is |
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.
CoalesceSpaces(String)
Declaration
public static string CoalesceSpaces(string sText)
Parameters
Type | Name | Description |
---|---|---|
System.String | sText |
Returns
Type | Description |
---|---|
System.String |
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.
Declaration
public static string CreateFakeCreditCardNo(string sMaskedCreditCardNo, char chMaskChar = '*')
Parameters
Type | Name | Description |
---|---|---|
System.String | sMaskedCreditCardNo | A masked credit card number that consists solely of digits and the
|
System.Char | chMaskChar |
Returns
Type | Description |
---|---|
System.String | If the credit card number did not contain any |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter |
System.ArgumentException | The length of |
FormatAcctNo(String)
Remove spaces and add leading 0 up to MAXGERMANACCTNOLENGTH
Declaration
public static string FormatAcctNo(string sAcctNo)
Parameters
Type | Name | Description |
---|---|---|
System.String | sAcctNo |
Returns
Type | Description |
---|---|
System.String |
IsMaskedCreditCardNo(String, String, Char)
Declaration
public static bool IsMaskedCreditCardNo(string sCreditCardNo, string sMaskedCreditCardNo, char chMaskChar = '*')
Parameters
Type | Name | Description |
---|---|---|
System.String | sCreditCardNo | |
System.String | sMaskedCreditCardNo | |
System.Char | chMaskChar | The substitution character that is used in the
|
Returns
Type | Description |
---|---|
System.Boolean |
IsValidGermanAcctNo(String)
Checks whether the given account number consists of 2 to 10 digits, ignoring leading zeroes.
Declaration
public static bool IsValidGermanAcctNo(string sAcctNo)
Parameters
Type | Name | Description |
---|---|---|
System.String | sAcctNo |
Returns
Type | Description |
---|---|
System.Boolean |
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.
Declaration
public static bool IsValidGermanBankCode(string sBankCode)
Parameters
Type | Name | Description |
---|---|---|
System.String | sBankCode |
Returns
Type | Description |
---|---|
System.Boolean |
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[], Int32, Int32)
Determines if a buffer is a valid UTF-8 encoding.
Declaration
public static bool IsValidUTF8(byte[] vbData, int nOffset, int nLength)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vbData | |
System.Int32 | nOffset | |
System.Int32 | nLength |
Returns
Type | Description |
---|---|
System.Boolean | If the buffer is a valid UTF-8 encoding, then |
NullTrim(String, Int32)
Trim whitespace and truncate string. Returns null
when result is an empty string.
Declaration
public static string NullTrim(string s, int nMaxLength = 2147483647)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string from which to trim leading and trailing whitespace. If this is
|
System.Int32 | nMaxLength | The 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
Type | Description |
---|---|
System.String | If, after trimming, the resulting string is an empty string, then |
ParseDate(String, String)
Declaration
public static DateTime ParseDate(string sDate, string sOrder = "DMY")
Parameters
Type | Name | Description |
---|---|---|
System.String | sDate | Date 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". |
System.String | sOrder | The 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
Type | Description |
---|---|
System.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
Type | Condition |
---|---|
System.ArgumentNullException | The parameter sOrder was |
System.ArgumentException | The parameter sOrder did not consist of the three letters 'Y', 'M', and 'D' in any order. |
System.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)
Declaration
public static decimal ParseValue(string sValue, ScraperDecimalFormat nFormat = ScraperDecimalFormat.Unknown)
Parameters
Type | Name | Description |
---|---|---|
System.String | sValue | The value string that shall be parsed. This must not be |
ScraperDecimalFormat | nFormat | Selects the decimal number format that shall be parsed. The default value is Unknown. |
Returns
Type | Description |
---|---|
System.Decimal | The signed decimal value of the parsed string. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter sValue was |
Squeeze(String)
Removes any leading, trailing or interior whitespace from the given string.
Declaration
public static string Squeeze(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s |
Returns
Type | Description |
---|---|
System.String |
Trim(String, Int32)
Trim whitespace and truncate string.
Declaration
public static string Trim(string s, int nMaxLength = 2147483647)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string from which to trim leading and trailing whitespace. If this is
|
System.Int32 | nMaxLength | The 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
Type | Description |
---|---|
System.String |