How do I turn a c# attribute into a text content? -
i have solution several c# class libraries plugins in larger system. system registers plugins in windows' registry. describe registry keys in way can extracted compiled dlls , put text (.reg) file, preferably part of build process.
is there predefined attribute type of metadata? , there command line tool or msbuild task can extract them?
imagine attribute
[system.attributeusage(system.attributetargets.class, allowmultiple = true) // multiuse attribute.] public class registrykey : system.attribute { public string name {get; private set;} public string type {get; private set;} public string data {get; private set;} public registrykey(string name, string type, string data) { name = name; type = type; data = data; } }
consume reflection this
var attrs = system.attribute.getcustomattributes(typeof(mahclass)); foreach (var attr in attrs) { if (attr registrykey) { var name = attr.name; ... } }
Comments
Post a Comment