Last active
November 22, 2019 21:42
-
-
Save InvaderZim85/c9cd9ac584724270e238419d07a0bfb4 to your computer and use it in GitHub Desktop.
Usage of the custom attribute in the meta module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InfoMetadataModule : MetadataModule<CustomMetadata> | |
{ | |
public InfoMetadataModule() | |
{ | |
var metaData = GetCustomMetadata(); | |
foreach (var entry in metaData) | |
{ | |
Describe[entry.Name] = x => new CustomMetadata(x, entry.Description); | |
} | |
} | |
private List<RouteDescriptionAttribute> GetCustomMetadata() | |
{ | |
return (from constructor in typeof(InfoModule).GetConstructors() | |
from attribute in constructor.GetCustomAttributes<RouteDescriptionAttribute>() | |
select attribute).ToList(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment