c#代碼生成器,生成代碼可用於Web及Winform編程,可批量導出代碼,導出代碼直接拷貝到VS中就可以使用,支持MSSqlServer,Oracle數據庫.生成UI、BLL、DAL、MODEL;我做.net開發3年,一直都用這個生成器,覺得很好用,分享給大家;希望該工具能幫到你!
1.代碼生成靈活,根據用戶所編輯的模板生成代碼。
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ToolFunction;
using System.Data;
using CSScriptLibrary;
using Microsoft.CSharp;
using System.Reflection;
using System.Windows.Forms;
namespace AUTOCODE
{
////// 測試類
///public class @GetClassName(SourceTable)
{
@InitProperty(SourceTable)
}
}
#START@GetCamelCaseName
public static string GetCamelCaseName(string value)
{
return value.ToLower();
}
#END
#START@ConvertFirstCharToUpper
public static string ConvertFirstCharToUpper(string value)
{
return value.Substring(0, 1).ToUpper() + value.Substring(1);
}
#END
#START@InitProperty
///
//////數據源///
{
string _strLine = "";
foreach (DataColumn item in p_dtSource.Columns)
{
_strLine += "\n private " + GetCSharpVariableType(item) + " " + item.ColumnName.ToLower() + ";";
_strLine += "\n" + "public " + GetCSharpVariableType(item) + " " + GetPropertyName(item.ColumnName);
_strLine += "\n" + "{ ";
_strLine += "\n" + "get { return " + item.ColumnName.ToLower() + ";}";
_strLine += "\n" + "set {" + item.ColumnName.ToLower() + "= value;}";
_strLine += "\n" + "}";
}
return _strLine;
}
#END
#START@GetClassName
///
//////表///
{
if (p_dtTable == null)
{
return null;
}
string _strTemp = p_dtTable.TableName.Substring(0, 1).ToUpper() + p_dtTable.TableName.Substring(1).ToLower();
return _strTemp;
}
#END
#START@GetPropertyName
///
/////////
{
if (p_strName == null)
{
return null;
}
if (p_strName.Length == 1)
{
return p_strName.ToLower();
}
return p_strName.Substring(0, 1).ToUpper() + p_strName.Substring(1).ToLower();
}
#END
#START@GetLowerCaseName
public static string GetLowerCaseName(string value)
{
return value.ToLower();
}
#END
#START@GetCSharpVariableType
///
//////表列///
{
if (p_dcColumn.ColumnName.EndsWith("TypeCode")) return p_dcColumn.ColumnName;
switch (p_dcColumn.DataType.Name.ToString())
{
case "AnsiString": return "string";
case "AnsiStringFixedLength": return "string";
case "Binary": return "byte[]";
case "Boolean": return "bool";
case "Byte": return "byte";
case "Currency": return "decimal";
case "Date": return "DateTime";
case "DateTime": return "DateTime";
case "Decimal": return "decimal";
case "Double": return "double";
case "Guid": return "Guid";
case "Int16": return "short";
case "Int32": return "int";
case "Int64": return "long";
case "Object": return "object";
case "SByte": return "sbyte";
case "Single": return "float";
case "String": return "string";
case "StringFixedLength": return "string";
case "Time": return "TimeSpan";
case "UInt16": return "ushort";
case "UInt32": return "uint";
case "UInt64": return "ulong";
case "VarNumeric": return "decimal";
default:
{
return "__UNKNOWN__";
}
}
}
#END
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ToolFunction;
using System.Data;
using CSScriptLibrary;
using Microsoft.CSharp;
using System.Reflection;
using System.Windows.Forms;
namespace AUTOCODE
{
////// 測試類
///public class @GetClassName(SourceTable)
{
@InitProperty(SourceTable)
}
}
#START@GetCamelCaseName
public static string GetCamelCaseName(string value)
{
return value.ToLower();
}
#END
#START@ConvertFirstCharToUpper
public static string ConvertFirstCharToUpper(string value)
{
return value.Substring(0, 1).ToUpper() + value.Substring(1);
}
#END
#START@InitProperty
///
//////數據源///
{
string _strLine = "";
foreach (DataColumn item in p_dtSource.Columns)
{
_strLine += "\n private " + GetCSharpVariableType(item) + " " + item.ColumnName.ToLower() + ";";
_strLine += "\n" + "public " + GetCSharpVariableType(item) + " " + GetPropertyName(item.ColumnName);
_strLine += "\n" + "{ ";
_strLine += "\n" + "get { return " + item.ColumnName.ToLower() + ";}";
_strLine += "\n" + "set {" + item.ColumnName.ToLower() + "= value;}";
_strLine += "\n" + "}";
}
return _strLine;
}
#END
#START@GetClassName
///
//////表///
{
if (p_dtTable == null)
{
return null;
}
string _strTemp = p_dtTable.TableName.Substring(0, 1).ToUpper() + p_dtTable.TableName.Substring(1).ToLower();
return _strTemp;
}
#END
#START@GetPropertyName
///
/////////
{
if (p_strName == null)
{
return null;
}
if (p_strName.Length == 1)
{
return p_strName.ToLower();
}
return p_strName.Substring(0, 1).ToUpper() + p_strName.Substring(1).ToLower();
}
#END
#START@GetLowerCaseName
public static string GetLowerCaseName(string value)
{
return value.ToLower();
}
#END
#START@GetCSharpVariableType
///
//////表列///
{
if (p_dcColumn.ColumnName.EndsWith("TypeCode")) return p_dcColumn.ColumnName;
switch (p_dcColumn.DataType.Name.ToString())
{
case "AnsiString": return "string";
case "AnsiStringFixedLength": return "string";
case "Binary": return "byte[]";
case "Boolean": return "bool";
case "Byte": return "byte";
case "Currency": return "decimal";
case "Date": return "DateTime";
case "DateTime": return "DateTime";
case "Decimal": return "decimal";
case "Double": return "double";
case "Guid": return "Guid";
case "Int16": return "short";
case "Int32": return "int";
case "Int64": return "long";
case "Object": return "object";
case "SByte": return "sbyte";
case "Single": return "float";
case "String": return "string";
case "StringFixedLength": return "string";
case "Time": return "TimeSpan";
case "UInt16": return "ushort";
case "UInt32": return "uint";
case "UInt64": return "ulong";
case "VarNumeric": return "decimal";
default:
{
return "__UNKNOWN__";
}
}
}
#END
2.提供模板文件管理模塊。
3.提供基礎配置模塊,方便數據庫連接,導出目錄設置。
4.模板包含屬性說明區,函數注冊區,靜態文本區,動態函數區。規範嚴謹,易於書寫編輯。
5.通過動態編譯實現了模板中可添加c#函數,對數據源進行動態操作。
6.多種文件格式導出(隻有想生成的文件與數據表有緊密聯係,均可根據動態函數區的代碼進行代碼生成)
未完成功能
支持SqlServer、mysql.
76.4M / 03-25
立即下載55M / 06-05
立即下載237.9M / 04-13
立即下載140.5M / 03-06
立即下載900.9M / 03-02
立即下載96.2M / 07-06
立即下載311.2M / 07-06
立即下載335M / 07-06
立即下載200M / 07-06
立即下載413.8M / 07-06
立即下載353.9M / 06-05
立即下載131.8M / 04-13
立即下載230.8M / 03-03
立即下載195.6M / 03-03
立即下載165.4M / 03-03
立即下載45.6M / 09-08
立即下載665.2M / 07-06
立即下載2.84G / 07-06
立即下載93M / 07-06
立即下載338.3M / 07-06
立即下載1.38G / 07-26
立即下載488.3M / 07-16
立即下載109.8M / 06-03
立即下載142M / 01-08
立即下載1.2M / 11-23
立即下載548.8M / 04-13
立即下載1.6M / 04-13
立即下載1.48G / 03-18
立即下載646.6M / 03-03
立即下載133.7M / 03-03
立即下載325.8M / 06-07
立即下載60M / 04-29
立即下載254M / 04-25
立即下載659M / 04-23
立即下載1M / 12-26
立即下載253.4M / 12-08
立即下載253M / 12-08
立即下載1.19G / 11-16
立即下載110.5M / 04-23
立即下載26.7M / 03-16
立即下載488.3M / 07-16
立即下載248.9M / 12-08
立即下載248.9M / 12-08
立即下載201.2M / 04-13
立即下載100.6M / 03-06
立即下載148.9M / 03-06
立即下載1.12G / 07-06
立即下載1.25G / 07-06
立即下載9.48G / 07-06
立即下載50KB / 07-06
立即下載116.2M / 04-10
立即下載1.92G / 04-17
立即下載201.5M / 04-13
立即下載7.31G / 07-01
立即下載94.3M / 07-06
立即下載2.48G / 07-06
立即下載7.63G / 07-06
立即下載1M / 07-06
立即下載778.1M / 07-06
立即下載509.7M / 07-06
立即下載561.8M / 07-11
立即下載1.32G / 01-19
立即下載72M / 07-06
立即下載548.7M / 07-06
立即下載1.00G / 07-06
立即下載9.13G / 07-06
立即下載126.2M / 07-06
立即下載72M / 07-06
立即下載105.1M / 07-06
立即下載132M / 07-06
立即下載