C# Coding Solutions—Transformer Functor

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:Articles
C# Articles

C# Coding Solutions

© 2006 Christian Gross

The Transformer Functor

Another type of functor is the Transformer functor. It takes one type as a parameter and uses a mapping to return some equivalent of the original type to a new type. The big picture idea behind a Transformer functor is to make it possible for a user to continue using one type that will be converted dynamically into another type. For instance, the Transformer functor is useful in the context of integrating a new system with legacy objects, or vice versa.

The following is the delegate definition of the Transformer functor:

public delegate outType
    DelegateTransformer<inpType, outType>(inpType input);

The delegate DelegateTransformer<> is a .NET Generics type with two parameters, where the type inpType is the input, and the type outType is the output that the input is converted into.


Previous_Page_.gif Next_Page_.gif


Personal tools