37 lines
1.3 KiB
Plaintext
37 lines
1.3 KiB
Plaintext
|
|
using System;
|
||
|
|
|
||
|
|
// ReSharper disable once CheckNamespace
|
||
|
|
namespace DTS.DASLib.Service
|
||
|
|
{
|
||
|
|
/// <inheritdoc />
|
||
|
|
/// <summary>
|
||
|
|
/// This attribute is used to control whether a gain is available to unmodified gen 3 SPS
|
||
|
|
/// http://fogbugz/fogbugz/default.asp?10080
|
||
|
|
/// the gain should still be available for modified SPS
|
||
|
|
/// this attribute is optional, it is assumed to be available unless explicitly marked as
|
||
|
|
/// unavailable
|
||
|
|
/// </summary>
|
||
|
|
public class GainAvailableUnmodifiedAttribute : Attribute
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// returns whether gain is available to unmodified SPS gen 3 or not
|
||
|
|
/// http://fogbugz/fogbugz/default.asp?10080
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="o"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
public static bool IsGainAvailableToUnmodified(object o)
|
||
|
|
{
|
||
|
|
if (o == null) return true;
|
||
|
|
var mi = o.GetType().GetMember(o.ToString());
|
||
|
|
if (mi.Length <= 0) return true;
|
||
|
|
return !(GetCustomAttribute(mi[0], typeof(GainAvailableUnmodifiedAttribute)) is GainAvailableUnmodifiedAttribute attr) || attr._bAvailable;
|
||
|
|
}
|
||
|
|
|
||
|
|
private readonly bool _bAvailable;
|
||
|
|
public GainAvailableUnmodifiedAttribute(bool available)
|
||
|
|
{
|
||
|
|
_bAvailable = available;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|