、程序集:是 .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. TCP/IP图解学习总结(二)

    注意:这里的第n层是依照OSI协议来的 I   网桥--2层交换机.数据链路层面上链接两个网络的设备.它可以识别数据链路层中的数据帧. II  路由器-3层交换机.网络层面上连接两个网络,并对分组报文 ...

  2. absolute、relative,toggle()

    測试代码例如以下: <div> <div class="global">不应用样式</div> <div class="glob ...

  3. JavaScript全讲-架构原则解析

    因为近期一直在忙,非常久没有更新,见谅. 上篇我们讲完JavaScript函数式编程的特性,今天我们就来聊聊JavaScript中的架构. 提到JavaScript架构.非常多人会认为不可思议,由于架 ...

  4. golang标准包中文手册

    golang标准包中文手册 http://files.cnblogs.com/files/rojas/liudiwu-pkgdoc-master.zip

  5. winform程序,备份数据库+并压缩+并删除以前的备份

    说明:为了定时备份服务器上的数据库并压缩到指定目录,方便下载到本地而写本程序.配合windows的任务计划,可以达到定时备份数据库的目的. 程序需引用SQLDMO.DLL,如电脑上已安装sqlserv ...

  6. win7桌面有个无法删除的IE图标

    平台:win7 症状:安装软件时没仔细看,结果装上了一大堆,挨个卸载后桌面残留了一个IE无法删除.在该图标上点右键只有“打开”“属性”“创建快捷方式”三个选项,主页默认为www.2345.com. 解 ...

  7. react取消监听scroll事件

    如果要移除事件addEventListener的执行函数必须使用外部函数而不能直接使用匿名函数 错误写法: // 这样写是移除不了滚动事件的 componentDidMount() { // 添加滚动 ...

  8. import 与export详解

    ES6 1.export default 其他模块加载该模块时,import命令可以为该匿名函数指定任意名字. 如: import Vue from 'vue' vue里面的第三方模块都是用了这个 使 ...

  9. Centos7安装.Net Core 2.2环境以及部署.Net Core MVC程序(Apache+Jexus环境)

    原文:Centos7安装.Net Core 2.2环境以及部署.Net Core MVC程序(Apache+Jexus环境) 1.双11抢购***VPS.配置如下: CPU:2 核 内存:2048 M ...

  10. Maven学习总结(18)——深入理解Maven仓库

    一.本地仓库(Local Repository) 本地仓库就是一个本机的目录,这个目录被用来存储我们项目的所有依赖(插件的jar包还有一些其他的文件),简单的说,当你build一个Maven项目的时候 ...