生成具有特定领域编程C#类库项目 [英] Generate C# Class Library project programatically with given fields

查看:218
本文介绍了生成具有特定领域编程C#类库项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个模块,从给定的数据库列,其中将包括资讯类,DataProvider类,每个有自己的cs文件contorller类生成类库项目。我现在做的是创造信息,供应商和控制器类。

I am trying to create a module that will generate class library project from given database columns that will include info class,dataprovider class and contorller class each having their own .cs file. What i have done now is that create info,provider and controller class.

我已经研究以编程方式创建类库项目,但仍然没有太大的成功。我想要做的就是编程方式创建一个类库项目,并谨编译库项目到项目folder.After这些文件和生成的dll文件并移至该网站的bin文件夹。

I have researched to create class library project programatically but still not much success..What i want to do is create a class library project programatically and move those files to the project folder.After that compile the library project and generate dll file and move that to bin folder of website.

任何人都可以请点我正确的方向,或提供一些有用的资源,这样我可以用它来解决我的问题。

Can anyone please point me to the right direction or give some useful resources so that i can use that to solve my problem.

推荐答案

我已经使用了T4模板,它是同类型的code一代非常有用的。我们可以有XML配置(类和属性),然后自动我们能为他们创造类。它们是有用的,因为相同的结构可以用于数据库层,映射属性到数据库字段等等,以便后端的层可以实现自动化。

I have used the T4 template and it is very useful for same type of code generation. We can have XML for configuration (class and properties) and then automatically we can create classes for them. They are useful since the same configuration can be used for database layer, mapping properties to database fields etc. so your back-end layers can be automated.

请注意:所有的类都应该有共同的设计。另外,还要类部分,这样你可以随时将它添加更多的功能。

Note: All classes should have common design. Also make class as partial so that you can always add more functionality to it.

这篇关于生成具有特定领域编程C#类库项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆