AuxiliaryLibraries 1.3.0
dotnet add package AuxiliaryLibraries --version 1.3.0
NuGet\Install-Package AuxiliaryLibraries -Version 1.3.0
<PackageReference Include="AuxiliaryLibraries" Version="1.3.0" />
paket add AuxiliaryLibraries --version 1.3.0
#r "nuget: AuxiliaryLibraries, 1.3.0"
// Install AuxiliaryLibraries as a Cake Addin #addin nuget:?package=AuxiliaryLibraries&version=1.3.0 // Install AuxiliaryLibraries as a Cake Tool #tool nuget:?package=AuxiliaryLibraries&version=1.3.0
Table of Contents
- About The Project
- Auxiliary Calendar
- Auxiliary General Response
- Auxiliary Directory File Helper
- Auxiliary Encryption (RC4, AES, RSA)
- Auxiliary Http
- Auxiliary Object Copier
- Auxiliary Rest API
- Auxiliary Zip
- Auxiliary IP Address
- Auxiliary Extensions
- Auxiliary Sample Data Generator
- Auxiliary Enum Extension
- Auxiliary String Compression
- Auxiliary Queue
Get Started
About AuxiliaryLibraries
This library helps you to get rid of some repetitive code blocks about date-times, IP, Rest, JSON, encryption, files, directories, queue, zip, objects, and string extensions. This is a good helper, and saves lots of time, especially for Iranian programmers. Project URL: https://www.nuget.org/packages/AuxiliaryLibraries/
Auxiliary Calendar
- ToPrettyDate() ⇒ Parameters : DateTime dateTime, bool isUtc = false, bool toPersian = true ⇒ Return: string
var persianDate = DateTime.Now.ToPrettyDate();
persianDate : "امروز ساعت 10:57"
set isUtc as true
var persianDate2 = DateTime.UtcNow.ToPrettyDate(true);
persianDate2 : "امروز ساعت 10:57"
set toPersian as false will return DateTime in English
var persianDate3 = DateTime.UtcNow.ToPrettyDate(toPersian:false);
persianDate3 : "Today at 10:57"
- ToPrettyTime()
⇒ Parameters : DateTime dateTime, bool isUtc = false, bool toPersian = true
⇒ Return: string
var persianDate = DateTime.Now.AddMinutes(-10).ToPrettyTime();
persianDate : "10 دقیقه پیش"
set isUtc as true
var persianDate = DateTime.UtcNow.AddDays(-15).ToPrettyTime(true);
persianDate2 : "2 هفته پیش"
set toPersian as false will return datetime in english
var persianDate3 = DateTime.UtcNow.AddMonths(-3).ToPrettyTime(toPersian:false);
persianDate3 : "3 months ago"
- ToPrettyDateTime()
⇒ Parameters : DateTime dateTime, bool isUtc = false, bool toPersian = true
⇒ Return: string
var persianDate = DateTime.Now.AddMinutes(-10).ToPrettyDateTime();
persianDate : "هجدهم آذر ماه 1395 ساعت 14:30"
set isUtc as true set toPersian as false will return DateTime in English
var persianDate2 = DateTime.UtcNow.AddDays(-15).ToPrettyDateTime(isUtc:true, toPersian:false);
persianDate2 : "Ninth of December 2016 at 14:30"
- ToPrettyDay()
⇒ Parameters : DateTime dateTime, bool isUtc = false, bool toPersian = true
⇒ Return: string
var persianDate1 = DateTime.Now.ToPrettyDay();
persianDate1 : "امروز"
var persianDate2 = DateTime.Now.AddMinutes(-1).ToPrettyDay();
persianDate2 : "دیروز"
var persianDate3 = DateTime.Now.AddMinutes(1).ToPrettyDay();
persianDate3 : "فردا"
var persianDate4 = DateTime.Now.AddMinutes(-35).ToPrettyDay();
persianDate4 : "5 هفته پیش"
- ToPrettyDayOfWeek()
⇒ Parameters : DateTime dateTime, bool isUtc = false, bool toPersian = true, bool dayNumber = false
⇒ Return: string
var persianDate1 = DateTime.Now.ToPrettyDayOfWeek();
persianDate1 : "امروز"
var persianDate2 = DateTime.Now.AddMinutes(-1).ToPrettyDayOfWeek();
persianDate2 : "دیروز"
var persianDate3 = DateTime.Now.AddMinutes(+10).ToPrettyDayOfWeek();
persianDate3 : "جمعه"
var persianDate4 = DateTime.Now.AddMinutes(-5).ToPrettyDayOfWeek();
persianDate4 : "شنبه"
- ToPersianDateTime()
⇒ Parameters : DateTime dateTime, bool isUtc = false, string delimiter = "/"
⇒ Return: string
var persianDate = DateTime.Now.ToPersianDateTime();
persianDate : "1395/9/30 ساعت 10:57"
var persianDate2 = DateTime.Now.ToPersianDateTime(false, "-");
persianDate2 : "1395-9-30 ساعت 10:57"
UTC:
var persianDate = DateTime.UtcNow.ToPersianDateTime(true);
persianDate : "1395/9/30 ساعت 10:57"
var persianDate2 = DateTime.UtcNow.ToPersianDateTime(true, "-");
persianDate2 : "1395-9-30 ساعت 10:57"
- ToPersianDate()
⇒ Parameters : DateTime dateTime, bool isUtc = false, string delimiter = "/"
⇒ Return: string
var persianDate = DateTime.Now.ToPersianDate();
persianDate : "1395/09/30"
var persianDate2 = DateTime.Now.ToPersianDate(false, "-");
persianDate2 : "1395-9-30"
UTC:
var persianDate = DateTime.UtcNow.ToPersianDate(true);
persianDate : "1395/09/30"
var persianDate2 = DateTime.UtcNow.ToPersianDate(true, "-");
persianDate2 : "1395-9-30"
- ToPersianFullDateTime()
⇒ Parameters : DateTime dateTime, bool isUtc = false, string delimiter = "/"
⇒ Return: string
var persianDate = DateTime.Now.ToPersianFullDateTime();
persianDate : "1395/9/30 10:57:23:547"
var persianDate2 = DateTime.Now.ToPersianFullDateTime(false, "-");
persianDate2 : "1395-9-30 10:57:23:547"
UTC:
var persianDate = DateTime.UtcNow.ToPersianFullDateTime(true);
persianDate : "1395/09/30 10:57:23:547"
var persianDate2 = DateTime.UtcNow.ToPersianFullDateTime(true, "-");
persianDate2 : "1395-9-30 10:57:23:547"
- BeginDate()
var midnight = DateTime.Now.BeginDate();
midnight : 12/20/2016 00:00:00
- EndDate()
var tommorowMidnight = DateTime.Now.EndDate();
12/20/2016 23:59:59
- ConvertFromUTC()
⇒ Parameters : DateTime dateTime, TimeZoneInfo destinationTimeZone
⇒ Return: DateTime
var date = DateTime.UtcNow.ConvertFromUTC(TimeZoneInfo.FindSystemTimeZoneById(AuxiliaryCalendar.IranianTimeZone));
date : "2016/9/30 10:57:23:547"
- DayOfWeek()
⇒ Parameters : DateTime dateTime, bool toPersian = true, bool dayNumber = false
⇒ Return: string
var persianDate = DateTime.Now.DayOfWeek();
persianDate : " چهارشنبه"
var persianDate2 = DateTime.Now.DayOfWeek(toPersian:false);
persianDate2 : "Wednesday"
var persianDate3 = DateTime.Now.DayOfWeek(dayNumber:true);
persianDate3 : "4 شنبه"
- DayOfMonth()
⇒ Parameters: int day, bool isPersian
⇒ Return: string
var persianDate = AuxiliaryCalendar.DayOfMonth(20);
persianDate : " بیستم"
- Month()
⇒ Parameters: int day, bool isPersian
⇒ Return: string
var persianDate = AuxiliaryCalendar.Month(9);
persianDate : " آذر"
- GetFirstDayOfThisMonth()
⇒ Parameters : bool isPersian = true
⇒ Return: DateTime
Get the first day of the current Persian month
var date = AuxiliaryCalendar.GetFirstDayOfThisMonth();
date : "2016-06-18"
Get the first day of the current milady month
var date = AuxiliaryCalendar.GetFirstDayOfThisMonth(isPersian:false);
date : "2016-06-01"
- GetFirstDayOfThisWeek()
⇒ Parameters : bool isPersian = true
⇒ Return: DateTime
Get the first day of the current Persian week
var date = AuxiliaryCalendar.GetFirstDayOfThisWeek();
date : "2016-06-20"
Get the first day of the current milady week
var date = AuxiliaryCalendar.GetFirstDayOfThisWeek(isPersian:false);
//date : "2016-06-22"
- GetNextNearestWeekday() Get the Next Nearest day of the Week, For example, get the next nearest Sunday from Now
⇒ Parameters : DateTime start, DayOfWeek day ⇒ Return: DateTime
var date = DateTime.Now.GetNextNearestWeekday(DayOfWeek.Sunday);
//date : "2016-06-29"
- GetFirstDayOfLastXDay() Get the First Day Of the Last X-Day It will give you the first nearest xDay from the beginning of the month.
⇒ Parameters : int xDay, bool isPersian = true ⇒ Return: DateTime
//xDay = 7, Today = 23 => it will return : 21
//xDay = 15, Today = 23 => it will return : 15
//Be careful xDay Must be less than 30
Auxiliary GeneralResponse
It is better to have a structure for your responses over the project. GeneralResponse is a wrapper over your response. It has a result property that will fill with your response and a status property which will fill according to your response status.
// In case of the requested information does not find, and you want to return not found (404 HTTP Status Code)
// You can pass the custom message or leave to fill in the default NotFound message
return GeneralResponse<TResult>.GenerateResponse().NotFound(message: "custom message");
// OR
return GeneralResponseStatusCode.NOT_FOUND.Error<TResult>("custom message");
// In case of the user doesn't have permission to access the resource, and you want to return forbidden (403 HTTP Status Code)
// You can pass the custom message or leave to fill in the default Forbidden message
return GeneralResponse<TResult>.GenerateResponse().Forbidden(message: "custom message");
// OR
return GeneralResponseStatusCode.UNAUTHENTICATED.Error<TResult>("custom message");
// In case of user didn't log in or the token was expired, and you want to return unauthorized (401 HTTP Status Code)
// You can pass the custom message or leave to fill in the default Unauthorized message
return GeneralResponse<TResult>.GenerateResponse().Unauthorized(message: "custom message");
// OR
return GeneralResponseStatusCode.UNAUTHORIZED.Error<TResult>("custom message");
// In case you blocked the user for any reason, and you want to return Locked (423 HTTP Status Code)
// You can pass the custom message or leave to fill in the default Blocked message
return GeneralResponse<TResult>.GenerateResponse().Blocked(message: "custom message");
// OR
return GeneralResponseStatusCode.USER_IS_BLOCKED.Error<TResult>("custom message");
// In case of any particular error return which you want to be more specific or none of above
// Here you have to pass at least the GeneralResponseStatusCode which is an enum, you can also pass the custom message or leave it to fill
// the default Blocked message (this function will return 400 HTTP Status Code for GeneralResponseStatusCode.REQUEST_IS_NOT_PERMITTED,
// but of you change the GeneralResponseStatusCode the proper HTTP Status Code will be picked.)
return GeneralResponse<TResult>.GenerateResponse().Error(GeneralResponseStatusCode.REQUEST_IS_NOT_PERMITTED);
// OR
return GeneralResponseStatusCode.REQUEST_IS_NOT_PERMITTED.Error<TResult>("custom message");
// In case of returning success, you have to return the response data as well
// You can pass the custom message or leave to fill in the default Success message (200 HTTP Status Code)
return GeneralResponse<TResult>.GenerateResponse().Success(responseData, "custom message");
If you want to cast or deserialize something to GeneralResponse it is not possible. Because it doesn't have a public constructor. To fix this issue we have access to another class called BaseGeneralResponse which GeneralResponse itself inherits from BaseGeneralResponse. So you can cast or deserialize everything to it.
var result = await _httpClient.GetFromJsonAsync<BaseGeneralResponse<List<UserResponseModel>>>(url);
// OR
var result = JsonConvert.DeserializeObject<BaseGeneralResponse<List<UserResponseModel>>>(data);
Auxiliary DirectoryFileHelper
- CreateFolderIfNeeded() Create a folder if it doesn't exist
⇒ Parameters : string path ⇒ Return: bool
AuxiliaryDirectoryFileHelper.CreateFolderIfNeeded("C:/My Folder");
- CopyFolder() Copy a Folder (including every file and subfolders in it) from 'sourcePath' to 'destinationPath'
⇒ Parameters : string sourcePath, string destinationPath ⇒ Return: bool
AuxiliaryDirectoryFileHelper.CopyFolder("C:/My Folder1", "C:/My Folder2");
- CopyFile() Copy a File from 'sourcePath' to 'destinationPath'
⇒ Parameters : string sourcePath, string destinationPath ⇒ Return: bool
AuxiliaryDirectoryFileHelper.CopyFile("C:/My Folder1/image.jpg", "C:/My Folder2/image.jpg");
- Download() Download a file by its 'URL' and save it to 'destination'
⇒ Parameters: string URL, string destination ⇒ Return: bool
AuxiliaryDirectoryFileHelper.Download("https://google.com/1.jpg", "C:/My Folder1/image.jpg");
- IsImage() Understing this file is image or not
⇒ Parameters : string contentType ⇒ Return: bool
AuxiliaryDirectoryFileHelper.IsImage("C:/My Folder1", "C:/My Folder2");
- GetMimeTypeFromFilePath() Get Mime Type From File Path
⇒ Parameters : string filePath ⇒ Return: string
AuxiliaryDirectoryFileHelper.GetMimeTypeFromFilePath("C:/My Folder1/image.jpg");
- GetMimeTypeFromFilePath() Get Mime Type From File Format
⇒ Parameters : string format ⇒ Return: string
AuxiliaryDirectoryFileHelper.GetMimeTypeFromFilePath(".jpg");
Auxiliary Encription
RC4
- Encrypt() Encrypt your data with key
⇒ Parameters: string key, string data, Encoding encoding, bool skipZero = false ⇒ Return: string
var encrypted = AuxiliaryEncryption.RC4.Encrypt("KEY", "Keeping in mind that every character of that string is 1 byte, or 8 bits, in size (assuming ASCII/UTF8 encoding), we are encoding 6 bytes, or 48 bits, of data. According to the equation, we expect the output length to be (6 bytes / 3 bytes) * 4 characters = 8 characters.Nov 14, 2012");
- Encrypt() Encrypt your data with key and encoding
⇒ Parameters: string key, string data ⇒ Return: string
var encrypted = AuxiliaryEncryption.RC4.Encrypt("KEY", "Keeping in mind that every character of that string is 1 byte, or 8 bits, in size (assuming ASCII/UTF8 encoding), we are encoding 6 bytes, or 48 bits, of data. According to the equation, we expect the output length to be (6 bytes / 3 bytes) * 4 characters = 8 characters.Nov 14, 2012", Encoding.UTF8);
- Decrypt() Decrypt your data with key
⇒ Parameters : string key, string data, Encoding encoding, bool skipZero = false ⇒ Return: string
var decrypted = AuxiliaryEncryption.RC4.Decrypt("KEY", encrypted);
- Decrypt() Decrypt your data with key and encoding
⇒ Parameters: string key, string data ⇒ Return: string
var decrypted = AuxiliaryEncryption.RC4.Decrypt("KEY", encrypted, Encoding.UTF8);
AES
- EncryptFile() Encrypt your file, config of encryption is inside the constructor
⇒ Parameters : string inputFile, string outputFile ⇒ Return: string
var key = "4352821A-787A-4982-9A41-B1EB003BE9A1";
var aes = new AuxiliaryEncryption.AES(key, System.Text.Encoding.UTF8);
aes.EncryptFile(@"C:\Test.jpg", @"C:\Test_EncryptFile.jpg");
- Encrypt() Encrypt your data
⇒ Parameters : string strtoencrypt ⇒ Return: byte[]
var key = "4352821A-787A-4982-9A41-B1EB003BE9A1";
var aes = new AuxiliaryEncryption.AES(key, System.Text.Encoding.UTF8);
var encrypted = aes.Encrypt("Some Text");
- DecryptFile() Decrypt your file, , config of decryption is inside the constructor
⇒ Parameters : string inputFile, string outputFile ⇒ Return: string
var key = "4352821A-787A-4982-9A41-B1EB003BE9A1";
var aes = new AuxiliaryEncryption.AES(key, System.Text.Encoding.UTF8);
aes.EncryptFile(@"C:\Test.jpg", @"C:\Test_EncryptFile.jpg");
aes.DecryptFile(@"C:\Test_EncryptFile.jpg", @"C:\Test_DecryptFile.jpg");
- Decrypt() Decrypt your data
⇒ Parameters : string strtoencrypt ⇒ Return: string
var key = "4352821A-787A-4982-9A41-B1EB003BE9A1";
var aes = new AuxiliaryEncryption.AES(key, System.Text.Encoding.UTF8);
var encrypted = aes.Encrypt("Some Text");
var decrypted = aes.Decrypt(encrypted);
RSA
*Initialize RSA Encryption
//By creating an instance, the public key and private key automatically will be generated by default
var rsa = new AuxiliaryEncryption.RSA(2048);
//You can use public key and private key and save them as *.xml or *.pem file by using functions SavePublicKeyToXmlFile, SavePublicKeyToPemFile,SavePrivateKeyToXmlFile, and SavePrivateKeyToPemFile
//XML File
rsa.SavePrivateKeyToXmlFile(@"C:\PrivateKey.xml");
rsa.SavePublicKeyToXmlFile(@"C:\PublicKey.xml");
//PEM File
rsa.SavePrivateKeyToPemFile(@"C:\PrivateKey.pem");
rsa.SavePublicKeyToPemFile(@"C:\PublicKey.pem");
//You can also replace the public key and private key with your own public key and private key by using SetPublicKey and SetPrivateKey (pass the path of *.xml or *.pem file)
//XML File
rsa.SetPublicKey(@"C:\PrivateKey.xml");
rsa.SetPrivateKey(@"C:\PublicKey.xml");
//PEM File
rsa.SetPublicKey(@"C:\PrivateKey.pem");
rsa.SetPrivateKey(@"C:\PublicKey.pem");
- Encrypt() Encrypt your data, config (Sign, PrivateKey, PublicKey) of encryption is inside the constructor
⇒ Parameters : string plainText ⇒ Return: string
var txt = "Keeping in mind that every character of that string is 1 byte, or 8 bits, in size (assuming ASCII/UTF8 encoding), we";
var encrypted = rsa.Encrypt(txt);
- Decrypt() Decrypt your data, , config (Sign, PrivateKey, PublicKey) of decryption is inside the constructor
⇒ Parameters : string inputFile, string outputFile ⇒ Return: string
var decrypted = rsa.Decrypt(encrypted);
Auxiliary Http
- Read() Fetch Requests (HttpRequestMessage) as a List of object
⇒ Parameters : System.Net.Http.HttpRequestMessage Request ⇒ Return: System.Collections.Generic.List < object >
var objectList = Request.Read()
- IsMobileRequest() Check whether the user request was sent from mobile or not
⇒ Parameters : NONE ⇒ Return: bool
if(AuxiliaryHttp.IsMobileRequest())
{
//Request is sent by a Mobile Device not a Desktop
}
Auxiliary Object Copier
- Clone() Perform a deep copy of the object via serialization. Be careful, The type must be serializable.
⇒ Parameters : T source ⇒ Return: T
var person = new Person();
var clonedPerson = person.Clone();
Auxiliary RestApi
- Send() Send your request to RestSharp
⇒ Parameters : string baseUrl, string functionName, Method method, IDictionary<string, string> headers, IDictionary<string, object> parametersBody, string userName, string password ⇒ Return: IRestResponse
IDictionary<string, object> body = new Dictionary<string, object>();
body.Add("action", action);
body.Add("CellNumber", phoneNumber);
IDictionary<string, string> header = new Dictionary<string, string>();
header.Add("content-type", "application/json;charset=UTF-8");
string output = AuxiliaryLibraries.AuxiliaryRestApi.Send(url, header, body, "POST");
var responseDTO = JsonConvert.DeserializeObject<ResponseDTO>(output);
- Send() Send your request to RestSharp
⇒ Parameters : string baseUrl, string functionName, Method method, IDictionary<string, string> headers, object body, string userName, string password ⇒ Return: IRestResponse
IDictionary<string, object> body = new Dictionary<string, object>();
body.Add("action", action);
body.Add("CellNumber", phoneNumber);
IDictionary<string, string> header = new Dictionary<string, string>();
header.Add("content-type", "application/json;charset=UTF-8");
string output = AuxiliaryLibraries.AuxiliaryRestApi.Send(url, header, body, "POST");
var responseDTO = JsonConvert.DeserializeObject<ResponseDTO>(output);
- Send() Send your request to WebClient
⇒ Parameters : string url, IDictionary<string, string> headers, IDictionary<string, object> parametersBody, string method = "GET", bool contentLength = true ⇒ Return: string
IDictionary<string, object> body = new Dictionary<string, object>();
body.Add("action", action);
body.Add("CellNumber", phoneNumber);
IDictionary<string, string> header = new Dictionary<string, string>();
header.Add("content-type", "application/json;charset=UTF-8");
string output = AuxiliaryLibraries.AuxiliaryRestApi.Send(url, header, body, "POST");
var responseDTO = JsonConvert.DeserializeObject<ResponseDTO>(output);
AuxiliaryZip
- Compress() Create a ZIP file of the files provided.
⇒ Parameters : IEnumerable< string > fileNames, string destinationFileName ⇒ Return: void
- Compress() Compress the entire folder by passing the directory Path
⇒ Parameters : string directoryPath ⇒ Return: void
- Decompress() Decompress *.zip file, if pathIsDirectory passes as false. (One Zip file) Decompress every *.zip file inside the folder by passing directory Path, if pathIsDirectory passes as true. (Multiple Zip files)
⇒ Parameters : string path, bool pathIsDirectory = false ⇒ Return: void
- Decompress() Decompress *.zip file by passing FileInfo If you pass newFileName, the zip file extracted on this path, otherwise (if you pass newFileName as null, default value) the zip file extracted on the parent folder
⇒ Parameters : System.IO.FileInfo fileToDecompress, string newFileName = null ⇒ Return: void
Auxiliary IpAddress
- IsInRange() Return true, if IP is in the range of lower range and upper range
⇒ Parameters : IPAddress ip, IPAddress lowerRange, IPAddress upperRange ⇒ Return: bool
Auxiliary Extensions
Convert Letters To Letters
- IsEnglish()
Check if the text is English or not
var txt = "Keeping in mind that every character";
var isEnglish = txt.IsEnglish();
- ToPersianNumber()
Convert all other numbers in the text to Persian numbers
var txt = "Hello 123 World";
string persianFormat = txt.ToPersianNumber();
- ToPersianNumber()
Convert numbers to Persian numbers
int number = 123;
string persianFormat = number.ToPersianNumber(isMoney: false);
- ToEnglishNumber()
Convert numbers to English numbers
var number = "۱۲۳";
string text = number.ToEnglishNumber();
- ToArabicNumbers()
Convert numbers to Arabic numbers
var number = "123";
string text = number.ToArabicNumbers();
- ToPersianLetters()
Convert all Arabic letters to Persian letters
var txt = "این یك مبدل حرفة اي است";
string text = text.ToPersianLetters();
- ToPersianLetters()
Convert numbers to Persian letters
int txt = 14752;
string text = number.ToPersianLetters();
// result => "چهارده هزار و خفتصد و پنجاه و دو"
long txt = 14752;
string text = number.ToPersianLetters();
// result => "چهارده هزار و خفتصد و پنجاه و دو"
Ignore Cases
- EqualIgnoreCase()
Ignorance Case Sensitive in comparison
var result = "firststring".EqualIgnoreCase("FirstString");
// result is true
- ContainsIgnoreCase()
Ignorance Case Sensitive in comparison
var collection = new List<string>(){ "secondString", "FirstString", "thirdString", "forthString" };
var result = collection.ContainsIgnoreCase("firststring");
// result is true
User Identity Information
- NormalizeMobileNumber()
Normalize mobile number as Iranian mobile number (989*********). You can pass '+98', '98' or '0' on 'startWith'. Def If phone number is not valid, it will return number itself.
var mobile = "09123456789".NormalizeMobileNumber(); // mobile = "989123456789"
var mobile = "9123456789".NormalizeMobileNumber(); // mobile = "989123456789"
var mobile = "+989123456789".NormalizeMobileNumber(); // mobile = "989123456789"
var mobile = "09123456789".NormalizeMobileNumber("+98"); // mobile = "+989123456789"
- IsNationalIdValid()
Check validity of Iranian national identity. It validate the lenght and the foramt of the NationalId
var result = "NationalId".IsNationalIdValid(); // result will be true if "NationalId" is Iranian NationalId format
- IsEmailValid()
Check validity of email format
var result = "email".IsEmailValid(); // result will be true if "email" has a correct format
- IsCellNumberValid()
Check validity of Cell Number/ Mobile Number format
var result = "CellNumber".IsCellNumberValid(); // result will be true if "CellNumber" has a correct Iranian format
- IsPhoneNumberValid()
Check validity of Phone Number format. It will check the House/Office Numbers foramt.
var result = "PhoneNumber".IsCellNumberValid(); // result will be true if "PhoneNumber" has a correct Iranian format
- IsShebaValid()
Check validity of Sheba format.
var result = "Sheba".IsShebaValid(); // result will be true if "Sheba" has a correct Iranian format
- IsShebaValid()
Check validity of Sheba format.
var result = "Sheba".IsShebaValid(); // result will be true if "Sheba" has a correct Iranian format
Hash AND Encryption
Comma Delimited
- ToCommaDelimited()
Convert price to string and Seperate it by separator.
var result = 123456789.ToCommaDelimited(); // result => "123,456,789"
var result = 123456789.ToCommaDelimited(separator: ";"); // result => "123;456;789"
var result = 123456789.ToCommaDelimited(separatedSize: 2); // result => "1,23,45,67,89"
var result = 123456789.987654.ToCommaDelimited(); // result => "123,456,789.987,654"
var result = 123456789.9876543.ToCommaDelimited(seperatorRtlAlign : false); // result => "123,456,789.987,654,3"
var result = 123456789.9876543.ToCommaDelimited(seperatorRtlAlign : true); // result => "123,456,789.9,876,543"
Money And Currency
Utilities
- ToPrettySize()
ToPrettySize helps you to get size of files as a pereety format. Convert bytes to nearest pretty fromat.
- 512 MG
- 512 مگابایت
var result = 123456.ToPrettySize(toPersian: false);
var result = 123456.ToPrettySize();
- Split()
Splitting a string into chunks of a certain size
var result = "Splitting a string into chunks of a certain size".Split(chunkSize : 5);
Auxiliary Sample Data Generator
- GenerateInstanceOf()
It will help you to generate a sample fake data fro any kind of data. It can be value types or reference types. It can be int, long, string, datetime, or even complex objects. It can be a List of an object, or maybe a Dictionary.
var result = AuxiliarySampleDataGenerator.GenerateInstanceOf<T>();
// and T can be anything
var result = AuxiliarySampleDataGenerator.GenerateInstanceOf<int>();
var result = AuxiliarySampleDataGenerator.GenerateInstanceOf<string>();
var result = AuxiliarySampleDataGenerator.GenerateInstanceOf<List<Person>>();
var result = AuxiliarySampleDataGenerator.GenerateInstanceOf<Dictionary<Guid, Person>>();
Auxiliary Enum Extension
- GetDescription()
Get Enum Description Imagine we have an enum like this
public enum Temp{
[Description("Enum1")]
Enum1 = 1,
[Description("Enum2")]
Enum2 = 2
}
var result = Temp.Enum1.GetDescription();
- GetEnumList()
Get List of Enum Imagine we have an enum like this
public enum Temp{
[Description("Enum1")]
Enum1 = 1,
[Description("Enum2")]
Enum2 = 2
}
List<EnumToListModel> result = AuxiliaryEnumExtension.GetEnumList<Temp>();
public class EnumToListModel
{
public string Key { get; set; }
public int Value { get; set; }
public string Description { get; set; }
}
- GetValueFromDescription()
Get Enum value by its Description Imagine we have an enum like this
public enum Temp{
[Description("Enum1")]
Enum1 = 1,
[Description("Enum2")]
Enum2 = 2
}
var result = "Enum1".GetValueFromDescription<Temp>();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- Portable.BouncyCastle (>= 1.9.0)
- RestSharp (>= 105.2.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.3.0 | 285 | 4/13/2023 |
1.2.9 | 412 | 12/26/2021 |
1.2.8 | 307 | 12/26/2021 |
1.2.7 | 287 | 12/25/2021 |
1.2.6 | 541 | 9/4/2021 |
1.2.5 | 482 | 7/26/2021 |
1.2.4 | 425 | 7/26/2021 |
1.2.3 | 774 | 3/6/2021 |
1.2.2 | 427 | 3/1/2021 |
1.2.1 | 456 | 2/28/2021 |
1.2.0 | 491 | 2/17/2021 |
1.1.9 | 419 | 2/17/2021 |
1.1.8 | 396 | 2/16/2021 |
1.1.7 | 409 | 2/15/2021 |
1.1.6 | 425 | 2/1/2021 |
1.1.5 | 431 | 1/31/2021 |
1.1.4 | 459 | 1/13/2021 |
1.1.3 | 950 | 6/29/2020 |
1.1.2 | 513 | 6/29/2020 |
1.1.1 | 564 | 4/22/2020 |
1.1.0 | 772 | 4/10/2019 |
1.0.19 | 819 | 1/13/2019 |
1.0.18 | 671 | 4/10/2019 |
1.0.17 | 879 | 10/14/2018 |
1.0.16 | 884 | 10/14/2018 |
1.0.15 | 847 | 10/13/2018 |
1.0.14 | 1,085 | 5/8/2018 |
1.0.13 | 1,192 | 11/22/2017 |
1.0.12 | 1,169 | 11/22/2017 |
1.0.11 | 1,219 | 11/22/2017 |
1.0.10 | 1,123 | 11/22/2017 |
1.0.9 | 1,041 | 11/1/2017 |
1.0.8 | 1,130 | 4/12/2017 |
1.0.7 | 1,115 | 2/7/2017 |
1.0.6 | 1,217 | 2/7/2017 |
1.0.5 | 1,110 | 12/20/2016 |
1.0.4 | 1,245 | 12/7/2016 |
1.0.3 | 1,157 | 12/6/2016 |
1.0.2 | 1,157 | 12/6/2016 |
1.0.1 | 1,178 | 12/6/2016 |
1.0.0 | 1,642 | 12/6/2016 |
Update AES and RSA Encryptions.