This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

ExtensionMethods

What are extension methods?

Extensions methods can be applied to a specific data type. They are methods which can be called on this specific type.

For Example:

string blub = "Hello World";

if(blub.IsNotNullOrEmpty)
{
    Console.WriteLine("The method returned true");
}

1 - Text

In this class are stored all ExtensionMethods which deal with text.


Methods

1. ToCamelCase

This method converts a string into an camel-case-string. Its purpose is to lower the first character of the string. This is needed for example if you are exchanging data with an other programm written in an language that prefers camel-case.

2. SplitToString

SplitToString combines the strings in an array or a list together to a single string. A seperator string must be provided. This seperator will be attached between each of the to be combined strings.

2 - Mapping

Here there are all methods which deal with mapping


Methods

1. MapSimple

This method maps an object to another object. It uses the AutoMapper nuget.

var result = model.MapSimple<MappedExampleModel, ExampleModel>();

3 - Collections

In this class are stored all ExtensionMethods based on collections.


Methods

1. IsNullOrEmpty

Checks if a IEnumerable is null or empty. It returns true if the IEnumerable is null or empty.

2. IsNotNullOrEmpty

Checks if a IEnumerable is null or empty. It returns false if the IEnumerable is null or empty.