1
:塞西爾 - 使用已定義的屬性,我使用塞西爾嘗試讀取我的屬性屬性屬性
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class TraceMethodAttribute : Attribute {
public TraceMethodAttribute() {
MethodStart = true;
MethodReturn = true;
MethodMessages = true;
}
public bool MethodStart { get; set; }
public bool MethodReturn { get; set; }
public bool MethodMessages { get; set; }
}
[TraceMethod(MethodMessages = false)]
static void Main(string[] args) {
}
...
if (attribute.Constructor.DeclaringType.FullName == typeof(TraceMethodAttribute).FullName) {
if ((bool)attribute.Fields["MethodMessages"] == true) {
EditMethodStart(assembly, method);
}
這是,我想這最後一塊例如,代碼檢查應用於Main的屬性是否將MethodMessages設置爲true或false。從我所看到的,似乎都屬性.Fields.Count和attributes.Properties.Count設置爲0.爲什麼?
謝謝