Show / Hide Table of Contents

Namespace Existential

Classes

ArgumentTypeException

An exception that indicates the use of an unexpected type.

Disposable

Contains a method that supports the correct usage of System.IDisposable objects.

GetGenericEnumerable

A static class for creating generic IEnumerables.

GetGenericEnumerable<T>

A static class for creating generic IEnumerables.

HashCodeHelper

A class containing methods to help with hash codes.

Maybe

Class Maybe. Provides additional support for the struct, Maybe<T>.

MaybeExtensions

Extensions for IEnumerable<T>, and for some specific types of Maybe<T>, to support the wider use of Maybe<T>:

  • IEnumerable<T>
  • Maybe<string>
  • Maybe<Guid>
  • Maybe<T[]>
  • Maybe<List<T>>
These methods make it easier to work with Maybe<T> in a variety of contexts.

PredicateExtensions

Extensions to System.Predicate<T>.

ThisMethod

A utility class for caller methods.

TypeExtensions

Contains Type extension methods for better support of generics.

Validate

The static Validate class contains a collection of methods for validating arguments; mainly to ensure they're not null or empty. The name of the value being validated must be passed in to ensure that it can be included in any exception message.

There are several practical advantages of these methods.

  • The name of the parameter that failed validation will be included in the exception message.
  • They're expressive, but succinct - they'll save you several lines of code every time you need a check.
  • If the value validates, the method returns it - so pass-through validation is possible in places like chained constructor calls, where you just can't write several lines of code to do this.

Since the nameof operator was introduced in C# 6.0, it's been possible for callers of the methods in this class to use nameof to retrieve the value's name in a way that will not be broken by refactoring. When using older versions of C#, it was necessary to pass an explicit string value.

Structs

Maybe<T>

A container representing a value that may or may not exist. Additional support is provided by the types Maybe and MaybeExtensions.

In This Article
Back to top Copyright © 2021 Dr. Gavin T.D. Greig.