Build | Status | Current Version |
---|---|---|
CI | N/A | |
Packages | ||
Packages |
Follow instructions on Nuget.
In dotnet framework there aren't some useful features. These features are essential and every time we start a new project we need them so we look for them or rewrite them. In this package there are some useful feature for every great developer.
- ConcurrentList
- like List<T> but thread safe.
- String Comparer Extensions
- With this extension you can use every string comparison but configured in the same way of your database.
- String Extensions
- It adds some feature like ReplaceFirst or ReplaceLast.
- URL base 64 encode & decode
- String extension to encode string to valid url encoded 64 and viceversa.
- Reflection Extensions
- It adds features to all object like SetPropertyValue and GetPropertyValue.
- Json Extensions
- It adds features to all objects like .ToJson() and .ToObject() for the string type.
- Compression Extension
- It adds features to all object to zip an instance of object.
- Serializer Extensions
- It adds features to all object to serialize them to and from byte[]
- Cryptography Extensions
- It adds feature to encrypt and decrypt strings
- List<> or IEnumerable<> Extensions
- It adds feature to List and IEnumerable such 'Split'
- Visitor Extensions
- It adds visitor (graph explorer\object tree explorer) to traverse object graph\aggregate
The first step is to install this package from Nuget.
Add this using
using DevExtremeToys.Concurrent;
Now you can use ConcurrentList in a multi threading environment
ConcurrentList<int> list = new ConcurrentList<int>();
list.Add(i);
ConcurrentList<MyClass> list = new ConcurrentList<MyClass>();
list.Add(new MyClass() { Name = "Test"});
With this extension you can compare string with Case Sensitive and Accent Sensitive options.
Add this using
using DevExtremeToys.StringComparer;
Now you can compare strings with database rules
You can configure comparer rule once or use different configuration for every comparison.
In this example we use a global configuration
CompareSettings.Instance.GetSetting = () =>
{
return new Settings()
{
CaseOption = CaseOptions.Insensitive,
AccentOption = AccentOptions.Sensitive
};
};
string s1 = "à1abbbcccaaabbbccc";
string s2 = "à1ABBBCCCAAABBBCCC";
Assert.True(s1.CompareToDevEx(s1) == 0);
In this example we use a specific configuration
var localSettings = new Settings()
{
CaseOption = CaseOptions.Sensitive,
AccentOption = AccentOptions.Sensitive
};
Assert.False(s1.CompareToDevEx(s2, localSettings) == 0);
Add this using
using DevExtremeToys.Strings;
Now your strings have new features like ReplaceLast, ReplaceFirst
string s1 = "a1abbbcccaaabbbccc";
var r = s1.ReplaceLast("bbb", "ZZZ");
Add this using
using DevExtremeToys.Url;
Now your strings have EncodeURL64 and DecodeURL64 methods
string sourceString = "Dinanzi a me non fuor cose create \r\nse non etterne, e io etterno duro. \r\nLasciate ogne speranza, voi ch’intrate";
var encoded = sourceString.EncodeURL64();
var decoded = encoded.DecodeURL64();
Add this using
using DevExtremeToys.Reflection;
Now all objects have new features like:
- GetPropertyValue
- SetPropertyValue
- GetFieldValue
- SetFieldValue
- GetPropertyAttribute
- GetFiledAttribute
MyClass myClass = new MyClas();
myClass.SetPropertyValue(nameof(MyClas.Name), "My Name");
Add this using
using DevExtremeToys.JSon;
Now all objects have .ToJson() method and strings have .ToObject<>() method
TestClass myClass = new TestClass()
{
Name = "My Name",
Description = "My Description",
Id = 10
};
var json = myClass.ToJSon();
TestClass deserialized = json.ToObject<TestClass>();
Add this using
using DevExtremeToys.Compression;
Now all objects have .Zip() method and byte[] has .Unzip<>() method
MyClass myClass = new MyClass()
{
Name = "My Name",
Description = "My Description",
Id = 10
};
var zip = myClass.Zip();
MyClass unZipped = zip.Unzip<MyClass>();
Add this using
using DevExtremeToys.Serialization;
Now all objects have .Zip() method and byte[] has .Unzip<>() method
MyClass myClass = new MyClass()
{
Name = "My Name",
Description = "My Description",
Id = 10
};
var tmp = myClass.ToUTF8ByteArray();
MyClass deserialized = tmp.FromUF8ByteArray<MyClass>();
Add this using
using DevExtremeToys.Strings;
Now all strings have .AesEncrypt method and .AesDecrypt methods
string key = "12345678901234567890123456789012";
string iv = "1234567890123456";
string plainText = "abcdefghijklmnopqrstuvwxyz1234567890";
string encrypted = plainText.AesEncrypt(key, iv);
string decrypted = encrypted.AesDecrypt(key, iv);
Add this using
using DevExtremeToys.List;
Now all List<> or IEnumerable<> have .Split method
IEnumerable<int> list = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var subLists = list.Split(3);
List<int> list = new List<int>();
//...
var items = list.Split(3);
Add this using
using DevExtremeToys.Visitors;
Now all objects .Visit method
MyClassA a = new MyClassA();
//...
//fill object properties (collection, objects, internals...)
//...
a.Visit((nodeInfo) =>
{
//nodeInfo.CurrentPath
//nodeInfo.CurrentPropertyInfo
//nodeInfo.CurrentInstance
//nodeInfo.ParentInstance
//nodeInfo.ParentNode
//nodeInfo.PropertyName
Debug.WriteLine(nodeInfo.CurrentPath);
});