您的位置:首页 > 编程语言

通过代码生成机制实现强类型编程-CodeSimth版

2010-09-25 09:23 513 查看
一直想写一个Code生成系列,但写到CodeSimth,发觉在TerryLee努力学习的小熊 两位大牛的博客里讲很详尽,所以就像写些示例方面的,但是苦于没有想到写些什么。最近Artech写了两篇从数据到代码——通过代码生成机制实现强类型编程--上篇和下篇,大牛写得是CodeDom的,今天我就想借借大牛的示例写个CodeSimth版的,希望Artech不要怪我,呵呵。我的Code生成技术已经写了CodeDom的见CodeDom系列目录,欢迎各位园友指教。

好直接到主题。首先是数据实体MessageEntry(我到老A的基础上添加了description属性作为代码字段描述):

代码

1 //Copyright (C) Wolf. All rights reserved.
2 using Wolf;
3 using System;
4 using System.Collections.Generic;
5 namespace Wolf.Message
6 {
7 public class Messages
8 {
9 public class Validation
10 {
11
12 /// <summary>
13 ///description
14 /// </summary>
15 public static Wolf.MessageEntry MandatoryField = new MessageEntry("MandatoryField",
16
17 "The {0} is mandatory.", "The {0} is mandatory.");
18
19 /// <summary>
20 ///description
21 /// </summary>
22 public static Wolf.MessageEntry GreaterThan = new MessageEntry("GreaterThan",
23
24 "The {0} must be greater than {1}.", "The {0} must be greater than {1}.");
25
26 }
27
28 public class Confirmation
29 {
30
31 /// <summary>
32 ///description
33 /// </summary>
34 public static Wolf.MessageEntry ReallyDelete = new MessageEntry("ReallyDelete",
35
36 "Do you really want to delete the {0}.", "Do you really want to delete the {0}.");
37
38 }
39
40 }
41 }
42
43

ok,全部完成。同时你也可以完全集成与VS中利用VSX Vs扩展,可以参考明年我18 的VSX系列
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐