.NET Portable TypeCast  3.1.0.4
A, easy-to-use tested, generic, portable, runtime-extensible, arbitrary type converter library
ConverterCollection.cs
Go to the documentation of this file.
1 // <copyright file=mitlicense.md url=http://lsauer.mit-license.org/ >
2 // Lo Sauer, 2013-2016
3 // </copyright>
4 // <summary> A tested, generic, portable, runtime-extensible type converter library </summary
5 // <language> C# > 6.0 </language>
6 // <version> 3.1.0.2 </version>
7 // <author> Lorenz Lo Sauer; people credited in the sources </author>
8 // <project> https://github.com/lsauer/dotnet-portable-type-cast </project>
9 namespace Core.TypeCast
10 {
11  using System;
12  using System.Collections;
13  using System.Collections.Concurrent;
14  using System.Collections.Generic;
15  using System.Globalization;
16  using System.Linq;
17  using System.Linq.Expressions;
18  using System.Reflection;
19  using System.Runtime.CompilerServices;
20  using System.Runtime.InteropServices;
21  using System.Threading;
22 
23  using Core.Extensions;
24  using Core.Singleton;
25  using Core.TypeCast.Base;
26 
27 
37  [Singleton(disposable: true, createInternal: true, initByAttribute: true)]
38  [System.Runtime.InteropServices.ComVisible(false)]
39  public partial class ConverterCollection : Singleton<ConverterCollection>, IConverterCollection, IDisposable, IEnumerable<Converter>, IQueryable<Converter>
40  {
44  public ConverterCollectionSettings Settings { get; set; }
45 
50  private readonly Dictionary<string, List<Type>> loadOnDemandConverters;
51 
54  private int count;
55 
62  : this(application: null, numberFormatDefault: null, converterClasses: null)
63  {
64  }
65 
72  public ConverterCollection(Type application)
73  : this(application: application, numberFormatDefault: null, converterClasses: null)
74  {
75  }
76 
85  public ConverterCollection(Type application, Type converterClass, NumberFormatInfo numberFormatDefault = null)
86  : this(application: application, numberFormatDefault: numberFormatDefault, converterClasses: converterClass)
87  {
88  }
89 
97  public ConverterCollection(Assembly assembly, NumberFormatInfo numberFormatDefault = null)
98  : this(application: null, numberFormatDefault: numberFormatDefault, converterClasses: null)
99  {
100  this.Initialize(assembly);
101  }
102 
108  public ConverterCollection(Type application = null, params Type[] converterClasses)
109  : this(application: application, numberFormatDefault: null, converterClasses: converterClasses)
110  {
111  }
112 
133  public ConverterCollection(Type application = null, NumberFormatInfo numberFormatDefault = null, params Type[] converterClasses)
134  {
135  this.Settings = new ConverterCollectionSettings();
136  this.loadOnDemandConverters = new Dictionary<string, List<Type>>();
137 
138  this.Factory = new ConverterFactory();
139  this.FactoryBaseClass = new BaseClassFactoryRT();
140 
141  this.AssemblyInitialized = new ConcurrentDictionary<Assembly, bool>();
142  this.ConverterClassInitialized = new ConcurrentDictionary<TypeInfo, bool>();
143  this.ConstructorAddedClasses = new List<Type>();
144  this.Items = new BlockingCollection<Converter>(boundedCapacity: this.Settings.BoundedCapacity);
145 
146  if(application != null)
147  {
148  ApplicationNameSpace = application.Namespace;
149  this.Initialize(ApplicationNameSpace);
150  }
151 
152  if(numberFormatDefault as NumberFormatInfo != null)
153  {
154  this.Settings.NumberFormat = numberFormatDefault;
155  }
156 
157  if(converterClasses != null)
158  {
159  foreach(var converterClass in converterClasses)
160  {
161  if(converterClass != null && converterClass.GetTypeInfo().IsClass == true)
162  {
163  ConstructorAddedClasses.Add(converterClass);
164 
165  this.AddAllConvertersByAttribute(converterClass.GetTypeInfo());
166  }
167  }
168  }
169 
170  // Load any declared converters from the own assembly
171  this.Initialize(this.GetType().GetTypeInfo()?.Assembly.DefinedTypes);
172  }
173 
177  public ConverterFactory Factory { get; }
178 
183  public BaseClassFactoryRT FactoryBaseClass { get; }
184 
188  public string ApplicationNameSpace { get; set; }
189 
193  public List<Type> ConstructorAddedClasses { get; }
194 
198  public ConcurrentDictionary<Assembly, bool> AssemblyInitialized { get; }
199 
203  public ConcurrentDictionary<TypeInfo, bool> ConverterClassInitialized { get; }
204 
219  public int Count
220  {
221  get
222  {
223  return this.Items.Count;
224  }
225 
226  private set
227  {
228  if(value != this.count)
229  {
230  OnPropertyChanged();
231  this.count = value;
232  }
233  }
234  }
235 
240  public BlockingCollection<Converter> Items { get; }
241 
246  public bool IsAddingCompleted
247  {
248  get
249  {
250  return this.Items.IsAddingCompleted;
251  }
252  set
253  {
254  if(value == true)
255  {
256  this.Items.CompleteAdding();
257  }
258 
259  }
260  }
261 
262  #region Implementation of IQueryable<Converter>
263 
268  public Type ElementType
269  {
270  get
271  {
272  return this.Items.AsQueryable().ElementType;
273  }
274  }
275 
280  public Expression Expression
281  {
282  get
283  {
284  return this.Items.AsQueryable().Expression;
285  }
286  }
287 
292  public IQueryProvider Provider
293  {
294  get
295  {
296  return this.Items.AsQueryable().Provider;
297  }
298  }
299 
300  #endregion
301 
307  public Converter this[int index]
308  {
309  get
310  {
311  return this.Items?.Skip(index)?.FirstOrDefault();
312  }
313  }
314 
321  public Converter this[Type typeFrom, Type typeTo]
322  {
323  get
324  {
325  return this.Get(typeFrom.GetTypeInfo(), typeTo.GetTypeInfo());
326  }
327  }
328 
335  public Converter this[TypeInfo typeFrom, TypeInfo typeTo]
336  {
337  get
338  {
339  return this.Get(typeFrom, typeTo);
340  }
341  }
342 
343 
349  public IEnumerable<Converter> this[TypeInfo typeFrom]
350  {
351  get
352  {
353  return this.WithFrom(typeFrom);
354  }
355  }
356 
366  public AddBuilder<TBase> AddStart<TBase>(ConverterCollectionSettings settings = null,
367  CancellationToken cancellationToken = default(CancellationToken)) where TBase : class
368  {
369  return new AddBuilder<TBase>(this, settings: settings, cancellationToken: ref cancellationToken);
370  }
371 
381  public AddBuilder<TBase> AddStart<TBase>(ConverterCollectionSettings settings,
382  ref CancellationToken cancellationToken) where TBase : class
383  {
384  return new AddBuilder<TBase>(this, settings: settings, cancellationToken: ref cancellationToken);
385  }
386 
398  public IConverterCollection Add<TIn, TOut>(
399  Func<TIn, TOut> converterAction,
400  Type baseType = null,
401  CancellationToken cancellationToken = default(CancellationToken))
402  {
403  var converter = Factory.Create<TIn, TOut>(converterAction);
404  return this.Add(converter: converter, baseType: baseType, cancellationToken: cancellationToken);
405  }
406 
407 
421  public IConverterCollection Add<TIn, TOut>(
422  Func<TIn, TOut> converterActionForward,
423  Func<TOut, TIn> converterActionBackward,
424  Type baseType = null,
425  CancellationToken cancellationToken = default(CancellationToken))
426  {
427  this.Add(converterAction: converterActionForward, baseType: baseType, cancellationToken: cancellationToken);
428  return this.Add(converterAction: converterActionBackward, baseType: baseType, cancellationToken: cancellationToken);
429  }
430 
442  public IConverterCollection Add<TIn, TOut, TBase>(Func<TIn, TOut> converterAction, CancellationToken cancellationToken = default(CancellationToken))
443  where TBase : class
444  {
445  var converter = Factory.Create<TIn, TOut>(converterAction);
446  return this.Add(converter: converter, baseType: typeof(TBase), cancellationToken: cancellationToken);
447  }
448 
459  public IConverterCollection Add<TIn, TOut, TBase>(
460  Func<TIn, TOut, TOut> converterActionDefault,
461  CancellationToken cancellationToken = default(CancellationToken)) where TBase : class
462  {
463  var converter = Factory.Create<TIn, TOut>(converterActionDefault);
464  return this.Add(converter: converter, baseType: typeof(TBase), cancellationToken: cancellationToken);
465  }
466 
479  public IConverterCollection Add<TIn, TArg, TOut, TBase>(
480  Func<TIn, TArg, TOut> converterActionAny,
481  CancellationToken cancellationToken = default(CancellationToken))
482  {
483  if(typeof(TOut) == typeof(TArg))
484  {
485  var converter = Factory.Create<TIn, TOut>((Func<TIn, TOut, TOut>)(object)converterActionAny);
486  return this.Add(converter: converter, baseType: typeof(TBase), cancellationToken: cancellationToken);
487  }
488  return this.Add(converterDelegate: converterActionAny, baseType: typeof(TBase), cancellationToken: cancellationToken);
489  }
490 
503  public IConverterCollection Add<TIn, TArg, TOut>(
504  Func<TIn, TArg, TOut> converterActionAny,
505  Type baseType = null,
506  CancellationToken cancellationToken = default(CancellationToken))
507  {
508  if(typeof(TOut) == typeof(TArg))
509  {
510  var converter = Factory.Create<TIn, TOut>((Func<TIn, TOut, TOut>)(object)converterActionAny);
511  return this.Add(converter: converter, baseType: baseType, cancellationToken: cancellationToken);
512  }
513  return this.Add(converterDelegate: converterActionAny, baseType: baseType, cancellationToken: cancellationToken);
514  }
515 
516 
525  public IConverterCollection Add<TBase>(object converterDelegate, CancellationToken cancellationToken = default(CancellationToken)) where TBase : class
526  {
527  return this.Add(converterDelegate: converterDelegate, baseType: typeof(TBase), cancellationToken: cancellationToken);
528  }
529 
551  public IConverterCollection Add(object converterDelegate, Type baseType = null, CancellationToken cancellationToken = default(CancellationToken))
552  {
553  if(converterDelegate == null)
554  {
555  throw new ConverterCollectionException(ConverterCollectionCause.ConverterArgumentNull, $"{nameof(converterDelegate)} must not be null and of Type Delegate");
556  }
557  if((converterDelegate is Delegate) == false)
558  {
559  throw new ConverterCollectionException(ConverterCollectionCause.ConverterArgumentWrongType, $"{nameof(converterDelegate)} must be a `Delegate` Type");
560  }
561 
562  if(baseType == null)
563  {
564  baseType = ((Delegate)converterDelegate).Target.GetType().DeclaringType;
565  }
566 
567  var methodInfo = ((Delegate)converterDelegate).GetMethodInfo(); //type.GetDeclaredMethod("Invoke");
568  return this.Add(methodInfo: methodInfo, converterDelegate: converterDelegate, baseType: baseType, cancellationToken: cancellationToken);
569  }
570 
581  public IConverterCollection Add(MethodInfo methodInfo, object converterDelegate = null, Type baseType = null, object baseInstance = null,
582  CancellationToken cancellationToken = default(CancellationToken))
583  {
584 
585  var converter = this.Factory.Create(methodInfo, converterDelegate);
586 
587  if(converter != null)
588  {
589  converter.Base = baseInstance;
590  return this.Add(converter: converter, baseType: baseType, cancellationToken: cancellationToken);
591  }
592  else
593  {
594  throw new ConverterException(ConverterCause.ConverterCollectionAddFailed);
595  }
596  }
597 
608  [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2200:RethrowToPreserveStackDetails")]
609  public IConverterCollection Add(Converter converter, Type baseType = null, bool allowDisambiguates = false, CancellationToken cancellationToken = default(CancellationToken))
610  {
611  if(converter == null)
612  {
613  throw new ConverterCollectionException(ConverterCollectionCause.ConverterArgumentNull);
614  }
615 
616  if(converter.HasFunction == false)
617  {
618  throw new ConverterCollectionException(ConverterCollectionCause.ConverterFunctionsNull);
619  }
620 
621  try
622  {
623  converter.SetCollectionDefaults(this);
624 
625  if(allowDisambiguates == false && baseType?.GetTypeInfo().BaseType == typeof(MulticastDelegate))
626  {
627  allowDisambiguates = true;
628  }
629 
630  converter.AllowDisambiguates = allowDisambiguates;
631  // if there is already a standard converter try to merge them. The condition is that the converter argument type match or is not used
632  if(allowDisambiguates == false && converter.Standard)
633  {
634  var converterLookup = this.Get(typeFrom: converter.From, typeTo: converter.To, typeArgument: typeof(object).GetTypeInfo(), loadOnDemand: false, isStandard: true);
635  try
636  {
637  if(converterLookup?.MergeStandard(converter) == true)
638  {
639  return this;
640  }
641  }
643  {
644  exc.Cause |= ConverterCollectionCause.AddFailed;
645  throw exc;
646  }
647  }
648  // update the base-type and thus the attribute access of the converter
649  converter.SetBaseType(baseType);
650 
651  this.Items.TryAdd(converter, 100, cancellationToken);
652  OnPropertyChanged(converter);
653  }
655  {
656  throw;
657  }
658  catch(ConverterException)
659  {
660  throw;
661  }
662  catch(Exception exc)
663  {
664  throw new ConverterException(ConverterCause.ConverterCollectionAddFailed, exc);
665  }
666 
667  return this;
668  }
669 
676  public bool CanConvertFrom(Type typeFrom)
677  {
678  return this.WithFrom(typeFrom.GetTypeInfo()).FirstOrDefault() != null;
679  }
680 
687  public bool CanConvertFrom<TIn>()
688  {
689  return this.WithFrom(typeof(TIn).GetTypeInfo()).FirstOrDefault() != null;
690  }
691 
698  public bool CanConvertTo(Type typeTo)
699  {
700  return this.WithTo(typeTo.GetTypeInfo()).FirstOrDefault() != null;
701  }
702 
709  public bool CanConvertTo<TOut>()
710  {
711  return this.WithTo(typeof(TOut).GetTypeInfo()).FirstOrDefault() != null;
712  }
713 
721  public ConverterAttribute ConverterAttributeFromIConverter(TypeInfo baseType, ConverterAttribute attribute = null, bool update = false)
722  {
723  if(baseType == null || (attribute != null && update == false))
724  {
725  return attribute;
726  }
727 
728  attribute = attribute ?? new ConverterAttribute();
729 
730  attribute.BaseType = baseType;
731  // look up a possible converter candidate with generic IConverter<,> support
732  var converter = this.Get(baseType.AsType());
733  if(converter != null && (converter.Attribute == null || converter.Attribute != null && update == true))
734  {
735  converter.Attribute = attribute;
736  }
737 
738  return attribute;
739  }
740 
750  public int LoadOnDemandConverter(Type typeTo)
751  {
752  var nameSpace = typeTo?.Namespace.Split('.').Last();
753  if(nameSpace != null && this.loadOnDemandConverters.ContainsKey(nameSpace))
754  {
755  var loaded = this.loadOnDemandConverters[nameSpace].Select(this.CreateConverterClassInstance).Count();
756  this.loadOnDemandConverters.Remove(nameSpace);
757  return loaded;
758  }
759  return 0;
760  }
761 
762 
766  private static bool AutoInitialized;
767 
776  public static void AutoInitialize()
777  {
778  // is the ConverterCollection Initialized?
779  if(AutoInitialized == false && CurrentInstance.Settings.AutoInitialize == true)
780  {
781  try
782  {
783  var getEntryAssembly = typeof(Assembly).GetRuntimeMethods().FirstOrDefault(m => m.Name.Equals("GetEntryAssembly"));
784  if(getEntryAssembly != null)
785  {
786  var assembly = getEntryAssembly.Invoke(null, null) as Assembly;
787  CurrentInstance.Initialize(assembly);
788  CurrentInstance.ApplicationNameSpace = assembly?.GetNamespacesByLevel(0)?.FirstOrDefault();
789  }
790  // set as initialized regardless of success, to run only once
791  AutoInitialized = true;
792  }
793  catch(Exception exc)
794  {
795  throw new ConverterException(ConverterCause.ConverterAutoInitializationFailed, exc);
796  }
797  }
798  }
799 
813  public void Initialize(string applicationNameSpace)
814  {
815  IEnumerable<TypeInfo> types = Assembly.Load(new AssemblyName(applicationNameSpace)).DefinedTypes;
816  this.Initialize(types);
817  }
818 
832  public void Initialize(Type applicationClass)
833  {
834  if(applicationClass != null)
835  {
836  var assembly = applicationClass.GetTypeInfo().Assembly;
837  this.Initialize(new[] { assembly });
838  }
839  }
840 
852  public void Initialize(Assembly assembly)
853  {
854  this.Initialize(new[] { assembly });
855  }
856 
869  public void Initialize(Assembly[] assemblies)
870  {
871  foreach(var assembly in assemblies)
872  {
873  if(assembly == null || this.AssemblyInitialized.ContainsKey(assembly) == true)
874  {
875  continue;
876  }
877 
878  var types = assembly.GetAtributedTypes<ConverterAttribute>().ToArray();
879  this.Initialize(types);
880  }
881  }
882 
894  public void Initialize(IEnumerable<TypeInfo> types)
895  {
896  foreach(var type in types)
897  {
898  this.AddAllConvertersByAttribute(type);
899  }
900  }
901 
909  [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "<Items>k__BackingField")]
910  protected override void Dispose(bool disposing)
911  {
912  this.Items.Dispose();
913  base.Dispose(disposing);
914  }
915 
921  protected bool SetAssemblyInitialized(TypeInfo type)
922  {
923  return this.AssemblyInitialized.AddOrUpdate(type.Assembly, true, (oldkey, oldval) => true);
924  }
925 
932  protected bool SetConverterClassInitialized(TypeInfo converterClass)
933  {
934  return this.ConverterClassInitialized.AddOrUpdate(converterClass, true, (oldkey, oldval) => true);
935  }
936 
943  private object CreateConverterClassInstance(Type converterClass)
944  {
945  object customConverter;
946 
947  customConverter = this.FactoryBaseClass.Create(converterClass, this);
948  this.SetConverterClassInitialized(converterClass.GetTypeInfo());
949 
950  return customConverter;
951  }
952 
953 
960  private bool AddAllConvertersByAttribute(TypeInfo type)
961  {
962  int count = this.Count;
963  object converterCustom = null;
964 
965  if(ConstructorAddedClasses?.Contains(type.AsType()) == false)
966  {
967  var attribute = type.GetCustomAttribute<ConverterAttribute>();
968  if(attribute == null)
969  {
970  if(type.IsClass == true && type.ImplementedInterfaces.Contains(typeof(IConverter)) == true)
971  {
972  attribute = this.ConverterAttributeFromIConverter(type, attribute, update: true);
973  }
974  // the type is not a converter, let's return
975  return false;
976  }
977 
978  if(attribute?.LoadOnDemand == true)
979  {
980  if(this.loadOnDemandConverters?.ContainsKey(attribute.NameSpace) == false)
981  {
982  this.loadOnDemandConverters.Add(attribute.NameSpace, new List<Type>());
983  }
984 
985  if(this.loadOnDemandConverters[attribute.NameSpace]?.Contains(type.AsType()) == false)
986  {
987  this.loadOnDemandConverters[attribute.NameSpace].Add(type.AsType());
988  }
989 
990  return false;
991  }
992 
993  if(attribute?.DependencInjection == true)
994  {
995  converterCustom = this.CreateConverterClassInstance(type.AsType());
996  }
997  }
998 
999  // discover attributed methods
1000  foreach(var declaredMethod in type.DeclaredMethods)
1001  {
1002  var customAttribute = declaredMethod.GetCustomAttribute<ConverterMethodAttribute>() as ConverterMethodAttribute;
1003  if(customAttribute != null)
1004  {
1005  // create a wrapper taking the own class-instance as first argument for methods that are attributed by `ConverterMethod`
1006  // and do not have any arguments or `PassInstance` set to `true`
1007  if((declaredMethod.IsStatic == false && declaredMethod.GetParameters().Length == 0) || customAttribute.PassInstance == true)
1008  {
1009  Converter converter = this.Factory.CreateWrapper(type, declaredMethod);
1010  this.Add(converter: converter, baseType: type.AsType());
1011  }
1012  else
1013  {
1014  if(converterCustom == null)
1015  {
1016  converterCustom = this.CreateConverterClassInstance(type.AsType());
1017  }
1018  if(converterCustom != null)
1019  {
1020  this.Add(methodInfo: declaredMethod, baseType: type.AsType(), baseInstance: converterCustom);
1021  }
1022  }
1023  }
1024  }
1025 
1026  this.SetAssemblyInitialized(type);
1027  return count != this.Count;
1028  }
1029 
1030  #region Implementation of IEnumerable
1031 
1038  public IEnumerator<Converter> GetEnumerator()
1039  {
1040  var enumerator = this.Items as IEnumerable<Converter>;//.GetConsumingEnumerable();
1041  return enumerator.GetEnumerator();
1042  }
1043 
1050  IEnumerator IEnumerable.GetEnumerator()
1051  {
1052  return ((IEnumerable)this.Items).GetEnumerator();
1053  }
1054 
1055  #endregion
1056  }
1057 }
int LoadOnDemandConverter(Type typeTo)
Tries to lookup the namespace obtained from typeTo in loadOnDemandConverters and add the converters...
void Initialize(Type applicationClass)
Initializes all attributed Converter classes, Initialize(Assembly[])
void Initialize(Assembly assembly)
Initializes all attributed Converter classes, Initialize(Assembly[])
ConverterCollection(Type application=null, params Type[] converterClasses)
Initializes a new instance of the ConverterCollection class with default-parameters.
IConverterCollection Add(Converter converter, Type baseType=null, bool allowDisambiguates=false, CancellationToken cancellationToken=default(CancellationToken))
Adds a Converter instance to the collection of ConverterCollection.Items
static void AutoInitialize()
Checks if the ConverterCollection is initialized. Attempts to initialize and load the user-assembly i...
ConverterCollection(Type application)
Initializes a new instance of the ConverterCollection class with default-parameters.
abstract TInstance Create(TIn1 parameter)
Abstract method for creating instances of TInstance defined only through parameter ...
bool HasFunction
Gets a value indicating whether the converter has either Function or FunctionDefault set...
Definition: Converter.cs:174
bool SetAssemblyInitialized(TypeInfo type)
Sets the Assembly as initialized in AssemblyInitialized
IConverterCollection Add(MethodInfo methodInfo, object converterDelegate=null, Type baseType=null, object baseInstance=null, CancellationToken cancellationToken=default(CancellationToken))
Creates and adds a Converter instance to the collection of ConverterCollection.Items using a MethodIn...
Creates instances from classes which are attributed by ConverterAttribute
TypeInfo From
Gets the Type of the object instance which is to be converted.
Definition: Converter.cs:106
bool CanConvertFrom(Type typeFrom)
Returns bool true if the ConverterCollection supports conversion for a given Type typeFrom ...
The thread-safe, static collection of Converter items, using Core.Singleton and supporting Core...
TypeInfo To
Gets the Type that the instance will be converted to.
Definition: Converter.cs:216
Use ConverterAttribute to declare a class as a logical Type Converter. As such the only contingent de...
Use ConverterMethodAttribute to declare a method in an arbitrary class as a logical Converter functio...
IConverterCollection Add(object converterDelegate, Type baseType=null, CancellationToken cancellationToken=default(CancellationToken))
Initializes a new instance of the ConverterCollection class with default-parameters.
The Exception-type which is raised exclusively by the Converter<TIn,TOut> Library ...
void Initialize(Assembly[] assemblies)
Initializes all attributed Converter classes, unless the ConverterAttribute parameter ConverterAttrib...
ConverterCollection(Assembly assembly, NumberFormatInfo numberFormatDefault=null)
Initializes a new instance of the ConverterCollection class with default-parameters.
The settings for the ConverterCollection.
void Initialize(IEnumerable< TypeInfo > types)
Initializes all attributed Converter classes, unless the ConverterAttribute parameter ConverterAttrib...
override void Dispose(bool disposing)
Dispose of the Items and underlying static Singleton<TClass> references.
void Initialize(string applicationNameSpace)
Initializes all attributed Converter classes, Initialize(Assembly[])
The Base Converter interface.
Definition: IConverter.cs:31
bool Standard
Gets a value indicating whether the Converter instance is strictly typed such that the ArgumentType i...
Definition: Converter.cs:192
ConverterCollectionCause
Contains the reasons for a ConverterCollectionException to be raised.
ConverterAttribute Attribute
Gets or sets the ConverterAttribute if the custom converter class has one defined, else it is set null.
Definition: Converter.cs:67
The abstract generic factory for creating arbitrary instances requiring up to two arguments...
Definition: Factory.cs:30
Allows to perform a deferred adding operation of multiple adds using a common Base-Class Type argumen...
bool SetConverterClassInitialized(TypeInfo converterClass)
Sets the Converter of the ConverterCollection as initialized
ConverterCollection()
Initializes a new instance of the ConverterCollection class with default-parameters.
ConverterCollectionCause Cause
Gets or sets the exception&#39;s ConverterCollectionCause, which is set through the parameterized excepti...
The Exception-type which is raised exclusively by the Converter<T> Library
Creates new instances of Converter<TIn, TOut> dependent on the source TIn and target Type TOut ...
bool CanConvertTo(Type typeTo)
Returns bool true if the ConverterCollection supports conversion for a given Type typeTo ...
IEnumerator< Converter > GetEnumerator()
Returns an enumerator that iterates through the collection.
ConverterAttribute ConverterAttributeFromIConverter(TypeInfo baseType, ConverterAttribute attribute=null, bool update=false)
Adds or updates an attribute for a Converter if it exists, dependent only on the source and target co...
ConverterCollection(Type application, Type converterClass, NumberFormatInfo numberFormatDefault=null)
Initializes a new instance of the ConverterCollection class with default-parameters.
bool AllowDisambiguates
Optional bool value to indicate whether a ConverterCollection is allowed to contain multiple converte...
Definition: Converter.cs:94
ConverterCause
Contains the reasons for a ConverterException to be raised.
The Converter base class, providing a simple container for conversion types, ConverterAttribute and c...
Definition: Converter.cs:22