public void Test_Type1Attribute() { Type1Attribute a = typeof(AttributeClass1).GetMyAttribute <Type1Attribute>(); Assert.AreEqual("20e00d57-fc17-4e90-8b93-8b0d1a51ed3f", a.Flag); SerializableAttribute sa = typeof(AttributeClass1).GetMyAttribute <SerializableAttribute>(); Assert.IsNull(sa); }
public void Test_Register_One() { string flag = "11111111111111111111111"; Type1Attribute a1 = new Type1Attribute { Flag = flag }; // 模拟 HttpContext 标记了 Type1Attribute AttributeCache.Register(typeof(HttpContext), a1); // 获取 Type1Attribute Type1Attribute a2 = typeof(HttpContext).GetMyAttribute <Type1Attribute>(); Assert.AreEqual(flag, a2.Flag); }