Remove the controllers-views project for ASP. net mvc rc and add the "scaffold" function (2)

Source: Internet
Author: User

In the previous article "Separating controllers-views for ASP. net mvc rc project and adding the" scaffold "function (I)", we talked about how to separateControllersAndViewsProject, andControllersAdd ProjectMVC RCIt is a pity that the "scaffold" function is too complete to be automatically created and viewed.ViewThe page will be carried out in the current project, unless you are willing to manually transfer the fileViews(Web) Project. Otherwise, the meaning of the "scaffold" is almost lost. In addition, it was transferred in time.. AspxAnd so on.ViewFile, so check is still in the current project. What should I do? This article will create a "one stone and two birds" method to solve this problem at the same time.ViewPage to add and view issues. 

View View

Because I have no efforts to study the internal mechanism of this "scaffold" (if any friend can implement it)HackSo I thought of a work und: Can IControllerAdd some "Shortcuts" to the corresponding content, and then search for the source file directly when viewing it? After some attempts, we found that creating a shortcut file directly (. Lnk.

So I started again.Mymvc. controllers. csprojIdea. After some tests and research, we found that. CsprojFile supports one<Link>Can be found inVSProgram(How to set the solution program and download the node provided later in this article)Code).

After a series of tests, theseLinkWill not be compiledMymvc. controllers. dllMedium,OK,ViewThe problem has come to an end, and the rest of the work is done by a unified solution.

View New

SinceMymvc. ControllersInViewThere is no practical shortcut, so the newly added files obviously cannot be left inMymvc. ControllersProject, so I thought of "Qian Kun big move" -- to the newViewAutomatically moveMymvc. WebProject, andMymvc. controllers. csprojProgram the corresponding file into a "shortcut ".

Final Solution -- Mvcscaffoldtool

MvcscaffoldtoolIt is a self-built and open-source tool used to solve the problem of creating scaffolding and viewing file paths. It is also applicable to other types of projects.

Starting from the outside, the most direct and automatic method is to write a program for automatic "monitoring"Mymvc. ControllersWhen it changes, the file is automatically transferred and the corresponding. CsprojFile.

Because it is rarely doneWinformTherefore, the following is a crude code:

The implementation code has been provided for download, which no longer occupies your valuable field of view.

Due to limited time, only some basic functions are supported. The principle is roughly as follows:

SpecifyViews (Web)AndControllersProject folders and files, monitoringControllersChanges to the node corresponding to the project file. When a new file is found to be added, transfer the fileWebProject, and modify the project files of the two projects (. Csproj),ControllersCreate a "shortcut" for the corresponding file in the projectWebCreate a real project file.

In addition to the above basic functions, there are also some areas that can be expanded and optimized, such as whenWebDelete someViewToControllersThe shortcut in is also deleted synchronously. The principle is similar to the above. In addition,MvcscaffoldtoolAutomatically hidden and runs in the background,Currently, you can only disable it through "task management ".(This feature has been upgraded) and reduced to the system tray in the system start column:

Double-click the chart to restore the operation window and pause monitoring.

Note:Vs2008 (SP1) and vs2010The test is successful.Vs2005Is there a way to install the officialMVC RCAnd "scaffolding", so no tests are conducted. You are also welcome to give feedback.

Mvcscaffoldtool Usage

MvcscaffoldtoolIs easy to use:

1, SetMvcscaffoldtool.exeCopy to solution (generally the parent directory of all project files ):

 

2 . Controllers Scaffolding creation in View Run before page Mvcscaffoldtool.exe (Enable it with the project), and select the correct project folder and project file:

The program will give priority. CsprojType files are used as project files. If there are multiple files, you can select them as needed.

3, Click "OK and start,Mvcscaffoldtool.exeCreatesXMLFile and run it in the background. If you have already createdXMLFile.XMLFile Reading, you do not have to set it every time you enable it.

Bytes ------------------------------------------------------------------------------------------------

Subsequent operations and common useMVC RCDevelopment is almost identical.

4, UseControllersScaffolding in the projectActionCreateViewPage:

 

5,ControlllersThe correspondingViewPage:

Strange, why?Mvcscaffoldtool.exeWhy didn't it work? Take a look at the next step:

6It is still time to delete the file. If you are sure to add the file, click "Save all:

 

7Without an accident, you will immediately see the following prompt:

And:

Don't worry. This indicates that the modification is successful. Click "reload.

Result After the project is reloaded:

 

You can clearly see that,Mymvc. ControllersThe. AspxThe file has been transferredMymvc. WebAt the same time, the original file becomes a shortcut. Click this shortcut to viewMvcscaffoldtool. aspx.

8Why is it not finished yet? Yes! And"Go to view"No tests!

ClickMvcscaffoldtool ()InGo to view:

At this time, although the current file in solution manager is Mymvc. Controllers The following is a shortcut, but the file opened is Mymvc. Web Under the real View File:

 

 

Mvcscaffoldtool Update log

2009-2-27 v1.0.0
Complete the basic functions of mvcscaffoldtool.

2009-2-27 v1.1.0
Solve the problem that mvcscaffoldtool must be disabled in the "Task Manager.
The mvcscaffoldtool can be minimized in the Start column as a tray and run in the background.

2009-2-28 v1.2.0
Added the function of automatically creating necessary directories for the views project to solve the bug of "reload repeatedly.

 

Provided belowMvcscaffoldtoolSource codeAnd separationV-CTest source code:

V2.0.0.0 EXE file download:/files/SZW/MvcScaffoldTool-v2.0.0.0.rar

Source code SVN:HTTP: // Mvc-scaffold-tool.googlecode.com/svn/trunk/

Open Source project home: http://code.google.com/p/mvc-scaffold-tool/

 

Mymvc source code

PS:Write this articleArticleThe purpose is to provide a feasible idea. If you have any better methods, please do not hesitate to give us your advice! From Problem Discovery to developmentMvcscaffoldtoolTo write these two articles, there are only3There will certainly be a lot of problems in such a rush for more than an hour. We hope you will forgive me for the inconvenience. We also welcome your feedback :)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.