Pear

public static class Pear
Null-safe extension methods for IPear and Pear<T>.

Methods

Format

#Example
public static string Format(this IPear pear)
Format a pear with support for nullness.
pear (IPear)

Format<T>

#Example
public static string Format<T>(this Pear<T> pear)
Format a pear with support for nullness.
pear (Pear<T>)

HasMeta

#Example
public static bool HasMeta(this IPear pear)
Test whether a pear has meta data in a null-safe way. I.e. if the pear is null, false is returned.
pear (IPear)

MergeMetaData

#Example
public static IPear MergeMetaData(this IPear pear, MetaData meta, MergeBehaviour mergeBehaviour)
Merge the existing meta data with other meta data.
pear (IPear)
meta (MetaData)
mergeBehaviour (MergeBehaviour)

MergeMetaData<T>

#Example
public static Pear<T> MergeMetaData<T>(this Pear<T> pear, MetaData meta, MergeBehaviour mergeBehaviour)
Merge the existing meta data with other meta data.
pear (Pear<T>)
meta (MetaData)
mergeBehaviour (MergeBehaviour)

ToStringSafe

#Example
public static string ToStringSafe(this IPear pear)
Format a pear with support for nullness.
pear (IPear)

ToStringSafe<T>

#Example
public static string ToStringSafe<T>(this Pear<T> pear)
Format a pear with support for nullness.
pear (Pear<T>)

ToType<T, TQ>

#Example
public static Pear<TQ> ToType<T, TQ>(this Pear<T> pear)
Convert this pear to a target type if possible. This method only attempts direct casting from whatever the current type is to T.
pear (Pear<T>)
A pear of the target type, possible a null value if the cast was not successful.

ToType<TQ>

#Example
public static Pear<TQ> ToType<TQ>(this IPear pear)
Convert this pear to a target type if possible. This method only attempts direct casting from whatever the current type is to T.
pear (IPear)
A pear of the target type, possible a null value if the cast was not successful.

TryMeta<T>

#Example
public static bool TryMeta<T>(this IPear pear, MetaName name, out T value)
Gets a specific meta value in a null-safe way. If the pear is null or lacks metadata, false is returned.
pear (IPear)
name (MetaName)
value (out T)

TryMeta

#Example
public static MetaData TryMeta(this IPear pear)
Gets the meta data of a pear in a null-safe way. I.e. if the pear is null, null is returned.
pear (IPear)

WithItem

#Example
public static IPear WithItem(this IPear pear, object item)
Create a new pear with a new item.
pear (IPear)
item (object)

WithItem<T>

#Example
public static Pear<T> WithItem<T>(this Pear<T> pear, T item)
Create a new pear with a new item.
pear (Pear<T>)
item (T)

WithMeta

#Example
public static IPear WithMeta(this IPear pear, MetaData meta)
Replace the meta data of a pear.
pear (IPear)
meta (MetaData)

WithMeta<T>

#Example
public static Pear<T> WithMeta<T>(this Pear<T> pear, MetaData meta)
Replace the meta data of a pear.
pear (Pear<T>)
meta (MetaData)