当前位置: 首页 > news >正文

html5网站源代码/网站优化公司上海

html5网站源代码,网站优化公司上海,wordpress时间差8小时,企业网站建设标准最近自己写了个ORM框架,里面用到的 属性和字段的特性装饰定义Attribute装饰类、实体类、字段结构体:View Code [AttributeUsage(AttributeTargets.Property)] //此属性只能用在Property上 public class CyAttribute : Attribute{private string _dataty…
最近自己写了个ORM框架,里面用到的 属性和字段的特性装饰
定义Attribute装饰类、实体类、字段结构体:
View Code
    [AttributeUsage(AttributeTargets.Property)] //此属性只能用在Property上 public class CyAttribute : Attribute{private string _datatype = string.Empty;private int _length = 0;public CyAttribute(string datatype, int length){_datatype = datatype;_length = length;}public string DataType{get { return _datatype; }set { _datatype = value; }}public int Length{get { return _length; }set { _length = value; }}}[AttributeUsage(AttributeTargets.Field)] //此属性只能用在Field上 public class CyAttributeField : Attribute{private string _datatype = string.Empty;private int _length = 0;public CyAttributeField(string datatype, int length){_datatype = datatype;_length = length;}public string DataType{get { return _datatype; }set { _datatype = value; }}public int Length{get { return _length; }set { _length = value; }}} [AttributeUsage(AttributeTargets.Field)] //此属性只能用在Field上 public class CyAttribute2 : Attribute{private string _op = string.Empty;public CyAttribute2(string op){_op = op;}public string Name{get { return _op; }set { _op = value; }}}/// <summary>/// 用户表实体类/// </summary>public class Users{[CyAttribute("System.String", 50)]public string Uname { get; set; }[CyAttribute("System.String", 20)]public string Pswd { get; set; }[CyAttribute("System.Int32", 4)]public int Age { get; set; }}/// <summary>///常量字段/// </summary>public struct Plat{[CyAttributeField("System.String", 89)]public const string FirstName = "FirstName";[CyAttributeField("System.Int32", 6), CyAttribute2("hahaha")]public const string Age = "Age";}
调用属性、字段 Attribute的方法:
View Cod
public void Test(){Type typetField = typeof(Plat);System.Reflection.FieldInfo finfo = typetField.GetField("Age");Attribute at1 = finfo.GetCustomAttributes(true)[0] as Attribute;foreach (Attribute at in finfo.GetCustomAttributes(true)){CyAttributeField att = at as CyAttributeField;if (att != null){string dataType = att.DataType;//字段数据类型int dataLen = att.Length;//字段数据长度
                }}foreach (System.Reflection.FieldInfo fieldInfo in typetField.GetFields()){foreach (Attribute at in fieldInfo.GetCustomAttributes(true)){CyAttributeField att = at as CyAttributeField;if (att != null){string dataType = att.DataType;//字段数据类型int dataLen = att.Length;//字段数据长度continue;} CyAttribute2 att2 = at as CyAttribute2;if (att2 != null){string name2 = att2.Name; ;//字段描述 continue;}}}Users user = new Users();user.Uname = "曹永思";user.Pswd = "123456";user.Age = 24;List<string> userInfo = new List<string>();Type typeProperty = typeof(Users);foreach (System.Reflection.PropertyInfo propertyInfo in typeProperty.GetProperties()){foreach (Attribute at in propertyInfo.GetCustomAttributes(true)){CyAttribute att = at as CyAttribute;if (att != null){userInfo.Add(propertyInfo.Name + "+" + att.DataType + "+" + att.Length + "+" + att.TypeId);}}}}

 //code by:博客园-曹永思

 欢迎转载,转载请注明出处,希望帮到更多人。

.net URL重写例子

 

转载于:https://www.cnblogs.com/yonsy/archive/2013/01/19/Attribute.html

http://www.jmfq.cn/news/4944349.html

相关文章:

  • 征婚网站做原油/谷歌推广平台
  • dede网站模板安装/竞价恶意点击犯法吗
  • 网站用户体验优化方案/最有效的免费推广方法
  • 做购物类网站有哪些/医疗器械龙头股
  • 网页设计与网站建设案例教程/宁波seo基础入门
  • 设计师招聘网站有哪些/怎样制作一个自己的网站
  • 推广网站怎么建/seo优化主要工作内容
  • 珠海网站推广/郑州网络营销公司哪个好
  • 网站建设方案案例/网络营销策划方案800字
  • 网站建设长春/百度学术官网论文查重免费
  • 南昌企业做网站设计/hao123网址导航
  • 国内建网站流程/各大搜索引擎提交入口
  • 做机械的外贸网站/长沙百度关键词排名
  • 网站开发需要准备什么/网络营销推广系统
  • 公司网站建设技术/seo产品推广
  • 广东品牌网站建设平台/搜索引擎网站
  • vue.js 可以做网站吗/如何做好网络营销管理
  • 网站建站公司排名/搜狗网
  • 平台网站的建设需求/做网站设计的公司
  • 阿里服务器怎么做网站服务器吗/高级搜索
  • 网站的功能建设/龙岗网站推广
  • 珠海营销网站建设/个人网站推广
  • 组织建设是什么/网站seo排名培训
  • 车机油哪个网站做的好/it培训班
  • 长沙网上商城网站建设方案/百度数据分析工具
  • 成都 网站建设 公司/全球网站流量排名查询
  • 广西网络网站建设/推广资源网
  • 广州疫情最新动态知乎/企业站seo外包
  • 如何建设移动端网站/网站建设方案开发
  • 单页网站模板做seo/宁波 seo排名公司