在通过T4模版引擎之基础入门 对T4有了初步印象后,我们开始实战篇。T4模板引擎可以当做一个代码生成器,代码生成器的职责当然是用来生成代码(这不是废话吗)。而这其中我们使用的最普遍的是根据数据库生成实体类。

  工欲善其事必先利其器,在这之前先来介绍一款T4编辑器T4 Editor,我们可以点击链接去下载然后安装,不过还是推荐大家直接在VS扩展管理器里直接安装来的方便 工具->扩展管理器->联机库 搜索 "T4 Editor",选择第一项 "tangible T4 Editor 2.0 plus modeling tools for VS2010" 进行安装即可,如下图所示:

安装上T4 Editor后,编辑T4模板是就有代码着色和智能提示了,下图为安装T4 Editor后的代码着色效果,怎么样是不是耳目一新,呵呵

 

接下来开始正式进入我们的主题,从数据库自动生成实体类

  1. 新建一个控制台项目,然后添加T4模板,这里我们起名字为Customers.tt

  2. 修改输出文件扩展名为.cs
    1. <#@ output extension=".cs" #>
  3. 添加常用的程序集和命名空间引用
    1. <#@ assembly name="System.Core.dll" #>
    2. <#@ assembly name="System.Data.dll" #>
    3. <#@ assembly name="System.Data.DataSetExtensions.dll" #>
    4. <#@ assembly name="System.Xml.dll" #>
    5. <#@ import namespace="System" #>
    6. <#@ import namespace="System.Xml" #>
    7. <#@ import namespace="System.Linq" #>
    8. <#@ import namespace="System.Data" #>
    9. <#@ import namespace="System.Data.SqlClient" #>
    10. <#@ import namespace="System.Collections.Generic" #>
    11. <#@ import namespace="System.IO" #>
  4. 添加数据库操作DbHelper引用
    DbHelper.ttinclude
    1. <#+
    2. public class DbHelper
    3. {
    4. #region GetDbTables
    5.  
    6. public static List<DbTable> GetDbTables(string connectionString, string database, string tables = null)
    7. {
    8.  
    9. if (!string.IsNullOrEmpty(tables))
    10. {
    11. tables = string.Format(" and obj.name in ('{0}')", tables.Replace(",", "','"));
    12. }
    13. #region SQL
    14. string sql = string.Format(@"SELECT
    15. obj.name tablename,
    16. schem.name schemname,
    17. idx.rows,
    18. CAST
    19. (
    20. CASE
    21. WHEN (SELECT COUNT(1) FROM sys.indexes WHERE object_id= obj.OBJECT_ID AND is_primary_key=1) >=1 THEN 1
    22. ELSE 0
    23. END
    24. AS BIT) HasPrimaryKey
    25. from {0}.sys.objects obj
    26. inner join {0}.dbo.sysindexes idx on obj.object_id=idx.id and idx.indid<=1
    27. INNER JOIN {0}.sys.schemas schem ON obj.schema_id=schem.schema_id
    28. where type='U' {1}
    29. order by obj.name", database, tables);
    30. #endregion
    31. DataTable dt = GetDataTable(connectionString, sql);
    32. return dt.Rows.Cast<DataRow>().Select(row => new DbTable
    33. {
    34. TableName = row.Field<string>("tablename"),
    35. SchemaName = row.Field<string>("schemname"),
    36. Rows = row.Field<int>("rows"),
    37. HasPrimaryKey = row.Field<bool>("HasPrimaryKey")
    38. }).ToList();
    39. }
    40. #endregion
    41.  
    42. #region GetDbColumns
    43.  
    44. public static List<DbColumn> GetDbColumns(string connectionString, string database, string tableName, string schema = "dbo")
    45. {
    46. #region SQL
    47. string sql = string.Format(@"
    48. WITH indexCTE AS
    49. (
    50. SELECT
    51. ic.column_id,
    52. ic.index_column_id,
    53. ic.object_id
    54. FROM {0}.sys.indexes idx
    55. INNER JOIN {0}.sys.index_columns ic ON idx.index_id = ic.index_id AND idx.object_id = ic.object_id
    56. WHERE idx.object_id =OBJECT_ID(@tableName) AND idx.is_primary_key=1
    57. )
    58. select
    59. colm.column_id ColumnID,
    60. CAST(CASE WHEN indexCTE.column_id IS NULL THEN 0 ELSE 1 END AS BIT) IsPrimaryKey,
    61. colm.name ColumnName,
    62. systype.name ColumnType,
    63. colm.is_identity IsIdentity,
    64. colm.is_nullable IsNullable,
    65. cast(colm.max_length as int) ByteLength,
    66. (
    67. case
    68. when systype.name='nvarchar' and colm.max_length>0 then colm.max_length/2
    69. when systype.name='nchar' and colm.max_length>0 then colm.max_length/2
    70. when systype.name='ntext' and colm.max_length>0 then colm.max_length/2
    71. else colm.max_length
    72. end
    73. ) CharLength,
    74. cast(colm.precision as int) Precision,
    75. cast(colm.scale as int) Scale,
    76. prop.value Remark
    77. from {0}.sys.columns colm
    78. inner join {0}.sys.types systype on colm.system_type_id=systype.system_type_id and colm.user_type_id=systype.user_type_id
    79. left join {0}.sys.extended_properties prop on colm.object_id=prop.major_id and colm.column_id=prop.minor_id
    80. LEFT JOIN indexCTE ON colm.column_id=indexCTE.column_id AND colm.object_id=indexCTE.object_id
    81. where colm.object_id=OBJECT_ID(@tableName)
    82. order by colm.column_id", database);
    83. #endregion
    84. SqlParameter param = new SqlParameter("@tableName", SqlDbType.NVarChar, 100) { Value = string.Format("{0}.{1}.{2}", database, schema, tableName) };
    85. DataTable dt = GetDataTable(connectionString, sql, param);
    86. return dt.Rows.Cast<DataRow>().Select(row => new DbColumn()
    87. {
    88. ColumnID = row.Field<int>("ColumnID"),
    89. IsPrimaryKey = row.Field<bool>("IsPrimaryKey"),
    90. ColumnName = row.Field<string>("ColumnName"),
    91. ColumnType = row.Field<string>("ColumnType"),
    92. IsIdentity = row.Field<bool>("IsIdentity"),
    93. IsNullable = row.Field<bool>("IsNullable"),
    94. ByteLength = row.Field<int>("ByteLength"),
    95. CharLength = row.Field<int>("CharLength"),
    96. Scale = row.Field<int>("Scale"),
    97. Remark = row["Remark"].ToString()
    98. }).ToList();
    99. }
    100.  
    101. #endregion
    102.  
    103. #region GetDataTable
    104.  
    105. public static DataTable GetDataTable(string connectionString, string commandText, params SqlParameter[] parms)
    106. {
    107. using (SqlConnection connection = new SqlConnection(connectionString))
    108. {
    109. SqlCommand command = connection.CreateCommand();
    110. command.CommandText = commandText;
    111. command.Parameters.AddRange(parms);
    112. SqlDataAdapter adapter = new SqlDataAdapter(command);
    113.  
    114. DataTable dt = new DataTable();
    115. adapter.Fill(dt);
    116.  
    117. return dt;
    118. }
    119. }
    120.  
    121. #endregion
    122. }
    123.  
    124. #region DbTable
    125. /// <summary>
    126. /// 表结构
    127. /// </summary>
    128. public sealed class DbTable
    129. {
    130. /// <summary>
    131. /// 表名称
    132. /// </summary>
    133. public string TableName { get; set; }
    134. /// <summary>
    135. /// 表的架构
    136. /// </summary>
    137. public string SchemaName { get; set; }
    138. /// <summary>
    139. /// 表的记录数
    140. /// </summary>
    141. public int Rows { get; set; }
    142.  
    143. /// <summary>
    144. /// 是否含有主键
    145. /// </summary>
    146. public bool HasPrimaryKey { get; set; }
    147. }
    148. #endregion
    149.  
    150. #region DbColumn
    151. /// <summary>
    152. /// 表字段结构
    153. /// </summary>
    154. public sealed class DbColumn
    155. {
    156. /// <summary>
    157. /// 字段ID
    158. /// </summary>
    159. public int ColumnID { get; set; }
    160.  
    161. /// <summary>
    162. /// 是否主键
    163. /// </summary>
    164. public bool IsPrimaryKey { get; set; }
    165.  
    166. /// <summary>
    167. /// 字段名称
    168. /// </summary>
    169. public string ColumnName { get; set; }
    170.  
    171. /// <summary>
    172. /// 字段类型
    173. /// </summary>
    174. public string ColumnType { get; set; }
    175.  
    176. /// <summary>
    177. /// 数据库类型对应的C#类型
    178. /// </summary>
    179. public string CSharpType
    180. {
    181. get
    182. {
    183. return SqlServerDbTypeMap.MapCsharpType(ColumnType);
    184. }
    185. }
    186.  
    187. /// <summary>
    188. ///
    189. /// </summary>
    190. public Type CommonType
    191. {
    192. get
    193. {
    194. return SqlServerDbTypeMap.MapCommonType(ColumnType);
    195. }
    196. }
    197.  
    198. /// <summary>
    199. /// 字节长度
    200. /// </summary>
    201. public int ByteLength { get; set; }
    202.  
    203. /// <summary>
    204. /// 字符长度
    205. /// </summary>
    206. public int CharLength { get; set; }
    207.  
    208. /// <summary>
    209. /// 小数位
    210. /// </summary>
    211. public int Scale { get; set; }
    212.  
    213. /// <summary>
    214. /// 是否自增列
    215. /// </summary>
    216. public bool IsIdentity { get; set; }
    217.  
    218. /// <summary>
    219. /// 是否允许空
    220. /// </summary>
    221. public bool IsNullable { get; set; }
    222.  
    223. /// <summary>
    224. /// 描述
    225. /// </summary>
    226. public string Remark { get; set; }
    227. }
    228. #endregion
    229.  
    230. #region SqlServerDbTypeMap
    231.  
    232. public class SqlServerDbTypeMap
    233. {
    234. public static string MapCsharpType(string dbtype)
    235. {
    236. if (string.IsNullOrEmpty(dbtype)) return dbtype;
    237. dbtype = dbtype.ToLower();
    238. string csharpType = "object";
    239. switch (dbtype)
    240. {
    241. case "bigint": csharpType = "long"; break;
    242. case "binary": csharpType = "byte[]"; break;
    243. case "bit": csharpType = "bool"; break;
    244. case "char": csharpType = "string"; break;
    245. case "date": csharpType = "DateTime"; break;
    246. case "datetime": csharpType = "DateTime"; break;
    247. case "datetime2": csharpType = "DateTime"; break;
    248. case "datetimeoffset": csharpType = "DateTimeOffset"; break;
    249. case "decimal": csharpType = "decimal"; break;
    250. case "float": csharpType = "double"; break;
    251. case "image": csharpType = "byte[]"; break;
    252. case "int": csharpType = "int"; break;
    253. case "money": csharpType = "decimal"; break;
    254. case "nchar": csharpType = "string"; break;
    255. case "ntext": csharpType = "string"; break;
    256. case "numeric": csharpType = "decimal"; break;
    257. case "nvarchar": csharpType = "string"; break;
    258. case "real": csharpType = "Single"; break;
    259. case "smalldatetime": csharpType = "DateTime"; break;
    260. case "smallint": csharpType = "short"; break;
    261. case "smallmoney": csharpType = "decimal"; break;
    262. case "sql_variant": csharpType = "object"; break;
    263. case "sysname": csharpType = "object"; break;
    264. case "text": csharpType = "string"; break;
    265. case "time": csharpType = "TimeSpan"; break;
    266. case "timestamp": csharpType = "byte[]"; break;
    267. case "tinyint": csharpType = "byte"; break;
    268. case "uniqueidentifier": csharpType = "Guid"; break;
    269. case "varbinary": csharpType = "byte[]"; break;
    270. case "varchar": csharpType = "string"; break;
    271. case "xml": csharpType = "string"; break;
    272. default: csharpType = "object"; break;
    273. }
    274. return csharpType;
    275. }
    276.  
    277. public static Type MapCommonType(string dbtype)
    278. {
    279. if (string.IsNullOrEmpty(dbtype)) return Type.Missing.GetType();
    280. dbtype = dbtype.ToLower();
    281. Type commonType = typeof(object);
    282. switch (dbtype)
    283. {
    284. case "bigint": commonType = typeof(long); break;
    285. case "binary": commonType = typeof(byte[]); break;
    286. case "bit": commonType = typeof(bool); break;
    287. case "char": commonType = typeof(string); break;
    288. case "date": commonType = typeof(DateTime); break;
    289. case "datetime": commonType = typeof(DateTime); break;
    290. case "datetime2": commonType = typeof(DateTime); break;
    291. case "datetimeoffset": commonType = typeof(DateTimeOffset); break;
    292. case "decimal": commonType = typeof(decimal); break;
    293. case "float": commonType = typeof(double); break;
    294. case "image": commonType = typeof(byte[]); break;
    295. case "int": commonType = typeof(int); break;
    296. case "money": commonType = typeof(decimal); break;
    297. case "nchar": commonType = typeof(string); break;
    298. case "ntext": commonType = typeof(string); break;
    299. case "numeric": commonType = typeof(decimal); break;
    300. case "nvarchar": commonType = typeof(string); break;
    301. case "real": commonType = typeof(Single); break;
    302. case "smalldatetime": commonType = typeof(DateTime); break;
    303. case "smallint": commonType = typeof(short); break;
    304. case "smallmoney": commonType = typeof(decimal); break;
    305. case "sql_variant": commonType = typeof(object); break;
    306. case "sysname": commonType = typeof(object); break;
    307. case "text": commonType = typeof(string); break;
    308. case "time": commonType = typeof(TimeSpan); break;
    309. case "timestamp": commonType = typeof(byte[]); break;
    310. case "tinyint": commonType = typeof(byte); break;
    311. case "uniqueidentifier": commonType = typeof(Guid); break;
    312. case "varbinary": commonType = typeof(byte[]); break;
    313. case "varchar": commonType = typeof(string); break;
    314. case "xml": commonType = typeof(string); break;
    315. default: commonType = typeof(object); break;
    316. }
    317. return commonType;
    318. }
    319. }
    320. #endregion
    321.  
    322. #>
    1. <#@ include file="$(ProjectDir)DbHelper.ttinclude" #>

    DbHelper相对比较复杂,把一些常用操作进行了简单封装,因此放到一个单独的文件里面进行引用,可以方便的进行复用,这里DbHelper的后缀名使用ttinclude,这里的后缀名可以随便起,按照微软的建议:用于include的文件尽量不要使用.tt做后缀名

  5. 在页面底部定义一些常用变量,以方便操作
    1. <#+
    2. public class config
    3. {
    4. public static readonly string ConnectionString="Data Source=(local);Integrated Security=true;Initial Catalog=Northwind;";
    5. public static readonly string DbDatabase="Northwind";
    6. public static readonly string TableName="Customers";
    7. }
    8. #>

    这里我们把数据库连接串和数据库、表名字定义一下,方便修改和使用

  6. 最后来编写用于实体类生成的代码
    1. //------------------------------------------------------------------------------
    2. // <auto-generated>
    3. // 此代码由T4模板自动生成
    4. // 生成时间 <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#> by 懒惰的肥兔
    5. // 对此文件的更改可能会导致不正确的行为,并且如果
    6. // 重新生成代码,这些更改将会丢失。
    7. // </auto-generated>
    8. //------------------------------------------------------------------------------
    9.  
    10. using System;
    11. namespace T4ConsoleApplication.Entities
    12. {
    13.  
    14. public class <#=config.TableName#>
    15. {
    16. <# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, config.TableName)){#>
    17.  
    18. /// <summary>
    19. /// <#=column.Remark#>
    20. /// </summary>
    21. public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
    22. <#}#>
    23.  
    24. }
    25. }
  7. 全部完成后我们的Customers.tt文件就编写好了
    Customers.tt
    1. <#@ template debug="false" hostspecific="false" language="C#" #>
    2. <#@ output extension=".cs" #>
    3. <#@ assembly name="System.Core.dll" #>
    4. <#@ assembly name="System.Data.dll" #>
    5. <#@ assembly name="System.Data.DataSetExtensions.dll" #>
    6. <#@ assembly name="System.Xml.dll" #>
    7. <#@ import namespace="System" #>
    8. <#@ import namespace="System.Xml" #>
    9. <#@ import namespace="System.Linq" #>
    10. <#@ import namespace="System.Data" #>
    11. <#@ import namespace="System.Data.SqlClient" #>
    12. <#@ import namespace="System.Collections.Generic" #>
    13. <#@ import namespace="System.IO" #>
    14. <#@ include file="$(ProjectDir)DbHelper.ttinclude" #>
    15. //------------------------------------------------------------------------------
    16. // <auto-generated>
    17. // 此代码由T4模板自动生成
    18. // 生成时间 <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#> by 懒惰的肥兔
    19. // 对此文件的更改可能会导致不正确的行为,并且如果
    20. // 重新生成代码,这些更改将会丢失。
    21. // </auto-generated>
    22. //------------------------------------------------------------------------------
    23.  
    24. using System;
    25. namespace T4ConsoleApplication.Entities
    26. {
    27.  
    28. public class <#=config.TableName#>
    29. {
    30. <# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, config.TableName)){#>
    31.  
    32. /// <summary>
    33. /// <#=column.Remark#>
    34. /// </summary>
    35. public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
    36. <#}#>
    37.  
    38. }
    39. }
    40.  
    41. <#+
    42. public class config
    43. {
    44. public static readonly string ConnectionString="Data Source=(local);Integrated Security=true;Initial Catalog=Northwind;";
    45. public static readonly string DbDatabase="Northwind";
    46. public static readonly string TableName="Customers";
    47. }
    48. #>

    进行保存后会自动生成Customers.cs文件

    Customers.cs
    1. //------------------------------------------------------------------------------
    2. // <auto-generated>
    3. // 此代码由T4模板自动生成
    4. // 生成时间 2012-07-18 17:51:26 by 懒惰的肥兔
    5. // 对此文件的更改可能会导致不正确的行为,并且如果
    6. // 重新生成代码,这些更改将会丢失。
    7. // </auto-generated>
    8. //------------------------------------------------------------------------------
    9.  
    10. using System;
    11. namespace T4ConsoleApplication.Entities
    12. {
    13.  
    14. public class Customers
    15. {
    16.  
    17. /// <summary>
    18. ///
    19. /// </summary>
    20. public string CustomerID { get; set; }
    21.  
    22. /// <summary>
    23. ///
    24. /// </summary>
    25. public string CompanyName { get; set; }
    26.  
    27. /// <summary>
    28. ///
    29. /// </summary>
    30. public string ContactName { get; set; }
    31.  
    32. /// <summary>
    33. ///
    34. /// </summary>
    35. public string ContactTitle { get; set; }
    36.  
    37. /// <summary>
    38. ///
    39. /// </summary>
    40. public string Address { get; set; }
    41.  
    42. /// <summary>
    43. ///
    44. /// </summary>
    45. public string City { get; set; }
    46.  
    47. /// <summary>
    48. ///
    49. /// </summary>
    50. public string Region { get; set; }
    51.  
    52. /// <summary>
    53. ///
    54. /// </summary>
    55. public string PostalCode { get; set; }
    56.  
    57. /// <summary>
    58. ///
    59. /// </summary>
    60. public string Country { get; set; }
    61.  
    62. /// <summary>
    63. ///
    64. /// </summary>
    65. public string Phone { get; set; }
    66.  
    67. /// <summary>
    68. ///
    69. /// </summary>
    70. public string Fax { get; set; }
    71.  
    72. }
    73. }

      至此完整演示了怎样一步步根据数据库生成实体类的操作,是不是很简单,如对语法和操作不理解的地方可以参考T4模版引擎之基础入门,稍微用心研究下,轻松打造属于自己的代码生成器。

  本文简单介绍了基于单个模板生成数据库实体类的示例,离具体实用还有一定的距离,毕竟总不能为每个数据表建一个模板吧,下一篇将揭晓如何通过单个T4模板生成多个文件,以及自动生成整个数据库的所有实体类,敬请期待

T4模版引擎之生成数据库实体类的更多相关文章

  1. T4教程2 T4模版引擎之生成数据库实体类

    T4模版引擎之生成数据库实体类   在通过T4模版引擎之基础入门 对T4有了初步印象后,我们开始实战篇.T4模板引擎可以当做一个代码生成器,代码生成器的职责当然是用来生成代码(这不是废话吗).而这其中 ...

  2. [转]T4模版引擎之生成数据库实体类

    本文转自:http://www.cnblogs.com/lzrabbit/archive/2012/07/18/2597953.html 在通过T4模版引擎之基础入门 对T4有了初步印象后,我们开始实 ...

  3. 【EF框架】EF DBFirst 快速生成数据库实体类 Database1.tt

    现有如下需求,数据库表快速映射到数据库实体类 VS给出的两个选择都有问题,并不能实现,都是坑啊 EF .x DbContext 生成器 EF .x DbContext 生成器 测试结果如下 生成文件 ...

  4. T4 生成数据库实体类

    来源不详,整理如下: <#@ template language="C#" debug="True" hostspecific="True&qu ...

  5. IntelliJ IDEA 学习(四)Idea逆向生成数据库实体类

    第一步配置 数据库 第二步  配置hibernate,如果没有cfg.xml文件,点击ok后会自动生成 第三步 选择hibernate配置文件生成实体 第四步 设置完点击,选中要生成的实体的表 注意: ...

  6. C# T4 模板 数据库实体类生成模板(带注释,娱乐用)

     说明:..,有些工具生成实体类没注释,不能和SqlServer的MS_Description属性一起使用,然后照着网上的资源,随便写了个生成模板,自娱自乐向,其实卵用都没有参考教程    1.htt ...

  7. 使用T4模板生成MySql数据库实体类

    注:本文系作者原创,但可随意转载. 现在呆的公司使用的数据库几乎都是MySQL.编程方式DatabaseFirst.即先写数据库设计,表设计按照规范好的文档写进EXCEL里,然后用公司的宏,生成建表脚 ...

  8. eclipse从数据库逆向生成Hibernate实体类

    做项目必然要先进行数据库表设计,然后根据数据库设计建立实体类(VO),这是理所当然的,但是到公司里做项目后,让我认识到,没有说既进行完数据库设计后还要再“自己”建立一变VO.意思是,在项目设计时,要么 ...

  9. [转]eclipse借助hibernate tool从数据库逆向生成Hibernate实体类

    如何从数据库逆向生成Hibernate实体类呢??? 1. 首先,要在eclipse中采用自带的数据库管理器(Data Management),连通你的数据库: 然后选择数据库,这里用的oracle, ...

随机推荐

  1. 乐在其中设计模式(C#) - 建造者模式(Builder Pattern)

    原文:乐在其中设计模式(C#) - 建造者模式(Builder Pattern) [索引页][源码下载] 乐在其中设计模式(C#) - 建造者模式(Builder Pattern) 作者:webabc ...

  2. curl 命令详解(转)

    命令事例 1.读取网页,将网页内容全部输出 curl http://www.linuxidc.com 2.保存网页.下载文件 以page.html命名下载网页:curl –o page.html ht ...

  3. Xampp mysql无法启动的解决方案(转)

    如果出现mysql 无法启动表明在安装xampp 前已经安装了mysql,造成mysql服务无法启动. [mysql] MySQL Service detected with wrong path23 ...

  4. perl操作sqlserver实现BCP

    #!C:\Perl64\bin #由BCP备份和恢复SQLSERVER指定表 use 5.014; #加载用户和password型材 my $username ; my $passwd; ##得到us ...

  5. Android 角色时间戳

    我是在用MediaRecorder进行录像时发生视频和音频不同步的问题,请教了一些人后感觉应该是没有时间戳,之前一直觉得时间戳就是给用户看的一个数据,查了一下发现不是的,以下是转载的.希望对大家实用: ...

  6. hdu 4454 Stealing a Cake(三分之二)

    pid=4454" target="_blank" style="">题目链接:hdu 4454 Stealing a Cake 题目大意:给定 ...

  7. freemarker错误九

    1.错误叙述性说明 五月 30, 2014 11:52:04 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template p ...

  8. Android截图

    Android截图很好的实现,从文档的发展,查看View有一个接口getDrawingCache(),这个接口可以得到View当调用这个接口的位图图像Bitmap. 抓取截图View在图像的某一个时刻 ...

  9. 解决Fedora升级时nvidia显卡问题

    ​ 升级到新版Fedora后登录不了gnome 小编最近升级了Fedora 20到21,结果就如之前从Fedora 19升级到20时类似,又出问题了.Fedora你到底行不行... gnome登录不了 ...

  10. 信息二战炸弹:中国到美国咨询公司Say no

    疯抢/文 在禁止Windows8操作系统參与政府採购,以及在中国销售的全部外国IT产品和服务都须通过新的安全审查之后,英国<金融时报>今天报料中国已禁止国企使用美国咨询公司服务. 这则消息 ...