So I created a custom Attribute that I will used to decorate StepViewModels.
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class WizardStepAttribute : Attribute
{
public String Name { get; set; }
//public virtual int? Order { get; set; }
}
[PropertiesMustMatch("Email","ConfirmEmail")]
[WizardStep(Name="Preparer's Information")]
public class Step0ViewModel : IStepViewModel
{...
In my IStepViewModel.cshtml I want to display the WizardStep property name if it exists.
Here is my own pretend code for what I want to happen…
@Html.Label(ViewModel.ModelMetaData.Properties("WizardStep").Name)
The correct way to do this is to implement a custom model metadata provider to add metadata to the model based on the attribute:
… then pull that data from the model metadata:
You will have to register this metadata provider in
Application_Startlike so:(Note that some DI Framework extensions for MVC automatically wire this up if you bind
ModelMetadataProvidertoMyModelMetadataProvider)