Table of Contents

Class ObjectExtensions

Namespace
LfrlAnvil.Functional.Extensions
Assembly
LfrlAnvil.Functional.dll

Contains various generic object extensions.

public static class ObjectExtensions
Inheritance
ObjectExtensions
Inherited Members

Methods

Mutate<T>(T, T)

Creates a new Mutation<T> instance.

[Pure]
public static Mutation<T> Mutate<T>(this T source, T newValue)

Parameters

source T

Source object.

newValue T

New value object.

Returns

Mutation<T>

New Mutation<T> instance with OldValue equal to the provided source and Value equal to the provided newValue.

Type Parameters

T

Object type.

ToEither<T>(T)

Creates a new PartialEither<T1> instance that can be used to create an Either<T1, T2> instance.

[Pure]
public static PartialEither<T> ToEither<T>(this T source)

Parameters

source T

Source object.

Returns

PartialEither<T>

New PartialEither<T1> instance.

Type Parameters

T

Object type.

ToErratic(Exception)

Creates a new Erratic<T> instance with Nil value type.

[Pure]
public static Erratic<Nil> ToErratic(this Exception source)

Parameters

source Exception

Source exception.

Returns

Erratic<Nil>

New Erratic<T> instance with an error equal to the provided source.

ToErratic<T>(Exception)

Creates a new Erratic<T> instance.

[Pure]
public static Erratic<T> ToErratic<T>(this Exception source)

Parameters

source Exception

Source exception.

Returns

Erratic<T>

New Erratic<T> instance with an error equal to the provided source.

Type Parameters

T

Object type.

ToErratic<T>(T)

Creates a new Erratic<T> instance.

[Pure]
public static Erratic<T> ToErratic<T>(this T source)

Parameters

source T

Source object.

Returns

Erratic<T>

New Erratic<T> instance without an error, equivalent to the provided source.

Type Parameters

T

Object type.

ToMaybe<T>(T?)

Creates a new Maybe<T> instance.

[Pure]
public static Maybe<T> ToMaybe<T>(this T? source) where T : notnull

Parameters

source T

Source object.

Returns

Maybe<T>

New Maybe<T> instance equivalent to source or None when source is null.

Type Parameters

T

Object type.

ToMutation<T>(T)

Creates a new Mutation<T> instance.

[Pure]
public static Mutation<T> ToMutation<T>(this T source)

Parameters

source T

Source object.

Returns

Mutation<T>

New Mutation<T> instance with OldValue and Value equal to the provided source.

Type Parameters

T

Object type.

TypeCast<T>(T)

Creates a new PartialTypeCast<TSource> instance that can be used to create a TypeCast<TSource, TDestination> instance.

[Pure]
public static PartialTypeCast<T> TypeCast<T>(this T source)

Parameters

source T

Source object.

Returns

PartialTypeCast<T>

New PartialTypeCast<TSource> instance.

Type Parameters

T

Source object type.