IsObsoleteAttribute
This attribute indicates the node is obsolete
using System;
using System.Reflection;
namespace Autodesk.DesignScript.Runtime
{
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property)]
public class IsObsoleteAttribute : Attribute
{
public string Message { get; set; }
public IsObsoleteAttribute()
{
Message = string.Empty;
}
public IsObsoleteAttribute(string message)
{
Message = message;
}
public IsObsoleteAttribute(string descriptionResourceID, Type resourceType)
{
LookupResourceByID(descriptionResourceID, resourceType);
}
public IsObsoleteAttribute(string descriptionResourceID, string typeName)
{
Type type = Type.GetType(typeName);
LookupResourceByID(descriptionResourceID, type);
}
private void LookupResourceByID(string descriptionResourceID, Type resourceType)
{
if (resourceType == (Type)null)
throw new ArgumentNullException("resourceType");
PropertyInfo property = resourceType.GetProperty(descriptionResourceID, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (property != (PropertyInfo)null && property.PropertyType == typeof(string))
Message = (property.GetValue(null, null) as string);
else
Message = descriptionResourceID;
}
}
}