public static void AddInterceptorAttributes(TypeBuilder typeBuilder, InterceptorAttributeDefinition[] attributes) { foreach (var customAttribute in attributes) { typeBuilder.AddCustomAttribute(customAttribute.AttributeData); } }
public void GetRosMessageTypeFromTypeAttribute_ShouldReturnProperRosMessageTypeString() { //arrange string typeName = "testType"; string rosMessageType = "testRosMessageType"; _typeBuilder.Inicialize(typeName, System.Reflection.TypeAttributes.Public, null); _typeBuilder.AddCustomAttribute(typeof(RosMessageTypeAttribute), new Type[] { typeof(string) }, new object[] { rosMessageType }); Type testType = _typeBuilder.CreateType(); //act string resultRosMessageTypeString = _testClass.GetRosMessageTypeFromTypeAttribute(testType); //assert resultRosMessageTypeString.Should().NotBeNull(); resultRosMessageTypeString.Should().Be(rosMessageType); }
static public void AddCustomAttribute <T, P1, P2, P3, P4, P5, P6, P7, P8, P9>(this TypeBuilder item, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) { item.AddCustomAttribute(typeof(T).GetInstanceConstructor <P1, P2, P3, P4, P5, P6, P7, P8, P9>(), p1, p2, p3, p4, p5, p6, p7, p8, p9); }
static public void AddCustomAttribute <T, P1, P2, P3, P4, P5>(this TypeBuilder item, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { item.AddCustomAttribute(typeof(T).GetInstanceConstructor <P1, P2, P3, P4, P5>(), p1, p2, p3, p4, p5); }
static public void AddCustomAttribute <T, P1, P2>(this TypeBuilder item, P1 p1, P2 p2) { item.AddCustomAttribute(typeof(T).GetInstanceConstructor <P1, P2>(), p1, p2); }
static public void AddCustomAttribute <T>(this TypeBuilder item) { item.AddCustomAttribute(typeof(T).GetInstanceConstructor()); }