-
-
Notifications
You must be signed in to change notification settings - Fork 0
Methods
Available methods in version 1.4.0 (all available from shared class 'Utils') :
Returns description of enum field.
Example
public enum KomunikatKod
{
[Description("User must enter valid captcha")]
NeedCaptcha = 1,
[Description("Result returned to many ID's")]
TooManyIds = 2,
[Description("Result empty")]
NoSubjects = 4,
[Description("User must login")]
NoSession = 7
}When using throw(); to pass exception to be handled in parent method, exception will not have full stack trace.
Example:
try
{
throw new ArgumentException(nameof(test));
}
catch (Exception)
{
throw;
}Will produce this exception, notice that line 54 is line where throw; is.
System.ArgumentException: test
w TestApp.Program.testFunc(String test) TestApp\Program.cs:wiersz 54
w TestApp.Program.Main(String[] args) w TestApp\Program.cs:wiersz 17
Now using function will produce more complete exception:
try
{
throw new ArgumentException(nameof(test));
}
catch (Exception e)
{
Utils.PreserveStackTrace(e);
throw e;
}Where line 51 is 'throw new Arg...' and line 56 is throw e;.
System.ArgumentException: test
w TestApp.Program.testFunc(String test) w TestApp\Program.cs:wiersz 51
w TestApp.Program.testFunc(String test) w TestApp\Program.cs:wiersz 56
w TestApp.Program.Main(String[] args) w TestApp\Program.cs:wiersz 18
Returns version of and assembly based on type.
Example:
GetVersion(typeof(Utils));Returns version of Utils library using method shown above.
Format Polish address from raw city, street etc. to one string.
Example:
FormatAddress("Warszawa", "00-000", "Warszawa", "Testowa", "12") => "ul. Testowa 12, 00-000 Warszawa"
FormatAddress("Testowo", "00-000", "Warszawa", "Testowa", "12") => "ul. Testowa 12, Testowo, 00-000 Warszawa"
FormatAddress("Warszawa", "00-000", "Warszawa", null, "12") => "Warszawa 12, 00-000 Warszawa"
Format Polish postal code and returns in XX-XXX format.
Returns SHA-1 hash of given string, optional parameter is encoding to use (null equals UTF-8).
Returns MD5 hash of given string, optional parameter is encoding to use (null equals UTF-8).
min <= value <= max
min < value <= max
min <= value < max
min < value < max
Return true if provided string is valid regex pattern.
Validate REGON number (Wikipedia)
Converts 9 digits REGON to 14 digits
Simple extension method. Instead:
var test = "Sample string";
if (string.IsNullOrEmpty(test))
return "It works!";You can use:
var test = "Sample string";
if (test.IsNullOrEmpty())
return "It works!";