.NET Portable TypeCast  3.1.0.4
A, easy-to-use tested, generic, portable, runtime-extensible, arbitrary type converter library
ConverterCollectionDependency.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.Base
10 {
11  using System;
12  using System.Diagnostics.CodeAnalysis;
13  using System.Reflection;
14 
15  using Core.Extensions;
16 
38  [System.Runtime.InteropServices.ComVisible(false)]
39  public abstract class ConverterCollectionDependency : DependencyInjection<IConverterCollection>
40  {
50  : base(collection)
51  {
52  }
53  }
54 
68  [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "Reviewed. Suppression is OK here.")]
69  public abstract class ConverterCollectionDependency<TIn, TOut> : ConverterCollectionDependency, IConverter<TIn, TOut>
70  {
85  : base(collection)
86  {
87  collection.Add((Func<TIn, TOut, TOut>)this.Convert, this.GetType());
88  }
89 
97  public abstract TOut Convert(TIn value, TOut defaultValue = default(TOut));
98  }
99 }
The converter dependency provides loose implementation of Converters, merely constricting the constru...
IConverterCollection Add(Converter converter, Type baseType=null, bool allowDisambiguates=false, CancellationToken cancellationToken=default(CancellationToken))
Adds a Converter instance to the collection of ConverterCollection.Items
The Base Converter interface.
Definition: IConverter.cs:31
The generic class used for deriving specific dependency-injection classes, used for reflection...
ConverterCollectionDependency(IConverterCollection collection)
Initializes a new instance of the ConverterCollectionDependency class.