.NET Portable TypeCast  3.1.0.4
A, easy-to-use tested, generic, portable, runtime-extensible, arbitrary type converter library
Core.TypeCast.Base.ConvertContext< TIn, TOut > Class Template Reference

Wraps the model value for the converter in a conversion-context More...

+ Collaboration diagram for Core.TypeCast.Base.ConvertContext< TIn, TOut >:

Public Member Functions

 ConvertContext (object modelValue)
 Creates a new instance of ConvertContext<TIn, TOut> More...
 
 ConvertContext (object modelValue)
 Creates a new instance of ConvertContext More...
 
override string ToString ()
 A string representation of the current instance. More...
 

Properties

Type From [get, set]
 The source Type from which to convert to the Type of To More...
 
Type To [get, set]
 The target Type to which to convert the Type of From to More...
 
Type Argument [get, set]
 The argument Type of the model as used in ConvertTo<TIn, TOut>(TIn, object) More...
 
object Value [get]
 An optional default value for the given type, which must not be null, otherwise an ConverterException may be thrown. More...
 
Converter Converter [get, set]
 The Converter instance for the corresponding types TIn and TOut More...
 
string Caller [get, set]
 The caller method name which is automatically filled-in via the CallerMemberNameAttribute, and used for context information. More...
 
bool Nullable [get, set]
 Whether the original From Type was nullable More...
 
bool ThrowExceptions [get, set]
 Whether to throw exceptions. false by default such that no ConverterException is thrown More...
 
object Method [get, set]
 The conversion method that was invoked More...
 
MethodInfo MethodInfo [get, set]
 The MethodInfo instance of the Method More...
 

Detailed Description

Wraps the model value for the converter in a conversion-context

Wraps the model value for the converter in a conversion-context.

On rare occasions, a contextual data structure may be required which provides meta-data about the converting-process.

Definition at line 26 of file ConvertContext.cs.

Constructor & Destructor Documentation

Core.TypeCast.Base.ConvertContext< TIn, TOut >.ConvertContext ( object  modelValue)

Creates a new instance of ConvertContext<TIn, TOut>

Parameters
modelValueThe model value that was passed as second parameter to the conversion function

Definition at line 32 of file ConvertContext.cs.

33  : base(modelValue)
34  {
35  this.From = typeof(TIn);
36  this.To = typeof(TOut);
37  }
Type To
The target Type to which to convert the Type of From to
Type From
The source Type from which to convert to the Type of To
Core.TypeCast.Base.ConvertContext< TIn, TOut >.ConvertContext ( object  modelValue)

Creates a new instance of ConvertContext

Parameters
modelValueThe model value that was passed as second parameter to the conversion function

Definition at line 50 of file ConvertContext.cs.

51  {
52  this.Value = modelValue;
53  }
object Value
An optional default value for the given type, which must not be null, otherwise an ConverterException...

Member Function Documentation

override string Core.TypeCast.Base.ConvertContext< TIn, TOut >.ToString ( )

A string representation of the current instance.

Returns
Returns a string representation of the fields in ConvertContext.

Definition at line 111 of file ConvertContext.cs.

112  {
113  var ret = new StringBuilder("{" + Environment.NewLine);
114  foreach(var property in this.GetType().GetRuntimeProperties())
115  {
116  ret.Append($"\t {property.Name} {{{property.PropertyType}}}: '{property.GetValue(this)}'" + Environment.NewLine);
117  }
118  return ret.ToString() + "}";
119  }

Property Documentation

Type Core.TypeCast.Base.ConvertContext< TIn, TOut >.Argument
getset

The argument Type of the model as used in ConvertTo<TIn, TOut>(TIn, object)

Definition at line 68 of file ConvertContext.cs.

string Core.TypeCast.Base.ConvertContext< TIn, TOut >.Caller
getset

The caller method name which is automatically filled-in via the CallerMemberNameAttribute, and used for context information.

Definition at line 83 of file ConvertContext.cs.

The Converter instance for the corresponding types TIn and TOut

Definition at line 78 of file ConvertContext.cs.

Type Core.TypeCast.Base.ConvertContext< TIn, TOut >.From
getset

The source Type from which to convert to the Type of To

Definition at line 58 of file ConvertContext.cs.

object Core.TypeCast.Base.ConvertContext< TIn, TOut >.Method
getset

The conversion method that was invoked

Definition at line 98 of file ConvertContext.cs.

MethodInfo Core.TypeCast.Base.ConvertContext< TIn, TOut >.MethodInfo
getset

The MethodInfo instance of the Method

Definition at line 103 of file ConvertContext.cs.

bool Core.TypeCast.Base.ConvertContext< TIn, TOut >.Nullable
getset

Whether the original From Type was nullable

Definition at line 88 of file ConvertContext.cs.

bool Core.TypeCast.Base.ConvertContext< TIn, TOut >.ThrowExceptions
getset

Whether to throw exceptions. false by default such that no ConverterException is thrown

Definition at line 93 of file ConvertContext.cs.

Type Core.TypeCast.Base.ConvertContext< TIn, TOut >.To
getset

The target Type to which to convert the Type of From to

Definition at line 63 of file ConvertContext.cs.

object Core.TypeCast.Base.ConvertContext< TIn, TOut >.Value
get

An optional default value for the given type, which must not be null, otherwise an ConverterException may be thrown.

Definition at line 73 of file ConvertContext.cs.


The documentation for this class was generated from the following file: