简体   繁体   中英

C# MVC Pattern 1:n - view:controller?

I'm supposed to make a simple application, an xHTML editor with some basic validation in C# with WinForm while using the MVC pattern. I'm a bit familiar with MVC, not in C# though, but I started programming this thing and the pattern got me a little confused.

A few words to describe my situation: As model I created 1 wrapper class EditorModel and 2 classes - Attribute and Element. Now to wrap these two I have dictionaries with elements ( where string is the name of an Element) and attributes () in EditorModel class. I think this should work just fine. As view I have WinForm initialization and event handling. I'm not really sure if it's good to have event handling in view, in these event methods I just call controller methods but I'm not sure if this is a good way for the view part. But the real confusion comes in the controller part. I was thinking of creating 4 classes - adder, parser, validator, highlighter. Now I'm not sure if I should create another wrapping class EditorController. But if I make it I don't really know how it all should work together because all of those 4 classes need to work with view items like textBox etc.

So basically my question is if I'm having the right idea here and whether I should or should not make the EditorController class to wrap those 4 control classes. Any suggestions will be appreciated. Thanks.

Well the problem you're facing is that in most practical implementations you have a Model and a ViewController. For very basic things just use the WinForms backend and events as a controller for your model, for more complex things keep tying in events to your specialist controller.

So basically what I'm saying is that you probably shouldn't add an EditorController, but that you should see the winform backend as EditorController, as long as it doesn't get too complex.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM