、程序集:是 .NET Framework 应用程序的构造块;程序集构成了部署、版本控制、重复使用、激活范围控制和

安全权限的基本单元。
、程序集的优点:版本控制问题、最终解决DLL冲突
、程序集分为两种:强命名程序集和弱命名程序集。
、.NET Framework 为开发全球通用的应用程序提供了广泛的支持。在开发全球通用的应用程序时, 建议将此过程分为三个步骤:全球化、本地化分析和本地化。
()全球化是全球通用应用程序创建过程的第一步。在这一步中将编写应用程序的可执行代码。 一个真正的全球化应用程序应是非特定区域性和非特定语言的。因此,应集中精力创建能够支持适用于所有用户的 本地化用户界面和区域数据的应用程序。注意,尽管全球化应用程序具有这种灵活性,但全球化过程本身并不涉及用户界面的翻译。 相反,应致力于使创建的应用程序具有对来自应用程序所支持的所有区域性和地区的用户均有效的功能。
()在继续进行本地化之前,应执行中间检查以确定应用程序的 本地化分析。如果应用程序可本地化, 说明已正确地将应用程序的可执行代码同其资源分开。如果正确地评估了应用程序的可本地化性,在本地化期间就 不需要修改应用程序的源代码。
()生成全球通用的应用程序的最后一步是 本地化,在这一步中,需要针对特定的区域性或地区自定义应用程序。 如果已正确执行了全球化和本地化分析这两个步骤,则本地化主要包括用户界面的翻译。
、设计和开发全球通用的应用程序有以下几个优点:
()全球范围的收入。
()可以迅速添加对新区域性的支持。
()使用资源的效率更高。
、System.Globalization 命名空间包含定义区域性相关信息的类,这些信息包括语言、国家/地区、 使用的日历、日期、货币和数字的格式模式以及字符串的排序顺序。我们可以使用这些类编写全球化(国际化)应用程序。
、并行编程:许多个人计算机和工作站都有两个或四个内核(即 CPU),使多个线程能够同时执行。 在不久的将来,计算机预期会有更多的内核。 为了利用当今和未来的硬件,您可以对代码进行并行化,以将工作分摊在多个处理器上。 、特性、反射、泛型综合实例 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization.Formatters.Soap;
using System.IO;
using System.Security.Permissions;
using System.Reflection; namespace RefAtrr
{ [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Property, AllowMultiple = true, Inherited = true)] //Author属性只能用于类和结构,AllowMultiple是否允许多次用属性, Inherited是这个属性是滞延续到子类。
public class SqlTableAttribute : System.Attribute
{
private string name;
public SqlTableAttribute(string name)
{
this.name = name;
}
public string Name
{
get { return name; }
}
}
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Property, AllowMultiple = true, Inherited = true)] //Author属性只能用于类和结构,AllowMultiple是否允许多次用属性, Inherited是这个属性是滞延续到子类。
public class SqlFieldAttribute : System.Attribute
{
private string name;
Type fieldtype;
bool key; public SqlFieldAttribute(string name, Type fieldtype, bool key)
{
this.name = name;
this.fieldtype = fieldtype;
this.key = key;
}
public Type FieldType
{
get { return fieldtype; }
set { fieldtype = value; }
} public bool Key
{
get { return key; }
set { key = value; }
} public string Name
{
get { return name; }
}
}
interface IEntityTable
{
}
[SqlTable("StuUsers")]
class User : IEntityTable
{
[SqlField("ID", typeof(int), true)]
public int Number
{
get;
set;
}
[SqlField("StuNum", typeof(string), false)]
public string StuNumber
{
get;
set;
}
[SqlField("Passwd", typeof(string), false)]
public string Password
{
get;
set;
}
}
[SqlTable("Announcement")]
class AnnClass : IEntityTable
{
[SqlField("ID", typeof(int), true)]
public int Number
{
get;
set;
}
[SqlField("PubTitle", typeof(string), false)]
public string Title
{
get;
set;
}
[SqlField("PubCon", typeof(string), false)]
public string Conn
{
get;
set;
}
}
enum SqlType
{
Select,
Update,
Insert,
Delete
}
class Program
{
static void Main()
{
AnnClass ac = new AnnClass();
ac.Number = ;
ac.Title = "通知";
ac.Conn = "好好工作,天天上网"; User user = new User();
user.Number = ;
user.StuNumber = "";
user.Password = ""; //用接口实现
EntitHandle Eh = new EntitHandle();
Console.WriteLine(Eh.GreatSQL(user, SqlType.Insert));
Console.WriteLine("--------------------------------------------------");
Console.WriteLine(Eh.GreatSQL(ac, SqlType.Delete));
Console.WriteLine("--------------------------------------------------");
//用泛型实现
EntityHandle<IEntityTable> EhG = new EntityHandle<IEntityTable>();
Console.WriteLine(EhG.GreatSQL(ac, SqlType.Select ));
Console.WriteLine("--------------------------------------------------");
Console.WriteLine(EhG.GreatSQL(user, SqlType.Update ));
Console.WriteLine("--------------------------------------------------");
} } class EntitHandle
{
public string GreatSQL(IEntityTable EntityTable, SqlType sqltype)
{
Type usertype = EntityTable.GetType();
object[] ObjArr = usertype.GetCustomAttributes(true);
string tablename = ((SqlTableAttribute)ObjArr[]).Name;
PropertyInfo[] properties = usertype.GetProperties();
string SQL = "";
switch (sqltype)
{
case SqlType.Select:
SQL = Select(EntityTable, tablename, properties);
break;
case SqlType.Delete:
SQL = Delete(EntityTable, tablename, properties);
break;
case SqlType.Insert:
SQL = Insert(EntityTable, tablename, properties);
break;
case SqlType.Update:
SQL = Update(EntityTable, tablename, properties);
break;
}
return SQL; }
string Insert(IEntityTable EntityTable, string tablename, PropertyInfo[] properties)
{
string value = "";
foreach (PropertyInfo o in properties)
{
value += ((SqlFieldAttribute)o.GetCustomAttributes(true)[]).Name + "='" + o.GetValue(EntityTable, null).ToString() + "',";
}
value = value.TrimEnd(',');
string SQL = string.Format("insert into {0} values({1})", tablename, value);
return SQL;
}
string Update(IEntityTable EntityTable, string tablename, PropertyInfo[] properties)
{
string value = "";
string condition = "";
foreach (PropertyInfo o in properties)
{
SqlFieldAttribute sfa = (SqlFieldAttribute)o.GetCustomAttributes(false)[];
value += sfa.Name + "='" + o.GetValue(EntityTable, null).ToString() + "',";
if (sfa.Key)
{
string keyname = sfa.Name;
string keyvalue = o.GetValue(EntityTable, null).ToString();
condition = string.Format(" where {0}='{1}'", keyname, keyvalue);
}
}
value = value.TrimEnd(',') + condition;
string SQL = string.Format("update {0} set {1} ", tablename, value);
return SQL;
}
string Delete(IEntityTable EntityTable, string tablename, PropertyInfo[] properties)
{
string condition = "";
foreach (PropertyInfo o in properties)
{
SqlFieldAttribute sfa = (SqlFieldAttribute)o.GetCustomAttributes(false)[];
if (sfa.Key)
{
string keyname = sfa.Name;
string keyvalue = o.GetValue(EntityTable, null).ToString();
condition = string.Format(" where {0}='{1}'", keyname, keyvalue);
}
}
string SQL = string.Format("delete {0} where {1}", tablename, condition);
return SQL;
}
string Select(IEntityTable EntityTable, string tablename, PropertyInfo[] properties)
{
string value = "";
foreach (PropertyInfo o in properties)
{
value += ((SqlFieldAttribute)o.GetCustomAttributes(true)[]).Name + ",";
}
value = value.TrimEnd(',');
string SQL = string.Format("select {0} from {1}", value, tablename);
return SQL;
}
} class EntityHandle<T> where T : IEntityTable
{
public string GreatSQL(T EntityTable, SqlType sqltype)
{
Type usertype = EntityTable.GetType();
object[] ObjArr = usertype.GetCustomAttributes(true);
string tablename = ((SqlTableAttribute)ObjArr[]).Name;
PropertyInfo[] properties = usertype.GetProperties();
string SQL = "";
switch (sqltype)
{
case SqlType.Select:
SQL = Select(EntityTable, tablename, properties);
break;
case SqlType.Delete:
SQL = Delete(EntityTable, tablename, properties);
break;
case SqlType.Insert:
SQL = Insert(EntityTable, tablename, properties);
break;
case SqlType.Update:
SQL = Update(EntityTable, tablename, properties);
break;
}
return SQL;
}
string Insert(IEntityTable EntityTable, string tablename, PropertyInfo[] properties)
{
string value = "";
foreach (PropertyInfo o in properties)
{
value += ((SqlFieldAttribute)o.GetCustomAttributes(true)[]).Name + "='" + o.GetValue(EntityTable, null).ToString() + "',";
}
value = value.TrimEnd(',');
string SQL = string.Format("insert into {0} values({1})", tablename, value);
return SQL;
}
string Update(IEntityTable EntityTable, string tablename, PropertyInfo[] properties)
{
string value = "";
string condition = "";
foreach (PropertyInfo o in properties)
{
SqlFieldAttribute sfa = (SqlFieldAttribute)o.GetCustomAttributes(false)[];
value += sfa.Name + "='" + o.GetValue(EntityTable, null).ToString() + "',";
if (sfa.Key)
{
string keyname = sfa.Name;
string keyvalue = o.GetValue(EntityTable, null).ToString();
condition = string.Format(" where {0}='{1}'", keyname, keyvalue);
}
}
value = value.TrimEnd(',') + condition;
string SQL = string.Format("update {0} set {1} ", tablename, value);
return SQL;
}
string Delete(IEntityTable EntityTable, string tablename, PropertyInfo[] properties)
{
string condition = "";
foreach (PropertyInfo o in properties)
{
SqlFieldAttribute sfa = (SqlFieldAttribute)o.GetCustomAttributes(false)[];
if (sfa.Key)
{
string keyname = sfa.Name;
string keyvalue = o.GetValue(EntityTable, null).ToString();
condition = string.Format(" where {0}='{1}'", keyname, keyvalue);
}
}
string SQL = string.Format("delete {0} where {1}", tablename, condition);
return SQL;
}
string Select(IEntityTable EntityTable, string tablename, PropertyInfo[] properties)
{
string value = "";
foreach (PropertyInfo o in properties)
{
value += ((SqlFieldAttribute)o.GetCustomAttributes(true)[]).Name + ",";
}
value = value.TrimEnd(',');
string SQL = string.Format("select {0} from {1}", value, tablename);
return SQL;
}
}
}

本文出自 “大懒丫头” 博客,请务必保留此出处http://lanyatou.blog.51cto.com/3306130/633163

.NET Framework基础知识(五)(转载)的更多相关文章

  1. RabbitMQ基础知识(转载)

    RabbitMQ基础知识(转载) 一.背景 RabbitMQ是一个由erlang开发的AMQP(Advanced Message Queue )的开源实现.AMQP 的出现其实也是应了广大人民群众的需 ...

  2. .NET Framework基础知识总结

    之前给大家总结了java的面试几次技巧总结,同学们看了觉得还是不错,能够得到大家的认可,感觉还是挺不错的.现在又有同学来想小编索要.NET面试的总结了,好吧.谁让小编这么好呢!以下是.NET面试之框架 ...

  3. Python基础知识(五)------字典

    Python基础知识(四)------字典 字典 一丶什么是字典 ​ dict关键字 , 以 {} 表示, 以key:value形式保存数据 ,每个逗号分隔 ​ 键: 必须是可哈希,(不可变的数据类型 ...

  4. .NET Framework基础知识(四)(转载)

    .反射:是编程的读取与类型相关联的元数据的行为.通过读取元数据,可以了解它是什么类型以及类型的成员. 比如类中的属性,方法,事件等.所属命名空间System.Reflection. 例:using S ...

  5. .NET Framework基础知识(三)(转载)

    .正则表达式:用一串字符验证是否符合一种规范,这个规范就是正则表达式. .正则表达式中常用的元字符: . 匹配除换行符以外的任意字符 \w 匹配字母或数字或下划线或汉字 \s 匹配空白符 \d 匹配数 ...

  6. .NET Framework基础知识(二)(转载)

    1.课外:为什么object数组可以赋值给object类型,int数组却不能赋值给int类型? 答:因为不管是什么什么数组都继承自Array,而Array又继承自object. 2.线程:是操作系统分 ...

  7. Android学习之基础知识五—创建自定义控件

    下面是控件和布局的继承关系: 从上面我们看到: 1.所有控件都是直接或间接继承View,所有的布局都是直接或间接继承ViewGroup 2.View是Android中最基本的UI组件,各种组件其实就是 ...

  8. APP开发基础知识(转载)

    来源:https://www.cnblogs.com/wangsea/p/9413672.html 本文针对小白用户对App做一个简单的介绍,首先要了解App都有哪些类型,不同的类型适用于哪些需求,用 ...

  9. MySQL系列(一)--基础知识(转载)

    安装就不说了,网上多得是,我的MySQL是8.0版本,可以参考:CentOS7安装MySQL8.0图文教程和MySQL8.0本地访问设置为远程访问权限 我的MySQL安装在阿里云上面,阿里云向外暴露端 ...

随机推荐

  1. ubuntu-虚拟机分辨率设定

    前两天下载的虚拟机,一直调节不好分辨率,就是说,全屏的时候,虚拟机要么是不能充满屏幕,要么就是在屏幕充满的时候,会出现显示不全,需要滚动条,给人的体验非常的不好.自己调节了好长时间都没有刚好合适的尺寸 ...

  2. android中图片倒影、圆角效果重绘

    本文用来记录一些Android 操作图片的方法,方便查看. 1.将Drawable转化为Bitmap public static Bitmap drawableToBitmap(Drawable dr ...

  3. js---BOM 的理解方法

    windows 方法 window.close(); //关闭窗口   window.alert("message"); //弹出一个具有OK按钮的系统消息框,显示指定的文本   ...

  4. Docker 内程序时间设置,很重要

    原文:Docker 内程序时间设置,很重要 重要!!!!! 创建容器时候需要修改一个参数,设置tomcat的时区 -e TZ="Asia/Shanghai" -v /etc/loc ...

  5. 洛谷 P1223 排队接水

    洛谷 P1223 排队接水 题目描述 有n个人在一个水龙头前排队接水,假如每个人接水的时间为Ti,请编程找出这n个人排队的一种顺序,使得n个人的平均等待时间最小. 输入输出格式 输入格式: 输入文件共 ...

  6. HDU——T 3579 Hello Kiki

    http://acm.hdu.edu.cn/showproblem.php?pid=3579 Time Limit: 2000/1000 MS (Java/Others)    Memory Limi ...

  7. Apple Watch 集成环信SDK

    本文简单的讲述下怎样用Apple Watch Kit集成环信SDK. 升级xcode到version 6.2,和 IOS SDK8.2 下载环信SDK从官网 打开XCode->new proje ...

  8. RocketMQ(九):消息发送(续)

    匠心零度 转载请注明原创出处,谢谢! RocketMQ网络部署图 NameServer:在系统中是做命名服务,更新和发现 broker服务. Broker-Master:broker 消息主机服务器. ...

  9. 【例题 7-4 UVA - 524】Prime Ring Problem

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 预处理出所有的答案. 打表输出. [代码] import java.util.ArrayList; import java.util ...

  10. [Angular] Stagger animation v4.3.3

    For example, when we open a form, we want to see all the inputs fields comes into one by one. Code f ...