私はここのような属性の紹介を達成しようとしていますが、私の属性には次のようなプロパティ引数があります:[Foo(Bar = "Baz")]
引数を正しく渡すにはどうすればよいですか? 私は別のものから属性をコピーしていないので、CustomAttributeData を使用できないと思いますか?
You can set properties of your custom attributes by using ObjectConstruction.NamedArguments
dictionary.
For example:
public IEnumerable<AspectInstance> ProvideAspects(object targetElement)
{
Type targetType = (Type) targetElement;
var objectConstruction =
new ObjectConstruction(typeof (MyCustomAttribute).GetConstructor(Type.EmptyTypes));
objectConstruction.NamedArguments["Bar"] = "Baz";
var introduceAttributeAspect = new CustomAttributeIntroductionAspect(objectConstruction);
yield return new AspectInstance(targetType, introduceAttributeAspect);
}