Visual Studio:您使用什么方法来“模拟”类似项目的管道?

时间:2022-09-01 08:12:20

When building ASP.NET projects there is a certain amount of boilerplate, or plumbing that needs to be done, which is often identical across projects. This is especially the case with MVC and ALT.NET approaches. [I'm thinking of things such as: IoC, ORM, Solution structure (projects), Session Management, User Management, I18n etc.]

在构建ASP.NET项目时,需要完成一定数量的样板或管道,这在整个项目中通常是相同的。 MVC和ALT.NET方法尤其如此。 [我正在考虑以下事项:IoC,ORM,解决方案结构(项目),会话管理,用户管理,I18n等]

I would like to know what approach you find best for 'reusing' this plumbing across projects?

我想知道你最喜欢什么方法来“重用”这些管道跨项目?

  • Have a 'master solution' which you duplicate and rename somehow? (I'm using a this to a degree at the moment, but it's fairly messy. Would be interested how people do this 'better')
  • 有一个'主解决方案',你复制并以某种方式重命名? (我现在正在使用这个程度,但它相当混乱。会对人们如何做得更好感兴趣)

  • Mainly rely on Shared Library projects? (I find this appropriate for some things, but too restrictive for things that have to be customised)
  • 主要依靠共享库项目? (我发现这适用于某些事情,但对于必须定制的事情限制太多)

  • Code generation tools, such as T4? (Similar to the approach used by SharpArchitecture - have not tried this myself)
  • 代码生成工具,如T4? (类似于SharpArchitecture使用的方法 - 我自己没试过)

  • Something else?

6 个解决方案

#1


5  

Visual Studio supports Custom Templates.

Visual Studio支持自定义模板。

#2


3  

I definitely (mostly!) go for T4 templates in conjunction with a modified version of SubSonic 3. I kind of use the database to model my domain and then use the T4 templates to generate the model and associated controllers and views. It takes about 50-60% of the effort out and keeps a consistency in place.

我绝对(主要是!)与SubSonic 3的修改版本一起使用T4模板。我使用数据库来模拟我的域,然后使用T4模板生成模型以及相关的控制器和视图。它需要大约50-60%的努力并保持一致性。

I then work on overrides (partials) of the classes along with filters and extension methods to 'make the app'. Now that I'm familiar with the environment and what I'm doing, I can have a basic model with good plumbing in place in a very short space of time. More importantly, because I create a set of partial class files, I can regenerate all I want without losing any of my 'custom' coding.

然后我研究类的覆盖(部分)以及用于“制作应用程序”的过滤器和扩展方法。既然我熟悉环境和我正在做的事情,我可以在很短的时间内建立一个基本模型,并且管道很好。更重要的是,因为我创建了一组部分类文件,所以我可以重新生成我想要的所有文件而不会丢失任何“自定义”编码。

It works for me anyway :)

无论如何它对我有用:)

#3


2  

You could do it the bearded, t-shirted, agile style and create a nice template and put it in sourcecontrol. So when you need a new project, you just checkout the template?

你可以做胡子,T恤,敏捷的风格,并创建一个很好的模板,并把它放在sourcecontrol中。那么当你需要一个新项目时,你只需要结帐模板?

#4


2  

For insanely fast MVC site setup, I use modified T4 templates (created with T4 Editor) and with ALOT of help from Oleg Sych's blogs for page generation (for your typical add/edit/index pages) combined with an awesome implementation of an automated create-update-delete called MVCCrud (if LINQ-to-SQL is your preferred data access method)

对于疯狂快速的MVC站点设置,我使用修改后的T4模板(使用T4编辑器创建)和Oleg Sych博客的大量帮助,用于页面生成(针对典型的添加/编辑/索引页面)以及自动创建的强大实现-update-delete名为MVCCrud(如果LINQ-to-SQL是您首选的数据访问方法)

Using modified T4 templates and MVCCrud you can create fully functional entities (Create/Edit/List/Delete) with error handling and intuitive error messages in about 4 minutes for each.

使用修改后的T4模板和MVCCrud,您可以创建功能完整的实体(创建/编辑/列表/删除),每个实体具有错误处理和直观的错误消息,大约需要4分钟。

#5


1  

I create a new project using the new project wizard so that I get unique project GUIDs assigned. Then I would use "Add Existing Item" to copy items from similar projects if it made sense to do so.

我使用新项目向导创建一个新项目,以便分配唯一的项目GUID。然后我会使用“添加现有项目”来复制类似项目中的项目,如果这样做的话。

I sometimes use a file diff tool to copy references from one project to another, otherwise I just add the references by hand. A file diff tool can also be used to include similar source files, but the underlying files have to be copied anyway, so I prefer "Add Existing Item".

我有时使用文件差异工具将引用从一个项目复制到另一个项目,否则我只是手动添加引用。文件差异工具也可用于包含类似的源文件,但无论如何都必须复制底层文件,所以我更喜欢“添加现有项”。

I've used T4 to generate solution and project files, but that definitely seems like an edge case and not something that would normally be necessary. In that case, I'd probably wrap the T4 in a PowerShell like script to create and populate the rest of the directory structure.

我已经使用T4生成解决方案和项目文件,但这看起来似乎是一个边缘情况,而不是通常需要的东西。在这种情况下,我可能会将T4包装在类似PowerShell的脚本中,以创建和填充目录结构的其余部分。

I use "shared libraries" pretty aggressively in general, but not specifically due to this scenario.

我总体上非常积极地使用“共享库”,但不是特别由于这种情况。

In general, I don't find myself reusing plumbing between projects much. It's probably more often that I hack away in one "prototype" project, then abandon it, and rebuild the project from scratch following the above approach and only bring over the "non-hacky" code.

一般来说,我并没有发现自己在项目之间重复使用管道。我可能更经常地在一个“原型”项目中进行攻击,然后放弃它,并按照上述方法从头开始重建项目,并且只带来“非hacky”代码。

#6


1  

I'm creating a MVC2 application template at http://erictopia.com. It will contain all the basic items I think should be in a MVC project. These include BDD specifications, an ORM (NHibernate and possibly Lightspeed), T4 templates, custom providers, ELMAH support, CSS/Javascript minifier, etc.

我正在http://erictopia.com上创建一个MVC2应用程序模板。它将包含我认为应该在MVC项目中的所有基本项目。这些包括BDD规范,ORM(NHibernate和可能的Lightspeed),T4模板,自定义提供程序,ELMAH支持,CSS / Javascript minifier等。

#1


5  

Visual Studio supports Custom Templates.

Visual Studio支持自定义模板。

#2


3  

I definitely (mostly!) go for T4 templates in conjunction with a modified version of SubSonic 3. I kind of use the database to model my domain and then use the T4 templates to generate the model and associated controllers and views. It takes about 50-60% of the effort out and keeps a consistency in place.

我绝对(主要是!)与SubSonic 3的修改版本一起使用T4模板。我使用数据库来模拟我的域,然后使用T4模板生成模型以及相关的控制器和视图。它需要大约50-60%的努力并保持一致性。

I then work on overrides (partials) of the classes along with filters and extension methods to 'make the app'. Now that I'm familiar with the environment and what I'm doing, I can have a basic model with good plumbing in place in a very short space of time. More importantly, because I create a set of partial class files, I can regenerate all I want without losing any of my 'custom' coding.

然后我研究类的覆盖(部分)以及用于“制作应用程序”的过滤器和扩展方法。既然我熟悉环境和我正在做的事情,我可以在很短的时间内建立一个基本模型,并且管道很好。更重要的是,因为我创建了一组部分类文件,所以我可以重新生成我想要的所有文件而不会丢失任何“自定义”编码。

It works for me anyway :)

无论如何它对我有用:)

#3


2  

You could do it the bearded, t-shirted, agile style and create a nice template and put it in sourcecontrol. So when you need a new project, you just checkout the template?

你可以做胡子,T恤,敏捷的风格,并创建一个很好的模板,并把它放在sourcecontrol中。那么当你需要一个新项目时,你只需要结帐模板?

#4


2  

For insanely fast MVC site setup, I use modified T4 templates (created with T4 Editor) and with ALOT of help from Oleg Sych's blogs for page generation (for your typical add/edit/index pages) combined with an awesome implementation of an automated create-update-delete called MVCCrud (if LINQ-to-SQL is your preferred data access method)

对于疯狂快速的MVC站点设置,我使用修改后的T4模板(使用T4编辑器创建)和Oleg Sych博客的大量帮助,用于页面生成(针对典型的添加/编辑/索引页面)以及自动创建的强大实现-update-delete名为MVCCrud(如果LINQ-to-SQL是您首选的数据访问方法)

Using modified T4 templates and MVCCrud you can create fully functional entities (Create/Edit/List/Delete) with error handling and intuitive error messages in about 4 minutes for each.

使用修改后的T4模板和MVCCrud,您可以创建功能完整的实体(创建/编辑/列表/删除),每个实体具有错误处理和直观的错误消息,大约需要4分钟。

#5


1  

I create a new project using the new project wizard so that I get unique project GUIDs assigned. Then I would use "Add Existing Item" to copy items from similar projects if it made sense to do so.

我使用新项目向导创建一个新项目,以便分配唯一的项目GUID。然后我会使用“添加现有项目”来复制类似项目中的项目,如果这样做的话。

I sometimes use a file diff tool to copy references from one project to another, otherwise I just add the references by hand. A file diff tool can also be used to include similar source files, but the underlying files have to be copied anyway, so I prefer "Add Existing Item".

我有时使用文件差异工具将引用从一个项目复制到另一个项目,否则我只是手动添加引用。文件差异工具也可用于包含类似的源文件,但无论如何都必须复制底层文件,所以我更喜欢“添加现有项”。

I've used T4 to generate solution and project files, but that definitely seems like an edge case and not something that would normally be necessary. In that case, I'd probably wrap the T4 in a PowerShell like script to create and populate the rest of the directory structure.

我已经使用T4生成解决方案和项目文件,但这看起来似乎是一个边缘情况,而不是通常需要的东西。在这种情况下,我可能会将T4包装在类似PowerShell的脚本中,以创建和填充目录结构的其余部分。

I use "shared libraries" pretty aggressively in general, but not specifically due to this scenario.

我总体上非常积极地使用“共享库”,但不是特别由于这种情况。

In general, I don't find myself reusing plumbing between projects much. It's probably more often that I hack away in one "prototype" project, then abandon it, and rebuild the project from scratch following the above approach and only bring over the "non-hacky" code.

一般来说,我并没有发现自己在项目之间重复使用管道。我可能更经常地在一个“原型”项目中进行攻击,然后放弃它,并按照上述方法从头开始重建项目,并且只带来“非hacky”代码。

#6


1  

I'm creating a MVC2 application template at http://erictopia.com. It will contain all the basic items I think should be in a MVC project. These include BDD specifications, an ORM (NHibernate and possibly Lightspeed), T4 templates, custom providers, ELMAH support, CSS/Javascript minifier, etc.

我正在http://erictopia.com上创建一个MVC2应用程序模板。它将包含我认为应该在MVC项目中的所有基本项目。这些包括BDD规范,ORM(NHibernate和可能的Lightspeed),T4模板,自定义提供程序,ELMAH支持,CSS / Javascript minifier等。