Class ScraperUtil

Namespace
Subsembly.Scraper
Assembly
Subsembly.Scraper.dll
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

int

Methods

AcctNoCompare(string, string)

Compare two account numbers, ignoring leading zeroes.

public static bool AcctNoCompare(string sAcctNo1, string sAcctNo2)

Parameters

sAcctNo1 string
sAcctNo2 string

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

aTxn SepaTransactionDetails

The transaction where the remittance information line shall be added to. Must not be null.

sRmtInfLine string

The text line to be appended. If this is null or 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

aTxn SepaTransactionDetails
sRmtInfText string

Exceptions

ArgumentNullException

CoalesceSpaces(string)

public static string CoalesceSpaces(string sText)

Parameters

sText string

Returns

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.

public static string CreateFakeCreditCardNo(string sMaskedCreditCardNo, char chMaskChar = '*')

Parameters

sMaskedCreditCardNo string

A 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.

chMaskChar char

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 sMaskedCreditCardNo was null.

ArgumentException

The length of sMaskedCreditCardNo is not a valid credit card number length. -or- The sMaskedCreditCardNo did contain a character that is neither a digit nor the chMaskChar.

FormatAcctNo(string)

Remove spaces and add leading 0 up to MAXGERMANACCTNOLENGTH

public static string FormatAcctNo(string sAcctNo)

Parameters

sAcctNo string

Returns

string

IsMaskedCreditCardNo(string, string, char)

public static bool IsMaskedCreditCardNo(string sCreditCardNo, string sMaskedCreditCardNo, char chMaskChar = '*')

Parameters

sCreditCardNo string
sMaskedCreditCardNo string
chMaskChar char

The substitution character that is used in the sMaskedCreditCardNo as a replacement for the masked digits. By default this is '*'.

Returns

bool

IsValidGermanAcctNo(string)

Checks whether the given account number consists of 2 to 10 digits, ignoring leading zeroes.

public static bool IsValidGermanAcctNo(string sAcctNo)

Parameters

sAcctNo string

Returns

bool

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

sBankCode string

Returns

bool

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

vbData byte[]
nOffset int
nLength int

Returns

bool

If the buffer is a valid UTF-8 encoding, then true is returned. This includes buffers that contain solely ASCII bytes. If the buffer is not a valid UTF-8 encoding, then false is 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

s string

The string from which to trim leading and trailing whitespace. If this is null, then this method also returns null.

nMaxLength int

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

string

If, after trimming, the resulting string is an empty string, then null is returned instead of an empty string.

ParseDate(string, string)

public static DateTime ParseDate(string sDate, string sOrder = "DMY")

Parameters

sDate string

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".

sOrder string

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

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

sValue string

The value string that shall be parsed. This must not be null.

nFormat ScraperDecimalFormat

Selects 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

s string

Returns

string

Trim(string, int)

Trim whitespace and truncate string.

public static string Trim(string s, int nMaxLength = 2147483647)

Parameters

s string

The string from which to trim leading and trailing whitespace. If this is null, then this method also returns null.

nMaxLength int

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

string