类的特性
using System;
public enum RemoteServers
{
TTT,
AAA,
CHAIN
}
public class RemoteObjectAttribute:Attribute
{
public RemoteObjectAttribute ( RemoteServers Server)
{
this.server=Server;
}
protected RemoteServers server;
public string Server
{
get
{
return Enum.GetName(typeof(RemoteServers),this.server);
}
}
}
[RemoteObjectAttribute(RemoteServers.TTT)]
public class RemoteObjectClass
{
}
public class ClientTestApp
{
public static void Main()
{
System.Type type=typeof(RemoteObjectClass);
foreach(Attribute attr in type.GetCustomAttributes(true))
{
RemoteObjectAttribute remoteAttr= attr as RemoteObjectAttribute;
if(attr!=null)
{
Console.WriteLine(remoteAttr.Server);
}
}
}
}