-
Notifications
You must be signed in to change notification settings - Fork 2
DevFast: Program Declaratively
- Reference it in your project
- Take a string and type
.Tto find possibilities
Sample codes of following PNG snapshots are available as Dot.Net.DevFast.Sample
Many more articles on the library can be found HERE
DevFast (NuGet)
- Hello DevFast
- String.T variants
- .Throw variants
- .ToBase64 variants
- Miscellaneous Methods
- JSON Methods
- Compression Methods
DevFast takes a mile to provide the most declarative way to program your C#.Net solutions.
DevFast stands for "Develop Fast", without compromising the code quality. Library is equipped with extensive documentation and features set of, expressive & simplest to use, methods any programmer requires almost all the time.
Naming convention of these methods make sure that code stays highly readable. In the v1, we cover simple extension methods on string, ValueTypes, stream and more... Let's have a look.
Before we look are those methods, first let's see if we would like to write following program:
"Create a function that accepts a string, parses it as DateTime, if parsing fails returns 12 Jan, 2000 as value"
To write such a simple program, we might need to consider null values, perform unit testing, maintain it throughout the project lifetime and so on... The interesting thing is we need to spend time writing it! It means during that time we CANNOT do something else! Furthermore, such parsing requirements are SELDOM project specific; so if you missed packetized it you need to reinvent the wheel again.
On the other hand, what if you can do all this in one-liner code? With DevFast added as reference, this code is as simple as:
myString.ToOrDefault(new DateTime(2000, 1, 12));
Following picture shows some trivial comparison:

Following are available methods on string:
- .TryTo => string parsing to
bool,int,long,decimal,DateTime,Enum,Typeetc - .ToOrDefault => string parsing to
bool,int,long,decimal,DateTime,Enum,Typeetc with given default value - .To variants => string parsing to 'FileInfo',
DirectoryInfo,bool,int,long,decimal,DateTime,Enum,Typeetc. Throws Exception when parsing fails. - .Trim variants => string
trimspecific methods - .Throw variants => Exception throwing methods when string satisfies certain conditions.
- .ToBase64 / .FromBase64 variants =>
Base64string conversion methods - .Transform variants => String transformation methods (
Base64is a special case)
Below picture shows some sample use cases:

- .ThrowIf / .ThrowIfNot => on bool. throws when true (ThrowIf) or false (ThrowIfNot). Though might look trivial but very powerful. Almost all other Throws fallbacks on it.
- .ThrowIfNull => On any
Twhich isclass(ReferenceType). - .ThrowIfNullOrEmpty => On any
Twhich isICollection(Array,Listetc). - .ThrowOnMiss => On Dictionary / Collections type. When supplied Key / valye is not in it.
- .ThrowIfZero / .ThrowIfNotZero => as the name suggests (
int/long) - .ThrowIfEqual / .ThrowIfNotEqual => Any
Twhich isIEquatable - .ThrowIfLess / .ThrowIfGreater => Any
Twhich isIComparable - .ThrowIfBounded / .ThrowIfNotBounded => Any
Twhich isIComparable
Below picture shows some sample use cases:

- .ToBase64 / .FromBase64 => on
string,byte[],ArraySegment<byte> - .ToBase64Async/ .FromBase64Async => on
string,byte[],ArraySegment<byte>,StringBuilder,Stream
Below picture shows some sample use cases:

- .TransformAsync => on
string,byte[],ArraySegment<byte>,StringBuilder,Streamto perform variousCryptotransformations - .CreateFileInfo => on
DirectoryInfoto createFileInfoobject. - .CreateBytes => on
ArraySegment<byte>to createbyte[]
Below picture shows some sample use cases:

For detailed usage, please see Simply DevFast article series.
- .ToJson/.FromJson => on
string,byte[],ArraySegment<byte>,StringBuilder,Streamto perform JSON serialization/deserialization - .ToJsonArray/.FromJsonAsEnumerable => on
string,byte[],ArraySegment<byte>,StringBuilder,Streamto perform JSON serialization/deserialization based on genericIEnumerable<T> - .ToJsonArrayParallely/.FromJsonArrayParallely => on
string,byte[],ArraySegment<byte>,StringBuilder,Streamto perform JSON serialization/deserialization based on genericBlockingCollection<T>in order to realize parallel producer-consumer pattern.
For detailed usage, please see Simply DevFast article series.
- .CompressAsync => on
string,byte[],ArraySegment<byte>,StringBuilder,Streamto perform Deflate/GZip compression. - .DecompressXXXAsync => on
string,byte[],ArraySegment<byte>,StringBuilder,Streamto perform Deflate/GZip decompression.
More to come in next releases... let us know your requirements, on the way we'll prioritize those. Thanks!