37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
|
|
using System;
|
|||
|
|
|
|||
|
|
// ReSharper disable once CheckNamespace
|
|||
|
|
namespace DTS.DASLib.Service
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// this attribute controls whether a gain is disabled or not
|
|||
|
|
/// this was done for
|
|||
|
|
/// http://fogbugz/fogbugz/default.asp?10080
|
|||
|
|
/// to prevent the higher range gains which were considered just not useful
|
|||
|
|
/// this attribute is optional, it is assume the gain is not disabled
|
|||
|
|
/// unless it's explicitly marked as disabled
|
|||
|
|
/// </summary>
|
|||
|
|
public class GainDisabledAttribute : Attribute
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// returns whether the gain is disabled or not
|
|||
|
|
/// http://fogbugz/fogbugz/default.asp?10080
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="o"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public static bool IsGainDisabled(object o)
|
|||
|
|
{
|
|||
|
|
if (o == null) return false;
|
|||
|
|
var mi = o.GetType().GetMember(o.ToString());
|
|||
|
|
if (mi.Length <= 0) return false;
|
|||
|
|
return GetCustomAttribute(mi[0], typeof(GainDisabledAttribute)) is GainDisabledAttribute attr && attr._bDisabled;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private readonly bool _bDisabled;
|
|||
|
|
public GainDisabledAttribute(bool disabled)
|
|||
|
|
{
|
|||
|
|
_bDisabled = disabled;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|