、程序集:是 .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. Android学习笔记技巧之给文本加边框

    BorderTextViews.Java package xiaosi.BorderTextView; import android.content.Context; import android.g ...

  2. 最优子结构(Optimal Substructure)

    最优子结构的存在是应用动态规划的前提(或者说必要条件),由此可以避免重复计算: 1. 图算法 最短路径的子路径也一定是最短的: 简单地反证,如果最短路径的中间两点,之间的路径不是最短路径的话,那么一定 ...

  3. 71.sscanf数据挖掘

    数据挖掘 sscanf(str, "%d %s %s %d %d %s %s %s", &ph[i].id, ph[i].name, ph[i].sex, &ph[ ...

  4. 洛谷 P1054 等价表达式

    洛谷 P1054 等价表达式 题目描述 明明进了中学之后,学到了代数表达式.有一天,他碰到一个很麻烦的选择题.这个题目的题干中首先给出了一个代数表达式,然后列出了若干选项,每个选项也是一个代数表达式, ...

  5. Ten ways to improve the performance of large tables in MySQL--转载

    原文地址:http://www.tocker.ca/2013/10/24/improving-the-performance-of-large-tables-in-mysql.html Today I ...

  6. [Android 4.4.2] 泛泰A870 Mokee4.4.2 20140531 RC1.0 by syhost

    欢迎关注泛泰非盈利专业第三方开发团队 VegaDevTeam  (本team 由 syhost suky zhaochengw(z大) xuefy(大星星) tenfar(R大师) loogeo cr ...

  7. amazeui学习笔记--js插件(UI增强3)--折叠面板Collapse

    amazeui学习笔记--js插件(UI增强3)--折叠面板Collapse 一.总结 注意点: 1.data-am-collapse:这个东西就是展开折叠事件 2.am-collapse(包括其下属 ...

  8. 源码笔记---MBProgressHUD

    前言 作为初学者,想要快速提高自己的水平,阅读一些优秀的第三方源代码是一个非常好的途径.通过看别人的代码,可以学习不一样的编程思路,了解一些没有接触过的类和方法. MBProgressHUD是一个非常 ...

  9. 【redis,1】java操作redis: 将string、list、map、自己定义的对象保存到redis中

    一.操作string .list .map 对象 1.引入jar: jedis-2.1.0.jar   2.代码 /**      * @param args      */     public s ...

  10. 【重拾Effective Java】一

    之前看这本<Effective Java(第二版)>都是非常早曾经了.这本书确实是本好书.须要细嚼慢咽,每次看都有不同的体验. 在此写博客巩固一下. 第一章.创建和销毁对象 考虑用静态工厂 ...