.NET Portable TypeCast  3.1.0.4
A, easy-to-use tested, generic, portable, runtime-extensible, arbitrary type converter library
ConverterMethodAttribute.cs
Go to the documentation of this file.
1 // <copyright file=mitlicense.md url=http://lsauer.mit-license.org/ >
2 // Lo Sauer, 2016
3 // </copyright>
4 // <summary> A generic, portable and easy to use Converter pattern library </summary
5 // <language> C# > 6.0 </language>
6 // <version> 3.1.0.2 </version>
7 // <author> Lo Sauer; people credited in the sources </author>
8 // <project> https://github.com/lsauer/csharp-Converter </project>
9 namespace Core.TypeCast
10 {
11  using System;
12  using System.Diagnostics.CodeAnalysis;
13  using System.Reflection;
14  using System.Runtime.CompilerServices;
15  using Base;
16 
56  [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
57  public sealed class ConverterMethodAttribute : Attribute
58  {
68  public ConverterMethodAttribute(bool isStatic = true, bool loadOnDemand = true, string name = "", bool passInstance = false)
69  {
70  this.LoadOnDemand = loadOnDemand;
71  this.Name = name;
72  this.IsStatic = isStatic;
73  this.PassInstance = passInstance;
74  }
75 
80  public Type BaseType { get; set; }
81 
112  public bool LoadOnDemand { get; }
113 
117  public bool IsStatic { get; }
118 
139  public string Name { get; }
140 
145  public bool PassInstance { get; }
146 
153  public override string ToString()
154  {
155  return $"[Sta:{this.IsStatic},LoD:{this.LoadOnDemand},BaTy:{this.BaseType},Name:{this.Name}]";
156  }
157 
158  }
159 }
ConverterMethodAttribute(bool isStatic=true, bool loadOnDemand=true, string name="", bool passInstance=false)
Initializes a new instance of the ConverterMethodAttribute class, to declare a custom Converter funct...
Use ConverterMethodAttribute to declare a method in an arbitrary class as a logical Converter functio...