English 中文(简体)
MVC Toolkit and XmlMetadataProvider
原标题:

I have been working on validation with the ASP.NET MVC BETA 2. Some of the reading that I have done is very critical of the buddy class approach because it isn t DRY (Don t Repeat Yourself) and because it puts the buddy class in the model layer and not in the web layer. I understand these arguments and through lots of searching I found an old reference to the MVC Toolkit 3.5 Preview 1.

Inside the toolkit is an XmlMetadataProvider. It is fairly basic but easy enough to extend. This would put the meta data for the model into an XML file with the web project and it seems that it would solve the issues raised by others with the Buddy Classes.

Does anyone have any thoughts or feedback on this toolkit approach? Have you used it? Do you know where I can get a more up to date example?

Old MVC Toolkit

问题回答

Huh, I have to say I disagree with those arguments. The reason I use buddy classes is that that model is often regenerated if you use SubSonic or a LINQ2SQL provider. One would have to rewrite the properties on the fields if buddy classes wern t used. Buddy classes should be in the model, they are annotations of the model. Saying "this field is required" does not vary from view to view. As for the DRY issue I can see where people are coming from but it is really the simplest approach. Blindly adhering to rules in even the best programming books is a recipie for disaster.

Stick with the buddy classes.





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签