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
Implements
System.IEquatable<Formatter>
Namespace: Cesil
Assembly: Cesil.dll
Syntax
public sealed class Formatter : Object, IEquatable<Formatter>, ICreatesCacheableDelegate<Formatter.DynamicFormatterDelegate>, IElseSupporting<Formatter>

Methods

AllowNullValues()

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
Type Description
Formatter

Else(Formatter)

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
Type Description
Formatter

Equals(Formatter)

Compares for equality to another Formatter.

Declaration
public bool Equals(Formatter formatter)
Parameters
Type Name Description
Formatter formatter
Returns
Type Description
System.Boolean

Equals(Object)

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

ForbidNullValues()

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
Type Description
Formatter

ForDelegate<TValue>(FormatterDelegate<TValue>)

Create a Formatter from the given delegate.

Declaration
public static Formatter ForDelegate<TValue>(FormatterDelegate<TValue> del)
Parameters
Type Name Description
FormatterDelegate<TValue> del
Returns
Type Description
Formatter
Type Parameters
Name Description
TValue

ForMethod(MethodInfo)

Create a formatter from a method.

Formatter needs to:

  • be static
  • take
  • 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
Type Description
Formatter

GetDefault(TypeInfo)

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
Type Description
Formatter

GetHashCode()

Returns a hash code for this Getter.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

ToString()

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

Equality(Formatter, Formatter)

Compare two Formatters for equality

Declaration
public static bool operator ==(Formatter a, Formatter b)
Parameters
Type Name Description
Formatter a
Formatter b
Returns
Type Description
System.Boolean

Explicit(Delegate to Formatter)

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
Type Description
Formatter

Explicit(MethodInfo to Formatter)

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
Type Description
Formatter

Inequality(Formatter, Formatter)

Compare two Formatters for inequality

Declaration
public static bool operator !=(Formatter a, Formatter b)
Parameters
Type Name Description
Formatter a
Formatter b
Returns
Type Description
System.Boolean

Implements

System.IEquatable<>
In This Article
Back to top Generated by DocFX