.NET Portable TypeCast  3.1.0.4
A, easy-to-use tested, generic, portable, runtime-extensible, arbitrary type converter library
Core.TypeCast.ConverterCollection.AddBuilder< TBase > Class Template Reference

Allows to perform a deferred adding operation of multiple adds using a common Base-Class Type argument, common ConverterCollectionSettings as well as a mutual CancellationToken for the added group of converters. The operation is applied upon invoking End, and can be explicitly canceled by invoking Cancel More...

+ Collaboration diagram for Core.TypeCast.ConverterCollection.AddBuilder< TBase >:

Public Member Functions

 AddBuilder (ConverterCollection converterCollection, ConverterCollectionSettings settings=null, CancellationToken cancellationToken=default(CancellationToken))
 Creates a new instance of AddBuilder<TBase> for grouped-adding of converter-functions with default arguments defined in the constructor More...
 
 AddBuilder (ConverterCollection converterCollection, ConverterCollectionSettings settings, ref CancellationToken cancellationToken)
 Creates a new instance of AddBuilder<TBase> for grouped-adding of converter-functions with mutual arguments defined in the constructor More...
 
AddBuilder< TBase > Add< TIn, TOut > (Func< TIn, TOut > converterAction)
 Creates and adds a Converter instance to the collection of ConverterCollection.Items using a Delegate More...
 
AddBuilder< TBase > Add< TIn, TOut > (Func< TIn, TOut, TOut > converterActionDefault)
 Creates and adds a Converter instance to the collection of ConverterCollection.Items using a Delegate More...
 
IConverterCollection Cancel ()
 Dummy function to explicitly end the current chained builder operation without applying any deferred calls and clear any resources More...
 
IConverterCollection End ()
 End the deferred adding operation by invocation the deferred list of actions More...
 

Detailed Description

Allows to perform a deferred adding operation of multiple adds using a common Base-Class Type argument, common ConverterCollectionSettings as well as a mutual CancellationToken for the added group of converters. The operation is applied upon invoking End, and can be explicitly canceled by invoking Cancel

Template Parameters
TBaseThe declaring, attributed Type of the converter-functions to add as a group.
Type Constraints
TBase :class 

Definition at line 45 of file ConverterCollection.AddBuilder.cs.

Constructor & Destructor Documentation

Core.TypeCast.ConverterCollection.AddBuilder< TBase >.AddBuilder ( ConverterCollection  converterCollection,
ConverterCollectionSettings  settings = null,
CancellationToken  cancellationToken = default(CancellationToken) 
)

Creates a new instance of AddBuilder<TBase> for grouped-adding of converter-functions with default arguments defined in the constructor

Parameters
converterCollectionA reference to the ConverterCollection instance
settingsA reference to an optional ConverterCollectionSettings instance to be applied only for the group of converter-functions
cancellationTokenAn optional value-instance to the mutual CancellationToken

Definition at line 75 of file ConverterCollection.AddBuilder.cs.

78  : this(converterCollection: converterCollection, settings: settings, cancellationToken: ref cancellationToken)
79  {
80 
81  }
Core.TypeCast.ConverterCollection.AddBuilder< TBase >.AddBuilder ( ConverterCollection  converterCollection,
ConverterCollectionSettings  settings,
ref CancellationToken  cancellationToken 
)

Creates a new instance of AddBuilder<TBase> for grouped-adding of converter-functions with mutual arguments defined in the constructor

Parameters
converterCollectionA reference to the ConverterCollection instance
settingsA reference to an optional ConverterCollectionSettings instance to be applied only for the group of converter-functions
cancellationTokenAn optional reference to the mutual CancellationToken

Definition at line 91 of file ConverterCollection.AddBuilder.cs.

94  {
95  this.baseClass = converterCollection;
96  this.settings = settings;
97  this.cancellationToken = cancellationToken;
98  this.actions = new List<Action>();
99  }

Member Function Documentation

AddBuilder<TBase> Core.TypeCast.ConverterCollection.AddBuilder< TBase >.Add< TIn, TOut > ( Func< TIn, TOut >  converterAction)

Creates and adds a Converter instance to the collection of ConverterCollection.Items using a Delegate

Template Parameters
TInThe Source- / From- Typefrom which to Converter<TIn,TOut>.Convert(object,object)
TOutThe Target / To- Type to which to Converter<TIn,TOut>.Convert(object,object)
Parameters
converterActionA function delegate Func<TIn, TOut> to use as the Converter.Function
cancellationTokenOptional token to propagate notification that operations should be canceled. From System.Threading.Tasks.
Returns
Returns a (nested-class) instance of AddBuilder<TBase> with strongly-typed generic methods for deferred grouped-adding.
Exceptions
ConverterExceptionThrows a ConverterCause.ConverterCollectionAddFailed with a wrapped Exception.InnerException if an internal error occurred

Definition at line 111 of file ConverterCollection.AddBuilder.cs.

112  {
113  actions.Add(() => this.baseClass.Add<TIn, TOut, TBase>(converterAction, this.cancellationToken));
114  return this;
115  }
IConverterCollection Add(object converterDelegate, Type baseType=null, CancellationToken cancellationToken=default(CancellationToken))
Initializes a new instance of the ConverterCollection class with default-parameters.
AddBuilder<TBase> Core.TypeCast.ConverterCollection.AddBuilder< TBase >.Add< TIn, TOut > ( Func< TIn, TOut, TOut >  converterActionDefault)

Creates and adds a Converter instance to the collection of ConverterCollection.Items using a Delegate

Template Parameters
TInThe Source- / From- Typefrom which to Converter<TIn,TOut>.Convert(object,object)
TOutThe Target / To- Type to which to Converter<TIn,TOut>.Convert(object,object)
Parameters
converterActionDefaultA function delegate Func<TIn, TOut, TOut> to use as the Converter.Function
cancellationTokenOptional token to propagate notification that operations should be canceled. From System.Threading.Tasks.
Returns
Returns a (nested-class) instance of AddBuilder<TBase> with strongly-typed generic methods for deferred grouped-adding.
Exceptions
ConverterExceptionThrows a ConverterCause.ConverterCollectionAddFailed with a wrapped Exception.InnerException if an internal error occurred

Definition at line 127 of file ConverterCollection.AddBuilder.cs.

128  {
129  actions.Add(() => this.baseClass.Add<TIn, TOut, TBase>(converterActionDefault, this.cancellationToken));
130  return this;
131  }
IConverterCollection Add(object converterDelegate, Type baseType=null, CancellationToken cancellationToken=default(CancellationToken))
Initializes a new instance of the ConverterCollection class with default-parameters.

Dummy function to explicitly end the current chained builder operation without applying any deferred calls and clear any resources

Returns
Returns a IConverterCollection for safe, constricted function chaining.

Definition at line 137 of file ConverterCollection.AddBuilder.cs.

138  {
139  return baseClass;
140  }

End the deferred adding operation by invocation the deferred list of actions

Returns
Returns a IConverterCollection for safe, constricted function chaining.

Definition at line 146 of file ConverterCollection.AddBuilder.cs.

147  {
148  // temporarily switch out settings for any passed builder-settings argument
149  if(this.settings != null)
150  {
151  var tmp = this.baseClass.Settings;
152  this.baseClass.Settings = this.settings;
153  actions.Add(() => this.baseClass.Settings = tmp);
154  }
155  actions.Count(a => { a.Invoke(); return true; });
156  return baseClass;
157  }
ConverterCollectionSettings Settings
The settings for the ConverterCollection.

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