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>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Cesil
Assembly: Cesil.dll
Syntax
public sealed class Formatter : IEquatable<Formatter>, ICreatesCacheableDelegate<Formatter.DynamicFormatterDelegate>, IElseSupporting<Formatter>

Methods

| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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
Overrides
System.Object.Equals(System.Object)
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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
MethodInfo method
Returns
Type Description
Formatter
| Improve this Doc View Source

GetDefault(TypeInfo)

Returns the default formatter for the given type, if one exists.

Declaration
public static Formatter GetDefault(TypeInfo forType)
Parameters
Type Name Description
TypeInfo forType
Returns
Type Description
Formatter
| Improve this Doc View Source

GetHashCode()

Returns a hash code for this Getter.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.Object.GetHashCode()
| Improve this Doc View Source

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
Overrides
System.Object.ToString()

Operators

| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

Explicit(Nullable<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.Nullable<MethodInfo> method
Returns
Type Description
Formatter
| Improve this Doc View Source

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<T>
  • Improve this Doc
  • View Source
Back to top Generated by DocFX