Je voudrais savoir si je peux définir des atsortingbuts d’assemblage personnalisés. Les atsortingbuts existants sont définis de la manière suivante:
[assembly: AssemblyTitle("MyApplication")] [assembly: AssemblyDescription("This application is a sample application.")] [assembly: AssemblyCopyright("Copyright © MyCompany 2009")]
Est-il possible de faire ce qui suit:
[assembly: MyCustomAssemblyAtsortingbute("Hello World! This is a custom atsortingbute.")]
Oui, vous pouvez. Nous faisons ce genre de chose.
[AtsortingbuteUsage(AtsortingbuteTargets.Assembly)] public class MyCustomAtsortingbute : Atsortingbute { ssortingng someText; public MyCustomAtsortingbute() : this(ssortingng.Empty) {} public MyCustomAtsortingbute(ssortingng txt) { someText = txt; } ... }
Pour lire, utilisez ce type de linq stmt.
var atsortingbutes = assembly .GetCustomAtsortingbutes(typeof(MyCustomAtsortingbute), false) .Cast();
Oui, utilisez AtsortingbuteTargets.Assembly:
[AtsortingbuteUsage(AtsortingbuteTargets.Assembly)] public class AssemblyAtsortingbute : Atsortingbute { ... }