1
可能性の重複:クラス属性が設定されているクラスのタイプを取得するにはどうすればよいですか?
[AttributeUsage(AttributeTargets.Class)] public class ConfigurableClass : Attribute { public Type Control { get; private set; } public bool IsSingleton { get; private set; } public string Name { get; private set; } public ConfigurableClass(bool isSingleton) : this(null, isSingleton) { } public ConfigurableClass(Type control, bool isSingleton) { Control = control; this.IsSingleton = isSingleton; this.Name = ""; //set name to typename of the attached class here? } public ConfigurableClass(Type control, bool isSingleton, string name) : this(control, isSingleton) { this.Name = name; } }
お知らせそれにコメントして行:
How to determine the attached type from within a custom attribute?
私はこのカスタムクラス属性を持っています。このクラス属性が添付されているクラスの型を取得することは可能ですか、そうではありませんか?
私はあなたが何を意味しているのかわかりません、どのオブジェクトのタイプですか? – Magnus