LASAPlatform/Infrastructure/Extensions/StringExtension.cs

867 lines
188 KiB
C#
Raw Normal View History

2025-04-23 09:19:29 +08:00
using System;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using Infrastructure.Const;
using Microsoft.International.Converters.PinYinConverter;
namespace Infrastructure.Extensions
{
public static class StringExtension
{
public static bool _windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
/// <summary>
/// 自动调整windows/linux下面文件目录斜杠的处理
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static string ReplacePath(this string path)
{
if (string.IsNullOrEmpty(path))
return "";
if (_windows)
return path.Replace("/", "\\");
return path.Replace("\\", "/");
}
/// <summary>
/// 把一个字符串转成驼峰规则的字符串
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string ToCamelCase(this string str)
{
if(!string.IsNullOrEmpty(str) && str.Length > 1)
{
return Char.ToLowerInvariant(str[0]) + str.Substring(1);
}
return str;
}
private static DateTime dateStart = new DateTime(1970, 1, 1, 8, 0, 0);
private static long longTime = 621355968000000000;
private static int samllTime = 10000000;
/// <summary>
/// 获取时间戳
/// </summary>
/// <param name="dateTime"></param>
/// <returns></returns>
public static long GetTimeStamp(this DateTime dateTime)
{
return (dateTime.ToUniversalTime().Ticks - longTime) / samllTime;
}
/// <summary>
/// 时间戳转换成日期
/// </summary>
/// <param name="timeStamp"></param>
/// <returns></returns>
public static DateTime GetTimeSpmpToDate(this object timeStamp)
{
if (timeStamp == null) return dateStart;
DateTime dateTime = new DateTime(longTime + Convert.ToInt64(timeStamp) * samllTime, DateTimeKind.Utc).ToLocalTime();
return dateTime;
}
public static bool IsUrl(this string str)
{
if (string.IsNullOrEmpty(str))
return false;
string Url = @"(http://)?([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?";
return Regex.IsMatch(str, Url);
}
/// <summary>
/// 判断是不是正确的手机号码
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static bool IsPhoneNo(this string input)
{
if (string.IsNullOrEmpty(input))
return false;
if (input.Length != 11)
return false;
if (new Regex(@"^1[3578][01379]\d{8}$").IsMatch(input)
|| new Regex(@"^1[34578][01256]\d{8}").IsMatch(input)
|| new Regex(@"^(1[012345678]\d{8}|1[345678][0123456789]\d{8})$").IsMatch(input)
)
return true;
return false;
}
public static string GetDBCondition(this string stringType)
{
string reslut = "";
switch (stringType?.ToLower())
{
case HtmlElementType.droplist:
case HtmlElementType.selectlist:
case HtmlElementType.textarea:
case HtmlElementType.checkbox:
reslut = HtmlElementType.Contains;
break;
case HtmlElementType.thanorequal:
reslut = HtmlElementType.ThanOrEqual;
break;
case HtmlElementType.lessorequal:
reslut = HtmlElementType.LessOrequal;
break;
case HtmlElementType.gt:
reslut = HtmlElementType.GT;
break;
case HtmlElementType.lt:
reslut = HtmlElementType.lt;
break;
case HtmlElementType.like:
reslut = HtmlElementType.like;
break;
default:
reslut = HtmlElementType.Equal;
break;
}
return reslut;
}
public static LinqExpressionType GetLinqCondition(this string stringType)
{
LinqExpressionType linqExpression;
switch (stringType)
{
case HtmlElementType.Contains:
linqExpression = LinqExpressionType.In;
break;
case HtmlElementType.ThanOrEqual:
linqExpression = LinqExpressionType.ThanOrEqual;
break;
case HtmlElementType.LessOrequal:
linqExpression = LinqExpressionType.LessThanOrEqual;
break;
case HtmlElementType.GT:
linqExpression = LinqExpressionType.GreaterThan;
break;
case HtmlElementType.lt:
linqExpression = LinqExpressionType.LessThan;
break;
case HtmlElementType.like:
linqExpression = LinqExpressionType.Contains;
break;
default:
linqExpression = LinqExpressionType.Equal;
break;
}
return linqExpression;
}
public static bool GetGuid(this string guid, out Guid outId)
{
Guid emptyId = Guid.Empty;
return Guid.TryParse(guid, out outId);
}
public static bool IsGuid(this string guid)
{
Guid newId;
return GetGuid(guid, out newId);
}
public static bool IsInt(this object obj)
{
if (obj == null)
return false;
bool reslut = Int32.TryParse(obj.ToString(), out int _number);
return reslut;
}
public static bool IsDate(this object str)
{
return IsDate(str, out _);
}
public static bool IsDate(this object str, out DateTime dateTime)
{
dateTime = DateTime.Now;
if (str == null || str.ToString() == "")
{
return false;
}
return DateTime.TryParse(str.ToString(), out dateTime);
}
/// <summary>
/// 根据传入格式判断是否为小数
/// </summary>
/// <param name="str"></param>
/// <param name="formatString">18,5</param>
/// <returns></returns>
public static bool IsNumber(this string str, string formatString)
{
if (string.IsNullOrEmpty(str))
return false;
int precision = 32;
int scale = 5;
try
{
if (string.IsNullOrEmpty(formatString))
{
precision = 10;
scale = 2;
}
else
{
string[] numbers = formatString.Split(',');
precision = Convert.ToInt32(numbers[0]);
scale = numbers.Length == 0 ? 2 : Convert.ToInt32(numbers[1]);
}
}
catch { };
return IsNumber(str, precision, scale);
}
/**/
/// <summary>
/// 判断一个字符串是否为合法数字(指定整数位数和小数位数)
/// </summary>
/// <param name="str">字符串</param>
/// <param name="precision">整数位数</param>
/// <param name="scale">小数位数</param>
/// <returns></returns>
public static bool IsNumber(this string str, int precision, int scale)
{
if ((precision == 0) && (scale == 0))
{
return false;
}
string pattern = @"(^\d{1," + precision + "}";
if (scale > 0)
{
pattern += @"\.\d{0," + scale + "}$)|" + pattern;
}
pattern += "$)";
return Regex.IsMatch(str, pattern);
}
public static bool IsNullOrEmpty(this object str)
{
if (str == null)
return true;
return str.ToString() == "";
}
public static int GetInt(this object obj)
{
if (obj == null)
return 0;
int.TryParse(obj.ToString(), out int _number);
return _number;
}
/// <summary>
/// 获取 object 中的枚举值
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
/// <remarks></remarks>
public static long GetLong(this object obj)
{
if (obj == null)
return 0;
try
{
return Convert.ToInt64(Convert.ToDouble(obj));
}
catch
{
return 0;
}
}
/// <summary>
/// 获取 object 中的 float
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static float GetFloat(this object obj)
{
if (System.DBNull.Value.Equals(obj) || null == obj)
return 0;
try
{
return float.Parse(obj.ToString());
}
catch
{
return 0;
}
}
public static double GetDouble(this object obj)
{
if (System.DBNull.Value.Equals(obj) || null == obj)
return 0;
try
{
return Convert.ToDouble(obj);
}
catch
{
return 0;
}
}
/// <summary>
/// 获取 object 中的 decimal
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
/// <remarks></remarks>
public static decimal GetDecimal(this object obj)
{
if (System.DBNull.Value.Equals(obj) || null == obj)
return 0;
try
{
return Convert.ToDecimal(obj);
}
catch
{
return 0;
}
}
/// <summary>
/// 获取 object 中的 decimal
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
/// <remarks></remarks>
public static dynamic GetDynamic(this object obj)
{
if (System.DBNull.Value.Equals(obj) || null == obj)
return null;
try
{
string str = obj.ToString();
if (IsNumber(str, 25, 15)) return Convert.ToDecimal(obj);
else return str;
}
catch
{
return string.Empty;
}
}
public static DateTime? GetDateTime(this object obj)
{
if (System.DBNull.Value.Equals(obj) || null == obj)
return null;
bool result = DateTime.TryParse(obj.ToString(), out DateTime dateTime);
if (!result)
return null;
return dateTime;
}
public static object ParseTo(this string str, string type)
{
switch (type)
{
case "System.Boolean":
return ToBoolean(str);
case "System.SByte":
return ToSByte(str);
case "System.Byte":
return ToByte(str);
case "System.UInt16":
return ToUInt16(str);
case "System.Int16":
return ToInt16(str);
case "System.uInt32":
return ToUInt32(str);
case "System.Int32":
return ToInt32(str);
case "System.UInt64":
return ToUInt64(str);
case "System.Int64":
return ToInt64(str);
case "System.Single":
return ToSingle(str);
case "System.Double":
return ToDouble(str);
case "System.Decimal":
return ToDecimal(str);
case "System.DateTime":
return ToDateTime(str);
case "System.Guid":
return ToGuid(str);
}
throw new NotSupportedException(string.Format("The string of \"{0}\" can not be parsed to {1}", str, type));
}
public static sbyte? ToSByte(this string value)
{
sbyte value2;
if (sbyte.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static byte? ToByte(this string value)
{
byte value2;
if (byte.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static ushort? ToUInt16(this string value)
{
ushort value2;
if (ushort.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static short? ToInt16(this string value)
{
if (short.TryParse(value, out short value2))
{
return value2;
}
return null;
}
public static uint? ToUInt32(this string value)
{
uint value2;
if (uint.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static ulong? ToUInt64(this string value)
{
ulong value2;
if (ulong.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static long? ToInt64(this string value)
{
long value2;
if (long.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static float? ToSingle(this string value)
{
float value2;
if (float.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static double? ToDouble(this string value)
{
double value2;
if (double.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static decimal? ToDecimal(this string value)
{
decimal value2;
if (decimal.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static bool? ToBoolean(this string value)
{
bool value2;
if (bool.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static Guid? ToGuid(this string str)
{
Guid value;
if (Guid.TryParse(str, out value))
{
return value;
}
return null;
}
public static DateTime? ToDateTime(this string value)
{
DateTime value2;
if (DateTime.TryParse(value, out value2))
{
return value2;
}
return null;
}
public static int? ToInt32(this string input)
{
if (string.IsNullOrEmpty(input))
{
return null;
}
int value;
if (int.TryParse(input, out value))
{
return value;
}
return null;
}
/// <summary>
/// 替换空格字符
/// </summary>
/// <param name="input"></param>
/// <param name="replacement">替换为该字符</param>
/// <returns>替换后的字符串</returns>
public static string ReplaceWhitespace(this string input, string replacement = "")
{
return string.IsNullOrEmpty(input) ? null : Regex.Replace(input, "\\s", replacement, RegexOptions.Compiled);
}
private static char[] randomConstant ={
'0','1','2','3','4','5','6','7','8','9',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
};
/// <summary>
/// 生成指定长度的随机数
/// </summary>
/// <param name="length"></param>
/// <returns></returns>
public static string GenerateRandomNumber(this int length)
{
System.Text.StringBuilder newRandom = new System.Text.StringBuilder(62);
Random rd = new Random();
for (int i = 0; i < length; i++)
{
newRandom.Append(randomConstant[rd.Next(62)]);
}
return newRandom.ToString();
}
public static string MaxSubstring(this string origin, int maxLength)
{
return origin.Length >= maxLength ? origin.Substring(0, maxLength) : origin;
}
public static string ToMd5(this string origin)
{
if (string.IsNullOrWhiteSpace(origin))
{
return string.Empty;
}
var md5Algorithm = MD5.Create();
var utf8Bytes = Encoding.UTF8.GetBytes(origin);
var md5Hash = md5Algorithm.ComputeHash(utf8Bytes);
var hexString = new StringBuilder();
foreach (var hexByte in md5Hash)
{
hexString.Append(hexByte.ToString("x2"));
}
return hexString.ToString();
}
//
// 摘要:
// 把汉字转换成拼音(全拼)
//
// 参数:
// text:
// 汉字字符串
//
// 返回结果:
// 转换后的拼音(全拼)字符串
public static string ConvertPinYin(string text)
{
string text2 = string.Empty;
for (int i = 0; i < text.Length; i++)
{
char ch = text[i];
try
{
ChineseChar chineseChar = new ChineseChar(ch);
if (chineseChar.Pinyins.Count > 0 && chineseChar.Pinyins[0].Length > 0)
{
string text3 = chineseChar.Pinyins[0].ToString();
text2 += text3.Substring(0, text3.Length - 1);
}
}
catch (Exception)
{
text2 += ch;
}
}
return text2;
}
//
// 摘要:
// 获取汉字的拼音简码,即首字母缩写,范例:中国,返回zg
//
// 参数:
// chineseText:
// 汉字文本,范例: 中国
public static string PinYin(string chineseText)
{
if (string.IsNullOrWhiteSpace(chineseText))
{
return string.Empty;
}
StringBuilder stringBuilder = new StringBuilder();
foreach (char text in chineseText)
{
stringBuilder.AppendFormat("{0}", ResolvePinYin(text));
}
return stringBuilder.ToString().ToLower();
}
//
// 摘要:
// 解析单个汉字的拼音简码
//
// 参数:
// text:
// 单个汉字
private static string ResolvePinYin(char text)
{
byte[] bytes = Encoding.Default.GetBytes(text.ToString());
if (bytes[0] <= 127)
{
return text.ToString();
}
ushort unicode = (ushort)(bytes[0] * 256 + bytes[1]);
string text2 = ResolvePinYinByCode(unicode);
if (!string.IsNullOrWhiteSpace(text2))
{
return text2;
}
return ResolvePinYinByFile(text.ToString());
}
//
// 摘要:
// 使用字符编码方式获取拼音简码
private static string ResolvePinYinByCode(ushort unicode)
{
if (unicode >= 45217 && unicode <= 45252)
{
return "A";
}
if (unicode >= 45253 && unicode <= 45760 && unicode != 45464)
{
return "B";
}
if (unicode >= 45761 && unicode <= 46317)
{
return "C";
}
if (unicode >= 46318 && unicode <= 46825)
{
return "D";
}
if (unicode >= 46826 && unicode <= 47009)
{
return "E";
}
if (unicode >= 47010 && unicode <= 47296)
{
return "F";
}
if (unicode >= 47297 && unicode <= 47613)
{
return "G";
}
if (unicode >= 47614 && unicode <= 48118)
{
return "H";
}
if (unicode >= 48119 && unicode <= 49061)
{
return "J";
}
if (unicode >= 49062 && unicode <= 49323)
{
return "K";
}
if (unicode >= 49324 && unicode <= 49895)
{
return "L";
}
if (unicode >= 49896 && unicode <= 50370)
{
return "M";
}
if (unicode >= 50371 && unicode <= 50613)
{
return "N";
}
if (unicode >= 50614 && unicode <= 50621)
{
return "O";
}
if (unicode >= 50622 && unicode <= 50905)
{
return "P";
}
if (unicode >= 50906 && unicode <= 51386)
{
return "Q";
}
if (unicode >= 51387 && unicode <= 51445)
{
return "R";
}
if (unicode >= 51446 && unicode <= 52217)
{
return "S";
}
if (unicode >= 52218 && unicode <= 52697)
{
return "T";
}
if (unicode >= 52698 && unicode <= 52979)
{
return "W";
}
if (unicode >= 52980 && unicode <= 53640)
{
return "X";
}
if (unicode >= 53689 && unicode <= 54480)
{
return "Y";
}
if (unicode >= 54481 && unicode <= 55289)
{
return "Z";
}
return string.Empty;
}
//
// 摘要:
// 从拼音简码文件获取
//
// 参数:
// text:
// 单个汉字
public static string ResolvePinYinByFile(string text)
{
int num = "丂k丄s丅x丆m丏m丒c丗s丢d丠q両l丣y并b丩j丮j丯j丱g丳c丵z丷b丼j乀f乁y讈l乆j乑y乕h乗c乚h乛w乢g乣j乤h乧d乨s乪n乫g乬g乭d乮m乯o乲c乴x乵y乶p乷s乸n乹q乺s乻e乼z乽z乿z亀g亁q乱l亃l亄y亅j亇m亊s亐y亖s亗s亘g亜y亝q亚y亣d亪y亯x亰j亱y亴y亶d亷l亸d亹m亼j亽j亾w仈b仌b仏f仐j仒e仚x仛t仜h仢b仦c仧c仩c仭r仮f仯c仱q仴w仸y仹f仺c仼w仾d伀z伂p伃y伄d伅d伆w伇y伈x汲j伌a伒j伓p伔d伖t伜c伝y伡c伣q伨x伩x伬c伭x伮n伱n伳x伵x伷z伹q伻b伾p伿z佀s佁a佄h佅m伫z布b佉q佊b佋z佌c佒y占z佖b佡x佢q佦s佨b徊h佫h佭x佮g佱f佲m佷h佸h佺q佽c侁s侂t侅g来l侇y侊g侌y侎m侐x侒a侓l侕e仑l侘c侙c侚x侜z侞r侟c価s侢d侤t侫n侭j侰j侱c侲z侳z侴h侣l局j侸s侹t侺s侻t侾x俀t俣y系j俆x俇g俈k俉w俋y俌f俍l俒h俓j俔q俕s俖p俙x俛f侠x俢x俤d俥c俧z俫l俬s俰h俲x俴j俵b俶c俷f俹y俻b俼y俽x俿h伥c倁z倂b倃j倅c俩l倇w倈l仓c倊z个g倎t倐s们m倓t倕c幸x倗p倛q倝g倞j倠s倢j仿f値z倧z伦l倯s倰l倱h倲d倳z倴b倵w倶j倷n倸c倹j倻y倽s倿n偀y偁c偂q偄r偅z偆c伟w偊y偋b偍t偐y偑f偒t偓w偔e偖c偗s偘k偙d偛c偝b偞x偠y偡z偢c偣a偦x偧z偨c偩f偪b偫z偭m偮j偯y偰x偱x偲c偳d侧c侦z偸t偹b咱z偼j伪w傁s傂z傃s傄x傆y傇r傉n傊y傋j傌m傎d傏t傐h杰j傒x傓s傔q傕j伧c傗c伞s备b傚x傛r傜y傝t傞s傟y傠f傡b家j傤z傦g傪c傫l佣y傮z偬z傰p傱s传c伛y债z伤s傹j傼h傽z倾q傿y僀d僁x偻l僃b僄b仅j僆l戮l僈m佥q僊x僋t僌y働d僎z僐s侨q僒j僓t僔z仆p僗l僘c僙g僛q僜d僝c僞w僟j僠b僡h僢c僣t僤d侥j偾f僩x僪y僫e僯l僰b雇g僲x僴x僶m僷y僸j价j僺q僼f僽z僾a僿s仪y儁j侬n儃c亿y当d侩k俭j儊c儌j儍s儎z儏c傧b儑a儓t俦c侪c儖l儗y尽j儙q儚m儛w儜n儝q儞n偿c儠l儢l儣k儤b儥y儦b儧z儨z儩s优y儫h儬q儭c儮l儯t儰w儱l储c儳c儴x儵s儶h俪l罗l儹z傩n傥t俨y儽l儾n兂z凶x兊d兑d兎t兏c児e儿e兖y兘s兟s兡b兤h兦w内n两l兪y兯h兲t兾j兿y冃m冄r円y冇m册c冋j冎g冏j冐m胄z冓g冔x冘y冚k冝y冞s冟s冡m冣z冦k冧l冨f冩x幂m冭t冮g冴y冸p冹f冺m冾q冿j凁s凂m凃t凅g净j凊q冻d凎g凐y凒a凓l凔c凕m凖z凗c凘s凙d凚j凛l凞x凟d凢f凣f凥j処c凧y凨f凩k凪n凬f凮f凯k凲g凴p凷k凾h刄r刅c刉j刋q刌c刏j刐d刓w刔j刕l刜f刞q刟d刡m刢l刣z别b刦j刧j删s刬c刯g刱c刲k刴d刵e刼j刾c刭j剅d剆l则z剈y剉c克k刹c剒c剓l剕f剗c剘q剙c剚z刚g剥b剟d剠q剢d剣j剤j剦y剨h剫d剬z剭w剐g剰s剱j剳d剀k创c剶c铲c剸t剹l剺l剻p剼s剾k劀g划h劄z劅z劆l剧j刘l刽g劋j刿g剑j劎j劏t剂j劒j劔j劕z劖c劗z劘m劙l劚z劜y劤j劥k劦x劧z劮y劯z劰m労l劵j劶k劷y劸w効x劺m匡k劼j劽l勀k劲j勂g勄m勅c勆l勈y勊k勌j勍q勎l勏b勑c勓k勔m动d勖x务w勚y勋x勜w胜s劳l勠l勡p势s积j勥j剿c勧q勨x勪q勫f勬j勭t勮j勯d劢m勲x勳x勴l励l勶c勷x劝q匀y勼j勽b匁m匂x匃g匄g匇y匉p匊j匋t匌g匎e匑g匒d匓j匔g匘n匛j匜y匞j匟k匢h匤q匥f匧q匨z匩k匫h匬y匦g汇h匰d匮k匲l匳l匴s匵d匶j匷j匸x匼k匽y区o卂x卄n卆z卋s卌x卍w卐w协x単d卙j卛s卝g卥x卨x卪j卬a卭q卲s卶c恤x却q卼w卽j卾e厀x厁s厃w厇z厈h厊y厎d厏z厐p厑y厒q厓y厔z厖m厗t厍s厛t厜z厞f厡y厤l厧d厪j厫a厬g厌y厯l厰c厱q厉l厳y厣y厵y厷g厸l厹r厺q厼k厽l厾d叀z参c叄c叅c叆a叇d収s叏g叐b叒r叓l叕z叚j叜s叝j叞w叡r丛c叧g叴q叺c叾d叿h吀m吂m吅x吇z寸c吔y吘o吙h吚y吜c吢q吤j吥b吪e吰h吴w呐n吷x吺d吽h吿g呁j吕l呄g呅w呇q呉w呌j呍h尺c呏s呑t呚h呝e呞s呟j呠p呡w呣m呥r呧d呪z呫t呬x呭y呮q呯p呰z呴g呹y呺x呾d呿q咁x咃t咅p咇b咈f咉y咊h咍h咑d咓w咗z咘b咜t咞x咟h咠q咡e咢e咥d咮z咰s咲x咵k咶g咷t咹e咺x呙g咾l哃t哅x哊y哋d哖n哘x哛p哠h员y哢l哣p哤m哫z哬h哯x哰l哱b哴l哵b哶m哸s哹f哻h哾c唀y唂g唃g呗b含h唈y唊j唋t唌d唍w唎l唒q唓c唕z唖y唗d唘q唙d唚q唜m唝g唞d唟g唡l唥l唦s唨z唩w唫j唭q唲e唴q唵a唶j念n唹y唺t唻l唽x啀a啂g啇d啈h啋c啌q啍z啎w问w啑s啒g啓q啔q啗d啘w啚b啝h哑y启q啠z啢l
if (num < 0)
{
return string.Empty;
}
return "丂k丄s丅x丆m丏m丒c丗s丢d丠q両l丣y并b丩j丮j丯j丱g丳c丵z丷b丼j乀f乁y讈l乆j乑y乕h乗c乚h乛w乢g乣j乤h乧d乨s乪n乫g乬g乭d乮m乯o乲c乴x乵y乶p乷s乸n乹q乺s乻e乼z乽z乿z亀g亁q乱l亃l亄y亅j亇m亊s亐y亖s亗s亘g亜y亝q亚y亣d亪y亯x亰j亱y亴y亶d亷l亸d亹m亼j亽j亾w仈b仌b仏f仐j仒e仚x仛t仜h仢b仦c仧c仩c仭r仮f仯c仱q仴w仸y仹f仺c仼w仾d伀z伂p伃y伄d伅d伆w伇y伈x汲j伌a伒j伓p伔d伖t伜c伝y伡c伣q伨x伩x伬c伭x伮n伱n伳x伵x伷z伹q伻b伾p伿z佀s佁a佄h佅m伫z布b佉q佊b佋z佌c佒y占z佖b佡x佢q佦s佨b徊h佫h佭x佮g佱f佲m佷h佸h佺q佽c侁s侂t侅g来l侇y侊g侌y侎m侐x侒a侓l侕e仑l侘c侙c侚x侜z侞r侟c価s侢d侤t侫n侭j侰j侱c侲z侳z侴h侣l局j侸s侹t侺s侻t侾x俀t俣y系j俆x俇g俈k俉w俋y俌f俍l俒h俓j俔q俕s俖p俙x俛f侠x俢x俤d俥c俧z俫l俬s俰h俲x俴j俵b俶c俷f俹y俻b俼y俽x俿h伥c倁z倂b倃j倅c俩l倇w倈l仓c倊z个g倎t倐s们m倓t倕c幸x倗p倛q倝g倞j倠s倢j仿f値z倧z伦l倯s倰l倱h倲d倳z倴b倵w倶j倷n倸c倹j倻y倽s倿n偀y偁c偂q偄r偅z偆c伟w偊y偋b偍t偐y偑f偒t偓w偔e偖c偗s偘k偙d偛c偝b偞x偠y偡z偢c偣a偦x偧z偨c偩f偪b偫z偭m偮j偯y偰x偱x偲c偳d侧c侦z偸t偹b咱z偼j伪w傁s傂z傃s傄x傆y傇r傉n傊y傋j傌m傎d傏t傐h杰j傒x傓s傔q傕j伧c傗c伞s备b傚x傛r傜y傝t傞s傟y傠f傡b家j傤z傦g傪c傫l佣y傮z偬z傰p傱s传c伛y债z伤s傹j傼h傽z倾q傿y僀d僁x偻l僃b僄b仅j僆l戮l僈m佥q僊x僋t僌y働d僎z僐s侨q僒j僓t僔z仆p僗l僘c僙g僛q僜d僝c僞w僟j僠b僡h僢c僣t僤d侥j偾f僩x僪y僫e僯l僰b雇g僲x僴x僶m僷y僸j价j僺q僼f僽z僾a僿s仪y儁j侬n儃c亿y当d侩k俭j儊c儌j儍s儎z儏c傧b儑a儓t俦c侪c儖l儗y尽j儙q儚m儛w儜n儝q儞n偿c儠l儢l儣k儤b儥y儦b儧z儨z儩s优y儫h儬q儭c儮l儯t儰w儱l储c儳c儴x儵s儶h俪l罗l儹z傩n傥t俨y儽l儾n兂z凶x兊d兑d兎t兏c児e儿e兖y兘s兟s兡b兤h兦w内n两l兪y兯h兲t兾j兿y冃m冄r円y冇m册c冋j冎g冏j冐m胄z冓g冔x冘y冚k冝y冞s冟s冡m冣z冦k冧l冨f冩x幂m冭t冮g冴y冸p冹f冺m冾q冿j凁s凂m凃t凅g净j凊q冻d凎g凐y凒a凓l凔c凕m凖z凗c凘s凙d凚j凛l凞x凟d凢f凣f凥j処c凧y凨f凩k凪n凬f凮f凯k凲g凴p凷k凾h刄r刅c刉j刋q刌c刏j刐d刓w刔j刕l刜f刞q刟d刡m刢l刣z别b刦j刧j删s刬c刯g刱c刲k刴d刵e刼j刾c刭j剅d剆l则z剈y剉c克k刹c剒c剓l剕f剗c剘q剙c剚z刚g剥b剟d剠q剢d剣j剤j剦y剨h剫d剬z剭w剐g剰s剱j剳d剀k创c剶c铲c剸t剹l剺l剻p剼s剾k劀g划h劄z劅z劆l剧j刘l刽g劋j刿g剑j劎j劏t剂j劒j劔j劕z劖c劗z劘m劙l劚z劜y劤j劥k劦x劧z劮y劯z劰m労l劵j劶k劷y劸w効x劺m匡k劼j劽l勀k劲j勂g勄m勅c勆l勈y勊k勌j勍q勎l勏b勑c勓k勔m动d勖x务w勚y勋x勜w胜s劳l勠l勡p势s积j勥j剿c勧q勨x勪q勫f勬j勭t勮j勯d劢m勲x勳x勴l励l勶c勷x劝q匀y勼j勽b匁m匂x匃g匄g匇y匉p匊j匋t匌g匎e匑g匒d匓j匔g匘n匛j匜y匞j匟k匢h匤q匥f匧q匨z匩k匫h匬y匦g汇h匰d匮k匲l匳l匴s匵d匶j匷j匸x匼k匽y区o卂x卄n卆z卋s卌x卍w卐w协x単d卙j卛s卝g卥x卨x卪j卬a卭q卲s卶c恤x却q卼w卽j卾e厀x厁s厃w厇z厈h厊y厎d厏z厐p厑y厒q厓y厔z厖m厗t厍s厛t厜z厞f厡y厤l厧d厪j厫a厬g厌y厯l厰c厱q厉l厳y厣y厵y厷g厸l厹r厺q厼k厽l厾d叀z参c叄c叅c叆a叇d収s叏g叐b叒r叓l叕z叚j叜s叝j叞w叡r丛c叧g叴q叺c叾d叿h吀m吂m吅x吇z寸c吔y吘o吙h吚y吜c吢q吤j吥b吪e吰h吴w呐n吷x吺d吽h吿g呁j吕l呄g呅w呇q呉w呌j呍h尺c呏s呑t呚h呝e呞s呟j呠p呡w呣m呥r呧d呪z呫t呬x呭y呮q呯p呰z呴g呹y呺x呾d呿q咁x咃t咅p咇b咈f咉y咊h咍h咑d咓w咗z咘b咜t咞x咟h咠q咡e咢e咥d咮z咰s咲x咵k咶g咷t咹e咺x呙g咾l哃t哅x哊y哋d哖n哘x哛p哠h员y哢l哣p哤m哫z哬h哯x哰l哱b哴l哵b哶m哸s哹f哻h哾c唀y唂g唃g呗b含h唈y唊j唋t唌d唍w唎l唒q唓c唕z唖y唗d唘q唙d唚q唜m唝g唞d唟g唡l唥l唦s唨z唩w唫j唭q唲e唴q唵a唶j念n唹y唺t唻l唽x啀a啂g啇d啈h啋c啌q啍z啎w问w啑s啒g啓q啔q啗d啘w啚b啝h哑y启q啠z啢l衔
}
//
// 摘要:
// 获取类名
//
// 参数:
// dbColumnName:
public static string CsharpName(string dbColumnName)
{
if (dbColumnName.Contains("_"))
{
string[] value = (from it in dbColumnName.Split('_')
select FirstUpper(it)).ToArray();
return string.Join("", value);
}
return FirstUpper(dbColumnName);
}
//
// 摘要:
// 将值的首字母大写
//
// 参数:
// value:
// 值
public static string FirstUpper(string value)
{
string text = value.Substring(0, 1).ToUpper();
return text + value.Substring(1, value.Length - 1);
}
}
}