Class Formatter
Represents code used to format a value into a IBufferWriter(char).
Wraps either a static method or a delegate.
Inheritance
System.Object
Formatter
Namespace: Cesil
Assembly: Cesil.dll
public sealed class Formatter : Object, IEquatable<Formatter>, ICreatesCacheableDelegate<Formatter.DynamicFormatterDelegate>, IElseSupporting<Formatter>
Methods
Returns a Formatter that differs from this by explicitly allowing
null values to be passed to it.
If the backing method, or delegate does not expect null values, this may lead
to errors at runtime.
Declaration
public Formatter AllowNullValues()
Returns
Create a new Formatter that will try this formatter, but if it returns false
it will then try the given fallback Formatter.
Declaration
public Formatter Else(Formatter fallbackFormatter)
Parameters
| Type |
Name |
Description |
| Formatter |
fallbackFormatter |
|
Returns
Compares for equality to another Formatter.
Declaration
public bool Equals(Formatter formatter)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
Compares for equality to another Formatter.
Declaration
public override bool Equals(object obj)
Parameters
| Type |
Name |
Description |
| System.Object |
obj |
|
Returns
| Type |
Description |
| System.Boolean |
|
Returns a new Formatter that differs from this by explicitly forbidding
null values to be passed to it.
If the .NET runtime cannot guarantee the absense of null values, null checks
will be injected.
Declaration
public Formatter ForbidNullValues()
Returns
Create a Formatter from the given delegate.
Declaration
public static Formatter ForDelegate<TValue>(FormatterDelegate<TValue> del)
Parameters
Returns
Type Parameters
Create a formatter from a method.
Formatter needs to:
- the type to be formatter (or one it is assignable to)
- an in (or by ref) WriteContext
-an IBufferWriter(char)
- return bool (false indicates value could not be formatted)
Declaration
public static Formatter ForMethod(MethodInfo method)
Parameters
| Type |
Name |
Description |
| System.Reflection.MethodInfo |
method |
|
Returns
Returns the default formatter for the given type, if one exists.
Declaration
public static Formatter GetDefault(TypeInfo forType)
Parameters
| Type |
Name |
Description |
| System.Reflection.TypeInfo |
forType |
|
Returns
Returns a hash code for this Getter.
Declaration
public override int GetHashCode()
Returns
| Type |
Description |
| System.Int32 |
|
Describes this Formatter.
This is provided for debugging purposes, and the format is not guaranteed to be stable between releases.
Declaration
public override string ToString()
Returns
| Type |
Description |
| System.String |
|
Operators
Compare two Formatters for equality
Declaration
public static bool operator ==(Formatter a, Formatter b)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
Convenience operator, equivalent to calling Formatter.ForDelegate if non-null.
Returns null if del is null.
Declaration
public static explicit operator Formatter(Delegate del)
Parameters
| Type |
Name |
Description |
| System.Delegate |
del |
|
Returns
Convenience operator, equivalent to calling Formatter.ForMethod if non-null.
Returns null if method is null.
Declaration
public static explicit operator Formatter(MethodInfo method)
Parameters
| Type |
Name |
Description |
| System.Reflection.MethodInfo |
method |
|
Returns
Compare two Formatters for inequality
Declaration
public static bool operator !=(Formatter a, Formatter b)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
Implements
System.IEquatable<>