using System; using System.Linq; namespace SharpShell.Attributes { /// <summary> /// The ServerTypeAttribute can be used internally by SharpShell /// to mark the type of a server base class. By setting this type, /// classes derived from the decorated class will be able to use /// the COMServerAssociationAttribute without any extra configuration. /// </summary> internal class ServerTypeAttribute : Attribute { /// <summary> /// Initializes a new instance of the <see cref="ServerTypeAttribute"/> class. /// </summary> /// <param name="serverType">Type of the server.</param> public ServerTypeAttribute(ServerType serverType) { // Set the server type. ServerType = serverType; } /// <summary> /// Gets the server type of a type of the association. /// </summary> /// <param name="type">The type.</param> /// <returns>The ServerType of the type, or None if not set.</returns> public static ServerType GetServerType(Type type) { var attribute = type.GetCustomAttributes(typeof(ServerTypeAttribute), true) .OfType<ServerTypeAttribute>().FirstOrDefault(); return attribute != null ? attribute.ServerType : ServerType.None; } /// <summary> /// Gets the type of the server. /// </summary> /// <value> /// The type of the server. /// </value> public ServerType ServerType { get; private set; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The MIT License