init
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
DescriptionAttributeCoder.cs
|
||||
|
||||
* 12/18/2008 Relo'd from Dave to SVN-controlled utilities project.
|
||||
|
||||
$Log: DescriptionAttributeCoder.cs,v $
|
||||
Revision 1.1 2006/09/14 18:41:54 Paul Hrissikopoulos
|
||||
Moved AttributeCoder files from Dave solution.
|
||||
|
||||
Revision 1.2 2006/09/07 20:43:08 Paul Hrissikopoulos
|
||||
Expanded commentary.
|
||||
|
||||
Revision 1.1 2006/08/17 23:05:11 Paul Hrissikopoulos
|
||||
Added generically-derived SelectionCriterion.ComparisonType enumeration attributes.
|
||||
|
||||
Copyright © 2006
|
||||
Diversified Technical Services
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DTS.Common.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for "matching" <see cref="DescriptionAttribute"/>s and the "TargetType" data
|
||||
/// type data type they're attached to.
|
||||
/// </summary>
|
||||
///
|
||||
/// <typeparam name="TTargetType">
|
||||
/// The data type the attribute being encoded to/decoded from is attached to.
|
||||
/// </typeparam>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Generally useful with enumeration target types in which each enumeration value
|
||||
/// has a specific "DescriptionAttribute" assigned to it. This class essentially
|
||||
/// allows one to "encode" the a specific description value into the enumeration
|
||||
/// value it's attached to, as well as "decode" an enumeration into the description
|
||||
/// that's attached to it. For example, if we create an enumeration type whose
|
||||
/// values at some point need to be converted to string values (and back again),
|
||||
/// we can simply attach DescriptionAttributes containing the string conversion
|
||||
/// to each value in the enumeration definition and use the DescriptionAttributeCoder
|
||||
/// to convert directly from one to the other without the need for any kind of
|
||||
/// seperate lookup table.
|
||||
///</remarks>
|
||||
///
|
||||
public class DescriptionAttributeCoder<TTargetType>
|
||||
: AttributeCoder<TTargetType, DescriptionAttribute, string>
|
||||
{
|
||||
/// <summary>
|
||||
/// constructs a <see cref="T:DescriptionAttributeCoder" /> object
|
||||
/// </summary>
|
||||
public DescriptionAttributeCoder()
|
||||
: base(delegate (DescriptionAttribute attribute) { return attribute.Description; },
|
||||
delegate (string s1, string s2) { return s1.Equals(s2, StringComparison.OrdinalIgnoreCase); })
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user