Metadata

This attribute is a Attribute.
When you want to create an attribute which need to be retrieve using property metadata, your attribute should inherit from this attribute.

You must add this line to your global.asax
ModelMetadataProviders.Current = new MvcToolbox.CustomModelMetadataProvider();


example:
/// <summary>
/// Class HiddenProperty Attribute
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class HiddenPropertyAttribute : MetadataAttribute
{
    /// <summary>
    /// Initializes a new instance of the <see cref="HiddenPropertyAttribute"/> class.
    /// </summary>
    public HiddenPropertyAttribute()
    {
    }

    /// <summary>
    /// Method for processing custom attribute data.
    /// </summary>
    /// <param name="modelMetaData">A ModelMetaData instance.</param>
    public override void Process(ModelMetadata modelMetaData)
    {
        modelMetaData.AdditionalValues.Add("HiddenPropertyAttribute", this);
    }
}

ModelMetadataProviders.Current = new SgResearch.Code.Managers.CustomModelMetadataProvider();

Last edited Jun 12, 2013 at 11:56 AM by jefflequeux, version 1

Comments

No comments yet.