TypeUnification

References
public sealed class TypeUnification
Create a collection of a single type from a stream of mixed types. This is useful for example when operating on collections which contain integer, doubles and complex numbers, and you wish to convert everything to the most complex type present.

Constructors

TypeUnification

#
public TypeUnification(int capacity = 4)
Create a new type unification.
capacity (int = 4)Capacity for final unit list.

Properties

Count

#
public int Count { get; }
Gets the number of values stored.

UnitType

#
public Type UnitType { get; }
Gets the type describing the current unification.

Values

#
public IEnumerable<object> Values { get; }
Enumerate over the unitised values.

Indexers

this[]

#
public object this[int index] { get; }
Access the nth item.
index (int)

Methods

AddConversion<T1, T2>

#
public void AddConversion<T1, T2>(Func<T1, T2> convert)
Add a conversion from one type to another.
convert (Func<T1, T2>)Conversion method.

AddValue

#
public bool AddValue(object value)
Add a value to this unification.
value (object)Value to add.
True if value was added.

FindConversion

#
public Func<object, object> FindConversion(Type source, Type target)
Find the conversion method between two types.
source (Type)
target (Type)
The conversion method or null.

ToArray<T>

#
public T[] ToArray<T>(bool skipNulls)
Convert this collection to an array of a specific type.
skipNulls (bool)If true nulls will not be included in the array.

TowardsComplex

#
public static TypeUnification TowardsComplex()
Create a unification from int→BigInteger→double→Complex.

TowardsDouble

#
public static TypeUnification TowardsDouble()
Create a unification from int→BigInteger→double.

TowardsVector

#
public static TypeUnification TowardsVector()
Create a unification from int→BigInteger→double→Complex→Point3d→Vector3d.