The SOAP Extension Attribute Class
Listing 2. Use a custom .NET attribute to decorate Web methods that require role-based protection. /// <summary> /// An attribute that is used to decorate /// methods that require role-based /// protection. /// </summary> [AttributeUsage (AttributeTargets.Method)] public class AuthorizedRolesAttribute : SoapExtensionAttribute { int _priority = 1; string roles = ""; public AuthorizedRolesAttribute( string roles) { this.roles = roles; } public string Roles { get { return roles; } } /// <summary> /// The priority determines the order /// in which the extension is fired. /// </summary> public override int Priority { get { return _priority; } set { _priority = value; } } /// <summary> /// Returns the class that /// implements the extension... /// in this case /// typeof (AuthorizedRolesExtension) /// </summary> public override Type ExtensionType { get { return typeof (AuthozizedRolesExtension); } } } |