Class FinUtil
a collection of static utility methods that did not fit into any other class.
public static class FinUtil
- Inheritance
-
FinUtil
- Inherited Members
Properties
ApiVersion
Privides the version of the Subsembly FinTS API
public static Version ApiVersion { get; }
Property Value
GermanEncoding
public static Encoding GermanEncoding { get; }
Property Value
IsGermanTimeZone
Indicates whether the local time zone of this computer equals the German time zone.
public static bool IsGermanTimeZone { get; }
Property Value
Now
Returns the current German Date and Time, regardless of the local timezone of this computer.
public static DateTime Now { get; }
Property Value
Remarks
If the local timezone of this computer is the German time zone, then the
DateTime.Kind property will be DateTimeKind.Local. If the local
timezone of this computer is any other time zone, then the DateTime.Kind
property will be DateTimeKind.Unspecified.
In FinTS date stamps there is no timezone indicator and the FinTS specification does not specify which time zone should be used for date stamps. Hence, we can only presume, that all date stamps are expected to use the current German time zone. To ensure appropriate date stamps, the date/time properties and methods of the FinUtil helper class should be used instead of the DateTime class.
Today
Returns the current German Date, regardless of the local timezone of this computer.
public static DateTime Today { get; }
Property Value
Remarks
If the local timezone of this computer is the German time zone, then the
DateTime.Kind property will be DateTimeKind.Local. If the local
timezone of this computer is any other time zone, then the DateTime.Kind
property will be DateTimeKind.Unspecified.
In FinTS date stamps there is no timezone indicator and the FinTS specification does not specify which time zone should be used for date stamps. Hence, we can only presume, that all date stamps are expected to use the current German time zone. To ensure appropriate date stamps, the date/time properties and methods of the FinUtil helper class should be used instead of the DateTime class.
Methods
CompareAcctNo(string, string)
Compares two account numbers.
public static int CompareAcctNo(string sAcctNo1, string sAcctNo2)
Parameters
Returns
- int
If both account numbers are logically equal, then zero is returned. The result is less than zero if the first account number preceedes the second account number, and greater than zero is the second account number preceedes the first.
Remarks
When comparing the account numbers any leading zeroes are ignores. The case of any characters in the account number is ignored.
CompareBytes(byte[], byte[])
Compares to byte arrays for equality.
public static bool CompareBytes(byte[] vb1, byte[] vb2)
Parameters
Returns
- bool
Returns
trueonly if both array references arenull, or both refences are the same, or both arrays have the same length and contain the same bytes.
ConvertToGermanTime(DateTime)
Attempts to convert a given DateTime to the same point in time at the German time zone.
public static DateTime ConvertToGermanTime(DateTime tDateTime)
Parameters
tDateTimeDateTimeThe DateTime value to be converted. If this DateTime is DateTime.MinValue or is of DateTimeKind Unspecified, then this method does nothing and just returns the given parameter. If the given DateTimeKind is Local and the TimeZoneInfo.Local is already the German time zone, then is also does nothing and just returns the parameter. In any other case a conversion is attempted.
Returns
- DateTime
If the local time zone is the German time zone, then the returned DateTimeKind is Local. If the local time zone is different, then the returned DateTimeKind is Unspecified.
ConvertToUtc(DateTime)
Attempts to convert a given DateTime, which may be a time at the German time zone, into a UTC date time specification.
public static DateTime ConvertToUtc(DateTime tDateTime)
Parameters
tDateTimeDateTimeThe DateTime value to be converted. If this DateTime is DateTime.MinValue, then this method does nothing and just returns the given parameter. If the
DateTime.Kindof this parameter isDateTimeKind.Unspecified, then it is assumed to be a German date time specification and is converted accordingly. If theDateTime.Kindof this parameter isDateTimeKind.Local, then it is converted from whatever local time zone this computer is in.
Returns
CopyBytes(byte[], int, int)
Extracts a range of bytes from a byte array.
public static byte[] CopyBytes(byte[] vb, int nOffset, int nLength)
Parameters
vbbyte[]Source byte array from which to extract the byte range.
nOffsetintOffset where the byte range starts. This must not be negative, but may indicate an offset beyond the end of the source array.
nLengthintThe number of bytes to extract. This must not be negative, but may indicate a length that exceeds the end of the source array.
Returns
- byte[]
A new byte array that contains the byte range from the source byte array. If the parameter vb was null, then the return value is null, too. If the indicated byte range exceeds the end of the array, then only the actually available bytes are returned, which may produce an empty byte array.
DigitCount(string)
Returns the number of digits in a given string.
public static int DigitCount(string s)
Parameters
sstringThe string to count the digits of. May be
null.
Returns
- int
If the parameter s is
null, then zero is returned. In any other case, the count of digits is returned.
Remarks
This strange utility function is required to determine the challenge class in the even more strange Smart-TAN security procedure.
GetAuthenticateResultMessage(FinAuthenticateResult, FinSecurityMediaType)
Provides a descriptive message for an authentication result for the purpose of presenting the message to the user.
public static string GetAuthenticateResultMessage(FinAuthenticateResult nAuthRes, FinSecurityMediaType nMediaType)
Parameters
nAuthResFinAuthenticateResultThe authentication result code.
nMediaTypeFinSecurityMediaTypeThe type of security media for which to generate the message. This must be either KeyFile, SmartCard, or Void
Returns
- string
A German descriptive string is returned. If the given nAuthRes value indicates Success, then
nullis returned.
Remarks
For the security media type SmartCard the term "PIN" is used. For the security media type KeyFile the term "Password" is used.
GetCommErrorMessage(FinCommServiceException)
Translates a communication exception to a human readable string.
public static string GetCommErrorMessage(FinCommServiceException xCommService)
Parameters
xCommServiceFinCommServiceException
Returns
GetSecurityErrorMessage(FinSecurityException)
public static string GetSecurityErrorMessage(FinSecurityException xSecurity)
Parameters
xSecurityFinSecurityException
Returns
IsDigit(char)
public static bool IsDigit(char c)
Parameters
cchar
Returns
IsDigits(string)
Checks whether a string solely consists of digits.
public static bool IsDigits(string s)
Parameters
sstringThe string to be checked.
Returns
- bool
If the given string was
null, thenfalseis returned. If the given string was empty, thentrueis returned. If the string contains only digits, thentrueis returned, otherwisefalseis returned.
IsUpperAscii(char)
public static bool IsUpperAscii(char c)
Parameters
cchar
Returns
IsUpperAscii(string)
Checks whether a string solely consists of upper ASCII characters.
public static bool IsUpperAscii(string s)
Parameters
sstringThe string to be checked.
Returns
- bool
If the given string was
null, thenfalseis returned. If the given string was empty, thentrueis returned. If the string contains only upper ASCII characters in the range 'A' through 'Z', thentrueis returned, otherwisefalseis returned.
IsUpperOrDigit(char)
public static bool IsUpperOrDigit(char c)
Parameters
cchar
Returns
IsUpperOrDigits(string)
public static bool IsUpperOrDigits(string s)
Parameters
sstring
Returns
IsValidBankCode(string)
Checks whether the given string is a syntactically correct bank code.
public static bool IsValidBankCode(string sBankCode)
Parameters
sBankCodestring
Returns
Remarks
This check allows pseudo bank codes starting with '9', but it does not allow bank codes starting with '0'.
Trim(string)
Trims whitespace from a string.
public static string Trim(string s)
Parameters
sstringString to be trimmed. May be
null.
Returns
- string
If the parameter s was
null, thennullis returned, otherwise the trimmed string is returned. If the given string consists solely of whitespace, then an empty string will be returned.
TrimBankCode(string)
Trims leading, trailing and any internal white-space.
public static string TrimBankCode(string sBankCode)
Parameters
sBankCodestringThe bank code to be trimmed. May be
null.
Returns
- string
If the parameter sBankCode was
null, thennullis returned, otherwise the trimmed string is returned. If the given string consists solely of whitespace, then an empty string will be returned.
Remarks
For example, if the bank code is given as "701 500 00 ", then the returned string will be "70150000". This method should be used whenever a bank code entered by the used is processed.
TryParseInt32(string, int)
Parses an Int32 from a String without throwing any exceptions.
public static int TryParseInt32(string s, int nDefault)
Parameters
sstringThe string to be parsed. This may be
nullor otherwise invalid.nDefaultintThe default value that will be returned when the given string was
nullor could not be parsed for some other reason.
Returns
- int
If parsing was successful, then the parsed Int32 value from the given string is returned. If the string could not be parsed, then the value of nDefault is returned.