将一些公用的东西弄到一个类库DM.T4里面,哪个项目需要用到t4生成的话,将DM.T4的生成事件中将dll和ModelAuto.ttinclude复制到需要使用T4的项目的生成目录下,如果这样

copy $(TargetPath) $(SolutionDir)DM.Domain\$(OutDir)
copy $(TargetDir)ModelAuto.ttinclude $(SolutionDir)DM.Domain\$(OutDir)

然后在需要就可以添加T4文件了,T4文件头部引入即可,例如下面的这个例子,就是根据表生成一些类

<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ output extension=".cs" #>
<#@ assembly name="System.Data" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="$(TargetDir)DM.T4.dll"#>
<#@ import namespace="System" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.Data" #>
<#@ import namespace="System.Data.SqlClient" #>
<#@ import namespace="System.Collections.Generic"#>
<#@ import namespace="System.Text.RegularExpressions"#>
<#@ import namespace="DM.T4"#>
<#@ include file="$(TargetDir)ModelAuto.ttinclude"#>
<# var manager2 = new Manager(Host, GenerationEnvironment, true) { OutputPath = Path.GetDirectoryName(Host.TemplateFile)}; #>
<#
ModelManager manager = new ModelManager();
List<string> list=manager.GetTableList();
foreach (var item in list)
{
string tableName=item;
DataTable table= manager.GetTableSchema(tableName);
string strTableMemo=string.Empty;
if(table!=null&&table.Rows.Count>)
{
strTableMemo=table.Rows[]["表说明"].ToString();
}
manager2.StartBlock(tableName+"Repository.cs");
#>
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码从T4模板生成。
// 黄正辉(623128629@qq.com)
// 手动更改此文件可能导致应用程序出现意外的行为。
// 如果重新生成代码,将覆盖对此文件的手动更改。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq.Expressions;
using System.Data.Common;
using DM.Domain;
using DM.Tools;
using DM.Interface;
using DM.Interface.IRepository; namespace DM.Repository.BusinessRepository
{
/// <summary>
/// 仓储实现:<#= strTableMemo #> (<#= tableName #>)
/// </summary>
public partial class <#=tableName #>Repository :RepositoryBase<<#=tableName #>>, I<#=tableName #>Repository,IDependency
{
/// <summary>
/// 插入一个数据
/// </summary>
/// <param name="entity">实体</param>
/// <returns>受影响行数</returns>
public virtual int Insert(<#=tableName #> entity)
{
return base.Insert(entity);
}
/// <summary>
/// 插入一个数据列表
/// </summary>
/// <param name="entity">实体列表</param>
/// <returns>受影响行数</returns>
public virtual int Insert(List<<#=tableName #>> entitys)
{
return base.Insert(entitys);
}
/// <summary>
/// 修改一个数据
/// </summary>
/// <param name="entity">实体</param>
/// <returns>受影响行数</returns>
public virtual int Update(<#=tableName #> entity)
{
return base.Update(entity);
}
/// <summary>
/// 删除一个数据
/// </summary>
/// <param name="entity">实体</param>
/// <returns>受影响行数</returns>
public virtual int Delete(<#=tableName #> entity)
{
return base.Delete(entity);
}
/// <summary>
/// 根据表达式删除
/// </summary>
/// <param name="predicate">实体</param>
/// <returns>受影响行数</returns>
public virtual int Delete(Expression<Func<<#=tableName #>, bool>> predicate)
{
return base.Delete(predicate);
}
/// <summary>
/// 根据主键查询一个数据
/// </summary>
/// <param name="keyValue">主键值</param>
/// <returns>实体</returns>
public virtual <#=tableName #> FindEntity(object keyValue)
{
return base.FindEntity(keyValue);
}
/// <summary>
/// 根据表达式查询一个数据
/// </summary>
/// <param name="predicate">表达式</param>
/// <returns>实体</returns>
public virtual <#=tableName #> FindEntity(Expression<Func<<#=tableName #>, bool>> predicate)
{
return base.FindEntity(predicate);
}
/// <summary>
/// 查询IQueryable列表
/// </summary>
/// <returns>IQueryable列表</returns>
public virtual IQueryable<<#=tableName #>> IQueryable()
{
return base.IQueryable();
}
/// <summary>
/// 根据表达式查询IQueryable列表数据
/// </summary>
/// <param name="predicate">表达式</param>
/// <returns>IQueryable列表</returns>
public virtual IQueryable<<#=tableName #>> IQueryable(Expression<Func<<#=tableName #>, bool>> predicate)
{
return base.IQueryable(predicate);
}
/// <summary>
/// 根据Sql查询数据
/// </summary>
/// <param name="strSql">Sql</param>
/// <returns>数据列表</returns>
public virtual List<<#=tableName #>> FindList(string strSql)
{
return base.FindList(strSql);
}
/// <summary>
/// 根据Sql查询数据
/// </summary>
/// <param name="strSql">Sql</param>
/// <param name="dbParameter">参数列表</param>
/// <returns>数据列表</returns>
public virtual List<<#=tableName #>> FindList(string strSql, DbParameter[] dbParameter)
{
return base.FindList(strSql,dbParameter);
}
/// <summary>
/// 查询分页数据
/// </summary>
/// <param name="pagination">分页参数</param>
/// <returns>数据列表</returns>
public virtual List<<#=tableName #>> FindList(Pagination pagination)
{
return base.FindList(pagination);
}
/// <summary>
/// 查询表达式查询分页数据
/// </summary>
/// <param name="predicate">表达式</param>
/// <param name="pagination">分页参数</param>
/// <returns>数据列表</returns>
public virtual List<<#=tableName #>> FindList(Expression<Func<<#=tableName #>, bool>> predicate, Pagination pagination)
{
return base.FindList(predicate,pagination);
}
}
}
<# manager2.EndBlock();
}
manager2.Process(true);
#>

生成后的结果是这样的

文件的内容如下

//------------------------------------------------------------------------------
// <auto-generated>
// 此代码从T4模板生成。
// 黄正辉(623128629@qq.com)
// 手动更改此文件可能导致应用程序出现意外的行为。
// 如果重新生成代码,将覆盖对此文件的手动更改。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq.Expressions;
using System.Data.Common;
using DM.Domain;
using DM.Tools;
using DM.Interface;
using DM.Interface.IRepository; namespace DM.Repository.BusinessRepository
{
/// <summary>
/// 仓储实现: (Sys_Role)
/// </summary>
public partial class Sys_RoleRepository :RepositoryBase<Sys_Role>, ISys_RoleRepository,IDependency
{
/// <summary>
/// 插入一个数据
/// </summary>
/// <param name="entity">实体</param>
/// <returns>受影响行数</returns>
public virtual int Insert(Sys_Role entity)
{
return base.Insert(entity);
}
/// <summary>
/// 插入一个数据列表
/// </summary>
/// <param name="entity">实体列表</param>
/// <returns>受影响行数</returns>
public virtual int Insert(List<Sys_Role> entitys)
{
return base.Insert(entitys);
}
/// <summary>
/// 修改一个数据
/// </summary>
/// <param name="entity">实体</param>
/// <returns>受影响行数</returns>
public virtual int Update(Sys_Role entity)
{
return base.Update(entity);
}
/// <summary>
/// 删除一个数据
/// </summary>
/// <param name="entity">实体</param>
/// <returns>受影响行数</returns>
public virtual int Delete(Sys_Role entity)
{
return base.Delete(entity);
}
/// <summary>
/// 根据表达式删除
/// </summary>
/// <param name="predicate">实体</param>
/// <returns>受影响行数</returns>
public virtual int Delete(Expression<Func<Sys_Role, bool>> predicate)
{
return base.Delete(predicate);
}
/// <summary>
/// 根据主键查询一个数据
/// </summary>
/// <param name="keyValue">主键值</param>
/// <returns>实体</returns>
public virtual Sys_Role FindEntity(object keyValue)
{
return base.FindEntity(keyValue);
}
/// <summary>
/// 根据表达式查询一个数据
/// </summary>
/// <param name="predicate">表达式</param>
/// <returns>实体</returns>
public virtual Sys_Role FindEntity(Expression<Func<Sys_Role, bool>> predicate)
{
return base.FindEntity(predicate);
}
/// <summary>
/// 查询IQueryable列表
/// </summary>
/// <returns>IQueryable列表</returns>
public virtual IQueryable<Sys_Role> IQueryable()
{
return base.IQueryable();
}
/// <summary>
/// 根据表达式查询IQueryable列表数据
/// </summary>
/// <param name="predicate">表达式</param>
/// <returns>IQueryable列表</returns>
public virtual IQueryable<Sys_Role> IQueryable(Expression<Func<Sys_Role, bool>> predicate)
{
return base.IQueryable(predicate);
}
/// <summary>
/// 根据Sql查询数据
/// </summary>
/// <param name="strSql">Sql</param>
/// <returns>数据列表</returns>
public virtual List<Sys_Role> FindList(string strSql)
{
return base.FindList(strSql);
}
/// <summary>
/// 根据Sql查询数据
/// </summary>
/// <param name="strSql">Sql</param>
/// <param name="dbParameter">参数列表</param>
/// <returns>数据列表</returns>
public virtual List<Sys_Role> FindList(string strSql, DbParameter[] dbParameter)
{
return base.FindList(strSql,dbParameter);
}
/// <summary>
/// 查询分页数据
/// </summary>
/// <param name="pagination">分页参数</param>
/// <returns>数据列表</returns>
public virtual List<Sys_Role> FindList(Pagination pagination)
{
return base.FindList(pagination);
}
/// <summary>
/// 查询表达式查询分页数据
/// </summary>
/// <param name="predicate">表达式</param>
/// <param name="pagination">分页参数</param>
/// <returns>数据列表</returns>
public virtual List<Sys_Role> FindList(Expression<Func<Sys_Role, bool>> predicate, Pagination pagination)
{
return base.FindList(predicate,pagination);
}
}
}

这样就完成了批量生成文件的功能了

项目是DM.T4的项目结构

ModelAuto.ttinclude

<#@ assembly name="System.Core"#>
<#@ assembly name="EnvDTE"#>
<#@ import namespace="System.Collections.Generic"#>
<#@ import namespace="System.IO"#>
<#@ import namespace="System.Text"#>
<#@ import namespace="Microsoft.VisualStudio.TextTemplating"#> <#+ class Manager
{
public struct Block {
public String Name;
public int Start, Length;
} public List<Block> blocks = new List<Block>();
public Block currentBlock;
public Block footerBlock = new Block();
public Block headerBlock = new Block();
public ITextTemplatingEngineHost host;
public ManagementStrategy strategy;
public StringBuilder template;
public String OutputPath { get; set; } public Manager(ITextTemplatingEngineHost host, StringBuilder template, bool commonHeader) {
this.host = host;
this.template = template;
OutputPath = String.Empty;
strategy = ManagementStrategy.Create(host);
} public void StartBlock(String name) {
currentBlock = new Block { Name = name, Start = template.Length };
} public void StartFooter() {
footerBlock.Start = template.Length;
} public void EndFooter() {
footerBlock.Length = template.Length - footerBlock.Start;
} public void StartHeader() {
headerBlock.Start = template.Length;
} public void EndHeader() {
headerBlock.Length = template.Length - headerBlock.Start;
} public void EndBlock() {
currentBlock.Length = template.Length - currentBlock.Start;
blocks.Add(currentBlock);
} public void Process(bool split) {
String header = template.ToString(headerBlock.Start, headerBlock.Length);
String footer = template.ToString(footerBlock.Start, footerBlock.Length);
blocks.Reverse();
foreach(Block block in blocks) {
String fileName = Path.Combine(OutputPath, block.Name);
if (split) {
String content = header + template.ToString(block.Start, block.Length) + footer;
strategy.CreateFile(fileName, content);
template.Remove(block.Start, block.Length);
} else {
strategy.DeleteFile(fileName);
}
}
}
} class ManagementStrategy
{
internal static ManagementStrategy Create(ITextTemplatingEngineHost host) {
return (host is IServiceProvider) ? new VSManagementStrategy(host) : new ManagementStrategy(host);
} internal ManagementStrategy(ITextTemplatingEngineHost host) { } internal virtual void CreateFile(String fileName, String content) {
File.WriteAllText(fileName, content);
} internal virtual void DeleteFile(String fileName) {
if (File.Exists(fileName))
File.Delete(fileName);
}
} class VSManagementStrategy : ManagementStrategy
{
private EnvDTE.ProjectItem templateProjectItem; internal VSManagementStrategy(ITextTemplatingEngineHost host) : base(host) {
IServiceProvider hostServiceProvider = (IServiceProvider)host;
if (hostServiceProvider == null)
throw new ArgumentNullException("Could not obtain hostServiceProvider"); EnvDTE.DTE dte = (EnvDTE.DTE)hostServiceProvider.GetService(typeof(EnvDTE.DTE));
if (dte == null)
throw new ArgumentNullException("Could not obtain DTE from host"); templateProjectItem = dte.Solution.FindProjectItem(host.TemplateFile);
} internal override void CreateFile(String fileName, String content) {
base.CreateFile(fileName, content);
((EventHandler)delegate { templateProjectItem.ProjectItems.AddFromFile(fileName); }).BeginInvoke(null, null, null, null);
} internal override void DeleteFile(String fileName) {
((EventHandler)delegate { FindAndDeleteFile(fileName); }).BeginInvoke(null, null, null, null);
} private void FindAndDeleteFile(String fileName) {
foreach(EnvDTE.ProjectItem projectItem in templateProjectItem.ProjectItems) {
if (projectItem.get_FileNames() == fileName) {
projectItem.Delete();
return;
}
}
}
}#>

ModelManager.cs

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace DM.T4
{
public class ModelManager
{
/// <summary>
/// 数据库连接字符串
/// </summary>
private const string CONNECTION_STRING = "Server=.;Initial Catalog=DocumentManage;User ID=sa;Password=123456";
/// <summary>
/// 用户信息表名
/// </summary>
private const string PERSONINFO_TABLE_NAME = "USERINFO";
/// <summary>
/// 根据表名查询表结构信息
/// </summary>
private const string SELECT_SCHEMA_BY_TABLE_NAME = @"select d.name as 表名 --如果表名相同就返回空
, ddd.value as 表说明 --如果表名相同就返回空
, a.colorder as 字段序号
, a.name as 字段名
, (case
when columnproperty(a.id, a.name, 'IsIdentity') = 1 then
1
else
0
end
) as 是否自增标识
, (case
when
(
select count(*)
from sys.sysobjects --查询主键
where (name in
(
select name
from sys.sysindexes
where (id = a.id)
and (indid in
(
select indid
from sys.sysindexkeys
where (id = a.id)
and (colid in
(
select colid from sys.syscolumns where (id = a.id) and (name = a.name)
)
)
)
)
)
)
and (xtype = 'PK')
) > 0 then
1
else
0
end
) as 主键 --查询主键END
, b.name as 数据类型
, a.length as 占用字节数
, columnproperty(a.id, a.name, 'PRECISION') as 长度
, isnull(columnproperty(a.id, a.name, 'Scale'), 0) as 小数位
, (case
when a.isnullable = 1 then
1
else
0
end
) as 允许空
, isnull(e.text, '') as 缺省值
, isnull(g.value, '') as 备注
from sys.syscolumns a
left join sys.systypes b
on a.xtype = b.xusertype
inner join sys.sysobjects d
on a.id = d.id
and d.xtype = 'U'
and d.name <> 'dtproperties'
left outer join
(
select major_id
, value
from sys.extended_properties
where name = 'MS_Description'
and minor_id = 0
) as ddd
on a.id = ddd.major_id
left join sys.syscomments e
on a.cdefault = e.id
left join sys.extended_properties g
on a.id = g.major_id
and a.colid = g.minor_id
where d.name='{0}'
order by a.id
, a.colorder;"; private const string TABLE_FK_SQL = @"select
a.name as 约束名,
object_name(b.parent_object_id) as 外键表,
c.name as 外键列,
object_name(b.referenced_object_id) as 主健表,
d.name as 主键列
from sys.foreign_keys A
inner join sys.foreign_key_columns B on A.object_id=b.constraint_object_id
inner join sys.columns C on B.parent_object_id=C.object_id and B.parent_column_id=C.column_id
inner join sys.columns D on B.referenced_object_id=d.object_id and B.referenced_column_id=D.column_id
where object_name(b.parent_object_id)!=object_name(b.referenced_object_id)"; /// <summary>
/// 获得数据连接
/// </summary>
/// <returns></returns>
private SqlConnection GetConnection()
{
return new SqlConnection(SqlHelper.sqlConnectionStr);
} /// <summary>
/// 得到当前用户的所有表名
/// </summary>
/// <returns></returns>
public List<string> GetTableList()
{
string sql = "select table_name from information_schema.tables";
DataTable dt = SqlHelper.ExecuteDataTable(sql);
List<string> list = new List<string>();
if (dt != null && dt.Rows.Count > )
{
for (int i = ; i < dt.Rows.Count; i++)
{
list.Add(dt.Rows[i][].ToString());
}
}
return list;
} /// <summary>
/// 得到所有表主外键关系
/// </summary>
/// <returns></returns>
public List<FK> GetFK()
{
DataTable dt = SqlHelper.ExecuteDataTable(TABLE_FK_SQL);
List<FK> lst = new List<FK>();
for (int i = ; i < dt.Rows.Count; i++)
{
FK fk = new FK()
{
FKName = dt.Rows[i]["约束名"].ToString(),
WJ_Table = dt.Rows[i]["外键表"].ToString(),
WJ_Field = dt.Rows[i]["外键列"].ToString(),
ZJ_Table = dt.Rows[i]["主健表"].ToString(),
ZJ_Field = dt.Rows[i]["主键列"].ToString()
};
lst.Add(fk);
} return lst;
}
/// <summary>
/// 释放连接
/// </summary>
/// <param name="con"></param>
private void ReleaseConnection(SqlConnection con)
{
if (con != null)
{
if (con.State == ConnectionState.Open)
{
con.Close();
}
}
} public DataTable GetTableSchema(string tableName)
{
DataTable dt = SqlHelper.ExecuteDataTable(string.Format(SELECT_SCHEMA_BY_TABLE_NAME, tableName));
return dt;
} /// <summary>
/// SQL[不完善,需要的自己改造]
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public string TransFromSqlType(string type)
{
type = type.ToLower(); switch (type)
{
case "int": return "int";
case "bigint": return "Int64";
case "smallint": return "Int16";
case "text":
case "char":
case "nchar":
case "ntext":
case "nvarchar":
case "varchar": return "string";
case "varbinary":
case "image":
case "binary": return "Byte[]";
case "tinyint": return "byte";
case "bit": return "bool";
case "date":
case "time":
case "smalldatetime":
case "timestamp":
case "datetime": return "DateTime";
case "money":
case "numeric":
case "smallmoney":
case "decimal": return "decimal";
case "float": return "double";
case "real": return "Single";
default: return "string";
}
}
}
public class FK
{
public string FKName { get; set; }
public string WJ_Table { get; set; }
public string WJ_Field { get; set; }
public string ZJ_Table { get; set; }
public string ZJ_Field { get; set; }
}
}

SqlHelper.cs

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace DM.T4
{
public class SqlHelper
{
public static string sqlConnectionStr = "Server=.;Initial Catalog=DocumentManage;User ID=sa;Password=123456";
public static DataTable ExecuteDataTable(string sql, params SqlParameter[] paramList)
{
using (SqlConnection conn = new SqlConnection(sqlConnectionStr))
{
conn.Open();
using (SqlCommand command = conn.CreateCommand())
{
command.CommandText = sql;
command.Parameters.AddRange(paramList);
DataTable dt = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter(command);
adapter.Fill(dt);
return dt;
}
}
} public static int ExecuteNonQuery(string sql, params SqlParameter[] paramList)
{
using (SqlConnection conn = new SqlConnection(sqlConnectionStr))
{
conn.Open();
using (SqlCommand command = conn.CreateCommand())
{
command.CommandText = sql;
command.Parameters.AddRange(paramList);
return command.ExecuteNonQuery();
}
}
} public static object ExecuteScalar(string sql, params SqlParameter[] paramList)
{
using (SqlConnection conn = new SqlConnection(sqlConnectionStr))
{
conn.Open();
using (SqlCommand command = conn.CreateCommand())
{
command.CommandText = sql;
command.Parameters.AddRange(paramList);
return command.ExecuteScalar();
}
}
}
} }

T4生成整理的更多相关文章

  1. 懒人小工具:T4生成实体类Model,Insert,Select,Delete以及导出Excel的方法

    由于最近公司在用webform开发ERP,用到大量重复机械的代码,之前写了篇文章,懒人小工具:自动生成Model,Insert,Select,Delete以及导出Excel的方法,但是有人觉得这种方法 ...

  2. 用T4生成EF框架下的DAL、IDAL、BLL、IBLL

    (一)什么是T4模板? T4,即4个T开头的英文字母组合:Text Template Transformation Toolkit. T4文本模板,即一种自定义规则的代码生成器.根据业务模型可生成任何 ...

  3. .Net的EF+MVC框架使用T4生成各个层的代码的,在新增表的时候,调不到新增的实体

    如果确认有这个实体的话,只需要把T4模板全部重新生成就可以了

  4. 使用SqlSugar 4.X的T4生成实体类

    <#@ template debug="false" hostspecific="true" language="C#" #> ...

  5. T4 生成数据库实体类

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

  6. T4生成实体,单张表和多张表

    # 使用说明 . 把T4目录放在项目的根目录 . 配置连接字符串,在tt文件的最底部 . generateAllEntity.tt生成全部的实体类 . generateSingleEntityByNa ...

  7. T4 生成实体和简单的CRUD操作

    <#@ template debug="false" hostspecific="false" language="C#" #> ...

  8. .Net Core 中使用PetaPoco ,T4生成模版

    话不多说,直接上源码. 1.引用NuGet 2.添加T4 <#@ template debug="true" hostspecific="false" l ...

  9. T4生成实体和简单的CRUD操作

    主要跟大家交流下T4,我这里针对的是mysql,我本人比较喜欢用mysql,所以语法针对mysql,所以你要准备mysql的DLL了,同理sqlserver差不多,有兴趣可以自己写写,首先网上找了一个 ...

随机推荐

  1. 从文件 I/O 看 Linux 的虚拟文件系统

    1 引言 Linux 中允许众多不同的文件系统共存,如 ext2, ext3, vfat 等.通过使用同一套文件 I/O 系统 调用即可对 Linux 中的任意文件进行操作而无需考虑其所在的具体文件系 ...

  2. matplotlib tricks(关闭坐标刻度、坐标轴不可见)

    plt.gray():只有黑白两色,没有中间的渐进色 1. 关闭坐标刻度(plt 与 AxesSubplot) plt plt.xticks([]) plt.yticks([]) 关闭坐标轴: plt ...

  3. 接口测试——fiddler对soapui请求返回信息抓取

    原文:接口测试——fiddler对soapui请求返回信息抓取 背景:接口测试的时候,需要对接口的请求和返回信息进行查阅或者修改请求信息,可利用fiddler抓包工具对soapui的请求数据进行抓取或 ...

  4. MySQL复制slave服务器死锁案例

    原文:MySQL复制slave服务器死锁案例 MySQL复制刚刚触发了一个bug,该bug的触发条件是slave上Xtrabackup备份的时候执行flushs tables with read lo ...

  5. python 教程 第五章、 函数

    第五章. 函数 定义语句后面要加冒号 1)    定义函数 def sayHello(): print 'Hello World!' sayHello() 2)    变量作用域 LEGB原则 L本地 ...

  6. 峰识别 峰面积计算 peak detection peak area 源代码 下载

    原文:峰识别 峰面积计算 peak detection peak area 源代码 下载 Comparative  analysis  of  peak-detection  techniques   ...

  7. WPF在3D Cad模型中利用TextureCoordinates实现颜色渐变显示偏差值的变化

    原文:WPF在3D Cad模型中利用TextureCoordinates实现颜色渐变显示偏差值的变化 注:最近在做3D机械模型重建方面的软件,需要根据光栅传感器采集的数据绘制3D图形,并显示出色差以及 ...

  8. js到字符串数组,实现阵列成一个字符串

    数组字符串(阵列元件与字符串连接) var a, b; a = new Array(0,1,2,3,4); b = a.join("-");   字符串转数组(根据一个字符串被分成 ...

  9. Java Swing编程接口(30)---列表框:JList

    列表框同时可以在信息呈现给用户的列表多个选项,使用JList能够建立一个列表框. package com.beyole.util; import java.awt.Container; import ...

  10. String关于BeanFactory与ApplicationContext的简单区别

    1.创建的方式不同 ApplicationContext: ApplicationContext context = new ClassPathXmlApplicationContext(" ...