/// <summary> /// Applies an attribute to an event. /// </summary> /// <remarks>Does not work for EventBuilders created in the reflection only context.</remarks> /// <param name="event">An instance of AssemblyBuilder to apply the attribute to.</param> /// <param name="expression">An expression that represents the attribute.</param> public static void SetCustomAttribute(this EventBuilder @event, Expression <Func <Attribute> > expression) { var builder = new CustomAttributeBuilderBuilder(); var attribute = builder.Build(expression); @event.SetCustomAttribute(attribute); }
/// <summary> /// Applies an attribute to a method parameter. /// </summary> /// <remarks>Does not work for ParameterBuilders created in the reflection only context.</remarks> /// <param name="parameter">An instance of ParameterBuilder to apply the attribute to.</param> /// <param name="expression">An expression that represents the attribute.</param> public static void SetCustomAttribute(this ParameterBuilder parameter, Expression <Func <Attribute> > expression) { var builder = new CustomAttributeBuilderBuilder(); var attribute = builder.Build(expression); parameter.SetCustomAttribute(attribute); }