mardi 26 mai 2015

ModelMetaData Parenthood Hierarchy

I try to make it short... I Start working MVC a day ago, And i came across a validation type which is not exist within the Framework, with some help from forum, stack, etc... i did made it, and customize it... but now it came that i changed my model...

now i have a model like this

MyModel
{
  OldModel1
  OldModel2
  AnotherModel
  ...
}

Now, what i want is to reach to my base model from the property which is fetched by GetClientValidationRules(ModelMetadata metadata, ControllerContext context) Method.

But since it doesn't specify a references of path or direct access to objects for me, i can't get these objects.

In the end, after checking many properties and things, what i though of in the end was to do something like this:

SelfReferencedMethod-> GetAttributesOfHigherLevel(ModelMetadata metadata)
{
  ...
  if (! Top Level)
    GetAttributesOfHigherLevel(NextLevelMetadata);
}

So i can set several attribute on top of my models, and achieve the chipest way to do what i want... (i want Retrieve Names Generated By Asp Doing JQuery Processing Of Naming A model Properties, So I Can Handle Nested Model)

So Any Idea Accepted. Thank you.





Aucun commentaire:

Enregistrer un commentaire