Question

Photo of Jorge Recio

0

Loading of MEF attributes

Hi everyone,

I'm new to MEF (Managed Extensibility Framework) attributes, I'm working with some code related to "Protect My Ministry" and I can't seem to find where and how this attributes are being set.
The ProtectMyMinistry class that is under Rock\Security\BackgroundCheck  has the User Name, Password MEF attributes among others and would like to know how and where these are getting set at runtime as I need to implement something similar in a different class.

Thank you for your help.

  • Photo of David Leigh

    0

    Hi Jorge,

    If you look at the ProtectMyMinistry class, you will notice that it is decorated with some .NET Attributes, including the User Name and Password attributes that you refer to.
    For example:

    [TextField( "User Name", "Protect My Ministry User Name", true, "", "", 0 )]

    These attributes and their behaviors are defined by Rock, so when a component is loaded at run-time corresponding entries are automatically created in the Attributes table to store their values. So to create your own similar component, you can simply copy the ProtectMyMinistry class and change it's name, then add or modify the Attributes as needed - Rock will do the rest for you.

    Note that there are only two attributes on this class that are specifically related to MEF - "Export" and "ExportMetadata".
    These attributes tell the .NET framework that the class defines an MEF component that can be dynamically loaded.

    Hopefully, this is enough to get you started!