diff --git a/NewLife.Core/Agent/AgentService.cs b/NewLife.Core/Agent/AgentService.cs
index 53b6f80..9695779 100644
--- a/NewLife.Core/Agent/AgentService.cs
+++ b/NewLife.Core/Agent/AgentService.cs
@@ -6,13 +6,13 @@ namespace NewLife.Agent
{
#region 属性
/// <summary>线程数</summary>
- public override int ThreadCount { get { return 2; } }
+ public override System.Int32 ThreadCount { get { return 2; } }
/// <summary>显示名</summary>
- public override string DisplayName { get { return "新生命服务代理"; } }
+ public override System.String DisplayName { get { return "新生命服务代理"; } }
/// <summary>描述</summary>
- public override string Description { get { return "用于承载各种服务的服务代理!"; } }
+ public override System.String Description { get { return "用于承载各种服务的服务代理!"; } }
#endregion
#region 构造函数
@@ -28,7 +28,7 @@ namespace NewLife.Agent
/// <summary>核心工作方法。调度线程会定期调用该方法</summary>
/// <param name="index">线程序号</param>
/// <returns>是否立即开始下一步工作。某些任务能达到满负荷,线程可以不做等待</returns>
- public override bool Work(int index)
+ public override System.Boolean Work(System.Int32 index)
{
// XAgent讲开启ThreadCount个线程,0<index<ThreadCount,本函数即为每个任务线程的主函数,间隔Interval循环调用
//WriteLine("任务{0},当前时间:{1}", index, DateTime.Now);
diff --git a/NewLife.Core/Agent/AgentServiceBase.cs b/NewLife.Core/Agent/AgentServiceBase.cs
index 79b03fa..36e883e 100644
--- a/NewLife.Core/Agent/AgentServiceBase.cs
+++ b/NewLife.Core/Agent/AgentServiceBase.cs
@@ -44,7 +44,7 @@ namespace NewLife.Agent
if (Args.Length > 1)
{
#region 命令
- String cmd = Args[1].ToLower();
+ var cmd = Args[1].ToLower();
if (cmd == "-s") //启动服务
{
var ServicesToRun = new ServiceBase[] { service };
@@ -89,7 +89,7 @@ namespace NewLife.Agent
else if (cmd == "-step") //单步执行任务
{
var service2 = new TService();
- for (int i = 0; i < service2.ThreadCount; i++)
+ for (var i = 0; i < service2.ThreadCount; i++)
{
service2.Work(i);
}
@@ -143,11 +143,11 @@ namespace NewLife.Agent
try
{
var count = Instance.ThreadCount;
- Int32 n = 0;
+ var n = 0;
if (count > 1)
{
Console.Write("请输入要调试的任务(任务数:{0}):", count);
- ConsoleKeyInfo k = Console.ReadKey();
+ var k = Console.ReadKey();
Console.WriteLine();
n = k.KeyChar - '0';
}
@@ -155,7 +155,7 @@ namespace NewLife.Agent
Console.WriteLine("正在单步调试……");
if (n < 0 || n > count - 1)
{
- for (int i = 0; i < count; i++)
+ for (var i = 0; i < count; i++)
{
service.Work(i);
}
@@ -334,11 +334,11 @@ namespace NewLife.Agent
private Dictionary<String, IServer> _AttachServers;
/// <summary>附加服务</summary>
- public Dictionary<String, IServer> AttachServers { get { return _AttachServers ?? (_AttachServers = new Dictionary<string, IServer>()); } /*set { _AttachServers = value; }*/ }
+ public Dictionary<String, IServer> AttachServers { get { return _AttachServers ?? (_AttachServers = new Dictionary<String, IServer>()); } /*set { _AttachServers = value; }*/ }
/// <summary>服务启动事件</summary>
/// <param name="args"></param>
- protected override void OnStart(string[] args)
+ protected override void OnStart(String[] args)
{
StartWork();
@@ -436,7 +436,7 @@ namespace NewLife.Agent
/// <summary>销毁资源</summary>
/// <param name="disposing"></param>
- protected override void Dispose(bool disposing)
+ protected override void Dispose(Boolean disposing)
{
if (AttachServers != null)
{
@@ -460,7 +460,7 @@ namespace NewLife.Agent
try
{
- for (int i = 0; i < ThreadCount; i++)
+ for (var i = 0; i < ThreadCount; i++)
{
StartWork(i);
}
@@ -485,14 +485,14 @@ namespace NewLife.Agent
// 可以通过设置任务的时间间隔小于0来关闭指定任务
//var ts = Setting.Current.Intervals.SplitAsInt();
- Int32 time = Intervals[0];//ts[0];
+ var time = Intervals[0];//ts[0];
// 使用专用的时间间隔
if (index < Intervals.Length) time = Intervals[index];
if (time < 0) return;
Threads[index] = new Thread(workWaper);
//String name = "XAgent_" + index;
- String name = "A" + index;
+ var name = "A" + index;
if (ThreadNames != null && ThreadNames.Length > index && !String.IsNullOrEmpty(ThreadNames[index]))
name = ThreadNames[index];
Threads[index].Name = name;
@@ -505,14 +505,14 @@ namespace NewLife.Agent
/// <param name="data">线程序号</param>
private void workWaper(Object data)
{
- Int32 index = (Int32)data;
+ var index = (Int32)data;
// 旧异常
Exception oldEx = null;
while (true)
{
- Boolean isContinute = false;
+ var isContinute = false;
Active[index] = DateTime.Now;
try
@@ -551,7 +551,7 @@ namespace NewLife.Agent
}
//var ts = Setting.Current.Intervals.SplitAsInt();
- Int32 time = Intervals[0]; //ts[0];
+ var time = Intervals[0]; //ts[0];
//使用专用的时间间隔
if (index < Intervals.Length) time = Intervals[index];
@@ -690,7 +690,7 @@ namespace NewLife.Agent
if (_Active == null)
{
_Active = new DateTime[ThreadCount];
- for (int i = 0; i < ThreadCount; i++)
+ for (var i = 0; i < ThreadCount; i++)
{
_Active[i] = DateTime.Now;
}
@@ -706,7 +706,7 @@ namespace NewLife.Agent
if (Threads == null || Threads.Length < 1) return;
//检查已经停止了的工作线程
- for (int i = 0; i < ThreadCount; i++)
+ for (var i = 0; i < ThreadCount; i++)
{
if (Threads[i] != null && !Threads[i].IsAlive)
{
@@ -720,7 +720,7 @@ namespace NewLife.Agent
var max = Setting.Current.MaxActive;
if (max <= 0) return;
- for (int i = 0; i < ThreadCount; i++)
+ for (var i = 0; i < ThreadCount; i++)
{
var ts = DateTime.Now - Active[i];
if (ts.TotalSeconds > max)
@@ -743,7 +743,7 @@ namespace NewLife.Agent
if (max <= 0) return false;
var p = Process.GetCurrentProcess();
- long cur = p.WorkingSet64 + p.PrivateMemorySize64;
+ var cur = p.WorkingSet64 + p.PrivateMemorySize64;
cur = cur / 1024 / 1024;
if (cur > max)
{
@@ -809,7 +809,7 @@ namespace NewLife.Agent
WriteLine("重启服务!");
//在临时目录生成重启服务的批处理文件
- String filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "重启.bat");
+ var filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "重启.bat");
if (File.Exists(filename)) File.Delete(filename);
File.AppendAllText(filename, "net stop " + ServiceName);
@@ -820,10 +820,10 @@ namespace NewLife.Agent
//准备重启服务,等待所有工作线程返回
IsShutdowning = true;
- for (int i = 0; i < 10; i++)
+ for (var i = 0; i < 10; i++)
{
- Boolean b = false;
- foreach (Thread item in Threads)
+ var b = false;
+ foreach (var item in Threads)
{
if (item.IsAlive)
{
diff --git a/NewLife.Core/Agent/ServiceControl.cs b/NewLife.Core/Agent/ServiceControl.cs
index 2b65e60..de45b0a 100644
--- a/NewLife.Core/Agent/ServiceControl.cs
+++ b/NewLife.Core/Agent/ServiceControl.cs
@@ -89,7 +89,7 @@ namespace NewLife.Agent
/// <param name="cmd"></param>
protected static void RunSC(String cmd)
{
- String path = Environment.SystemDirectory;
+ var path = Environment.SystemDirectory;
path = Path.Combine(path, @"sc.exe");
if (!File.Exists(path)) path = "sc.exe";
if (!File.Exists(path)) return;
diff --git a/NewLife.Core/Agent/ServiceHelper.cs b/NewLife.Core/Agent/ServiceHelper.cs
index 70acddd..0884d9c 100644
--- a/NewLife.Core/Agent/ServiceHelper.cs
+++ b/NewLife.Core/Agent/ServiceHelper.cs
@@ -160,7 +160,7 @@ namespace NewLife.Agent
try
{
//尝试访问一下才知道是否已安装
- Boolean b = control.CanShutdown;
+ var b = control.CanShutdown;
return true;
}
catch { return false; }
@@ -180,7 +180,7 @@ namespace NewLife.Agent
try
{
//尝试访问一下才知道是否已安装
- Boolean b = control.CanShutdown;
+ var b = control.CanShutdown;
}
catch { return false; }
diff --git a/NewLife.Core/Applications/IP/Ip.cs b/NewLife.Core/Applications/IP/Ip.cs
index fdf62b5..3e26d7e 100644
--- a/NewLife.Core/Applications/IP/Ip.cs
+++ b/NewLife.Core/Applications/IP/Ip.cs
@@ -11,7 +11,7 @@ namespace NewLife.IP
/// <summary>IP搜索</summary>
public static class Ip
{
- private static object lockHelper = new object();
+ private static Object lockHelper = new Object();
private static Zip zip;
/// <summary>数据文件</summary>
@@ -126,11 +126,11 @@ namespace NewLife.IP
}
}
- static uint IPToUInt32(String IpValue)
+ static UInt32 IPToUInt32(String IpValue)
{
var ss = IpValue.Split('.');
var buf = new Byte[4];
- for (int i = 0; i < 4; i++)
+ for (var i = 0; i < 4; i++)
{
var n = 0;
if (i < ss.Length && Int32.TryParse(ss[i], out n))
@@ -144,7 +144,7 @@ namespace NewLife.IP
class MyIpProvider : NetHelper.IpProvider
{
- public string GetAddress(IPAddress addr)
+ public String GetAddress(IPAddress addr)
{
return Ip.GetAddress(addr);
}
diff --git a/NewLife.Core/Applications/IP/Zip.cs b/NewLife.Core/Applications/IP/Zip.cs
index 45348f9..d3a8629 100644
--- a/NewLife.Core/Applications/IP/Zip.cs
+++ b/NewLife.Core/Applications/IP/Zip.cs
@@ -6,11 +6,11 @@ namespace NewLife.IP
{
class Zip : IDisposable
{
- uint Index_Set;
- uint Index_End;
- uint Index_Count;
- uint Search_Index_Set;
- uint Search_Index_End;
+ UInt32 Index_Set;
+ UInt32 Index_End;
+ UInt32 Index_Count;
+ UInt32 Search_Index_Set;
+ UInt32 Search_Index_End;
IndexInfo Search_Set;
IndexInfo Search_Mid;
IndexInfo Search_End;
@@ -89,10 +89,10 @@ namespace NewLife.IP
return ReadAddressInfoAtOffset(Search_Set.Offset);
}
- String ReadAddressInfoAtOffset(uint Offset)
+ String ReadAddressInfoAtOffset(UInt32 Offset)
{
_Stream.Position = Offset + 4;
- Byte tag = GetTag();
+ var tag = GetTag();
String addr;
String area;
if (tag == 1)
@@ -101,7 +101,7 @@ namespace NewLife.IP
tag = GetTag();
if (tag == 2)
{
- uint offset = GetOffset();
+ var offset = GetOffset();
area = ReadArea();
_Stream.Position = offset;
addr = ReadString();
@@ -117,7 +117,7 @@ namespace NewLife.IP
{
if (tag == 2)
{
- uint offset = GetOffset();
+ var offset = GetOffset();
area = ReadArea();
_Stream.Position = offset;
addr = ReadString();
@@ -132,7 +132,7 @@ namespace NewLife.IP
return (addr + " " + area).Trim();
}
- uint GetOffset()
+ UInt32 GetOffset()
{
return BitConverter.ToUInt32(new Byte[]
{
@@ -145,7 +145,7 @@ namespace NewLife.IP
String ReadArea()
{
- Byte tag = GetTag();
+ var tag = GetTag();
if (tag == 1 || tag == 2)
_Stream.Position = GetOffset();
else
@@ -174,7 +174,7 @@ namespace NewLife.IP
return (Byte)_Stream.ReadByte();
}
- IndexInfo IndexInfoAtPos(uint Index_Pos)
+ IndexInfo IndexInfoAtPos(UInt32 Index_Pos)
{
var inf = new IndexInfo();
_Stream.Position = Index_Set + 7u * Index_Pos;
@@ -185,9 +185,9 @@ namespace NewLife.IP
return inf;
}
- uint GetUInt32()
+ UInt32 GetUInt32()
{
- Byte[] array = new Byte[4];
+ var array = new Byte[4];
_Stream.Read(array, 0, 4);
return BitConverter.ToUInt32(array, 0);
}
@@ -196,9 +196,9 @@ namespace NewLife.IP
/// <summary>索引结构</summary>
class IndexInfo
{
- public uint IpSet;
- public uint IpEnd;
- public uint Offset;
+ public UInt32 IpSet;
+ public UInt32 IpEnd;
+ public UInt32 Offset;
}
}
}
\ No newline at end of file
diff --git a/NewLife.Core/Collections/ConcurrentHashSet.cs b/NewLife.Core/Collections/ConcurrentHashSet.cs
index d44106b..178af9d 100644
--- a/NewLife.Core/Collections/ConcurrentHashSet.cs
+++ b/NewLife.Core/Collections/ConcurrentHashSet.cs
@@ -16,7 +16,7 @@ namespace NewLife.Collections
/// <summary>实例化一个并行哈希集合</summary>
public ConcurrentHashSet()
{
- _dic = new ConcurrentDictionary<T, byte>();
+ _dic = new ConcurrentDictionary<T, Byte>();
}
/// <summary>是否空集合</summary>
diff --git a/NewLife.Core/Collections/ListBase.cs b/NewLife.Core/Collections/ListBase.cs
index 1f848f0..f56bcbe 100644
--- a/NewLife.Core/Collections/ListBase.cs
+++ b/NewLife.Core/Collections/ListBase.cs
@@ -18,10 +18,10 @@ namespace NewLife.Collections
}
/// <summary>列表元素个数</summary>
- public virtual int Count { get { return InnerList.Count; } }
+ public virtual Int32 Count { get { return InnerList.Count; } }
/// <summary>是否固定大小</summary>
- public virtual bool IsFixedSize
+ public virtual Boolean IsFixedSize
{
get
{
@@ -30,7 +30,7 @@ namespace NewLife.Collections
}
/// <summary>是否只读</summary>
- public virtual bool IsReadOnly
+ public virtual Boolean IsReadOnly
{
get
{
@@ -41,7 +41,7 @@ namespace NewLife.Collections
/// <summary>获取或设置指定索引处的元素。</summary>
/// <param name="index"></param>
/// <returns></returns>
- public virtual T this[int index] { get { return InnerList[index]; } set { InnerList[index] = value; } }
+ public virtual T this[Int32 index] { get { return InnerList[index]; } set { InnerList[index] = value; } }
#endregion
#region 构造
@@ -64,7 +64,7 @@ namespace NewLife.Collections
/// <summary>清空</summary>
public virtual void Clear()
{
- for (int i = Count - 1; i >= 0; i--)
+ for (var i = Count - 1; i >= 0; i--)
{
RemoveAt(i);
}
@@ -73,7 +73,7 @@ namespace NewLife.Collections
/// <summary>是否包含指定元素</summary>
/// <param name="value">数值</param>
/// <returns></returns>
- public virtual bool Contains(T value)
+ public virtual Boolean Contains(T value)
{
return (IndexOf(value) != -1);
}
@@ -81,9 +81,9 @@ namespace NewLife.Collections
/// <summary>把元素复制到一个数组里面</summary>
/// <param name="array"></param>
/// <param name="index"></param>
- public virtual void CopyTo(T[] array, int index)
+ public virtual void CopyTo(T[] array, Int32 index)
{
- for (int i = 0; i < Count; i++)
+ for (var i = 0; i < Count; i++)
{
array[index + i] = this[i];
}
@@ -104,7 +104,7 @@ namespace NewLife.Collections
/// <summary>确定列表中特定项的索引。</summary>
/// <param name="value">要在列表中定位的对象。</param>
/// <returns></returns>
- public virtual int IndexOf(T value)
+ public virtual Int32 IndexOf(T value)
{
//for (int i = 0; i < this.Count; i++)
//{
@@ -120,12 +120,12 @@ namespace NewLife.Collections
/// <summary>将一个项插入指定索引处的列表。</summary>
/// <param name="index"></param>
/// <param name="value">数值</param>
- public virtual void Insert(int index, T value)
+ public virtual void Insert(Int32 index, T value)
{
InnerList.Insert(index, value);
}
- private static bool IsCompatibleType(object value)
+ private static Boolean IsCompatibleType(Object value)
{
if (((value != null) || typeof(T).IsValueType) && !(value is T))
{
@@ -137,9 +137,9 @@ namespace NewLife.Collections
/// <summary>从列表中移除指定对象</summary>
/// <param name="value">数值</param>
/// <returns></returns>
- public virtual bool Remove(T value)
+ public virtual Boolean Remove(T value)
{
- int index = IndexOf(value);
+ var index = IndexOf(value);
if (index >= 0)
{
RemoveAt(index);
@@ -150,22 +150,22 @@ namespace NewLife.Collections
/// <summary>移除指定索引处的列表项。</summary>
/// <param name="index"></param>
- public virtual void RemoveAt(int index)
+ public virtual void RemoveAt(Int32 index)
{
InnerList.RemoveAt(index);
}
#endregion
#region ICollection接口
- void ICollection.CopyTo(Array array, int index)
+ void ICollection.CopyTo(Array array, Int32 index)
{
- for (int i = 0; i < Count; i++)
+ for (var i = 0; i < Count; i++)
{
array.SetValue(this[i], index);
}
}
- bool ICollection.IsSynchronized
+ Boolean ICollection.IsSynchronized
{
get
{
@@ -173,7 +173,7 @@ namespace NewLife.Collections
}
}
- object ICollection.SyncRoot
+ Object ICollection.SyncRoot
{
get
{
@@ -187,7 +187,7 @@ namespace NewLife.Collections
{
//return new IListEnumerator<T>(this);
- foreach (T item in InnerList)
+ foreach (var item in InnerList)
{
yield return item;
}
@@ -201,7 +201,7 @@ namespace NewLife.Collections
#endregion
#region IList接口
- int IList.Add(object value)
+ Int32 IList.Add(Object value)
{
if (!IsCompatibleType(value)) throw new ArgumentException();
@@ -214,35 +214,35 @@ namespace NewLife.Collections
Clear();
}
- bool IList.Contains(object value)
+ Boolean IList.Contains(Object value)
{
if (!IsCompatibleType(value)) return false;
return Contains((T)value);
}
- int IList.IndexOf(object value)
+ Int32 IList.IndexOf(Object value)
{
if (!IsCompatibleType(value)) return -1;
return IndexOf((T)value);
}
- void IList.Insert(int index, object value)
+ void IList.Insert(Int32 index, Object value)
{
if (!IsCompatibleType(value)) throw new ArgumentException();
Insert(index, (T)value);
}
- void IList.Remove(object value)
+ void IList.Remove(Object value)
{
if (!IsCompatibleType(value)) throw new ArgumentException();
Remove((T)value);
}
- object IList.this[int index]
+ Object IList.this[Int32 index]
{
get
{
diff --git a/NewLife.Core/Common/CombGuid.cs b/NewLife.Core/Common/CombGuid.cs
index ab00eb0..613013f 100644
--- a/NewLife.Core/Common/CombGuid.cs
+++ b/NewLife.Core/Common/CombGuid.cs
@@ -162,7 +162,7 @@ namespace NewLife
else
{
m_value = new Byte[_SizeOfGuid];
- for (Int32 i = 0; i < _SizeOfGuid; i++)
+ for (var i = 0; i < _SizeOfGuid; i++)
{
m_value[_GuidComparisonOrders[i]] = value[i];
}
@@ -304,7 +304,7 @@ namespace NewLife
}
else
{
- for (Int32 i = 0; i < _SizeOfGuid; i++)
+ for (var i = 0; i < _SizeOfGuid; i++)
{
ret[i] = m_value[_GuidComparisonOrders[i]];
}
@@ -817,7 +817,7 @@ namespace NewLife
private static CombGuidComparison Compare(CombGuid x, CombGuid y)
{
// Swap to the correct order to be compared
- for (Int32 i = 0; i < _SizeOfGuid; i++)
+ for (var i = 0; i < _SizeOfGuid; i++)
{
Byte b1, b2;
@@ -1183,7 +1183,7 @@ namespace NewLife
if (hasHyphen && !ParseChar('-')) { return false; }
var _d = new Byte[8];
- for (Int32 i = 0; i < _d.Length; i++)
+ for (var i = 0; i < _d.Length; i++)
{
UInt64 dd;
if (!ParseHex(2, hasHyphen, out dd)) { return false; }
@@ -1218,7 +1218,7 @@ namespace NewLife
{
res = 0;
- for (Int32 i = 0; i < length; i++)
+ for (var i = 0; i < length; i++)
{
if (Eof) { return !((i + 1 != length)); }
diff --git a/NewLife.Core/Common/HardInfo.cs b/NewLife.Core/Common/HardInfo.cs
index 1ce85b2..d16ee44 100644
--- a/NewLife.Core/Common/HardInfo.cs
+++ b/NewLife.Core/Common/HardInfo.cs
@@ -103,7 +103,7 @@ namespace NewLife.Common
{
//if (String.IsNullOrEmpty(_Volume)) _Volume = GetInfo("Win32_DiskDrive", "Model");
//磁盘序列号不够明显,故使用驱动器序列号代替
- String id = AppDomain.CurrentDomain.BaseDirectory.Substring(0, 2);
+ var id = AppDomain.CurrentDomain.BaseDirectory.Substring(0, 2);
if (_Volume == null) _Volume = GetInfo("Win32_LogicalDisk Where DeviceID=\"" + id + "\"", "VolumeSerialNumber");
return _Volume;
}
@@ -120,17 +120,17 @@ namespace NewLife.Common
var cimobject = new ManagementClass("Win32_NetworkAdapterConfiguration");
var moc = cimobject.GetInstances();
var bbs = new List<String>();
- foreach (ManagementObject mo in moc)
+ foreach (var mo in moc)
{
if (mo != null &&
mo.Properties != null &&
mo.Properties["MacAddress"] != null &&
mo.Properties["MacAddress"].Value != null &&
mo.Properties["IPEnabled"] != null &&
- (bool)mo.Properties["IPEnabled"].Value)
+ (Boolean)mo.Properties["IPEnabled"].Value)
{
//bbs.Add(mo.Properties["MacAddress"].Value.ToString());
- String s = mo.Properties["MacAddress"].Value.ToString();
+ var s = mo.Properties["MacAddress"].Value.ToString();
if (!bbs.Contains(s)) bbs.Add(s);
}
}
@@ -157,19 +157,19 @@ namespace NewLife.Common
var cimobject = new ManagementClass("Win32_NetworkAdapterConfiguration");
var moc = cimobject.GetInstances();
var bbs = new List<String>();
- foreach (ManagementObject mo in moc)
+ foreach (var mo in moc)
{
if (mo != null &&
mo.Properties != null &&
mo.Properties["IPAddress"] != null &&
mo.Properties["IPAddress"].Value != null &&
mo.Properties["IPEnabled"] != null &&
- (bool)mo.Properties["IPEnabled"].Value)
+ (Boolean)mo.Properties["IPEnabled"].Value)
{
- String[] ss = (String[])mo.Properties["IPAddress"].Value;
+ var ss = (String[])mo.Properties["IPAddress"].Value;
if (ss != null)
{
- foreach (String s in ss)
+ foreach (var s in ss)
if (!bbs.Contains(s)) bbs.Add(s);
}
//bbs.Add(mo.Properties["IPAddress"].Value.ToString());
@@ -262,9 +262,9 @@ namespace NewLife.Common
set { _OSVersion = value; }
}
- private long _Memory;
+ private Int64 _Memory;
/// <summary>内存</summary>
- public long Memory
+ public Int64 Memory
{
get { return _Memory; }
set { _Memory = value; }
@@ -378,7 +378,7 @@ namespace NewLife.Common
var wql = String.Format("Select {0} From {1}", property, path);
var cimobject = new ManagementObjectSearcher(wql);
var moc = cimobject.Get();
- foreach (ManagementObject mo in moc)
+ foreach (var mo in moc)
{
if (mo != null &&
mo.Properties != null &&
diff --git a/NewLife.Core/Common/IdentityCard.cs b/NewLife.Core/Common/IdentityCard.cs
index 45c123a..dd15419 100644
--- a/NewLife.Core/Common/IdentityCard.cs
+++ b/NewLife.Core/Common/IdentityCard.cs
@@ -91,16 +91,16 @@ namespace NewLife.Common
idc.ParseBirthdayAndSex18(card);
//校验码验证 GB11643-1999标准
- String[] arrVarifyCode = ("1,0,x,9,8,7,6,5,4,3,2").Split(',');
- Int32[] Wi = new Int32[] { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
- char[] Ai = card.Remove(17).ToCharArray();
- int sum = 0;
- for (int i = 0; i < 17; i++)
+ var arrVarifyCode = ("1,0,x,9,8,7,6,5,4,3,2").Split(',');
+ var Wi = new Int32[] { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
+ var Ai = card.Remove(17).ToCharArray();
+ var sum = 0;
+ for (var i = 0; i < 17; i++)
{
sum += Wi[i] * (Ai[i] - '0');
}
- int y = -1;
+ var y = -1;
Math.DivRem(sum, 11, out y);
if (arrVarifyCode[y] != card.Substring(17, 1).ToLower())
throw new XException("验证码校验失败!");
@@ -115,10 +115,10 @@ namespace NewLife.Common
private static String ParseArea(String area)
{
- Int32 n = 0;
+ var n = 0;
if (!Int32.TryParse(area, out n)) throw new XException("非法地区编码!");
- String str = area.Substring(0, 2);
+ var str = area.Substring(0, 2);
if (!Int32.TryParse(str, out n)) throw new XException("非法省份编码!");
if (!ads.Contains(n)) throw new XException("没有找到该省份!");
@@ -130,22 +130,22 @@ namespace NewLife.Common
#region 分析生日、性别
private void ParseBirthdayAndSex15(String card)
{
- String str = card.Substring(6, 2);
- Int32 n = Int32.Parse(str);
+ var str = card.Substring(6, 2);
+ var n = Int32.Parse(str);
if (n < 20)
n = 20;
else
n = 19;
- String birth = n.ToString() + card.Substring(6, 6).Insert(2, "-").Insert(5, "-");
- DateTime d = DateTime.MinValue;
+ var birth = n.ToString() + card.Substring(6, 6).Insert(2, "-").Insert(5, "-");
+ var d = DateTime.MinValue;
if (!DateTime.TryParse(birth, out d)) throw new XException("生日不正确!");
Birthday = d;
//最后一位是性别
n = Convert.ToInt32(card.Substring(card.Length - 1, 1));
- Boolean man = n % 2 != 0;
+ var man = n % 2 != 0;
if (man)
Sex = SexType.Man;
@@ -155,14 +155,14 @@ namespace NewLife.Common
private void ParseBirthdayAndSex18(String card)
{
- String birth = card.Substring(6, 8).Insert(4, "-").Insert(7, "-");
- DateTime d = DateTime.MinValue;
+ var birth = card.Substring(6, 8).Insert(4, "-").Insert(7, "-");
+ var d = DateTime.MinValue;
if (!DateTime.TryParse(birth, out d)) throw new XException("生日不正确!");
Birthday = d;
//倒数第二位是性别
- Int32 n = Convert.ToInt32(card.Substring(card.Length - 2, 1));
- Boolean man = n % 2 != 0;
+ var n = Convert.ToInt32(card.Substring(card.Length - 2, 1));
+ var man = n % 2 != 0;
if (man)
Sex = SexType.Man;
diff --git a/NewLife.Core/Common/PinYin.cs b/NewLife.Core/Common/PinYin.cs
index 096098e..234b1e5 100644
--- a/NewLife.Core/Common/PinYin.cs
+++ b/NewLife.Core/Common/PinYin.cs
@@ -14,7 +14,7 @@ namespace NewLife.Common
public class PinYin
{
#region 数组信息
- private static int[] pyValue = new int[]
+ private static Int32[] pyValue = new Int32[]
{
-20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242,
-20230, -20051, -20036, -20032, -20026, -20002, -19990, -19986, -19982,
@@ -62,7 +62,7 @@ namespace NewLife.Common
-10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254
};
- private static string[] pyName = new string[]
+ private static String[] pyName = new String[]
{
"A", "Ai", "An", "Ang", "Ao", "Ba", "Bai", "Ban", "Bang", "Bao", "Bei",
"Ben", "Beng", "Bi", "Bian", "Biao", "Bie", "Bin", "Bing", "Bo", "Bu",
@@ -506,11 +506,11 @@ namespace NewLife.Common
#region 变量定义
// GB2312-80 标准规范中第一个汉字的机内码.即"啊"的机内码
- private const int firstChCode = -20319;
+ private const Int32 firstChCode = -20319;
// GB2312-80 标准规范中最后一个汉字的机内码.即"齄"的机内码
- private const int lastChCode = -2050;
+ private const Int32 lastChCode = -2050;
// GB2312-80 标准规范中最后一个一级汉字的机内码.即"座"的机内码
- private const int lastOfOneLevelChCode = -10247;
+ private const Int32 lastOfOneLevelChCode = -10247;
// 配置中文字符
//static Regex regex = new Regex("[\u4e00-\u9fa5]$");
#endregion
@@ -574,16 +574,16 @@ namespace NewLife.Common
if (chr <= lastOfOneLevelChCode)
{
// 将一级汉字分为12块,每块33个汉字.
- for (int aPos = 11; aPos >= 0; aPos--)
+ for (var aPos = 11; aPos >= 0; aPos--)
{
- int aboutPos = aPos * 33;
+ var aboutPos = aPos * 33;
// 从最后的块开始扫描,如果机内码大于块的第一个机内码,说明在此块中
if (chr >= pyValue[aboutPos])
{
// Console.WriteLine("存在于第 " + aPos.ToString() + " 块,此块的第一个机内码是: " + pyValue[aPos * 33].ToString());
// 遍历块中的每个音节机内码,从最后的音节机内码开始扫描,
// 如果音节内码小于机内码,则取此音节
- for (int i = aboutPos + 32; i >= aboutPos; i--)
+ for (var i = aboutPos + 32; i >= aboutPos; i--)
{
if (pyValue[i] <= chr)
{
diff --git a/NewLife.Core/Common/Runtime.cs b/NewLife.Core/Common/Runtime.cs
index 088692e..addc219 100644
--- a/NewLife.Core/Common/Runtime.cs
+++ b/NewLife.Core/Common/Runtime.cs
@@ -32,7 +32,7 @@ namespace NewLife
#if __MOBILE__ || __CORE__
_IsConsole = false;
#else
- IntPtr ip = Win32Native.GetStdHandle(-11);
+ var ip = Win32Native.GetStdHandle(-11);
if (ip == IntPtr.Zero || ip == INVALID_HANDLE_VALUE)
_IsConsole = false;
else
@@ -300,7 +300,7 @@ namespace NewLife
/// <returns></returns>
public static Boolean SetProcessWorkingSetSize(Int32 pid, Int32 min, Int32 max)
{
- Process p = pid <= 0 ? Process.GetCurrentProcess() : Process.GetProcessById(pid);
+ var p = pid <= 0 ? Process.GetCurrentProcess() : Process.GetProcessById(pid);
return Win32Native.SetProcessWorkingSetSize(p.Handle, min, max);
}
@@ -372,7 +372,7 @@ namespace NewLife
#else
/// <summary>标识系统上的程序组</summary>
[Flags]
- enum OSSuites : ushort
+ enum OSSuites : UInt16
{
//None = 0,
SmallBusiness = 0x00000001,
@@ -392,7 +392,7 @@ namespace NewLife
}
/// <summary>标识系统类型</summary>
- enum OSProductType : byte
+ enum OSProductType : Byte
{
/// <summary>工作站</summary>
[Description("工作站")]
@@ -410,50 +410,50 @@ namespace NewLife
class Win32Native
{
[DllImport("kernel32.dll", SetLastError = true)]
- internal static extern IntPtr GetStdHandle(int nStdHandle);
+ internal static extern IntPtr GetStdHandle(Int32 nStdHandle);
[SecurityCritical]
- internal static bool DoesWin32MethodExist(string moduleName, string methodName)
+ internal static Boolean DoesWin32MethodExist(String moduleName, String methodName)
{
- IntPtr moduleHandle = GetModuleHandle(moduleName);
+ var moduleHandle = GetModuleHandle(moduleName);
if (moduleHandle == IntPtr.Zero) return false;
return GetProcAddress(moduleHandle, methodName) != IntPtr.Zero;
}
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail), DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- private static extern IntPtr GetModuleHandle(string moduleName);
+ private static extern IntPtr GetModuleHandle(String moduleName);
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
- private static extern IntPtr GetProcAddress(IntPtr hModule, string methodName);
+ private static extern IntPtr GetProcAddress(IntPtr hModule, String methodName);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern IntPtr GetCurrentProcess();
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("kernel32.dll", SetLastError = true)]
- internal static extern bool IsWow64Process([In] IntPtr hSourceProcessHandle, [MarshalAs(UnmanagedType.Bool)] out bool isWow64);
+ internal static extern Boolean IsWow64Process([In] IntPtr hSourceProcessHandle, [MarshalAs(UnmanagedType.Bool)] out Boolean isWow64);
[DllImport("kernel32.dll")]
- internal static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max);
+ internal static extern Boolean SetProcessWorkingSetSize(IntPtr proc, Int32 min, Int32 max);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- internal static extern bool GetVersionEx([In, Out] OSVersionInfoEx ver);
+ internal static extern Boolean GetVersionEx([In, Out] OSVersionInfoEx ver);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal class OSVersionInfoEx
{
- public int OSVersionInfoSize;
- public int MajorVersion; // 系统主版本号
- public int MinorVersion; // 系统次版本号
- public int BuildNumber; // 系统构建号
- public int PlatformId; // 系统支持的平台
+ public Int32 OSVersionInfoSize;
+ public Int32 MajorVersion; // 系统主版本号
+ public Int32 MinorVersion; // 系统次版本号
+ public Int32 BuildNumber; // 系统构建号
+ public Int32 PlatformId; // 系统支持的平台
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
- public string CSDVersion; // 系统补丁包的名称
- public ushort ServicePackMajor; // 系统补丁包的主版本
- public ushort ServicePackMinor; // 系统补丁包的次版本
+ public String CSDVersion; // 系统补丁包的名称
+ public UInt16 ServicePackMajor; // 系统补丁包的主版本
+ public UInt16 ServicePackMinor; // 系统补丁包的次版本
public OSSuites SuiteMask; // 标识系统上的程序组
public OSProductType ProductType; // 标识系统类型
- public byte Reserved; // 保留
+ public Byte Reserved; // 保留
public OSVersionInfoEx()
{
OSVersionInfoSize = Marshal.SizeOf(this);
@@ -461,29 +461,29 @@ namespace NewLife
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
- public static extern int GetSystemMetrics(int nIndex);
+ public static extern Int32 GetSystemMetrics(Int32 nIndex);
public struct MEMORYSTATUSEX
{
- internal uint dwLength;
- internal uint dwMemoryLoad;
- internal ulong ullTotalPhys;
- internal ulong ullAvailPhys;
- internal ulong ullTotalPageFile;
- internal ulong ullAvailPageFile;
- internal ulong ullTotalVirtual;
- internal ulong ullAvailVirtual;
- internal ulong ullAvailExtendedVirtual;
+ internal UInt32 dwLength;
+ internal UInt32 dwMemoryLoad;
+ internal UInt64 ullTotalPhys;
+ internal UInt64 ullAvailPhys;
+ internal UInt64 ullTotalPageFile;
+ internal UInt64 ullAvailPageFile;
+ internal UInt64 ullTotalVirtual;
+ internal UInt64 ullAvailVirtual;
+ internal UInt64 ullAvailExtendedVirtual;
internal void Init()
{
- dwLength = checked((uint)Marshal.SizeOf(typeof(MEMORYSTATUSEX)));
+ dwLength = checked((UInt32)Marshal.SizeOf(typeof(MEMORYSTATUSEX)));
}
}
[SecurityCritical]
[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);
+ public static extern Boolean GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);
}
#endif
}
\ No newline at end of file
diff --git a/NewLife.Core/Common/Utility.cs b/NewLife.Core/Common/Utility.cs
index 6df51c6..d6cbe27 100644
--- a/NewLife.Core/Common/Utility.cs
+++ b/NewLife.Core/Common/Utility.cs
@@ -30,7 +30,7 @@ namespace System
/// <param name="value">待转换对象</param>
/// <param name="defaultValue">默认值。待转换对象无效时使用</param>
/// <returns></returns>
- public static long ToLong(this Object value, long defaultValue = 0) { return Convert.ToLong(value, defaultValue); }
+ public static Int64 ToLong(this Object value, Int64 defaultValue = 0) { return Convert.ToLong(value, defaultValue); }
/// <summary>转为浮点数,转换失败时返回默认值。支持字符串、全角、字节数组(小端)</summary>
/// <remarks>Single可以先转为最常用的Double后再二次处理</remarks>
@@ -143,7 +143,7 @@ namespace System
/// <param name="value">待转换对象</param>
/// <param name="defaultValue">默认值。待转换对象无效时使用</param>
/// <returns></returns>
- public virtual long ToLong(Object value, long defaultValue)
+ public virtual Int64 ToLong(Object value, Int64 defaultValue)
{
//暂时不做处理 先处理异常转换
try
@@ -281,15 +281,15 @@ namespace System
String ToDBC(String str)
{
var ch = str.ToCharArray();
- for (int i = 0; i < ch.Length; i++)
+ for (var i = 0; i < ch.Length; i++)
{
// 全角空格
if (ch[i] == 0x3000)
- ch[i] = (char)0x20;
+ ch[i] = (Char)0x20;
else if (ch[i] > 0xFF00 && ch[i] < 0xFF5F)
- ch[i] = (char)(ch[i] - 0xFEE0);
+ ch[i] = (Char)(ch[i] - 0xFEE0);
}
- return new string(ch);
+ return new String(ch);
}
/// <summary>时间日期转为yyyy-MM-dd HH:mm:ss完整字符串</summary>
diff --git a/NewLife.Core/Compression/SevenZip.cs b/NewLife.Core/Compression/SevenZip.cs
index 81bb71c..9fa8a99 100644
--- a/NewLife.Core/Compression/SevenZip.cs
+++ b/NewLife.Core/Compression/SevenZip.cs
@@ -128,7 +128,7 @@ namespace NewLife.Compression
p.Start();
p.WaitForExit();
- Int32 rs = 0;
+ var rs = 0;
if (p.HasExited)
{
rs = p.ExitCode;
diff --git a/NewLife.Core/Configuration/Config.cs b/NewLife.Core/Configuration/Config.cs
index b4fe9a2..445fede 100644
--- a/NewLife.Core/Configuration/Config.cs
+++ b/NewLife.Core/Configuration/Config.cs
@@ -74,7 +74,7 @@ namespace NewLife.Configuration
var nvs = AppSettings;
if (nvs == null || nvs.Count < 1) return false;
- for (int i = 0; i < names.Length; i++)
+ for (var i = 0; i < names.Length; i++)
{
if (TryGetConfig<T>(names[i], out value)) return true;
}
@@ -143,7 +143,7 @@ namespace NewLife.Configuration
var nvs = AppSettings;
if (nvs == null || nvs.Count < 1) return false;
- String str = nvs[name];
+ var str = nvs[name];
if (String.IsNullOrEmpty(str)) return false;
var code = Type.GetTypeCode(type);
@@ -154,7 +154,7 @@ namespace NewLife.Configuration
value = Convert.ToInt32(str);
else if (code == TypeCode.Boolean)
{
- Boolean b = false;
+ var b = false;
if (str.EqualIgnoreCase("1", Boolean.TrueString))
value = true;
else if (str.EqualIgnoreCase("0", Boolean.FalseString))
@@ -221,15 +221,15 @@ namespace NewLife.Configuration
var nvs = AppSettings;
if (nvs == null || nvs.Count < 1) return defaultValue;
- String str = GetConfig<String>(name);
+ var str = GetConfig<String>(name);
if (String.IsNullOrEmpty(str)) return defaultValue;
- String[] sps = String.IsNullOrEmpty(split) ? new String[] { ",", ";" } : new String[] { split };
- String[] ss = str.Split(sps, StringSplitOptions.RemoveEmptyEntries);
+ var sps = String.IsNullOrEmpty(split) ? new String[] { ",", ";" } : new String[] { split };
+ var ss = str.Split(sps, StringSplitOptions.RemoveEmptyEntries);
if (ss == null || ss.Length < 1) return defaultValue;
- T[] arr = new T[ss.Length];
- for (int i = 0; i < ss.Length; i++)
+ var arr = new T[ss.Length];
+ for (var i = 0; i < ss.Length; i++)
{
str = ss[i].Trim();
if (String.IsNullOrEmpty(str)) continue;
@@ -269,9 +269,9 @@ namespace NewLife.Configuration
}
/// <summary>判断appSettings中是否有此项</summary>
- private static bool AppSettingsKeyExists(string strKey, System.Configuration.Configuration config)
+ private static Boolean AppSettingsKeyExists(String strKey, System.Configuration.Configuration config)
{
- foreach (string str in config.AppSettings.Settings.AllKeys)
+ foreach (String str in config.AppSettings.Settings.AllKeys)
{
if (str == strKey) return true;
}
diff --git a/NewLife.Core/Event/WeakAction.cs b/NewLife.Core/Event/WeakAction.cs
index da9f63d..f655cde 100644
--- a/NewLife.Core/Event/WeakAction.cs
+++ b/NewLife.Core/Event/WeakAction.cs
@@ -125,7 +125,7 @@ namespace NewLife
#region 辅助
/// <summary>已重载</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (Method == null) return base.ToString();
diff --git a/NewLife.Core/Extension/BitHelper.cs b/NewLife.Core/Extension/BitHelper.cs
index b74296f..8d467a4 100644
--- a/NewLife.Core/Extension/BitHelper.cs
+++ b/NewLife.Core/Extension/BitHelper.cs
@@ -24,7 +24,7 @@ namespace System
{
if (length <= 0 || position >= 16) return value;
- Int32 mask = (2 << (length - 1)) - 1;
+ var mask = (2 << (length - 1)) - 1;
value &= (UInt16)~(mask << position);
value |= (UInt16)((bits & mask) << position);
@@ -41,7 +41,7 @@ namespace System
{
if (position >= 8) return value;
- Int32 mask = (2 << (1 - 1)) - 1;
+ var mask = (2 << (1 - 1)) - 1;
value &= (Byte)~(mask << position);
value |= (Byte)(((flag ? (Byte)1 : (Byte)0) & mask) << position);
@@ -67,7 +67,7 @@ namespace System
{
if (length <= 0 || position >= 16) return 0;
- Int32 mask = (2 << (length - 1)) - 1;
+ var mask = (2 << (length - 1)) - 1;
return (UInt16)((value >> position) & mask);
}
@@ -80,7 +80,7 @@ namespace System
{
if (position >= 8) return false;
- Int32 mask = (2 << (1 - 1)) - 1;
+ var mask = (2 << (1 - 1)) - 1;
return ((Byte)((value >> position) & mask)) == 1;
}
diff --git a/NewLife.Core/Extension/ConcurrentDictionaryExtensions.cs b/NewLife.Core/Extension/ConcurrentDictionaryExtensions.cs
index 4b28e76..b050009 100644
--- a/NewLife.Core/Extension/ConcurrentDictionaryExtensions.cs
+++ b/NewLife.Core/Extension/ConcurrentDictionaryExtensions.cs
@@ -16,7 +16,7 @@ namespace System
/// <param name="dict"></param>
/// <param name="key"></param>
/// <returns></returns>
- public static bool Remove<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dict, TKey key)
+ public static Boolean Remove<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dict, TKey key)
{
TValue value;
return dict.TryRemove(key, out value);
diff --git a/NewLife.Core/Extension/EndPointExtensions.cs b/NewLife.Core/Extension/EndPointExtensions.cs
index 2c3144e..a961541 100644
--- a/NewLife.Core/Extension/EndPointExtensions.cs
+++ b/NewLife.Core/Extension/EndPointExtensions.cs
@@ -12,7 +12,7 @@ namespace System
/// </summary>
/// <param name="endpoint"></param>
/// <returns></returns>
- public static string ToAddress(this EndPoint endpoint)
+ public static String ToAddress(this EndPoint endpoint)
{
return ((IPEndPoint)endpoint).ToAddress();
}
@@ -22,7 +22,7 @@ namespace System
/// </summary>
/// <param name="endpoint"></param>
/// <returns></returns>
- public static string ToAddress(this IPEndPoint endpoint)
+ public static String ToAddress(this IPEndPoint endpoint)
{
return string.Format("{0}:{1}", endpoint.Address, endpoint.Port);
}
@@ -32,9 +32,9 @@ namespace System
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
- public static IPEndPoint ToEndPoint(this string address)
+ public static IPEndPoint ToEndPoint(this String address)
{
- var array = address.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
+ var array = address.Split(new String[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
if (array.Length != 2)
{
throw new Exception("Invalid endpoint address: " + address);
@@ -49,9 +49,9 @@ namespace System
/// </summary>
/// <param name="addresses"></param>
/// <returns></returns>
- public static IEnumerable<IPEndPoint> ToEndPoints(this string addresses)
+ public static IEnumerable<IPEndPoint> ToEndPoints(this String addresses)
{
- var array = addresses.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
+ var array = addresses.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var list = new List<IPEndPoint>();
foreach (var item in array)
{
diff --git a/NewLife.Core/Extension/EnumHelper.cs b/NewLife.Core/Extension/EnumHelper.cs
index d7a9ec0..5ff6329 100644
--- a/NewLife.Core/Extension/EnumHelper.cs
+++ b/NewLife.Core/Extension/EnumHelper.cs
@@ -16,7 +16,7 @@ namespace System
{
if (value.GetType() != flag.GetType()) throw new ArgumentException("flag", "枚举标识判断必须是相同的类型!");
- UInt64 num = Convert.ToUInt64(flag);
+ var num = Convert.ToUInt64(flag);
return (Convert.ToUInt64(value) & num) == num;
}
@@ -30,8 +30,8 @@ namespace System
{
if (!(source is T)) throw new ArgumentException("source", "枚举标识判断必须是相同的类型!");
- UInt64 s = Convert.ToUInt64(source);
- UInt64 f = Convert.ToUInt64(flag);
+ var s = Convert.ToUInt64(source);
+ var f = Convert.ToUInt64(flag);
if (value)
{
@@ -88,9 +88,9 @@ namespace System
// 这里的快速访问方法会报错
//FieldInfoX fix = FieldInfoX.Create(item);
//PermissionFlags value = (PermissionFlags)fix.GetValue(null);
- Int32 value = Convert.ToInt32(item.GetValue(null));
+ var value = Convert.ToInt32(item.GetValue(null));
- String des = item.Name;
+ var des = item.Name;
//var dna = AttributeX.GetCustomAttribute<DisplayNameAttribute>(item, false);
var dna = item.GetCustomAttribute<DisplayNameAttribute>(false);
diff --git a/NewLife.Core/Extension/SpeakProvider.cs b/NewLife.Core/Extension/SpeakProvider.cs
index 75dcf67..445558f 100644
--- a/NewLife.Core/Extension/SpeakProvider.cs
+++ b/NewLife.Core/Extension/SpeakProvider.cs
@@ -98,15 +98,15 @@ namespace NewLife.Extension
}
}
- private object synth;
+ private Object synth;
void EnsureSynth()
{
if (synth == null)
{
try
{
- synth = _type.CreateInstance(new object[0]);
- synth.Invoke("SetOutputToDefaultAudioDevice", new object[0]);
+ synth = _type.CreateInstance(new Object[0]);
+ synth.Invoke("SetOutputToDefaultAudioDevice", new Object[0]);
}
catch (Exception ex)
{
diff --git a/NewLife.Core/Extension/StringHelper.cs b/NewLife.Core/Extension/StringHelper.cs
index f31d725..0e68df7 100644
--- a/NewLife.Core/Extension/StringHelper.cs
+++ b/NewLife.Core/Extension/StringHelper.cs
@@ -67,7 +67,7 @@ namespace System
{
if (value != null)
{
- for (int i = 0; i < value.Length; i++)
+ for (var i = 0; i < value.Length; i++)
{
if (!Char.IsWhiteSpace(value[i])) return false;
}
@@ -212,7 +212,7 @@ namespace System
if (String.IsNullOrEmpty(value)) return value;
// 特殊处理时间格式化。这些年,无数项目实施因为时间格式问题让人发狂
- for (int i = 0; i < args.Length; i++)
+ for (var i = 0; i < args.Length; i++)
{
if (args[i] is DateTime)
{
@@ -263,7 +263,7 @@ namespace System
if (String.IsNullOrEmpty(str)) return str;
if (starts == null || starts.Length < 1 || String.IsNullOrEmpty(starts[0])) return str;
- for (int i = 0; i < starts.Length; i++)
+ for (var i = 0; i < starts.Length; i++)
{
if (str.StartsWith(starts[i], StringComparison.OrdinalIgnoreCase))
{
@@ -286,7 +286,7 @@ namespace System
if (String.IsNullOrEmpty(str)) return str;
if (ends == null || ends.Length < 1 || String.IsNullOrEmpty(ends[0])) return str;
- for (int i = 0; i < ends.Length; i++)
+ for (var i = 0; i < ends.Length; i++)
{
if (str.EndsWith(ends[i], StringComparison.OrdinalIgnoreCase))
{
@@ -412,7 +412,7 @@ namespace System
if (String.IsNullOrEmpty(str)) return str;
if (starts == null || starts.Length < 1 || String.IsNullOrEmpty(starts[0])) return str;
- for (int i = 0; i < starts.Length; i++)
+ for (var i = 0; i < starts.Length; i++)
{
var p = str.IndexOf(starts[i]);
if (p >= 0)
@@ -433,7 +433,7 @@ namespace System
if (String.IsNullOrEmpty(str)) return str;
if (ends == null || ends.Length < 1 || String.IsNullOrEmpty(ends[0])) return str;
- for (int i = 0; i < ends.Length; i++)
+ for (var i = 0; i < ends.Length; i++)
{
var p = str.LastIndexOf(ends[i]);
if (p >= 0)
@@ -458,11 +458,11 @@ namespace System
{
if (IsNullOrWhiteSpace(key)) return new String[0];
- String[] keys = key.Split(new char[] { ' ', ' ' }, StringSplitOptions.RemoveEmptyEntries);
+ var keys = key.Split(new Char[] { ' ', ' ' }, StringSplitOptions.RemoveEmptyEntries);
- foreach (String item in keys)
+ foreach (var item in keys)
{
- int maxDist = (item.Length - 1) / 2;
+ var maxDist = (item.Length - 1) / 2;
var q = from str in words
where item.Length <= str.Length
@@ -492,12 +492,12 @@ namespace System
/// <param name="str1"></param>
/// <param name="str2"></param>
/// <returns></returns>
- public static int LevenshteinDistance(String str1, String str2)
+ public static Int32 LevenshteinDistance(String str1, String str2)
{
- int n = str1.Length;
- int m = str2.Length;
- int[,] C = new int[n + 1, m + 1];
- int i, j, x, y, z;
+ var n = str1.Length;
+ var m = str2.Length;
+ var C = new Int32[n + 1, m + 1];
+ Int32 i, j, x, y, z;
for (i = 0; i <= n; i++)
C[i, 0] = i;
for (i = 1; i <= m; i++)
@@ -529,8 +529,8 @@ namespace System
{
if (IsNullOrWhiteSpace(key) || words == null || words.Length == 0) return new String[0];
- String[] keys = key
- .Split(new char[] { ' ', '\u3000' }, StringSplitOptions.RemoveEmptyEntries)
+ var keys = key
+ .Split(new Char[] { ' ', '\u3000' }, StringSplitOptions.RemoveEmptyEntries)
.OrderBy(s => s.Length)
.ToArray();
@@ -555,18 +555,18 @@ namespace System
/// <param name="word"></param>
/// <param name="keys">多个关键字。长度必须大于0,必须按照字符串长度升序排列。</param>
/// <returns></returns>
- public static int LCSDistance(String word, String[] keys)
+ public static Int32 LCSDistance(String word, String[] keys)
{
- int sLength = word.Length;
- int result = sLength;
- bool[] flags = new bool[sLength];
- int[,] C = new int[sLength + 1, keys[keys.Length - 1].Length + 1];
+ var sLength = word.Length;
+ var result = sLength;
+ var flags = new Boolean[sLength];
+ var C = new Int32[sLength + 1, keys[keys.Length - 1].Length + 1];
//int[,] C = new int[sLength + 1, words.Select(s => s.Length).Max() + 1];
- foreach (String key in keys)
+ foreach (var key in keys)
{
- int wLength = key.Length;
- int first = 0, last = 0;
- int i = 0, j = 0, LCS_L;
+ var wLength = key.Length;
+ Int32 first = 0, last = 0;
+ Int32 i = 0, j = 0, LCS_L;
//foreach 速度会有所提升,还可以加剪枝
for (i = 0; i < sLength; i++)
for (j = 0; j < wLength; j++)
diff --git a/NewLife.Core/IO/EncodingHelper.cs b/NewLife.Core/IO/EncodingHelper.cs
index f880db5..117414e 100644
--- a/NewLife.Core/IO/EncodingHelper.cs
+++ b/NewLife.Core/IO/EncodingHelper.cs
@@ -145,7 +145,7 @@ namespace NewLife.IO
static Encoding DetectASCII(Byte[] data)
{
// 如果所有字节都小于128,则可以使用ASCII编码
- for (int i = 0; i < data.Length; i++)
+ for (var i = 0; i < data.Length; i++)
{
if (data[i] >= 128) return null;
}
@@ -199,7 +199,7 @@ namespace NewLife.IO
// character counts.
Int64 pos = 0;
- int skipUTF8Bytes = 0;
+ var skipUTF8Bytes = 0;
while (pos < data.Length)
{
@@ -219,7 +219,7 @@ namespace NewLife.IO
// 类似UTF-8的可疑序列
if (skipUTF8Bytes == 0)
{
- int len = DetectSuspiciousUTF8SequenceLength(data, pos);
+ var len = DetectSuspiciousUTF8SequenceLength(data, pos);
if (len > 0)
{
suspiciousUTF8SequenceCount++;
@@ -250,7 +250,7 @@ namespace NewLife.IO
// UTF-8
// 使用正则检测,参考http://www.w3.org/International/questions/qa-forms-utf-8
- string potentiallyMangledString = Encoding.ASCII.GetString(data);
+ var potentiallyMangledString = Encoding.ASCII.GetString(data);
var reg = new Regex(@"\A("
+ @"[\x09\x0A\x0D\x20-\x7E]" // ASCII
+ @"|[\xC2-\xDF][\x80-\xBF]" // 不太长的2字节
@@ -327,7 +327,7 @@ namespace NewLife.IO
/// <param name="buf"></param>
/// <param name="pos"></param>
/// <returns></returns>
- private static int DetectSuspiciousUTF8SequenceLength(Byte[] buf, Int64 pos)
+ private static Int32 DetectSuspiciousUTF8SequenceLength(Byte[] buf, Int64 pos)
{
if (buf.Length > pos + 1)
{
diff --git a/NewLife.Core/IO/FileSource.cs b/NewLife.Core/IO/FileSource.cs
index 80dab2a..468f2b1 100644
--- a/NewLife.Core/IO/FileSource.cs
+++ b/NewLife.Core/IO/FileSource.cs
@@ -71,7 +71,7 @@ namespace NewLife.IO
if (asm == null) asm = Assembly.GetCallingAssembly();
// 找到符合条件的资源
- String[] names = asm.GetManifestResourceNames();
+ var names = asm.GetManifestResourceNames();
if (names == null || names.Length < 1) return;
IEnumerable<String> ns = null;
if (prefix.IsNullOrWhiteSpace())
@@ -83,7 +83,7 @@ namespace NewLife.IO
if (!Path.IsPathRooted(dest))
{
- String str = Runtime.IsWeb ? HttpRuntime.BinDirectory : AppDomain.CurrentDomain.BaseDirectory;
+ var str = Runtime.IsWeb ? HttpRuntime.BinDirectory : AppDomain.CurrentDomain.BaseDirectory;
dest = Path.Combine(str, dest);
}
diff --git a/NewLife.Core/IO/IOHelper.cs b/NewLife.Core/IO/IOHelper.cs
index 01daad2..b588501 100644
--- a/NewLife.Core/IO/IOHelper.cs
+++ b/NewLife.Core/IO/IOHelper.cs
@@ -216,7 +216,7 @@ namespace System
if (bufferSize <= 0) bufferSize = 1024;
var buffer = new Byte[bufferSize];
- Int32 total = 0;
+ var total = 0;
while (true)
{
var count = bufferSize;
@@ -551,14 +551,14 @@ namespace System
data = data.ReadBytes(offset, 8);
if (isLittleEndian)
{
- int num1 = data[0] | data[1] << 8 | data[2] << 0x10 | data[3] << 0x18;
- int num2 = data[4] | data[5] << 8 | data[6] << 0x10 | data[7] << 0x18;
+ var num1 = data[0] | data[1] << 8 | data[2] << 0x10 | data[3] << 0x18;
+ var num2 = data[4] | data[5] << 8 | data[6] << 0x10 | data[7] << 0x18;
return (UInt32)num1 | (UInt64)num2 << 0x20;
}
else
{
- int num3 = data[0] << 0x18 | data[1] << 0x10 | data[2] << 8 | data[3];
- int num4 = data[4] << 0x18 | data[5] << 0x10 | data[6] << 8 | data[7];
+ var num3 = data[0] << 0x18 | data[1] << 0x10 | data[2] << 8 | data[3];
+ var num4 = data[4] << 0x18 | data[5] << 0x10 | data[6] << 8 | data[7];
return (UInt32)num4 | (UInt64)num3 << 0x20;
}
}
@@ -598,7 +598,7 @@ namespace System
{
if (isLittleEndian)
{
- for (int i = 0; i < 4; i++)
+ for (var i = 0; i < 4; i++)
{
data[offset++] = (Byte)n;
n >>= 8;
@@ -606,7 +606,7 @@ namespace System
}
else
{
- for (int i = 4 - 1; i >= 0; i--)
+ for (var i = 4 - 1; i >= 0; i--)
{
data[offset + i] = (Byte)n;
n >>= 8;
@@ -626,7 +626,7 @@ namespace System
{
if (isLittleEndian)
{
- for (int i = 0; i < 8; i++)
+ for (var i = 0; i < 8; i++)
{
data[offset++] = (Byte)n;
n >>= 8;
@@ -634,7 +634,7 @@ namespace System
}
else
{
- for (int i = 8 - 1; i >= 0; i--)
+ for (var i = 8 - 1; i >= 0; i--)
{
data[offset + i] = (Byte)n;
n >>= 8;
@@ -712,7 +712,7 @@ namespace System
public static Int32 ReadEncodedInt(this Stream stream)
{
Byte b;
- Int32 rs = 0;
+ var rs = 0;
Byte n = 0;
while (true)
{
@@ -790,16 +790,16 @@ namespace System
{
var list = new List<Byte>();
- Int32 count = 1;
- UInt64 num = (UInt64)value;
+ var count = 1;
+ var num = (UInt64)value;
while (num >= 0x80)
{
- list.Add((byte)(num | 0x80));
+ list.Add((Byte)(num | 0x80));
num = num >> 7;
count++;
}
- list.Add((byte)num);
+ list.Add((Byte)num);
stream.Write(list.ToArray(), 0, list.Count);
@@ -823,7 +823,7 @@ namespace System
for (Int64 i = 0; i < length;)
{
- Int32 c = stream.ReadByte();
+ var c = stream.ReadByte();
if (c == -1) return -1;
p++;
@@ -839,9 +839,9 @@ namespace System
//i = 0; // 只要有一个不匹配,马上清零
// 不能直接清零,那样会导致数据丢失,需要逐位探测,窗口一个个字节滑动
// 上一次匹配的其实就是j=0那个,所以这里从j=1开始
- Int64 n = i;
+ var n = i;
i = 0;
- for (int j = 1; j < n; j++)
+ for (var j = 1; j < n; j++)
{
// 在字节数组前(j,n)里面找自己(0,n-j)
if (CompareTo(buffer, j, n, buffer, 0, n - j) == 0)
@@ -881,7 +881,7 @@ namespace System
// 已匹配字节数
Int64 win = 0;
- for (Int64 i = start; i + length - win <= count; i++)
+ for (var i = start; i + length - win <= count; i++)
{
if (source[i] == buffer[offset + win])
{
@@ -925,9 +925,9 @@ namespace System
if (length <= 0 || length > buffer.Length - offset) length = buffer.Length - offset;
// 逐字节比较
- for (int i = 0; i < count && i < length; i++)
+ for (var i = 0; i < count && i < length; i++)
{
- Int32 rs = source[start + i].CompareTo(buffer[offset + i]);
+ var rs = source[start + i].CompareTo(buffer[offset + i]);
if (rs != 0) return i > 0 ? i : 1;
}
@@ -969,7 +969,7 @@ namespace System
public static Boolean StartsWith(this Stream source, Byte[] buffer)
{
var p = 0;
- for (int i = 0; i < buffer.Length; i++)
+ for (var i = 0; i < buffer.Length; i++)
{
var b = source.ReadByte();
if (b == -1) { source.Seek(-p, SeekOrigin.Current); return false; }
@@ -1004,7 +1004,7 @@ namespace System
{
if (source.Length < buffer.Length) return false;
- for (int i = 0; i < buffer.Length; i++)
+ for (var i = 0; i < buffer.Length; i++)
{
if (source[i] != buffer[i]) return false;
}
@@ -1020,7 +1020,7 @@ namespace System
if (source.Length < buffer.Length) return false;
var p = source.Length - buffer.Length;
- for (int i = 0; i < buffer.Length; i++)
+ for (var i = 0; i < buffer.Length; i++)
{
if (source[p + i] != buffer[i]) return false;
}
@@ -1078,9 +1078,9 @@ namespace System
// 上面的方法要替换-,效率太低
var cs = new Char[count * 2];
// 两个索引一起用,避免乘除带来的性能损耗
- for (int i = 0, j = 0; i < count; i++, j += 2)
+ for (Int32 i = 0, j = 0; i < count; i++, j += 2)
{
- Byte b = data[offset + i];
+ var b = data[offset + i];
cs[j] = GetHexValue(b / 0x10);
cs[j + 1] = GetHexValue(b % 0x10);
}
@@ -1122,7 +1122,7 @@ namespace System
if (!String.IsNullOrEmpty(separate)) len -= g * separate.Length;
}
var sb = new StringBuilder(len);
- for (int i = 0; i < count; i++)
+ for (var i = 0; i < count; i++)
{
if (sb.Length > 0)
{
@@ -1132,7 +1132,7 @@ namespace System
sb.Append(separate);
}
- Byte b = data[i];
+ var b = data[i];
sb.Append(GetHexValue(b / 0x10));
sb.Append(GetHexValue(b % 0x10));
}
@@ -1140,12 +1140,12 @@ namespace System
return sb.ToString();
}
- private static char GetHexValue(int i)
+ private static Char GetHexValue(Int32 i)
{
if (i < 10)
- return (char)(i + 0x30);
+ return (Char)(i + 0x30);
else
- return (char)(i - 10 + 0x41);
+ return (Char)(i - 10 + 0x41);
}
/// <summary>解密</summary>
@@ -1170,7 +1170,7 @@ namespace System
if (length <= 0) length = data.Length - startIndex;
var bts = new Byte[length / 2];
- for (int i = 0; i < bts.Length; i++)
+ for (var i = 0; i < bts.Length; i++)
{
bts[i] = Byte.Parse(data.Substring(startIndex + 2 * i, 2), NumberStyles.HexNumber);
}
diff --git a/NewLife.Core/IO/PathHelper.cs b/NewLife.Core/IO/PathHelper.cs
index 1456fd9..8c85094 100644
--- a/NewLife.Core/IO/PathHelper.cs
+++ b/NewLife.Core/IO/PathHelper.cs
@@ -268,10 +268,10 @@ namespace System.IO
using (var zip = ZipFile.Open(fi.FullName, ZipArchiveMode.Read, null))
{
var di = Directory.CreateDirectory(destDir);
- string fullName = di.FullName;
+ var fullName = di.FullName;
foreach (var current in zip.Entries)
{
- string fullPath = Path.GetFullPath(Path.Combine(fullName, current.FullName));
+ var fullPath = Path.GetFullPath(Path.Combine(fullName, current.FullName));
if (!fullPath.StartsWith(fullName, StringComparison.OrdinalIgnoreCase))
{
throw new IOException("IO_ExtractingResultsInOutside");
diff --git a/NewLife.Core/Log/ActionLog.cs b/NewLife.Core/Log/ActionLog.cs
index 238de17..8d7fb7f 100644
--- a/NewLife.Core/Log/ActionLog.cs
+++ b/NewLife.Core/Log/ActionLog.cs
@@ -24,7 +24,7 @@ namespace NewLife.Log
/// <summary>已重载</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return Method + "";
}
diff --git a/NewLife.Core/Log/CodeTimer.cs b/NewLife.Core/Log/CodeTimer.cs
index daae09a..21d2206 100644
--- a/NewLife.Core/Log/CodeTimer.cs
+++ b/NewLife.Core/Log/CodeTimer.cs
@@ -47,7 +47,7 @@ namespace NewLife.Log
#if !__MOBILE__
var currentForeColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
- Int32 left = Console.CursorLeft;
+ var left = Console.CursorLeft;
#endif
if (needTimeOne) timer.TimeOne();
timer.Time();
@@ -89,7 +89,7 @@ namespace NewLife.Log
static void Write(String name, Int32 max)
{
- Int32 len = Encoding.Default.GetByteCount(name);
+ var len = Encoding.Default.GetByteCount(name);
if (len < max) Console.Write(new String(' ', max - len));
Console.Write(name);
}
@@ -98,16 +98,16 @@ namespace NewLife.Log
#region PInvoke
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
- static extern bool QueryThreadCycleTime(IntPtr threadHandle, ref ulong cycleTime);
+ static extern Boolean QueryThreadCycleTime(IntPtr threadHandle, ref UInt64 cycleTime);
[DllImport("kernel32.dll")]
static extern IntPtr GetCurrentThread();
[DllImport("kernel32.dll", SetLastError = true)]
- static extern bool GetThreadTimes(IntPtr hThread, out long lpCreationTime, out long lpExitTime, out long lpKernelTime, out long lpUserTime);
+ static extern Boolean GetThreadTimes(IntPtr hThread, out Int64 lpCreationTime, out Int64 lpExitTime, out Int64 lpKernelTime, out Int64 lpUserTime);
static Boolean supportCycle = true;
- private static ulong GetCycleCount()
+ private static UInt64 GetCycleCount()
{
//if (Environment.Version.Major < 6) return 0;
@@ -115,7 +115,7 @@ namespace NewLife.Log
try
{
- ulong cycleCount = 0;
+ UInt64 cycleCount = 0;
QueryThreadCycleTime(GetCurrentThread(), ref cycleCount);
return cycleCount;
}
@@ -126,19 +126,19 @@ namespace NewLife.Log
}
}
- private static long GetCurrentThreadTimes()
+ private static Int64 GetCurrentThreadTimes()
{
- long l;
- long kernelTime, userTimer;
+ Int64 l;
+ Int64 kernelTime, userTimer;
GetThreadTimes(GetCurrentThread(), out l, out l, out kernelTime, out userTimer);
return kernelTime + userTimer;
}
#endregion
#region 私有字段
- ulong cpuCycles = 0;
- long threadTime = 0;
- int[] gen;
+ UInt64 cpuCycles = 0;
+ Int64 threadTime = 0;
+ Int32[] gen;
#endregion
#region 属性
@@ -155,7 +155,7 @@ namespace NewLife.Log
public Int32 Index { get; set; }
/// <summary>CPU周期</summary>
- public long CpuCycles { get; set; }
+ public Int64 CpuCycles { get; set; }
/// <summary>线程时间,单位是100ns,除以10000转为ms</summary>
public Int64 ThreadTime { get; set; }
@@ -211,7 +211,7 @@ namespace NewLife.Log
GC.Collect(GC.MaxGeneration);
gen = new Int32[GC.MaxGeneration + 1];
- for (Int32 i = 0; i <= GC.MaxGeneration; i++)
+ for (var i = 0; i <= GC.MaxGeneration; i++)
{
gen[i] = GC.CollectionCount(i);
}
@@ -231,7 +231,7 @@ namespace NewLife.Log
Init();
}
- for (Int32 i = 0; i < Times; i++)
+ for (var i = 0; i < Times; i++)
{
Index = i;
@@ -243,7 +243,7 @@ namespace NewLife.Log
Finish();
}
- CpuCycles = (long)(GetCycleCount() - cpuCycles);
+ CpuCycles = (Int64)(GetCycleCount() - cpuCycles);
ThreadTime = GetCurrentThreadTimes() - threadTime;
watch.Stop();
@@ -251,9 +251,9 @@ namespace NewLife.Log
// 统计GC代数
var list = new List<Int32>();
- for (Int32 i = 0; i <= GC.MaxGeneration; i++)
+ for (var i = 0; i <= GC.MaxGeneration; i++)
{
- int count = GC.CollectionCount(i) - gen[i];
+ var count = GC.CollectionCount(i) - gen[i];
list.Add(count);
}
Gen = list.ToArray();
@@ -262,7 +262,7 @@ namespace NewLife.Log
/// <summary>执行一次迭代,预热所有方法</summary>
public void TimeOne()
{
- Int32 n = Times;
+ var n = Times;
try
{
@@ -311,10 +311,10 @@ namespace NewLife.Log
void Progress(Object state)
{
#if !__MOBILE__
- Int32 left = Console.CursorLeft;
+ var left = Console.CursorLeft;
// 设置光标不可见
- Boolean cursorVisible = Console.CursorVisible;
+ var cursorVisible = Console.CursorVisible;
Console.CursorVisible = false;
#endif
var sw = new Stopwatch();
@@ -323,14 +323,14 @@ namespace NewLife.Log
{
try
{
- Int32 i = Index;
+ var i = Index;
if (i >= Times) break;
if (i > 0 && sw.Elapsed.TotalMilliseconds > 10)
{
- Double d = (Double)i / Times;
- Double ms = sw.Elapsed.TotalMilliseconds;
- TimeSpan ts = new TimeSpan(0, 0, 0, 0, (Int32)(ms * Times / i));
+ var d = (Double)i / Times;
+ var ms = sw.Elapsed.TotalMilliseconds;
+ var ts = new TimeSpan(0, 0, 0, 0, (Int32)(ms * Times / i));
Console.Write("{0,7:n0}ms {1:p} Total=>{2}", ms, d, ts);
#if !__MOBILE__
Console.CursorLeft = left;
@@ -353,7 +353,7 @@ namespace NewLife.Log
#region 重载
/// <summary>已重载。输出依次分别是:执行时间、CPU线程时间、时钟周期、GC代数</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
var ms = Elapsed.TotalMilliseconds;
if (msBase == 0) msBase = ms;
diff --git a/NewLife.Core/Log/CompositeLog.cs b/NewLife.Core/Log/CompositeLog.cs
index 2d9d572..0d9d13c 100644
--- a/NewLife.Core/Log/CompositeLog.cs
+++ b/NewLife.Core/Log/CompositeLog.cs
@@ -89,7 +89,7 @@ namespace NewLife.Log
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
var sb = new StringBuilder();
sb.Append(GetType().Name);
diff --git a/NewLife.Core/Log/ConsoleLog.cs b/NewLife.Core/Log/ConsoleLog.cs
index 4cb6009..baa8d4b 100644
--- a/NewLife.Core/Log/ConsoleLog.cs
+++ b/NewLife.Core/Log/ConsoleLog.cs
@@ -84,7 +84,7 @@ namespace NewLife.Log
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return String.Format("{0} UseColor={1}", GetType().Name, UseColor);
}
diff --git a/NewLife.Core/Log/Logger.cs b/NewLife.Core/Log/Logger.cs
index fd182bb..6020350 100644
--- a/NewLife.Core/Log/Logger.cs
+++ b/NewLife.Core/Log/Logger.cs
@@ -120,9 +120,9 @@ namespace NewLife.Log
class NullLogger : Logger
{
- public override bool Enable { get { return false; } set { } }
+ public override Boolean Enable { get { return false; } set { } }
- protected override void OnWrite(LogLevel level, string format, params object[] args) { }
+ protected override void OnWrite(LogLevel level, String format, params Object[] args) { }
}
#endregion
diff --git a/NewLife.Core/Log/LogLevel.cs b/NewLife.Core/Log/LogLevel.cs
index b85d966..91f3b7e 100644
--- a/NewLife.Core/Log/LogLevel.cs
+++ b/NewLife.Core/Log/LogLevel.cs
@@ -2,7 +2,7 @@
namespace NewLife.Log
{
/// <summary>日志等级</summary>
- public enum LogLevel : byte
+ public enum LogLevel : System.Byte
{
/// <summary>打开所有日志记录</summary>
All = 0,
diff --git a/NewLife.Core/Log/TextFileLog.cs b/NewLife.Core/Log/TextFileLog.cs
index 7b4e5fa..cfa6e54 100644
--- a/NewLife.Core/Log/TextFileLog.cs
+++ b/NewLife.Core/Log/TextFileLog.cs
@@ -44,7 +44,7 @@ namespace NewLife.Log
{
if (String.IsNullOrEmpty(path)) return Create(path);
- String key = path.ToLower();
+ var key = path.ToLower();
return cache.GetItem(key, k => new TextFileLog(path, true));
}
@@ -92,7 +92,7 @@ namespace NewLife.Log
/// <summary>初始化日志记录文件</summary>
private void InitLog()
{
- String path = LogPath.EnsureDirectory(false);
+ var path = LogPath.EnsureDirectory(false);
StreamWriter writer = null;
var logfile = LogFile;
@@ -110,7 +110,7 @@ namespace NewLife.Log
if (writer == null)
{
logfile = Path.Combine(path, DateTime.Now.ToString("yyyy_MM_dd") + ".log");
- int i = 0;
+ var i = 0;
while (i < 10)
{
try
@@ -170,7 +170,7 @@ namespace NewLife.Log
#region 异步写日志
private Timer _Timer;
- private object Log_Lock = new object();
+ private Object Log_Lock = new Object();
/// <summary>使用线程池线程异步执行日志写入动作</summary>
/// <param name="e"></param>
@@ -252,7 +252,7 @@ namespace NewLife.Log
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (!String.IsNullOrEmpty(LogFile))
return String.Format("{0} {1}", GetType().Name, LogFile);
diff --git a/NewLife.Core/Log/TimeCost.cs b/NewLife.Core/Log/TimeCost.cs
index 5a306cd..3e42298 100644
--- a/NewLife.Core/Log/TimeCost.cs
+++ b/NewLife.Core/Log/TimeCost.cs
@@ -37,7 +37,7 @@ namespace NewLife.Log
/// <summary>析构</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
Stop();
diff --git a/NewLife.Core/Log/TraceStream.cs b/NewLife.Core/Log/TraceStream.cs
index e4a5069..4747698 100644
--- a/NewLife.Core/Log/TraceStream.cs
+++ b/NewLife.Core/Log/TraceStream.cs
@@ -59,7 +59,7 @@ namespace NewLife.Log
/// <returns></returns>
public override Int32 Read(Byte[] buffer, Int32 offset, Int32 count)
{
- Int32 n = BaseStream.Read(buffer, offset, count);
+ var n = BaseStream.Read(buffer, offset, count);
RaiseAction("Read", buffer, offset, count, n);
@@ -70,7 +70,7 @@ namespace NewLife.Log
/// <returns></returns>
public override Int32 ReadByte()
{
- Int32 n = BaseStream.ReadByte();
+ var n = BaseStream.ReadByte();
RaiseAction("ReadByte", n);
@@ -300,8 +300,8 @@ namespace NewLife.Log
Console.Write("\t");
Byte[] buffer = null;
- Int32 offset = 0;
- Int32 count = 0;
+ var offset = 0;
+ var count = 0;
if (e.Arg2.Length > 1)
{
if (e.Arg2[0] is Byte[]) buffer = (Byte[])e.Arg2[0];
@@ -311,7 +311,7 @@ namespace NewLife.Log
if (e.Arg2.Length == 1)
{
- Int32 n = Convert.ToInt32(e.Arg2[0]);
+ var n = Convert.ToInt32(e.Arg2[0]);
// 大于10才显示十进制
if (n >= 10)
Console.Write("{0:X2} ({0})", n);
@@ -322,7 +322,7 @@ namespace NewLife.Log
{
if (count == 1)
{
- Int32 n = Convert.ToInt32(buffer[0]);
+ var n = Convert.ToInt32(buffer[0]);
// 大于10才显示十进制
if (n >= 10)
Console.Write("{0:X2} ({0})", n);
@@ -394,8 +394,8 @@ namespace NewLife.Log
sb.AppendFormat("\t");
Byte[] buffer = null;
- Int32 offset = 0;
- Int32 count = 0;
+ var offset = 0;
+ var count = 0;
if (e.Arg2.Length > 1)
{
if (e.Arg2[0] is Byte[]) buffer = (Byte[])e.Arg2[0];
@@ -405,7 +405,7 @@ namespace NewLife.Log
if (e.Arg2.Length == 1)
{
- Int32 n = Convert.ToInt32(e.Arg2[0]);
+ var n = Convert.ToInt32(e.Arg2[0]);
// 大于10才显示十进制
if (n >= 10)
sb.AppendFormat("{0:X2} ({0})", n);
@@ -416,7 +416,7 @@ namespace NewLife.Log
{
if (count == 1)
{
- Int32 n = Convert.ToInt32(buffer[0]);
+ var n = Convert.ToInt32(buffer[0]);
// 大于10才显示十进制
if (n >= 10)
sb.AppendFormat("{0:X2} ({0})", n);
diff --git a/NewLife.Core/Log/WriteLogEventArgs.cs b/NewLife.Core/Log/WriteLogEventArgs.cs
index 975ee64..207814e 100644
--- a/NewLife.Core/Log/WriteLogEventArgs.cs
+++ b/NewLife.Core/Log/WriteLogEventArgs.cs
@@ -104,7 +104,7 @@ namespace NewLife.Log
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (Exception != null) Message += Exception.ToString();
diff --git a/NewLife.Core/Log/XTrace.cs b/NewLife.Core/Log/XTrace.cs
index 3c7ad13..f414dfa 100644
--- a/NewLife.Core/Log/XTrace.cs
+++ b/NewLife.Core/Log/XTrace.cs
@@ -89,7 +89,7 @@ namespace NewLife.Log
}
#endif
- private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
+ private static void TaskScheduler_UnobservedTaskException(Object sender, UnobservedTaskExceptionEventArgs e)
{
if (!e.Observed)
{
@@ -102,7 +102,7 @@ namespace NewLife.Log
}
}
- static Object _lock = new object();
+ static Object _lock = new Object();
static Int32 _initing = 0;
/// <summary>
@@ -254,7 +254,7 @@ namespace NewLife.Log
Application.ThreadException += Application_ThreadException;
}
- static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
+ static void CurrentDomain_UnhandledException(Object sender, UnhandledExceptionEventArgs e)
{
var show = _ShowErrorMessage && Application.MessageLoop;
var ex = e.ExceptionObject as Exception;
@@ -273,7 +273,7 @@ namespace NewLife.Log
}
}
- static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
+ static void Application_ThreadException(Object sender, ThreadExceptionEventArgs e)
{
WriteException(e.Exception);
@@ -362,7 +362,7 @@ namespace NewLife.Log
}
[DllImport("kernel32.dll")]
- private static extern uint GetCurrentThreadId();
+ private static extern UInt32 GetCurrentThreadId();
public static Boolean TryDump(String dmpPath, MiniDumpType dmpType)
{
@@ -429,7 +429,7 @@ namespace NewLife.Log
/// <summary>堆栈调试。</summary>
/// <param name="maxNum">最大捕获堆栈方法数</param>
- public static void DebugStack(int maxNum)
+ public static void DebugStack(Int32 maxNum)
{
var msg = GetCaller(2, maxNum, Environment.NewLine);
WriteLine("调用堆栈:" + Environment.NewLine + msg);
@@ -438,7 +438,7 @@ namespace NewLife.Log
/// <summary>堆栈调试</summary>
/// <param name="start">开始方法数,0是DebugStack的直接调用者</param>
/// <param name="maxNum">最大捕获堆栈方法数</param>
- public static void DebugStack(int start, int maxNum)
+ public static void DebugStack(Int32 start, Int32 maxNum)
{
// 至少跳过当前这个
if (start < 1) start = 1;
@@ -451,7 +451,7 @@ namespace NewLife.Log
/// <param name="maxNum">最大层数</param>
/// <param name="split">分割符号,默认左箭头加上换行</param>
/// <returns></returns>
- public static String GetCaller(int start = 1, int maxNum = 0, String split = null)
+ public static String GetCaller(Int32 start = 1, Int32 maxNum = 0, String split = null)
{
// 至少跳过当前这个
if (start < 1) start = 1;
@@ -463,10 +463,10 @@ namespace NewLife.Log
var asm = Assembly.GetEntryAssembly();
var entry = asm == null ? null : asm.EntryPoint;
- int count = st.FrameCount;
+ var count = st.FrameCount;
var sb = new StringBuilder(count * 20);
//if (maxNum > 0 && maxNum < count) count = maxNum;
- for (int i = 0; i < count && maxNum > 0; i++)
+ for (var i = 0; i < count && maxNum > 0; i++)
{
var sf = st.GetFrame(i);
var method = sf.GetMethod();
diff --git a/NewLife.Core/Messaging/DefaultMessage.cs b/NewLife.Core/Messaging/DefaultMessage.cs
index 917e914..1c16468 100644
--- a/NewLife.Core/Messaging/DefaultMessage.cs
+++ b/NewLife.Core/Messaging/DefaultMessage.cs
@@ -1,70 +1,70 @@
-using System;
-using System.IO;
-using NewLife.Data;
-using NewLife.Reflection;
-
-namespace NewLife.Messaging
-{
- /// <summary>标准消息</summary>
- /// <remarks>
- /// 标准网络封包协议:1 Flag + 1 Sequence + 2 Length + N Payload
- /// 1个字节标识位,标识请求、响应、错误、加密、压缩等;
- /// 1个字节序列号,用于请求响应包配对;
- /// 2个字节数据长度N,大端,指示后续负载数据长度(不包含头部4个字节),解决粘包问题;
- /// N个字节负载数据,数据内容完全由业务决定,最大长度65535=64k。
- /// 如:
- /// Open => OK
- /// 01-01-00-04-"Open" => 81-01-00-02-"OK"
- ///
- /// 针对纯字符串场景,采用8字符HEX编码头部。
- /// 首字符0表示请求,8表示响应
- /// 如:
- /// Open => OK
- /// 01010004 Open => 81010002 OK
- /// </remarks>
- public class DefaultMessage : Message
- {
- #region 属性
- /// <summary>标记位</summary>
- public Byte Flag { get; set; }
-
- ///// <summary>是否有错</summary>
- //public Boolean Error { get; set; }
-
- /// <summary>序列号,匹配请求和响应</summary>
- public Byte Sequence { get; set; }
-
- /// <summary>对方使用纯字符串,不具备二进制编码能力</summary>
- private Boolean _IsChar;
- #endregion
-
- #region 方法
- /// <summary>根据请求创建配对的响应消息</summary>
- /// <returns></returns>
- public override IMessage CreateReply()
- {
- if (Reply) throw new Exception("不能根据响应消息创建响应消息");
-
- var type = GetType();
- var msg = type == typeof(DefaultMessage) ? new DefaultMessage() : type.CreateInstance() as DefaultMessage;
- msg.Flag = Flag;
- msg.Reply = true;
- msg.Sequence = Sequence;
-
- return msg;
- }
-
- /// <summary>从数据包中读取消息</summary>
- /// <param name="pk"></param>
- /// <returns>是否成功</returns>
- public override Boolean Read(Packet pk)
- {
- if (pk.Count < 4) throw new ArgumentOutOfRangeException(nameof(pk), "数据包头部长度不足4字节");
-
- var size = 4;
- var buf = pk.Data.ReadBytes(pk.Offset, size);
-
- // 检查纯字符串以字符0或8开头,所以二进制消息不许用0x30和0x38开头
+using System;
+using System.IO;
+using NewLife.Data;
+using NewLife.Reflection;
+
+namespace NewLife.Messaging
+{
+ /// <summary>标准消息</summary>
+ /// <remarks>
+ /// 标准网络封包协议:1 Flag + 1 Sequence + 2 Length + N Payload
+ /// 1个字节标识位,标识请求、响应、错误、加密、压缩等;
+ /// 1个字节序列号,用于请求响应包配对;
+ /// 2个字节数据长度N,大端,指示后续负载数据长度(不包含头部4个字节),解决粘包问题;
+ /// N个字节负载数据,数据内容完全由业务决定,最大长度65535=64k。
+ /// 如:
+ /// Open => OK
+ /// 01-01-00-04-"Open" => 81-01-00-02-"OK"
+ ///
+ /// 针对纯字符串场景,采用8字符HEX编码头部。
+ /// 首字符0表示请求,8表示响应
+ /// 如:
+ /// Open => OK
+ /// 01010004 Open => 81010002 OK
+ /// </remarks>
+ public class DefaultMessage : Message
+ {
+ #region 属性
+ /// <summary>标记位</summary>
+ public Byte Flag { get; set; }
+
+ ///// <summary>是否有错</summary>
+ //public Boolean Error { get; set; }
+
+ /// <summary>序列号,匹配请求和响应</summary>
+ public Byte Sequence { get; set; }
+
+ /// <summary>对方使用纯字符串,不具备二进制编码能力</summary>
+ private Boolean _IsChar;
+ #endregion
+
+ #region 方法
+ /// <summary>根据请求创建配对的响应消息</summary>
+ /// <returns></returns>
+ public override IMessage CreateReply()
+ {
+ if (Reply) throw new Exception("不能根据响应消息创建响应消息");
+
+ var type = GetType();
+ var msg = type == typeof(DefaultMessage) ? new DefaultMessage() : type.CreateInstance() as DefaultMessage;
+ msg.Flag = Flag;
+ msg.Reply = true;
+ msg.Sequence = Sequence;
+
+ return msg;
+ }
+
+ /// <summary>从数据包中读取消息</summary>
+ /// <param name="pk"></param>
+ /// <returns>是否成功</returns>
+ public override Boolean Read(Packet pk)
+ {
+ if (pk.Count < 4) throw new ArgumentOutOfRangeException(nameof(pk), "数据包头部长度不足4字节");
+
+ var size = 4;
+ var buf = pk.Data.ReadBytes(pk.Offset, size);
+
+ // 检查纯字符串以字符0或8开头,所以二进制消息不许用0x30和0x38开头
if (buf[0] == '0' || buf[0] == '8')
{
_IsChar = true;
@@ -72,42 +72,49 @@ namespace NewLife.Messaging
if (pk.Count < size) throw new ArgumentOutOfRangeException(nameof(pk), "数据包头部长度不足{0}字节".F(size));
buf = pk.Data.ReadBytes(pk.Offset, size).ToStr().ToHex();
- }
-
- Flag = buf[0];
- if ((Flag & 0x80) == 0x80) Reply = true;
- //if ((Flag & 0x40) == 0x40) Error = true;
-
- Sequence = buf[1];
-
- var len = (buf[2] << 8) | buf[3];
- if (size + len > pk.Count) throw new ArgumentOutOfRangeException(nameof(pk), "数据包长度{0}不足{1}字节".F(pk.Count, size + len));
-
- Payload = new Packet(pk.Data, pk.Offset + size, len);
-
- return true;
- }
-
- /// <summary>把消息写入到数据流中</summary>
- /// <param name="stream"></param>
- public override void Write(Stream stream)
- {
- // 标记位
- Byte b = Flag;
- if (Reply) b |= 0x80;
- //if (Error) b |= 0x40;
- stream.WriteByte(b);
-
- // 序列号
- stream.WriteByte(Sequence);
-
- // 2字节长度,大端
- var len = 0;
- if (Payload != null) len = Payload.Count;
- stream.Write(((UInt16)len).GetBytes(false));
-
- Payload?.WriteTo(stream);
- }
- #endregion
- }
+ }
+
+ Flag = buf[0];
+ if ((Flag & 0x80) == 0x80) Reply = true;
+ //if ((Flag & 0x40) == 0x40) Error = true;
+
+ Sequence = buf[1];
+
+ var len = (buf[2] << 8) | buf[3];
+ if (size + len > pk.Count) throw new ArgumentOutOfRangeException(nameof(pk), "数据包长度{0}不足{1}字节".F(pk.Count, size + len));
+
+ Payload = new Packet(pk.Data, pk.Offset + size, len);
+
+ return true;
+ }
+
+ /// <summary>把消息写入到数据流中</summary>
+ /// <param name="stream"></param>
+ public override void Write(Stream stream)
+ {
+ var ms = stream;
+ if (_IsChar) ms = new MemoryStream();
+
+ // 标记位
+ var b = Flag;
+ if (Reply) b |= 0x80;
+ //if (Error) b |= 0x40;
+ ms.WriteByte(b);
+
+ // 序列号
+ ms.WriteByte(Sequence);
+
+ // 2字节长度,大端
+ var len = 0;
+ if (Payload != null) len = Payload.Count;
+ //ms.Write(((UInt16)len).GetBytes(false));
+ ms.WriteByte((Byte)(len >> 8));
+ ms.WriteByte((Byte)(len & 0xFF));
+
+ if (_IsChar) stream.Write(ms.ToArray());
+
+ Payload?.WriteTo(stream);
+ }
+ #endregion
+ }
}
\ No newline at end of file
diff --git a/NewLife.Core/Messaging/MessageBase.cs b/NewLife.Core/Messaging/MessageBase.cs
index 0785efa..046ca9c 100644
--- a/NewLife.Core/Messaging/MessageBase.cs
+++ b/NewLife.Core/Messaging/MessageBase.cs
@@ -74,7 +74,7 @@ namespace NewLife.Messaging
#region 辅助
/// <summary>输出消息实体</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
var sb = new StringBuilder();
foreach (var pi in GetType().GetProperties(true))
diff --git a/NewLife.Core/Model/IPlugin.cs b/NewLife.Core/Model/IPlugin.cs
index 047c495..931e0b5 100644
--- a/NewLife.Core/Model/IPlugin.cs
+++ b/NewLife.Core/Model/IPlugin.cs
@@ -78,7 +78,7 @@ namespace NewLife.Model
/// <summary>子类重载实现资源释放逻辑时必须首先调用基类方法</summary>
/// <param name="disposing">从Dispose调用(释放所有资源)还是析构函数调用(释放非托管资源)。
/// 因为该方法只会被调用一次,所以该参数的意义不太大。</param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -133,7 +133,7 @@ namespace NewLife.Model
var ps = Plugins;
if (ps == null || ps.Count < 1) return;
- for (int i = ps.Count - 1; i >= 0; i--)
+ for (var i = ps.Count - 1; i >= 0; i--)
{
try
{
@@ -151,7 +151,7 @@ namespace NewLife.Model
#endregion
#region IServiceProvider 成员
- object IServiceProvider.GetService(Type serviceType)
+ Object IServiceProvider.GetService(Type serviceType)
{
if (serviceType == typeof(PluginManager)) return this;
diff --git a/NewLife.Core/Model/ObjectContainer.cs b/NewLife.Core/Model/ObjectContainer.cs
index 3467e12..32e2bcb 100644
--- a/NewLife.Core/Model/ObjectContainer.cs
+++ b/NewLife.Core/Model/ObjectContainer.cs
@@ -159,7 +159,7 @@ namespace NewLife.Model
#endregion
#region 方法
- public override string ToString()
+ public override String ToString()
{
return String.Format("[{0},{1}]", Identity, ImplementType != null ? ImplementType.Name : null);
}
@@ -439,7 +439,7 @@ namespace NewLife.Model
map.TypeName = item.Value;
break;
case "priority":
- Int32 n = 0;
+ var n = 0;
if (Int32.TryParse(item.Value, out n)) map.Priority = n;
break;
default:
@@ -453,7 +453,7 @@ namespace NewLife.Model
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString() { return String.Format("{0}[Count={1}]", GetType().Name, Stores.Count); }
+ public override String ToString() { return String.Format("{0}[Count={1}]", GetType().Name, Stores.Count); }
#endregion
}
}
\ No newline at end of file
diff --git a/NewLife.Core/Net/HttpSession.cs b/NewLife.Core/Net/HttpSession.cs
index 72c786f..4ff4f09 100644
--- a/NewLife.Core/Net/HttpSession.cs
+++ b/NewLife.Core/Net/HttpSession.cs
@@ -214,7 +214,7 @@ namespace NewLife.Net
// 分析响应头
var rs = ResponseHeaders;
rs.Clear();
- for (int i = 1; i < headers.Length; i++)
+ for (var i = 1; i < headers.Length; i++)
{
line = headers[i];
p = line.IndexOf(':');
diff --git a/NewLife.Core/Net/ISocket.cs b/NewLife.Core/Net/ISocket.cs
index b735d46..e564f08 100644
--- a/NewLife.Core/Net/ISocket.cs
+++ b/NewLife.Core/Net/ISocket.cs
@@ -59,7 +59,7 @@ namespace NewLife.Net
/// <summary>已重载。日志加上前缀</summary>
/// <param name="format"></param>
/// <param name="args"></param>
- void WriteLog(string format, params object[] args);
+ void WriteLog(String format, params Object[] args);
#endregion
#region 事件
@@ -197,7 +197,7 @@ namespace NewLife.Net
if (msInterval < 10)
{
- for (int i = 0; i < times; i++)
+ for (var i = 0; i < times; i++)
{
session.Send(pk);
}
diff --git a/NewLife.Core/Net/NetHelper.cs b/NewLife.Core/Net/NetHelper.cs
index eb8f172..cbde65a 100644
--- a/NewLife.Core/Net/NetHelper.cs
+++ b/NewLife.Core/Net/NetHelper.cs
@@ -30,11 +30,11 @@ namespace System
public static void SetTcpKeepAlive(this Socket socket, Boolean iskeepalive, Int32 starttime = 10000, Int32 interval = 10000)
{
if (socket == null || !socket.Connected) return;
- uint dummy = 0;
- byte[] inOptionValues = new byte[Marshal.SizeOf(dummy) * 3];
- BitConverter.GetBytes((uint)(iskeepalive ? 1 : 0)).CopyTo(inOptionValues, 0);
- BitConverter.GetBytes((uint)starttime).CopyTo(inOptionValues, Marshal.SizeOf(dummy));
- BitConverter.GetBytes((uint)interval).CopyTo(inOptionValues, Marshal.SizeOf(dummy) * 2);
+ UInt32 dummy = 0;
+ var inOptionValues = new Byte[Marshal.SizeOf(dummy) * 3];
+ BitConverter.GetBytes((UInt32)(iskeepalive ? 1 : 0)).CopyTo(inOptionValues, 0);
+ BitConverter.GetBytes((UInt32)starttime).CopyTo(inOptionValues, Marshal.SizeOf(dummy));
+ BitConverter.GetBytes((UInt32)interval).CopyTo(inOptionValues, Marshal.SizeOf(dummy) * 2);
socket.IOControl(IOControlCode.KeepAliveValues, inOptionValues, null);
}
@@ -355,7 +355,7 @@ namespace System
#if !__MOBILE__
static private ManagementObjectCollection GetInstances()
{
- ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
+ var mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
return mc.GetInstances();
}
@@ -370,12 +370,12 @@ namespace System
foreach (ManagementObject mo in moc)
{
- if (!(bool)mo["IPEnabled"]) continue;
+ if (!(Boolean)mo["IPEnabled"]) continue;
// 设置IP和掩码
var inPar = mo.GetMethodParameters("EnableStatic");
- inPar["IPAddress"] = new string[] { ip };
- inPar["SubnetMask"] = new string[] { mask };
+ inPar["IPAddress"] = new String[] { ip };
+ inPar["SubnetMask"] = new String[] { mask };
var outPar = mo.InvokeMethod("EnableStatic", inPar, null);
}
@@ -394,11 +394,11 @@ namespace System
foreach (ManagementObject mo in moc)
{
- if (!(bool)mo["IPEnabled"]) continue;
+ if (!(Boolean)mo["IPEnabled"]) continue;
// 设置网关
var inPar = mo.GetMethodParameters("SetGateways");
- inPar["DefaultIPGateway"] = new string[] { address };
+ inPar["DefaultIPGateway"] = new String[] { address };
var outPar = mo.InvokeMethod("SetGateways", inPar, null);
}
@@ -415,7 +415,7 @@ namespace System
foreach (ManagementObject mo in moc)
{
- if (!(bool)mo["IPEnabled"]) continue;
+ if (!(Boolean)mo["IPEnabled"]) continue;
mo.InvokeMethod("SetDNSServerSearchOrder", null);
// 开启DHCP
@@ -442,17 +442,17 @@ namespace System
{
mac = mac.Replace("-", null).Replace(":", null);
var buffer = new Byte[mac.Length / 2];
- for (int i = 0; i < buffer.Length; i++)
+ for (var i = 0; i < buffer.Length; i++)
{
buffer[i] = Byte.Parse(mac.Substring(i * 2, 2), NumberStyles.HexNumber);
}
var bts = new Byte[6 + 16 * buffer.Length];
- for (int i = 0; i < 6; i++)
+ for (var i = 0; i < 6; i++)
{
bts[i] = 0xFF;
}
- for (int i = 6, k = 0; i < bts.Length; i++, k++)
+ for (Int32 i = 6, k = 0; i < bts.Length; i++, k++)
{
if (k >= buffer.Length) k = 0;
@@ -468,7 +468,7 @@ namespace System
#region MAC获取/ARP协议
[DllImport("Iphlpapi.dll")]
- private static extern int SendARP(UInt32 destip, UInt32 srcip, Byte[] mac, ref Int32 length);
+ private static extern Int32 SendARP(UInt32 destip, UInt32 srcip, Byte[] mac, ref Int32 length);
/// <summary>根据IP地址获取MAC地址</summary>
/// <param name="ip"></param>
diff --git a/NewLife.Core/Net/NetServer.cs b/NewLife.Core/Net/NetServer.cs
index c1a912e..f0e6e9c 100644
--- a/NewLife.Core/Net/NetServer.cs
+++ b/NewLife.Core/Net/NetServer.cs
@@ -155,7 +155,7 @@ namespace NewLife.Net
/// <summary>已重载。释放会话集合等资源</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -240,7 +240,7 @@ namespace NewLife.Net
public virtual Int32 AddServer(IPAddress address, Int32 port, NetType protocol = NetType.Unknown, AddressFamily family = AddressFamily.Unspecified)
{
var list = CreateServer(address, port, protocol, family);
- Int32 count = 0;
+ var count = 0;
foreach (var item in list)
{
AttachServer(item);
@@ -652,7 +652,7 @@ namespace NewLife.Net
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
var servers = Servers;
if (servers == null || servers.Count < 1) return Name;
diff --git a/NewLife.Core/Net/NetSession.cs b/NewLife.Core/Net/NetSession.cs
index ca2ff41..23decf3 100644
--- a/NewLife.Core/Net/NetSession.cs
+++ b/NewLife.Core/Net/NetSession.cs
@@ -69,7 +69,7 @@ namespace NewLife.Net
/// <summary>子类重载实现资源释放逻辑时必须首先调用基类方法</summary>
/// <param name="disposing">从Dispose调用(释放所有资源)还是析构函数调用(释放非托管资源)</param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
if (LogSession && Log != null && Log.Enable) WriteLog("会话结束 {0}", Session);
@@ -127,7 +127,7 @@ namespace NewLife.Net
/// <summary>发送字符串</summary>
/// <param name="msg"></param>
/// <param name="encoding"></param>
- public virtual INetSession Send(string msg, Encoding encoding = null)
+ public virtual INetSession Send(String msg, Encoding encoding = null)
{
Session.Send(msg, encoding);
@@ -147,7 +147,7 @@ namespace NewLife.Net
/// <summary>错误处理</summary>
/// <param name="sender"></param>
/// <param name="e"></param>
- protected virtual void OnError(object sender, ExceptionEventArgs e) { }
+ protected virtual void OnError(Object sender, ExceptionEventArgs e) { }
#endregion
#region 日志
@@ -194,7 +194,7 @@ namespace NewLife.Net
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
var host = (this as INetSession).Host;
return String.Format("{0}[{1}] {2}", host == null ? "" : host.Name, ID, Session);
diff --git a/NewLife.Core/Net/NetUri.cs b/NewLife.Core/Net/NetUri.cs
index d5de830..7e5d359 100644
--- a/NewLife.Core/Net/NetUri.cs
+++ b/NewLife.Core/Net/NetUri.cs
@@ -7,7 +7,7 @@ using System.Xml.Serialization;
namespace NewLife.Net
{
/// <summary>协议类型</summary>
- public enum NetType : byte
+ public enum NetType : Byte
{
/// <summary>未知协议</summary>
Unknown = 0,
@@ -202,7 +202,7 @@ namespace NewLife.Net
if (p >= 0)
{
var pt = uri.Substring(p + 1);
- Int32 port = 0;
+ var port = 0;
if (Int32.TryParse(pt, out port))
{
Port = port;
@@ -242,7 +242,7 @@ namespace NewLife.Net
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
var p = Protocol;
switch (Type)
diff --git a/NewLife.Core/Net/SerialTransport.cs b/NewLife.Core/Net/SerialTransport.cs
index aa8bb23..9c4f7ea 100644
--- a/NewLife.Core/Net/SerialTransport.cs
+++ b/NewLife.Core/Net/SerialTransport.cs
@@ -236,7 +236,7 @@ namespace NewLife.Net
#endregion
#region 异步接收
- void DataReceived(object sender, SerialDataReceivedEventArgs e)
+ void DataReceived(Object sender, SerialDataReceivedEventArgs e)
{
// 发送者必须保持一定间隔,每个报文不能太大,否则会因为粘包拆包而出错
try
@@ -245,7 +245,7 @@ namespace NewLife.Net
WaitMore();
if (sp.BytesToRead > 0)
{
- var buf = new byte[sp.BytesToRead];
+ var buf = new Byte[sp.BytesToRead];
var count = sp.Read(buf, 0, buf.Length);
//if (count != buf.Length) buf = buf.ReadBytes(0, count);
@@ -492,7 +492,7 @@ namespace NewLife.Net
/// <summary>已重载</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (!String.IsNullOrEmpty(PortName))
return PortName;
diff --git a/NewLife.Core/Net/SessionBase.cs b/NewLife.Core/Net/SessionBase.cs
index 66b7f90..b30da3b 100644
--- a/NewLife.Core/Net/SessionBase.cs
+++ b/NewLife.Core/Net/SessionBase.cs
@@ -275,7 +275,7 @@ namespace NewLife.Net
if (_RecvCount >= MaxAsync) return false;
// 按照最大并发创建异步委托
- for (int i = _RecvCount; i < MaxAsync; i++)
+ for (var i = _RecvCount; i < MaxAsync; i++)
{
if (Interlocked.Increment(ref _RecvCount) > MaxAsync)
{
@@ -556,7 +556,7 @@ namespace NewLife.Net
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString() { return Local + ""; }
+ public override String ToString() { return Local + ""; }
#endregion
}
diff --git a/NewLife.Core/Net/SessionCollection.cs b/NewLife.Core/Net/SessionCollection.cs
index 12e3f37..d7cd667 100644
--- a/NewLife.Core/Net/SessionCollection.cs
+++ b/NewLife.Core/Net/SessionCollection.cs
@@ -30,7 +30,7 @@ namespace NewLife.Net
ClearPeriod = 1000;
}
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -169,9 +169,9 @@ namespace NewLife.Net
#region 成员
public void Clear() { _dic.Clear(); }
- public int Count { get { return _dic.Count; } }
+ public Int32 Count { get { return _dic.Count; } }
- public bool IsReadOnly { get { return (_dic as IDictionary<Int32, ISocketSession>).IsReadOnly; } }
+ public Boolean IsReadOnly { get { return (_dic as IDictionary<Int32, ISocketSession>).IsReadOnly; } }
public IEnumerator<ISocketSession> GetEnumerator() { return _dic.Values.GetEnumerator() as IEnumerator<ISocketSession>; }
@@ -182,11 +182,11 @@ namespace NewLife.Net
void IDictionary<String, ISocketSession>.Add(String key, ISocketSession value) { Add(value); }
- bool IDictionary<String, ISocketSession>.ContainsKey(String key) { return _dic.ContainsKey(key); }
+ Boolean IDictionary<String, ISocketSession>.ContainsKey(String key) { return _dic.ContainsKey(key); }
ICollection<String> IDictionary<String, ISocketSession>.Keys { get { return _dic.Keys; } }
- bool IDictionary<String, ISocketSession>.Remove(String key)
+ Boolean IDictionary<String, ISocketSession>.Remove(String key)
{
ISocketSession session;
if (!_dic.TryGetValue(key, out session)) return false;
@@ -197,7 +197,7 @@ namespace NewLife.Net
return _dic.Remove(key);
}
- bool IDictionary<String, ISocketSession>.TryGetValue(String key, out ISocketSession value) { return _dic.TryGetValue(key, out value); }
+ Boolean IDictionary<String, ISocketSession>.TryGetValue(String key, out ISocketSession value) { return _dic.TryGetValue(key, out value); }
ICollection<ISocketSession> IDictionary<String, ISocketSession>.Values { get { return _dic.Values; } }
@@ -212,11 +212,11 @@ namespace NewLife.Net
throw new XException("不支持!请使用Add(ISocketSession session)方法!");
}
- bool ICollection<KeyValuePair<String, ISocketSession>>.Contains(KeyValuePair<String, ISocketSession> item) { throw new NotImplementedException(); }
+ Boolean ICollection<KeyValuePair<String, ISocketSession>>.Contains(KeyValuePair<String, ISocketSession> item) { throw new NotImplementedException(); }
- void ICollection<KeyValuePair<String, ISocketSession>>.CopyTo(KeyValuePair<String, ISocketSession>[] array, int arrayIndex) { throw new NotImplementedException(); }
+ void ICollection<KeyValuePair<String, ISocketSession>>.CopyTo(KeyValuePair<String, ISocketSession>[] array, Int32 arrayIndex) { throw new NotImplementedException(); }
- bool ICollection<KeyValuePair<String, ISocketSession>>.Remove(KeyValuePair<String, ISocketSession> item) { throw new XException("不支持!请直接销毁会话对象!"); }
+ Boolean ICollection<KeyValuePair<String, ISocketSession>>.Remove(KeyValuePair<String, ISocketSession> item) { throw new XException("不支持!请直接销毁会话对象!"); }
#endregion
diff --git a/NewLife.Core/Net/Statistics.cs b/NewLife.Core/Net/Statistics.cs
index 8d381d9..7173622 100644
--- a/NewLife.Core/Net/Statistics.cs
+++ b/NewLife.Core/Net/Statistics.cs
@@ -99,7 +99,7 @@ namespace NewLife.Net
/// <summary>已重载。输出统计信息</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return "{0:n0}/{1:n0}/{2:n0}/{3:n0}".F(Speed, Max, Times, Total);
}
diff --git a/NewLife.Core/Net/TcpServer.cs b/NewLife.Core/Net/TcpServer.cs
index aa6dd80..eea7806 100644
--- a/NewLife.Core/Net/TcpServer.cs
+++ b/NewLife.Core/Net/TcpServer.cs
@@ -97,7 +97,7 @@ namespace NewLife.Net
/// <summary>已重载。释放会话集合等资源</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -130,7 +130,7 @@ namespace NewLife.Net
Active = true;
- for (int i = 0; i < MaxAsync; i++)
+ for (var i = 0; i < MaxAsync; i++)
{
var se = new SocketAsyncEventArgs();
se.Completed += (s, e) => ProcessAccept(e);
@@ -369,7 +369,7 @@ namespace NewLife.Net
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
var ss = Sessions;
var count = ss != null ? ss.Count : 0;
diff --git a/NewLife.Core/Net/TcpSession.cs b/NewLife.Core/Net/TcpSession.cs
index 3c9f45e..4f1c900 100644
--- a/NewLife.Core/Net/TcpSession.cs
+++ b/NewLife.Core/Net/TcpSession.cs
@@ -191,7 +191,7 @@ namespace NewLife.Net
return true;
}
- internal override bool OnSendAsync(SocketAsyncEventArgs se) { return Client.SendAsync(se); }
+ internal override Boolean OnSendAsync(SocketAsyncEventArgs se) { return Client.SendAsync(se); }
#endregion
#region 接收
@@ -207,7 +207,7 @@ namespace NewLife.Net
// return task.Result;
//}
- internal override bool OnReceiveAsync(SocketAsyncEventArgs se)
+ internal override Boolean OnReceiveAsync(SocketAsyncEventArgs se)
{
var client = Client;
if (client == null || !Active || Disposed) throw new ObjectDisposedException(GetType().Name);
@@ -281,7 +281,7 @@ namespace NewLife.Net
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (Remote != null && !Remote.EndPoint.IsAny())
{
diff --git a/NewLife.Core/Net/UdpServer.cs b/NewLife.Core/Net/UdpServer.cs
index dd008f6..51d50dc 100644
--- a/NewLife.Core/Net/UdpServer.cs
+++ b/NewLife.Core/Net/UdpServer.cs
@@ -195,7 +195,7 @@ namespace NewLife.Net
return await task.ConfigureAwait(false);
}
- internal override bool OnSendAsync(SocketAsyncEventArgs se)
+ internal override Boolean OnSendAsync(SocketAsyncEventArgs se)
{
if (se.RemoteEndPoint == null) se.RemoteEndPoint = Remote.EndPoint;
@@ -401,7 +401,7 @@ namespace NewLife.Net
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
var ss = Sessions;
if (ss != null && ss.Count > 0)
@@ -425,10 +425,10 @@ namespace NewLife.Net
Int64 total = 0;
var size = 1472;
- Byte[] buffer = new Byte[size];
+ var buffer = new Byte[size];
while (true)
{
- Int32 n = stream.Read(buffer, 0, buffer.Length);
+ var n = stream.Read(buffer, 0, buffer.Length);
if (n <= 0) break;
udp.Send(buffer, n, remoteEP);
diff --git a/NewLife.Core/Net/UdpSession.cs b/NewLife.Core/Net/UdpSession.cs
index dbdcf48..73dd845 100644
--- a/NewLife.Core/Net/UdpSession.cs
+++ b/NewLife.Core/Net/UdpSession.cs
@@ -46,7 +46,7 @@ namespace NewLife.Net
/// <summary>远程地址</summary>
public NetUri Remote { get; set; }
- private int _timeout;
+ private Int32 _timeout;
/// <summary>超时。默认3000ms</summary>
public Int32 Timeout
{
@@ -113,7 +113,7 @@ namespace NewLife.Net
WriteLog("New {0}", Remote.EndPoint);
}
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -255,7 +255,7 @@ namespace NewLife.Net
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (Remote != null && !Remote.EndPoint.IsAny())
return String.Format("{0}=>{1}", Local, Remote.EndPoint);
@@ -265,9 +265,9 @@ namespace NewLife.Net
#endregion
#region ITransport接口
- bool ITransport.Open() { return true; }
+ Boolean ITransport.Open() { return true; }
- bool ITransport.Close() { return true; }
+ Boolean ITransport.Close() { return true; }
#endregion
#region 日志
diff --git a/NewLife.Core/Net/WebSocketSession.cs b/NewLife.Core/Net/WebSocketSession.cs
index 4706306..07f83f2 100644
--- a/NewLife.Core/Net/WebSocketSession.cs
+++ b/NewLife.Core/Net/WebSocketSession.cs
@@ -74,7 +74,7 @@ namespace NewLife.Net
var len = ms.ReadByte();
- bool mask = (len & 0x80) == 0x80;
+ var mask = (len & 0x80) == 0x80;
/*
* 数据长度
@@ -102,7 +102,7 @@ namespace NewLife.Net
{
for (var i = 0; i < len; i++)
{
- data[i] = (byte)(data[i] ^ masks[i % 4]);
+ data[i] = (Byte)(data[i] ^ masks[i % 4]);
}
}
diff --git a/NewLife.Core/Reflection/AssemblyX.cs b/NewLife.Core/Reflection/AssemblyX.cs
index 614a7c8..a6c0df8 100644
--- a/NewLife.Core/Reflection/AssemblyX.cs
+++ b/NewLife.Core/Reflection/AssemblyX.cs
@@ -711,7 +711,7 @@ namespace NewLife.Reflection
#region 重载
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (!String.IsNullOrEmpty(Title))
return Title;
diff --git a/NewLife.Core/Reflection/DynamicInternal.cs b/NewLife.Core/Reflection/DynamicInternal.cs
index 1c0a06e..08aff70 100644
--- a/NewLife.Core/Reflection/DynamicInternal.cs
+++ b/NewLife.Core/Reflection/DynamicInternal.cs
@@ -65,7 +65,7 @@ namespace NewLife.Reflection
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return Real.ToString();
}
diff --git a/NewLife.Core/Reflection/DynamicXml.cs b/NewLife.Core/Reflection/DynamicXml.cs
index fe6304d..3d47868 100644
--- a/NewLife.Core/Reflection/DynamicXml.cs
+++ b/NewLife.Core/Reflection/DynamicXml.cs
@@ -31,7 +31,7 @@ namespace NewLife.Reflection
/// <param name="binder"></param>
/// <param name="value"></param>
/// <returns></returns>
- public override bool TrySetMember(SetMemberBinder binder, Object value)
+ public override Boolean TrySetMember(SetMemberBinder binder, Object value)
{
var setNode = Node.Element(binder.Name);
if (setNode != null)
@@ -50,7 +50,7 @@ namespace NewLife.Reflection
/// <param name="binder"></param>
/// <param name="result"></param>
/// <returns></returns>
- public override bool TryGetMember(GetMemberBinder binder, out Object result)
+ public override Boolean TryGetMember(GetMemberBinder binder, out Object result)
{
result = null;
var getNode = Node.Element(binder.Name);
diff --git a/NewLife.Core/Reflection/EmitHelper.cs b/NewLife.Core/Reflection/EmitHelper.cs
index 02c449f..62a2675 100644
--- a/NewLife.Core/Reflection/EmitHelper.cs
+++ b/NewLife.Core/Reflection/EmitHelper.cs
@@ -407,15 +407,15 @@ namespace NewLife.Reflection
/// <returns></returns>
public static ILGenerator CreateLocalsForByRefParams(this ILGenerator IL, MethodBase method)
{
- Int32 firstParamIndex = method.IsStatic ? 0 : 1;
- Int32 refParams = 0;
- ParameterInfo[] ps = method.GetParameters();
- for (Int32 i = 0; i < ps.Length; i++)
+ var firstParamIndex = method.IsStatic ? 0 : 1;
+ var refParams = 0;
+ var ps = method.GetParameters();
+ for (var i = 0; i < ps.Length; i++)
{
// 处理引用类型参数
if (!ps[i].ParameterType.IsByRef) continue;
- Type type = ps[i].ParameterType.GetElementType();
+ var type = ps[i].ParameterType.GetElementType();
IL.DeclareLocal(type);
// 处理输出类型
if (ps[i].IsOut)
@@ -438,10 +438,10 @@ namespace NewLife.Reflection
/// <returns></returns>
public static ILGenerator AssignByRefParamsToArray(this ILGenerator IL, MethodBase method)
{
- Int32 firstParamIndex = method.IsStatic ? 0 : 1;
- Int32 refParam = 0;
- ParameterInfo[] ps = method.GetParameters();
- for (Int32 i = 0; i < ps.Length; i++)
+ var firstParamIndex = method.IsStatic ? 0 : 1;
+ var refParam = 0;
+ var ps = method.GetParameters();
+ for (var i = 0; i < ps.Length; i++)
{
// 处理引用类型参数
if (!ps[i].ParameterType.IsByRef) continue;
@@ -462,10 +462,10 @@ namespace NewLife.Reflection
/// <returns></returns>
public static ILGenerator PushParamsOrLocalsToStack(this ILGenerator IL, MethodBase method)
{
- Int32 firstParamIndex = method.IsStatic ? 0 : 1;
- Int32 refParam = 0;
- ParameterInfo[] ps = method.GetParameters();
- for (Int32 i = 0; i < ps.Length; i++)
+ var firstParamIndex = method.IsStatic ? 0 : 1;
+ var refParam = 0;
+ var ps = method.GetParameters();
+ for (var i = 0; i < ps.Length; i++)
{
if (ps[i].ParameterType.IsByRef)
{
@@ -490,8 +490,8 @@ namespace NewLife.Reflection
/// <returns></returns>
public static ILGenerator PushParams(this ILGenerator IL, Int32 paramIndex, MethodBase method)
{
- ParameterInfo[] ps = method.GetParameters();
- for (Int32 i = 0; i < ps.Length; i++)
+ var ps = method.GetParameters();
+ for (var i = 0; i < ps.Length; i++)
{
IL.Ldarg(paramIndex)
.Ldc_I4(i)
@@ -511,7 +511,7 @@ namespace NewLife.Reflection
{
if (paramTypes == null || paramTypes.Length < 1) return IL;
- for (int i = 0; i < paramTypes.Length; i++)
+ for (var i = 0; i < paramTypes.Length; i++)
{
IL.Ldarg(paramIndex)
.Ldc_I4(i)
diff --git a/NewLife.Core/Reflection/IReflect.cs b/NewLife.Core/Reflection/IReflect.cs
index e7172c5..8aa6397 100644
--- a/NewLife.Core/Reflection/IReflect.cs
+++ b/NewLife.Core/Reflection/IReflect.cs
@@ -431,7 +431,7 @@ namespace NewLife.Reflection
if (pis == null || pis.Length < 1) return Invoke(target, method, null);
var ps = new Object[pis.Length];
- for (int i = 0; i < pis.Length; i++)
+ for (var i = 0; i < pis.Length; i++)
{
Object v = null;
if (parameters != null && parameters.Contains(pis[i].Name)) v = parameters[pis[i].Name];
diff --git a/NewLife.Core/Reflection/OrcasNamer.cs b/NewLife.Core/Reflection/OrcasNamer.cs
index 1a9fb6f..e5f875e 100644
--- a/NewLife.Core/Reflection/OrcasNamer.cs
+++ b/NewLife.Core/Reflection/OrcasNamer.cs
@@ -6,7 +6,7 @@ namespace NewLife.Reflection
{
class OrcasNamer
{
- public static string GetName(MemberInfo member)
+ public static String GetName(MemberInfo member)
{
using (TextWriter writer = new StringWriter())
{
@@ -31,7 +31,7 @@ namespace NewLife.Reflection
break;
case MemberTypes.Constructor:
writer.Write("M:");
- ConstructorInfo ctor = member as ConstructorInfo;
+ var ctor = member as ConstructorInfo;
if (!ctor.IsStatic)
WriteConstructor(ctor, writer);
else
@@ -92,7 +92,7 @@ namespace NewLife.Reflection
private static void WriteMethod(MethodInfo method, TextWriter writer)
{
- string name = method.Name;
+ var name = method.Name;
WriteType(method.DeclaringType, writer);
//MethodInfo eiiMethod = null;
@@ -130,7 +130,7 @@ namespace NewLife.Reflection
}
if (method.IsGenericMethod)
{
- Type[] genericParameters = method.GetGenericArguments();
+ var genericParameters = method.GetGenericArguments();
if (genericParameters != null)
{
writer.Write("``{0}", genericParameters.Length);
@@ -205,7 +205,7 @@ namespace NewLife.Reflection
{
if (parameters == null || parameters.Length == 0) return;
writer.Write("(");
- for (int i = 0; i < parameters.Length; i++)
+ for (var i = 0; i < parameters.Length; i++)
{
if (i > 0) writer.Write(",");
WriteType(parameters[i].ParameterType, writer);
@@ -221,7 +221,7 @@ namespace NewLife.Reflection
writer.Write("[");
if (type.GetArrayRank() > 1)
{
- for (int i = 0; i < type.GetArrayRank(); i++)
+ for (var i = 0; i < type.GetArrayRank(); i++)
{
if (i > 0) writer.Write(",");
writer.Write("0:");
@@ -266,7 +266,7 @@ namespace NewLife.Reflection
else
{
// namespace
- Type declaringType = type.DeclaringType;
+ var declaringType = type.DeclaringType;
if (declaringType != null)
{
// names of nested types begin with outer type name
@@ -285,7 +285,7 @@ namespace NewLife.Reflection
}
// name
//writer.Write(type.GetUnmangledNameWithoutTypeParameters());
- String typeName = type.Name;
+ var typeName = type.Name;
if (typeName.Contains("`"))
writer.Write(typeName.Substring(0, typeName.IndexOf("`")));
else
@@ -296,7 +296,7 @@ namespace NewLife.Reflection
if (type.IsGenericTypeDefinition)
{
// number of parameters
- Type[] parameters = type.GetGenericArguments();
+ var parameters = type.GetGenericArguments();
if (parameters != null)
{
writer.Write("`{0}", parameters.Length);
@@ -305,11 +305,11 @@ namespace NewLife.Reflection
else
{
// arguments
- Type[] arguments = type.GetGenericArguments();
+ var arguments = type.GetGenericArguments();
if (arguments != null && arguments.Length > 0)
{
writer.Write("{");
- for (int i = 0; i < arguments.Length; i++)
+ for (var i = 0; i < arguments.Length; i++)
{
//TypeNode argument = arguments[i];
if (i > 0) writer.Write(",");
diff --git a/NewLife.Core/Reflection/PEImage.cs b/NewLife.Core/Reflection/PEImage.cs
index 8939023..47a0276 100644
--- a/NewLife.Core/Reflection/PEImage.cs
+++ b/NewLife.Core/Reflection/PEImage.cs
@@ -133,7 +133,7 @@ namespace NewLife.Reflection
// pe32 = 0x10b pe64 = 0x20b
// Magic 2
- bool pe64 = reader.ReadUInt16() == 0x20b;
+ var pe64 = reader.ReadUInt16() == 0x20b;
// pe32 || pe64
@@ -230,12 +230,12 @@ namespace NewLife.Reflection
stream.Seek(8, SeekOrigin.Current);
}
- void ReadSections(BinaryReader reader, ushort count)
+ void ReadSections(BinaryReader reader, UInt16 count)
{
var stream = reader.BaseStream;
var sections = new Section[count];
- for (int i = 0; i < count; i++)
+ for (var i = 0; i < count; i++)
{
var section = new Section();
@@ -352,11 +352,11 @@ namespace NewLife.Reflection
struct DataDirectory
{
public readonly RVA VirtualAddress;
- public readonly uint Size;
+ public readonly RVA Size;
- public bool IsZero { get { return VirtualAddress == 0 && Size == 0; } }
+ public Boolean IsZero { get { return VirtualAddress == 0 && Size == 0; } }
- public DataDirectory(RVA rva, uint size)
+ public DataDirectory(RVA rva, RVA size)
{
VirtualAddress = rva;
Size = size;
@@ -367,11 +367,11 @@ namespace NewLife.Reflection
sealed class Section
{
- public string Name;
+ public String Name;
public RVA VirtualAddress;
//public uint VirtualSize;
- public uint SizeOfRawData;
- public uint PointerToRawData;
+ public RVA SizeOfRawData;
+ public RVA PointerToRawData;
//public byte[] Data;
}
#endregion
diff --git a/NewLife.Core/Reflection/Reflect.cs b/NewLife.Core/Reflection/Reflect.cs
index 029ff13..a653bb8 100644
--- a/NewLife.Core/Reflection/Reflect.cs
+++ b/NewLife.Core/Reflection/Reflect.cs
@@ -373,7 +373,7 @@ namespace NewLife.Reflection
if (args == null) return Type.EmptyTypes;
var typeArray = new Type[args.Length];
- for (int i = 0; i < typeArray.Length; i++)
+ for (var i = 0; i < typeArray.Length; i++)
{
if (args[i] == null)
typeArray[i] = typeof(Object);
diff --git a/NewLife.Core/Reflection/ScriptEngine.cs b/NewLife.Core/Reflection/ScriptEngine.cs
index abfe6b3..cfc223f 100644
--- a/NewLife.Core/Reflection/ScriptEngine.cs
+++ b/NewLife.Core/Reflection/ScriptEngine.cs
@@ -165,7 +165,7 @@ namespace NewLife.Reflection
var types = ps.GetTypeArray();
var dic = se.Parameters;
- for (int i = 0; i < names.Length; i++)
+ for (var i = 0; i < names.Length; i++)
{
dic.Add(names[i], types[i]);
}
@@ -185,14 +185,14 @@ namespace NewLife.Reflection
if (se != null && se.Method != null) return se.Invoke(parameters);
var names = new String[parameters.Length];
- for (int i = 0; i < names.Length; i++)
+ for (var i = 0; i < names.Length; i++)
{
names[i] = "p" + i;
}
var types = parameters.GetTypeArray();
var dic = se.Parameters;
- for (int i = 0; i < names.Length; i++)
+ for (var i = 0; i < names.Length; i++)
{
dic.Add(names[i], types[i]);
}
@@ -506,7 +506,7 @@ namespace NewLife.Reflection
if (Log != null) Log.Info(format, args);
}
- static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
+ static Assembly CurrentDomain_AssemblyResolve(Object sender, ResolveEventArgs args)
{
var name = args.Name;
if (String.IsNullOrEmpty(name)) return null;
diff --git a/NewLife.Core/Remoting/ApiAction.cs b/NewLife.Core/Remoting/ApiAction.cs
index d0b7a0f..aedfa10 100644
--- a/NewLife.Core/Remoting/ApiAction.cs
+++ b/NewLife.Core/Remoting/ApiAction.cs
@@ -116,7 +116,7 @@ namespace NewLife.Remoting
sb.Append("(");
var pis = Method.GetParameters();
- for (int i = 0; i < pis.Length; i++)
+ for (var i = 0; i < pis.Length; i++)
{
if (i > 0) sb.Append(", ");
sb.AppendFormat("{0} {1}", pis[i].ParameterType.Name, pis[i].Name);
diff --git a/NewLife.Core/Remoting/ApiAttribute.cs b/NewLife.Core/Remoting/ApiAttribute.cs
index 9c6d28a..945127f 100644
--- a/NewLife.Core/Remoting/ApiAttribute.cs
+++ b/NewLife.Core/Remoting/ApiAttribute.cs
@@ -7,10 +7,10 @@ namespace NewLife.Remoting
public class ApiAttribute : Attribute
{
/// <summary>名称</summary>
- public string Name { get; set; }
+ public String Name { get; set; }
/// <summary>实例化</summary>
/// <param name="name"></param>
- public ApiAttribute(string name) { Name = name; }
+ public ApiAttribute(String name) { Name = name; }
}
}
\ No newline at end of file
diff --git a/NewLife.Core/Remoting/ApiClient.cs b/NewLife.Core/Remoting/ApiClient.cs
index affd260..6e4304d 100644
--- a/NewLife.Core/Remoting/ApiClient.cs
+++ b/NewLife.Core/Remoting/ApiClient.cs
@@ -60,7 +60,7 @@ namespace NewLife.Remoting
/// <summary>销毁</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -124,7 +124,7 @@ namespace NewLife.Remoting
/// <param name="action"></param>
/// <param name="args"></param>
/// <returns></returns>
- public async Task<TResult> InvokeAsync<TResult>(String action, object args = null)
+ public async Task<TResult> InvokeAsync<TResult>(String action, Object args = null)
{
var ss = Client;
if (ss == null) return default(TResult);
diff --git a/NewLife.Core/Remoting/ApiHost.cs b/NewLife.Core/Remoting/ApiHost.cs
index e463ced..d860951 100644
--- a/NewLife.Core/Remoting/ApiHost.cs
+++ b/NewLife.Core/Remoting/ApiHost.cs
@@ -115,7 +115,7 @@ namespace NewLife.Remoting
Object args = null;
if (!enc.TryGet(dic, out action, out args)) return null;
- object result = null;
+ Object result = null;
var code = 0;
try
{
diff --git a/NewLife.Core/Remoting/ApiHttpClient.cs b/NewLife.Core/Remoting/ApiHttpClient.cs
index 584c2ae..a1e462f 100644
--- a/NewLife.Core/Remoting/ApiHttpClient.cs
+++ b/NewLife.Core/Remoting/ApiHttpClient.cs
@@ -5,7 +5,7 @@ namespace NewLife.Remoting
{
class ApiHttpClient : ApiNetClient
{
- public override bool Init(object config)
+ public override Boolean Init(Object config)
{
var uri = config as NetUri;
if (uri != null)
diff --git a/NewLife.Core/Remoting/ApiHttpServer.cs b/NewLife.Core/Remoting/ApiHttpServer.cs
index e274723..e243352 100644
--- a/NewLife.Core/Remoting/ApiHttpServer.cs
+++ b/NewLife.Core/Remoting/ApiHttpServer.cs
@@ -24,10 +24,10 @@ namespace NewLife.Remoting
/// <summary>监听器</summary>
public HttpListener Listener { get; set; }
- private readonly List<string> _prefixes = new List<string>();
+ private readonly List<String> _prefixes = new List<String>();
#endregion
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -37,7 +37,7 @@ namespace NewLife.Remoting
/// <summary>初始化</summary>
/// <param name="config"></param>
/// <returns></returns>
- public bool Init(string config)
+ public Boolean Init(String config)
{
_prefixes.AddRange(config.Split(";"));
diff --git a/NewLife.Core/Remoting/ApiNetClient.cs b/NewLife.Core/Remoting/ApiNetClient.cs
index 4113476..a01c19a 100644
--- a/NewLife.Core/Remoting/ApiNetClient.cs
+++ b/NewLife.Core/Remoting/ApiNetClient.cs
@@ -28,7 +28,7 @@ namespace NewLife.Remoting
#endregion
#region 方法
- public virtual bool Init(object config)
+ public virtual Boolean Init(Object config)
{
var uri = config is String ? new NetUri(config + "") : config as NetUri;
if (uri == null) return false;
diff --git a/NewLife.Core/Remoting/ApiNetServer.cs b/NewLife.Core/Remoting/ApiNetServer.cs
index b45c4a9..72586f0 100644
--- a/NewLife.Core/Remoting/ApiNetServer.cs
+++ b/NewLife.Core/Remoting/ApiNetServer.cs
@@ -32,7 +32,7 @@ namespace NewLife.Remoting
/// <summary>初始化</summary>
/// <param name="config"></param>
/// <returns></returns>
- public bool Init(string config)
+ public Boolean Init(String config)
{
Local = new NetUri(config);
#if DEBUG
@@ -110,7 +110,7 @@ namespace NewLife.Remoting
/// <param name="action"></param>
/// <param name="args"></param>
/// <returns></returns>
- public async Task<TResult> InvokeAsync<TResult>(string action, object args = null)
+ public async Task<TResult> InvokeAsync<TResult>(String action, Object args = null)
{
return await ApiHostHelper.InvokeAsync<TResult>(_ApiHost, this, action, args).ConfigureAwait(false);
}
diff --git a/NewLife.Core/Remoting/ApiServer.cs b/NewLife.Core/Remoting/ApiServer.cs
index e368d32..5686d8e 100644
--- a/NewLife.Core/Remoting/ApiServer.cs
+++ b/NewLife.Core/Remoting/ApiServer.cs
@@ -13,7 +13,7 @@ namespace NewLife.Remoting
{
#region 静态
/// <summary>协议到提供者类的映射</summary>
- public static IDictionary<string, Type> Providers { get; } = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
+ public static IDictionary<String, Type> Providers { get; } = new Dictionary<String, Type>(StringComparer.OrdinalIgnoreCase);
static ApiServer()
{
@@ -43,7 +43,7 @@ namespace NewLife.Remoting
/// <summary>使用指定端口实例化网络服务应用接口提供者</summary>
/// <param name="port"></param>
- public ApiServer(int port) : this()
+ public ApiServer(Int32 port) : this()
{
Add(new NetUri(NetType.Unknown, "", port));
}
@@ -57,7 +57,7 @@ namespace NewLife.Remoting
/// <summary>销毁时停止服务</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -83,7 +83,7 @@ namespace NewLife.Remoting
/// <summary>添加服务器</summary>
/// <param name="config"></param>
- public IApiServer Add(string config)
+ public IApiServer Add(String config)
{
var protocol = config.Substring(null, "://");
Type type;
diff --git a/NewLife.Core/Remoting/Controllers/ApiController.cs b/NewLife.Core/Remoting/Controllers/ApiController.cs
index 6aa896d..8affe6c 100644
--- a/NewLife.Core/Remoting/Controllers/ApiController.cs
+++ b/NewLife.Core/Remoting/Controllers/ApiController.cs
@@ -29,7 +29,7 @@ namespace NewLife.Remoting
sb.Append("(");
var pis = mi.GetParameters();
- for (int i = 0; i < pis.Length; i++)
+ for (var i = 0; i < pis.Length; i++)
{
if (i > 0) sb.Append(", ");
sb.AppendFormat("{0} {1}", pis[i].ParameterType.Name, pis[i].Name);
diff --git a/NewLife.Core/Remoting/Filters/ActionExecutedContext.cs b/NewLife.Core/Remoting/Filters/ActionExecutedContext.cs
index d501496..9ab3782 100644
--- a/NewLife.Core/Remoting/Filters/ActionExecutedContext.cs
+++ b/NewLife.Core/Remoting/Filters/ActionExecutedContext.cs
@@ -6,16 +6,16 @@ namespace NewLife.Remoting
public class ActionExecutedContext : ControllerContext
{
/// <summary>获取或设置一个值,该值指示此 <see cref="ActionExecutedContext"/> 对象已被取消。</summary>
- public virtual bool Canceled { get; set; }
+ public virtual Boolean Canceled { get; set; }
/// <summary>获取或设置在操作方法的执行过程中发生的异常(如果有)。</summary>
public virtual Exception Exception { get; set; }
/// <summary>获取或设置一个值,该值指示是否处理异常。</summary>
- public bool ExceptionHandled { get; set; }
+ public Boolean ExceptionHandled { get; set; }
/// <summary>获取或设置由操作方法返回的结果。</summary>
- public object Result { get; set; }
+ public Object Result { get; set; }
/// <summary>实例化</summary>
public ActionExecutedContext() { }
diff --git a/NewLife.Core/Remoting/Filters/GlobalFilters.cs b/NewLife.Core/Remoting/Filters/GlobalFilters.cs
index ad488c9..b9e6bdc 100644
--- a/NewLife.Core/Remoting/Filters/GlobalFilters.cs
+++ b/NewLife.Core/Remoting/Filters/GlobalFilters.cs
@@ -8,7 +8,7 @@ namespace NewLife.Remoting
public static class GlobalFilters
{
/// <summary>过滤器类型集合</summary>
- private static List<object> Filters { get; } = new List<Object>();
+ private static List<Object> Filters { get; } = new List<Object>();
///// <summary>添加过滤器</summary>
///// <typeparam name="T"></typeparam>
diff --git a/NewLife.Core/Remoting/IApiClient.cs b/NewLife.Core/Remoting/IApiClient.cs
index e437c79..e1a4821 100644
--- a/NewLife.Core/Remoting/IApiClient.cs
+++ b/NewLife.Core/Remoting/IApiClient.cs
@@ -15,7 +15,7 @@ namespace NewLife.Remoting
/// <summary>初始化</summary>
/// <param name="config"></param>
/// <returns></returns>
- bool Init(object config);
+ Boolean Init(Object config);
/// <summary>打开</summary>
void Open();
diff --git a/NewLife.Core/Remoting/IApiHost.cs b/NewLife.Core/Remoting/IApiHost.cs
index 9146b85..88f3dfd 100644
--- a/NewLife.Core/Remoting/IApiHost.cs
+++ b/NewLife.Core/Remoting/IApiHost.cs
@@ -58,7 +58,7 @@ namespace NewLife.Remoting
/// <param name="action"></param>
/// <param name="args"></param>
/// <returns></returns>
- public static async Task<TResult> InvokeAsync<TResult>(IApiHost host, IApiSession session, String action, object args = null)
+ public static async Task<TResult> InvokeAsync<TResult>(IApiHost host, IApiSession session, String action, Object args = null)
{
if (session == null) return default(TResult);
diff --git a/NewLife.Core/Remoting/IApiManager.cs b/NewLife.Core/Remoting/IApiManager.cs
index 397e76f..0c93243 100644
--- a/NewLife.Core/Remoting/IApiManager.cs
+++ b/NewLife.Core/Remoting/IApiManager.cs
@@ -9,7 +9,7 @@ namespace NewLife.Remoting
public interface IApiManager
{
/// <summary>可提供服务的方法</summary>
- IDictionary<string, ApiAction> Services { get; }
+ IDictionary<String, ApiAction> Services { get; }
/// <summary>注册服务提供类。该类的所有公开方法将直接暴露</summary>
/// <param name="requireApi">是否要求Api特性</param>
@@ -28,13 +28,13 @@ namespace NewLife.Remoting
/// <summary>查找服务</summary>
/// <param name="action"></param>
/// <returns></returns>
- ApiAction Find(string action);
+ ApiAction Find(String action);
}
class ApiManager : IApiManager
{
/// <summary>可提供服务的方法</summary>
- public IDictionary<string, ApiAction> Services { get; } = new Dictionary<string, ApiAction>();
+ public IDictionary<String, ApiAction> Services { get; } = new Dictionary<String, ApiAction>();
private void Register(Object controller, Type type, Boolean requireApi)
{
@@ -44,7 +44,7 @@ namespace NewLife.Remoting
foreach (var mi in type.GetMethods(flag))
{
if (mi.IsSpecialName) continue;
- if (mi.DeclaringType == typeof(object)) continue;
+ if (mi.DeclaringType == typeof(Object)) continue;
if (requireApi && mi.GetCustomAttribute<ApiAttribute>() == null) continue;
var act = new ApiAction(mi, type);
@@ -96,7 +96,7 @@ namespace NewLife.Remoting
/// <summary>查找服务</summary>
/// <param name="action"></param>
/// <returns></returns>
- public ApiAction Find(string action)
+ public ApiAction Find(String action)
{
ApiAction mi;
return Services.TryGetValue(action, out mi) ? mi : null;
diff --git a/NewLife.Core/Remoting/IApiServer.cs b/NewLife.Core/Remoting/IApiServer.cs
index 4f87634..3d2266d 100644
--- a/NewLife.Core/Remoting/IApiServer.cs
+++ b/NewLife.Core/Remoting/IApiServer.cs
@@ -21,7 +21,7 @@ namespace NewLife.Remoting
/// <summary>初始化</summary>
/// <param name="config"></param>
/// <returns></returns>
- bool Init(string config);
+ Boolean Init(String config);
/// <summary>开始</summary>
void Start();
diff --git a/NewLife.Core/Remoting/IApiSession.cs b/NewLife.Core/Remoting/IApiSession.cs
index 8794e55..5c29989 100644
--- a/NewLife.Core/Remoting/IApiSession.cs
+++ b/NewLife.Core/Remoting/IApiSession.cs
@@ -14,7 +14,7 @@ namespace NewLife.Remoting
/// <summary>获取/设置 用户会话数据</summary>
/// <param name="key"></param>
/// <returns></returns>
- object this[string key] { get; set; }
+ Object this[String key] { get; set; }
/// <summary>创建消息。低级接口,由框架使用</summary>
/// <param name="pk"></param>
@@ -31,6 +31,6 @@ namespace NewLife.Remoting
/// <param name="action"></param>
/// <param name="args"></param>
/// <returns></returns>
- Task<TResult> InvokeAsync<TResult>(string action, object args = null);
+ Task<TResult> InvokeAsync<TResult>(String action, Object args = null);
}
}
\ No newline at end of file
diff --git a/NewLife.Core/Remoting/JsonEncoder.cs b/NewLife.Core/Remoting/JsonEncoder.cs
index b6ef308..1616265 100644
--- a/NewLife.Core/Remoting/JsonEncoder.cs
+++ b/NewLife.Core/Remoting/JsonEncoder.cs
@@ -34,7 +34,7 @@ namespace NewLife.Remoting
WriteLog("<={0}", json);
var jp = new JsonParser(json);
- var dic = jp.Decode() as IDictionary<string, object>;
+ var dic = jp.Decode() as IDictionary<String, Object>;
return dic;
}
diff --git a/NewLife.Core/Security/Certificate.cs b/NewLife.Core/Security/Certificate.cs
index 643854b..df810ac 100644
--- a/NewLife.Core/Security/Certificate.cs
+++ b/NewLife.Core/Security/Certificate.cs
@@ -44,7 +44,7 @@ namespace NewLife.Security
if (!String.IsNullOrEmpty(insecurePassword))
{
password = new SecureString();
- foreach (char ch in insecurePassword)
+ foreach (var ch in insecurePassword)
{
password.AppendChar(ch);
}
@@ -206,17 +206,17 @@ namespace NewLife.Security
private static SystemTime ToSystemTime(DateTime dateTime)
{
- long fileTime = dateTime.ToFileTime();
+ var fileTime = dateTime.ToFileTime();
SystemTime systemTime;
Check(NativeMethods.FileTimeToSystemTime(ref fileTime, out systemTime));
return systemTime;
}
- private static void Check(bool nativeCallSucceeded)
+ private static void Check(Boolean nativeCallSucceeded)
{
if (!nativeCallSucceeded)
{
- int error = Marshal.GetHRForLastWin32Error();
+ var error = Marshal.GetHRForLastWin32Error();
Marshal.ThrowExceptionForHR(error);
}
}
@@ -224,23 +224,23 @@ namespace NewLife.Security
[StructLayout(LayoutKind.Sequential)]
private struct SystemTime
{
- public short Year;
- public short Month;
- public short DayOfWeek;
- public short Day;
- public short Hour;
- public short Minute;
- public short Second;
- public short Milliseconds;
+ public Int16 Year;
+ public Int16 Month;
+ public Int16 DayOfWeek;
+ public Int16 Day;
+ public Int16 Hour;
+ public Int16 Minute;
+ public Int16 Second;
+ public Int16 Milliseconds;
}
[StructLayout(LayoutKind.Sequential)]
private struct CryptoApiBlob
{
- public int DataLength;
+ public Int32 DataLength;
public IntPtr Data;
- public CryptoApiBlob(int dataLength, IntPtr data)
+ public CryptoApiBlob(Int32 dataLength, IntPtr data)
{
DataLength = dataLength;
Data = data;
@@ -254,65 +254,65 @@ namespace NewLife.Security
public String ContainerName;
[MarshalAs(UnmanagedType.LPWStr)]
public String ProviderName;
- public int ProviderType;
- public int Flags;
- public int ProviderParameterCount;
+ public Int32 ProviderType;
+ public Int32 Flags;
+ public Int32 ProviderParameterCount;
public IntPtr ProviderParameters; // PCRYPT_KEY_PROV_PARAM
- public int KeySpec;
+ public Int32 KeySpec;
}
private static class NativeMethods
{
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool FileTimeToSystemTime(
- [In] ref long fileTime,
+ public static extern Boolean FileTimeToSystemTime(
+ [In] ref Int64 fileTime,
out SystemTime systemTime);
[DllImport("AdvApi32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CryptAcquireContextW(
+ public static extern Boolean CryptAcquireContextW(
out IntPtr providerContext,
[MarshalAs(UnmanagedType.LPWStr)] String container,
[MarshalAs(UnmanagedType.LPWStr)] String provider,
- int providerType,
- int flags);
+ Int32 providerType,
+ Int32 flags);
[DllImport("AdvApi32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CryptReleaseContext(
+ public static extern Boolean CryptReleaseContext(
IntPtr providerContext,
- int flags);
+ Int32 flags);
[DllImport("AdvApi32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CryptGenKey(
+ public static extern Boolean CryptGenKey(
IntPtr providerContext,
- int algorithmId,
- int flags,
+ Int32 algorithmId,
+ Int32 flags,
out IntPtr cryptKeyHandle);
[DllImport("AdvApi32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CryptDestroyKey(
+ public static extern Boolean CryptDestroyKey(
IntPtr cryptKeyHandle);
[DllImport("Crypt32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CertStrToNameW(
- int certificateEncodingType,
+ public static extern Boolean CertStrToNameW(
+ Int32 certificateEncodingType,
IntPtr x500,
- int strType,
+ Int32 strType,
IntPtr reserved,
[MarshalAs(UnmanagedType.LPArray)] [Out] Byte[] encoded,
- ref int encodedLength,
+ ref Int32 encodedLength,
out IntPtr errorString);
[DllImport("Crypt32.dll", SetLastError = true, ExactSpelling = true)]
public static extern IntPtr CertCreateSelfSignCertificate(
IntPtr providerHandle,
[In] ref CryptoApiBlob subjectIssuerBlob,
- int flags,
+ Int32 flags,
[In] ref CryptKeyProviderInformation keyProviderInformation,
IntPtr signatureAlgorithm,
[In] ref SystemTime startTime,
@@ -321,47 +321,47 @@ namespace NewLife.Security
[DllImport("Crypt32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CertFreeCertificateContext(
+ public static extern Boolean CertFreeCertificateContext(
IntPtr certificateContext);
[DllImport("Crypt32.dll", SetLastError = true, ExactSpelling = true)]
public static extern IntPtr CertOpenStore(
[MarshalAs(UnmanagedType.LPStr)] String storeProvider,
- int messageAndCertificateEncodingType,
+ Int32 messageAndCertificateEncodingType,
IntPtr cryptProvHandle,
- int flags,
+ Int32 flags,
IntPtr parameters);
[DllImport("Crypt32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CertCloseStore(
+ public static extern Boolean CertCloseStore(
IntPtr certificateStoreHandle,
- int flags);
+ Int32 flags);
[DllImport("Crypt32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CertAddCertificateContextToStore(
+ public static extern Boolean CertAddCertificateContextToStore(
IntPtr certificateStoreHandle,
IntPtr certificateContext,
- int addDisposition,
+ Int32 addDisposition,
out IntPtr storeContextPtr);
[DllImport("Crypt32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CertSetCertificateContextProperty(
+ public static extern Boolean CertSetCertificateContextProperty(
IntPtr certificateContext,
- int propertyId,
- int flags,
+ Int32 propertyId,
+ Int32 flags,
[In] ref CryptKeyProviderInformation data);
[DllImport("Crypt32.dll", SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool PFXExportCertStoreEx(
+ public static extern Boolean PFXExportCertStoreEx(
IntPtr certificateStoreHandle,
ref CryptoApiBlob pfxBlob,
IntPtr password,
IntPtr reserved,
- int flags);
+ Int32 flags);
}
}
}
\ No newline at end of file
diff --git a/NewLife.Core/Security/Crc16.cs b/NewLife.Core/Security/Crc16.cs
index e203dbc..4126702 100644
--- a/NewLife.Core/Security/Crc16.cs
+++ b/NewLife.Core/Security/Crc16.cs
@@ -90,7 +90,7 @@ namespace NewLife.Security
/// <param name = "count">
/// The number of data bytes to update the CRC with.
/// </param>
- public Crc16 Update(byte[] buffer, int offset = 0, int count = -1)
+ public Crc16 Update(Byte[] buffer, Int32 offset = 0, Int32 count = -1)
{
if (buffer == null) throw new ArgumentNullException("buffer");
//if (count < 0) throw new ArgumentOutOfRangeException("count", "Count不能小于0!");
@@ -103,7 +103,7 @@ namespace NewLife.Security
//}
//crc16 = (UInt16)((crc16 << 8) ^ CrcTable[((crc16 >> 8) ^ pcrc[i])]);
crc ^= crc;
- for (int i = 0; i < count; i++)
+ for (var i = 0; i < count; i++)
{
crc = (UInt16)((crc << 8) ^ CrcTable[(crc >> 8 ^ buffer[offset + i]) & 0xFF]);
}
@@ -129,7 +129,7 @@ namespace NewLife.Security
//crc = CrcTable[(crc ^ b) & 0xFF] ^ (crc >> 8);
//crc = (UInt16)((crc << 8) ^ CrcTable[(crc ^ b) & 0xFF]);
crc ^= (Byte)b;
- for (int i = 0; i < 8; i++)
+ for (var i = 0; i < 8; i++)
{
if ((crc & 0x0001) != 0)
crc = (UInt16)((crc >> 1) ^ 0xa001);
diff --git a/NewLife.Core/Security/Crc32.cs b/NewLife.Core/Security/Crc32.cs
index 6b363a9..cdc2f74 100644
--- a/NewLife.Core/Security/Crc32.cs
+++ b/NewLife.Core/Security/Crc32.cs
@@ -32,20 +32,20 @@ namespace NewLife.Security
/// </remarks>
public sealed class Crc32 //: HashAlgorithm
{
- const uint CrcSeed = 0xFFFFFFFF;
+ const UInt32 CrcSeed = 0xFFFFFFFF;
#region 数据表
/// <summary>校验表</summary>
- public readonly static uint[] Table;
+ public readonly static UInt32[] Table;
static Crc32()
{
- Table = new uint[256];
- const uint kPoly = 0xEDB88320;
- for (uint i = 0; i < 256; i++)
+ Table = new UInt32[256];
+ const UInt32 kPoly = 0xEDB88320;
+ for (UInt32 i = 0; i < 256; i++)
{
- uint r = i;
- for (int j = 0; j < 8; j++)
+ var r = i;
+ for (var j = 0; j < 8; j++)
if ((r & 1) != 0)
r = (r >> 1) ^ kPoly;
else
@@ -61,7 +61,7 @@ namespace NewLife.Security
//}
/// <summary>校验值</summary>
- uint crc = CrcSeed;
+ UInt32 crc = CrcSeed;
/// <summary>校验值</summary>
public UInt32 Value { get { return crc ^ CrcSeed; } set { crc = value ^ CrcSeed; } }
@@ -72,7 +72,7 @@ namespace NewLife.Security
/// <param name = "value">
/// the byte is taken as the lower 8 bits of value
/// </param>
- public Crc32 Update(int value)
+ public Crc32 Update(Int32 value)
{
crc = Table[(crc ^ value) & 0xFF] ^ (crc >> 8);
@@ -89,7 +89,7 @@ namespace NewLife.Security
/// <param name = "count">
/// The number of data bytes to update the CRC with.
/// </param>
- public Crc32 Update(byte[] buffer, int offset = 0, int count = -1)
+ public Crc32 Update(Byte[] buffer, Int32 offset = 0, Int32 count = -1)
{
if (buffer == null) throw new ArgumentNullException("buffer");
//if (count < 0) throw new ArgumentOutOfRangeException("count", "Count不能小于0!");
diff --git a/NewLife.Core/Security/DSAHelper.cs b/NewLife.Core/Security/DSAHelper.cs
index cd439ac..a5a435b 100644
--- a/NewLife.Core/Security/DSAHelper.cs
+++ b/NewLife.Core/Security/DSAHelper.cs
@@ -10,7 +10,7 @@ namespace NewLife.Security
/// <summary>产生非对称密钥对</summary>
/// <param name="keySize">密钥长度,默认1024位强密钥</param>
/// <returns></returns>
- public static String[] GenerateKey(int keySize = 1024)
+ public static String[] GenerateKey(Int32 keySize = 1024)
{
var dsa = new DSACryptoServiceProvider(keySize);
diff --git a/NewLife.Core/Security/Rand.cs b/NewLife.Core/Security/Rand.cs
index 8bde020..8ecda7a 100644
--- a/NewLife.Core/Security/Rand.cs
+++ b/NewLife.Core/Security/Rand.cs
@@ -83,7 +83,7 @@ namespace NewLife.Security
public static String NextString(Int32 length)
{
var sb = new StringBuilder();
- for (int i = 0; i < length; i++)
+ for (var i = 0; i < length; i++)
{
var ch = (Char)Next((Int32)' ', 0x7F);
sb.Append(ch);
diff --git a/NewLife.Core/Security/RSAHelper.cs b/NewLife.Core/Security/RSAHelper.cs
index ec7d96e..7fd9c5e 100644
--- a/NewLife.Core/Security/RSAHelper.cs
+++ b/NewLife.Core/Security/RSAHelper.cs
@@ -18,7 +18,7 @@ namespace NewLife.Security
/// </remarks>
/// <param name="keySize">密钥长度,默认1024位强密钥</param>
/// <returns></returns>
- public static String[] GenerateKey(int keySize = 2048)
+ public static String[] GenerateKey(Int32 keySize = 2048)
{
var rsa = new RSACryptoServiceProvider(keySize);
diff --git a/NewLife.Core/Serialization/Binary/Binary.cs b/NewLife.Core/Serialization/Binary/Binary.cs
index 74778c0..53acd09 100644
--- a/NewLife.Core/Serialization/Binary/Binary.cs
+++ b/NewLife.Core/Serialization/Binary/Binary.cs
@@ -187,7 +187,7 @@ namespace NewLife.Serialization
var arr = new Byte[16];
var k = 0;
- Int32 count = 1;
+ var count = 1;
var num = (UInt32)value;
while (num >= 0x80)
{
@@ -196,7 +196,7 @@ namespace NewLife.Serialization
count++;
}
- arr[k++] = (byte)num;
+ arr[k++] = (Byte)num;
Write(arr, 0, k);
@@ -351,7 +351,7 @@ namespace NewLife.Serialization
public Int32 ReadEncodedInt32()
{
Byte b;
- Int32 rs = 0;
+ var rs = 0;
Byte n = 0;
while (true)
{
diff --git a/NewLife.Core/Serialization/Binary/BinaryComposite.cs b/NewLife.Core/Serialization/Binary/BinaryComposite.cs
index 6b466f1..bcabb32 100644
--- a/NewLife.Core/Serialization/Binary/BinaryComposite.cs
+++ b/NewLife.Core/Serialization/Binary/BinaryComposite.cs
@@ -99,7 +99,7 @@ namespace NewLife.Serialization
// 找到对象索引,并写入
var hs = Host.Hosts.ToArray();
- for (int i = 0; i < hs.Length; i++)
+ for (var i = 0; i < hs.Length; i++)
{
if (value == hs[i])
{
@@ -175,7 +175,7 @@ namespace NewLife.Serialization
var ac = value as IMemberAccessor;
// 获取成员
- for (int i = 0; i < ms.Count; i++)
+ for (var i = 0; i < ms.Count; i++)
{
var member = ms[i];
//if (IgnoreMembers != null && IgnoreMembers.Contains(member.Name)) continue;
diff --git a/NewLife.Core/Serialization/Binary/BinaryDictionary.cs b/NewLife.Core/Serialization/Binary/BinaryDictionary.cs
index 839e8c5..783229a 100644
--- a/NewLife.Core/Serialization/Binary/BinaryDictionary.cs
+++ b/NewLife.Core/Serialization/Binary/BinaryDictionary.cs
@@ -71,7 +71,7 @@ namespace NewLife.Serialization
var dic = value as IDictionary;
- for (int i = 0; i < count; i++)
+ for (var i = 0; i < count; i++)
{
Object key = null;
Object val = null;
diff --git a/NewLife.Core/Serialization/Binary/BinaryGeneral.cs b/NewLife.Core/Serialization/Binary/BinaryGeneral.cs
index e2550b7..b027dee 100644
--- a/NewLife.Core/Serialization/Binary/BinaryGeneral.cs
+++ b/NewLife.Core/Serialization/Binary/BinaryGeneral.cs
@@ -219,7 +219,7 @@ namespace NewLife.Serialization
#region 有符号整数
/// <summary>将 2 字节有符号整数写入当前流,并将流的位置提升 2 个字节。</summary>
/// <param name="value">要写入的 2 字节有符号整数。</param>
- public virtual void Write(short value)
+ public virtual void Write(Int16 value)
{
if (Host.EncodeInt)
WriteEncoded(value);
@@ -239,7 +239,7 @@ namespace NewLife.Serialization
/// <summary>将 8 字节有符号整数写入当前流,并将流的位置提升 8 个字节。</summary>
/// <param name="value">要写入的 8 字节有符号整数。</param>
- public virtual void Write(long value)
+ public virtual void Write(Int64 value)
{
if (Host.EncodeInt)
WriteEncoded(value);
@@ -264,34 +264,34 @@ namespace NewLife.Serialization
/// <summary>将 2 字节无符号整数写入当前流,并将流的位置提升 2 个字节。</summary>
/// <param name="value">要写入的 2 字节无符号整数。</param>
//[CLSCompliant(false)]
- public virtual void Write(ushort value) { Write((Int16)value); }
+ public virtual void Write(UInt16 value) { Write((Int16)value); }
/// <summary>将 4 字节无符号整数写入当前流,并将流的位置提升 4 个字节。</summary>
/// <param name="value">要写入的 4 字节无符号整数。</param>
//[CLSCompliant(false)]
- public virtual void Write(uint value) { Write((Int32)value); }
+ public virtual void Write(UInt32 value) { Write((Int32)value); }
/// <summary>将 8 字节无符号整数写入当前流,并将流的位置提升 8 个字节。</summary>
/// <param name="value">要写入的 8 字节无符号整数。</param>
//[CLSCompliant(false)]
- public virtual void Write(ulong value) { Write((Int64)value); }
+ public virtual void Write(UInt64 value) { Write((Int64)value); }
#endregion
#region 浮点数
/// <summary>将 4 字节浮点值写入当前流,并将流的位置提升 4 个字节。</summary>
/// <param name="value">要写入的 4 字节浮点值。</param>
- public virtual void Write(float value) { Write(BitConverter.GetBytes(value), -1); }
+ public virtual void Write(Single value) { Write(BitConverter.GetBytes(value), -1); }
/// <summary>将 8 字节浮点值写入当前流,并将流的位置提升 8 个字节。</summary>
/// <param name="value">要写入的 8 字节浮点值。</param>
- public virtual void Write(double value) { Write(BitConverter.GetBytes(value), -1); }
+ public virtual void Write(Double value) { Write(BitConverter.GetBytes(value), -1); }
/// <summary>将一个十进制值写入当前流,并将流位置提升十六个字节。</summary>
/// <param name="value">要写入的十进制值。</param>
protected virtual void Write(Decimal value)
{
- Int32[] data = Decimal.GetBits(value);
- for (Int32 i = 0; i < data.Length; i++)
+ var data = Decimal.GetBits(value);
+ for (var i = 0; i < data.Length; i++)
{
Write(data[i]);
}
@@ -401,7 +401,7 @@ namespace NewLife.Serialization
/// <summary>从当前流中读取 2 字节有符号整数,并使流的当前位置提升 2 个字节。</summary>
/// <returns></returns>
- public virtual short ReadInt16()
+ public virtual Int16 ReadInt16()
{
if (Host.EncodeInt)
return ReadEncodedInt16();
@@ -421,7 +421,7 @@ namespace NewLife.Serialization
/// <summary>从当前流中读取 8 字节有符号整数,并使流的当前位置向前移动 8 个字节。</summary>
/// <returns></returns>
- public virtual long ReadInt64()
+ public virtual Int64 ReadInt64()
{
if (Host.EncodeInt)
return ReadEncodedInt64();
@@ -434,27 +434,27 @@ namespace NewLife.Serialization
/// <summary>使用 Little-Endian 编码从当前流中读取 2 字节无符号整数,并将流的位置提升 2 个字节。</summary>
/// <returns></returns>
//[CLSCompliant(false)]
- public virtual ushort ReadUInt16() { return (UInt16)ReadInt16(); }
+ public virtual UInt16 ReadUInt16() { return (UInt16)ReadInt16(); }
/// <summary>从当前流中读取 4 字节无符号整数并使流的当前位置提升 4 个字节。</summary>
/// <returns></returns>
//[CLSCompliant(false)]
- public virtual uint ReadUInt32() { return (UInt32)ReadInt32(); }
+ public virtual UInt32 ReadUInt32() { return (UInt32)ReadInt32(); }
/// <summary>从当前流中读取 8 字节无符号整数并使流的当前位置提升 8 个字节。</summary>
/// <returns></returns>
//[CLSCompliant(false)]
- public virtual ulong ReadUInt64() { return (UInt64)ReadInt64(); }
+ public virtual UInt64 ReadUInt64() { return (UInt64)ReadInt64(); }
#endregion
#region 浮点数
/// <summary>从当前流中读取 4 字节浮点值,并使流的当前位置提升 4 个字节。</summary>
/// <returns></returns>
- public virtual float ReadSingle() { return BitConverter.ToSingle(ReadBytes(4), 0); }
+ public virtual Single ReadSingle() { return BitConverter.ToSingle(ReadBytes(4), 0); }
/// <summary>从当前流中读取 8 字节浮点值,并使流的当前位置提升 8 个字节。</summary>
/// <returns></returns>
- public virtual double ReadDouble() { return BitConverter.ToDouble(ReadBytes(8), 0); }
+ public virtual Double ReadDouble() { return BitConverter.ToDouble(ReadBytes(8), 0); }
#endregion
#region 字符串
@@ -464,10 +464,10 @@ namespace NewLife.Serialization
/// <summary>从当前流中读取一个字符串。字符串有长度前缀,一次 7 位地被编码为整数。</summary>
/// <returns></returns>
- public virtual string ReadString()
+ public virtual String ReadString()
{
// 先读长度
- Int32 n = Host.ReadSize();
+ var n = Host.ReadSize();
if (n < 0) return null;
if (n == 0) return String.Empty;
@@ -482,8 +482,8 @@ namespace NewLife.Serialization
/// <returns></returns>
public virtual Decimal ReadDecimal()
{
- Int32[] data = new Int32[4];
- for (Int32 i = 0; i < data.Length; i++)
+ var data = new Int32[4];
+ for (var i = 0; i < data.Length; i++)
{
data[i] = ReadInt32();
}
@@ -533,7 +533,7 @@ namespace NewLife.Serialization
public Int32 ReadEncodedInt32()
{
Byte b;
- Int32 rs = 0;
+ var rs = 0;
Byte n = 0;
while (true)
{
@@ -581,8 +581,8 @@ namespace NewLife.Serialization
{
var list = new List<Byte>();
- Int32 count = 1;
- UInt16 num = (UInt16)value;
+ var count = 1;
+ var num = (UInt16)value;
while (num >= 0x80)
{
list.Add((Byte)(num | 0x80));
@@ -607,8 +607,8 @@ namespace NewLife.Serialization
{
var list = new List<Byte>();
- Int32 count = 1;
- UInt32 num = (UInt32)value;
+ var count = 1;
+ var num = (UInt32)value;
while (num >= 0x80)
{
list.Add((Byte)(num | 0x80));
@@ -633,8 +633,8 @@ namespace NewLife.Serialization
{
var list = new List<Byte>();
- Int32 count = 1;
- UInt64 num = (UInt64)value;
+ var count = 1;
+ var num = (UInt64)value;
while (num >= 0x80)
{
list.Add((Byte)(num | 0x80));
diff --git a/NewLife.Core/Serialization/Binary/BinaryList.cs b/NewLife.Core/Serialization/Binary/BinaryList.cs
index 323423f..a8a3e15 100644
--- a/NewLife.Core/Serialization/Binary/BinaryList.cs
+++ b/NewLife.Core/Serialization/Binary/BinaryList.cs
@@ -19,7 +19,7 @@ namespace NewLife.Serialization
/// <param name="value"></param>
/// <param name="type"></param>
/// <returns></returns>
- public override bool Write(object value, Type type)
+ public override Boolean Write(Object value, Type type)
{
if (!typeof(IList).IsAssignableFrom(type)) return false;
@@ -46,7 +46,7 @@ namespace NewLife.Serialization
/// <param name="type"></param>
/// <param name="value"></param>
/// <returns></returns>
- public override bool TryRead(Type type, ref object value)
+ public override Boolean TryRead(Type type, ref Object value)
{
if (!typeof(IList).IsAssignableFrom(type)) return false;
@@ -69,7 +69,7 @@ namespace NewLife.Serialization
var list = value as IList;
// 如果是数组,则需要先加起来,再
//if (value is Array) list = typeof(IList<>).MakeGenericType(value.GetType().GetElementTypeEx()).CreateInstance() as IList;
- for (int i = 0; i < count; i++)
+ for (var i = 0; i < count; i++)
{
Object obj = null;
if (!Host.TryRead(elmType, ref obj)) return false;
diff --git a/NewLife.Core/Serialization/Binary/BinaryPair.cs b/NewLife.Core/Serialization/Binary/BinaryPair.cs
index 0f38bea..30dd49a 100644
--- a/NewLife.Core/Serialization/Binary/BinaryPair.cs
+++ b/NewLife.Core/Serialization/Binary/BinaryPair.cs
@@ -245,7 +245,7 @@ namespace NewLife.Serialization
if (list == null || list.Count == 0) return true;
// 循环写入数据
- for (int i = 0; i < list.Count; i++)
+ for (var i = 0; i < list.Count; i++)
{
WritePair(i + "", list[i]);
}
@@ -263,7 +263,7 @@ namespace NewLife.Serialization
var list = typeof(List<>).MakeGenericType(elmType).CreateInstance() as IList;
var ds = ReadPair();
- for (int i = 0; i < ds.Count; i++)
+ for (var i = 0; i < ds.Count; i++)
{
Object v = null;
if (TryReadPair(ds, i + "", elmType, ref v)) list.Add(v);
@@ -340,7 +340,7 @@ namespace NewLife.Serialization
Host.Hosts.Push(value);
// 获取成员
- for (int i = 0; i < ms.Count; i++)
+ for (var i = 0; i < ms.Count; i++)
{
var member = ms[i];
diff --git a/NewLife.Core/Serialization/Binary/BitSizeAttribute.cs b/NewLife.Core/Serialization/Binary/BitSizeAttribute.cs
index 93ec528..717645d 100644
--- a/NewLife.Core/Serialization/Binary/BitSizeAttribute.cs
+++ b/NewLife.Core/Serialization/Binary/BitSizeAttribute.cs
@@ -58,7 +58,7 @@ namespace NewLife.Serialization
Int32 GetMask()
{
var v = 0;
- for (int i = 0; i < Size; i++)
+ for (var i = 0; i < Size; i++)
{
v <<= 1;
v++;
diff --git a/NewLife.Core/Serialization/Binary/FieldSizeAttribute.cs b/NewLife.Core/Serialization/Binary/FieldSizeAttribute.cs
index 268635f..4c5896d 100644
--- a/NewLife.Core/Serialization/Binary/FieldSizeAttribute.cs
+++ b/NewLife.Core/Serialization/Binary/FieldSizeAttribute.cs
@@ -50,10 +50,10 @@ namespace NewLife.Serialization
// 考虑ReferenceName可能是圆点分隔的多重结构
MemberInfo mi = null;
- Type type = member.DeclaringType;
+ var type = member.DeclaringType;
value = target;
var ss = ReferenceName.Split(".");
- for (int i = 0; i < ss.Length; i++)
+ for (var i = 0; i < ss.Length; i++)
{
var pi = type.GetPropertyEx(ss[i]);
if (pi != null)
@@ -100,7 +100,7 @@ namespace NewLife.Serialization
if (value == null) return;
// 尝试计算大小
- Int32 size = 0;
+ var size = 0;
if (value is String)
{
if (encoding == null) encoding = Encoding.UTF8;
diff --git a/NewLife.Core/Serialization/Json/IJsonHost.cs b/NewLife.Core/Serialization/Json/IJsonHost.cs
index b73ce10..abc50d3 100644
--- a/NewLife.Core/Serialization/Json/IJsonHost.cs
+++ b/NewLife.Core/Serialization/Json/IJsonHost.cs
@@ -74,11 +74,11 @@ namespace NewLife.Serialization
{
var sb = new StringBuilder();
- bool escaping = false;
- bool inQuotes = false;
- int indentation = 0;
+ var escaping = false;
+ var inQuotes = false;
+ var indentation = 0;
- foreach (char ch in json)
+ foreach (var ch in json)
{
if (escaping)
{
@@ -153,7 +153,7 @@ namespace NewLife.Serialization
// }
//}
- private bool CheckScriptIgnoreAttribute(MemberInfo memberInfo)
+ private Boolean CheckScriptIgnoreAttribute(MemberInfo memberInfo)
{
#if !__MOBILE__
if (memberInfo.IsDefined(typeof(ScriptIgnoreAttribute), true)) return true;
@@ -320,12 +320,12 @@ class MyContractResolver : Newtonsoft.Json.Serialization.DefaultContractResolver
#region IJsonHost 成员
- public string Write(object value, bool indented = false)
+ public String Write(Object value, Boolean indented = false)
{
return new JsonWriter().ToJson(value, indented);
}
- public object Read(string json, Type type)
+ public Object Read(String json, Type type)
{
return new JsonReader().ToObject(json, type);
}
diff --git a/NewLife.Core/Serialization/Json/JsonArray.cs b/NewLife.Core/Serialization/Json/JsonArray.cs
index 25b6c4b..0102ae5 100644
--- a/NewLife.Core/Serialization/Json/JsonArray.cs
+++ b/NewLife.Core/Serialization/Json/JsonArray.cs
@@ -66,7 +66,7 @@ namespace NewLife.Serialization
/// <param name="value"></param>
/// <param name="type"></param>
/// <returns></returns>
- public override bool Write(object value, Type type)
+ public override Boolean Write(Object value, Type type)
{
if (!typeof(IList).IsAssignableFrom(type)) return false;
@@ -90,7 +90,7 @@ namespace NewLife.Serialization
/// <param name="type"></param>
/// <param name="value"></param>
/// <returns></returns>
- public override bool TryRead(Type type, ref object value)
+ public override Boolean TryRead(Type type, ref Object value)
{
if (!typeof(IList).IsAssignableFrom(type)) return false;
diff --git a/NewLife.Core/Serialization/Json/JsonComposite.cs b/NewLife.Core/Serialization/Json/JsonComposite.cs
index 9c99a86..e7f4f42 100644
--- a/NewLife.Core/Serialization/Json/JsonComposite.cs
+++ b/NewLife.Core/Serialization/Json/JsonComposite.cs
@@ -136,7 +136,7 @@ namespace NewLife.Serialization
var ac = value as IMemberAccessor;
// 获取成员
- for (int i = 0; i < ms.Count; i++)
+ for (var i = 0; i < ms.Count; i++)
{
var member = ms[i];
if (IgnoreMembers != null && IgnoreMembers.Contains(member.Name)) continue;
diff --git a/NewLife.Core/Serialization/Json/JsonParser.cs b/NewLife.Core/Serialization/Json/JsonParser.cs
index 845a00d..bf457e2 100644
--- a/NewLife.Core/Serialization/Json/JsonParser.cs
+++ b/NewLife.Core/Serialization/Json/JsonParser.cs
@@ -170,7 +170,7 @@ namespace NewLife.Serialization
_builder.Length = 0;
- Int32 runIndex = -1;
+ var runIndex = -1;
while (index < _json.Length)
{
@@ -239,12 +239,12 @@ namespace NewLife.Serialization
case 'u':
{
- Int32 remainingLength = _json.Length - index;
+ var remainingLength = _json.Length - index;
if (remainingLength < 4) break;
// ����32λʮ����������
- uint codePoint = ParseUnicode(_json[index], _json[index + 1], _json[index + 2], _json[index + 3]);
- _builder.Append((char)codePoint);
+ var codePoint = ParseUnicode(_json[index], _json[index + 1], _json[index + 2], _json[index + 3]);
+ _builder.Append((Char)codePoint);
index += 4;
}
@@ -255,24 +255,24 @@ namespace NewLife.Serialization
throw new Exception("�ѵ����ַ�����β");
}
- private uint ParseSingleChar(char c1, uint multipliyer)
+ private UInt32 ParseSingleChar(Char c1, UInt32 multipliyer)
{
- uint p1 = 0;
+ UInt32 p1 = 0;
if (c1 >= '0' && c1 <= '9')
- p1 = (uint)(c1 - '0') * multipliyer;
+ p1 = (UInt32)(c1 - '0') * multipliyer;
else if (c1 >= 'A' && c1 <= 'F')
- p1 = (uint)((c1 - 'A') + 10) * multipliyer;
+ p1 = (UInt32)((c1 - 'A') + 10) * multipliyer;
else if (c1 >= 'a' && c1 <= 'f')
- p1 = (uint)((c1 - 'a') + 10) * multipliyer;
+ p1 = (UInt32)((c1 - 'a') + 10) * multipliyer;
return p1;
}
- private uint ParseUnicode(char c1, char c2, char c3, char c4)
+ private UInt32 ParseUnicode(Char c1, Char c2, Char c3, Char c4)
{
- uint p1 = ParseSingleChar(c1, 0x1000);
- uint p2 = ParseSingleChar(c2, 0x100);
- uint p3 = ParseSingleChar(c3, 0x10);
- uint p4 = ParseSingleChar(c4, 1);
+ var p1 = ParseSingleChar(c1, 0x1000);
+ var p2 = ParseSingleChar(c2, 0x100);
+ var p3 = ParseSingleChar(c3, 0x10);
+ var p4 = ParseSingleChar(c4, 1);
return p1 + p2 + p3 + p4;
}
@@ -280,8 +280,8 @@ namespace NewLife.Serialization
private Int64 CreateLong(String s)
{
Int64 num = 0;
- bool neg = false;
- foreach (char cc in s)
+ var neg = false;
+ foreach (var cc in s)
{
if (cc == '-')
neg = true;
@@ -303,7 +303,7 @@ namespace NewLife.Serialization
// ��Ҫ�ع�1��λ�ã���Ϊ��һ������Ҳ��Toekn�����ܱ�������
var startIndex = index - 1;
- bool dec = false;
+ var dec = false;
do
{
if (index == _json.Length)
@@ -451,10 +451,10 @@ namespace NewLife.Serialization
static Int64 CreateLong(out Int64 num, String s, Int32 index, Int32 count)
{
num = 0;
- bool neg = false;
- for (Int32 x = 0; x < count; x++, index++)
+ var neg = false;
+ for (var x = 0; x < count; x++, index++)
{
- char cc = s[index];
+ var cc = s[index];
if (cc == '-')
neg = true;
diff --git a/NewLife.Core/Serialization/Json/JsonReader.cs b/NewLife.Core/Serialization/Json/JsonReader.cs
index c248a43..c94bb9f 100644
--- a/NewLife.Core/Serialization/Json/JsonReader.cs
+++ b/NewLife.Core/Serialization/Json/JsonReader.cs
@@ -62,7 +62,7 @@ namespace NewLife.Serialization
//return (jobj as IList<Object>).Select(e => e.ChangeType(elmType)).ToArray();
var src = jobj as IList<Object>;
var arr = Array.CreateInstance(elmType, src.Count);
- for (int i = 0; i < src.Count; i++)
+ for (var i = 0; i < src.Count; i++)
{
arr.SetValue(src[i].ChangeType(elmType), i);
}
@@ -175,7 +175,7 @@ namespace NewLife.Serialization
if (obj == null) obj = type.CreateInstance();
- Int32 circount = 0;
+ var circount = 0;
if (_circobj.TryGetValue(obj, out circount) == false)
{
circount = _circobj.Count + 1;
@@ -260,11 +260,11 @@ namespace NewLife.Serialization
private Int32 CreateInteger(String str, Int32 index, Int32 count)
{
- Int32 num = 0;
- bool neg = false;
- for (Int32 x = 0; x < count; x++, index++)
+ var num = 0;
+ var neg = false;
+ for (var x = 0; x < count; x++, index++)
{
- char cc = str[index];
+ var cc = str[index];
if (cc == '-')
neg = true;
@@ -297,7 +297,7 @@ namespace NewLife.Serialization
var str = (String)value;
- bool utc = false;
+ var utc = false;
Int32 year;
Int32 month;
@@ -305,7 +305,7 @@ namespace NewLife.Serialization
Int32 hour;
Int32 min;
Int32 sec;
- Int32 ms = 0;
+ var ms = 0;
year = CreateInteger(str, 0, 4);
month = CreateInteger(str, 5, 2);
@@ -329,9 +329,9 @@ namespace NewLife.Serialization
if (elmType == null) elmType = typeof(Object);
var arr = Array.CreateInstance(elmType, list.Count);
- for (Int32 i = 0; i < list.Count; i++)
+ for (var i = 0; i < list.Count; i++)
{
- Object ob = list[i];
+ var ob = list[i];
if (ob == null)
{
continue;
@@ -350,7 +350,7 @@ namespace NewLife.Serialization
private Object CreateGenericList(IList<Object> list, Type type, Type elmType)
{
var rs = type.CreateInstance() as IList;
- foreach (Object ob in list)
+ foreach (var ob in list)
{
if (ob is IDictionary)
rs.Add(Parse((IDictionary<String, Object>)ob, elmType, null));
@@ -419,8 +419,8 @@ namespace NewLife.Serialization
foreach (IDictionary<String, Object> values in list)
{
- Object key = values["k"];
- Object val = values["v"];
+ var key = values["k"];
+ var val = values["v"];
if (key is IDictionary<String, Object>)
key = Parse((IDictionary<String, Object>)key, tkey, null);
diff --git a/NewLife.Core/Serialization/Json/JsonWriter.cs b/NewLife.Core/Serialization/Json/JsonWriter.cs
index 4198f62..6390cb6 100644
--- a/NewLife.Core/Serialization/Json/JsonWriter.cs
+++ b/NewLife.Core/Serialization/Json/JsonWriter.cs
@@ -58,11 +58,11 @@ namespace NewLife.Serialization
_Builder.Append((obj + "").ToLower());
else if (
- obj is Int32 || obj is Int64 || obj is double ||
- obj is decimal || obj is float ||
- obj is Byte || obj is short ||
- obj is sbyte || obj is ushort ||
- obj is uint || obj is ulong
+ obj is Int32 || obj is Int64 || obj is Double ||
+ obj is Decimal || obj is Single ||
+ obj is Byte || obj is Int16 ||
+ obj is SByte || obj is UInt16 ||
+ obj is UInt32 || obj is UInt64
)
_Builder.Append(((IConvertible)obj).ToString(NumberFormatInfo.InvariantInfo));
@@ -170,7 +170,7 @@ namespace NewLife.Serialization
private Dictionary<Object, Int32> _cirobj = new Dictionary<Object, Int32>();
private void WriteObject(Object obj)
{
- Int32 i = 0;
+ var i = 0;
if (!_cirobj.TryGetValue(obj, out i)) _cirobj.Add(obj, _cirobj.Count + 1);
_Builder.Append('{');
@@ -302,8 +302,8 @@ namespace NewLife.Serialization
{
_Builder.Append('\"');
- Int32 idx = -1;
- Int32 len = str.Length;
+ var idx = -1;
+ var len = str.Length;
for (var index = 0; index < len; ++index)
{
var c = str[index];
diff --git a/NewLife.Core/Serialization/Xml/XmlComposite.cs b/NewLife.Core/Serialization/Xml/XmlComposite.cs
index 331a8ab..acc6cd6 100644
--- a/NewLife.Core/Serialization/Xml/XmlComposite.cs
+++ b/NewLife.Core/Serialization/Xml/XmlComposite.cs
@@ -59,7 +59,7 @@ namespace NewLife.Serialization
/// <param name="type"></param>
/// <param name="value"></param>
/// <returns></returns>
- public override bool TryRead(Type type, ref object value)
+ public override Boolean TryRead(Type type, ref Object value)
{
if (type == null)
{
diff --git a/NewLife.Core/Serialization/Xml/XmlGeneral.cs b/NewLife.Core/Serialization/Xml/XmlGeneral.cs
index bea7cb2..9e7a316 100644
--- a/NewLife.Core/Serialization/Xml/XmlGeneral.cs
+++ b/NewLife.Core/Serialization/Xml/XmlGeneral.cs
@@ -105,7 +105,7 @@ namespace NewLife.Serialization
/// <param name="type"></param>
/// <param name="value"></param>
/// <returns></returns>
- public override bool TryRead(Type type, ref object value)
+ public override Boolean TryRead(Type type, ref Object value)
{
if (type == null)
{
diff --git a/NewLife.Core/Threading/TaskHelper.cs b/NewLife.Core/Threading/TaskHelper.cs
index 93cb4fd..d748270 100644
--- a/NewLife.Core/Threading/TaskHelper.cs
+++ b/NewLife.Core/Threading/TaskHelper.cs
@@ -226,7 +226,7 @@ namespace System.Threading.Tasks
return tcs.Task;
}
- private static bool TrySetFromTask<TResult>(this TaskCompletionSource<TResult> tcs, Task source)
+ private static Boolean TrySetFromTask<TResult>(this TaskCompletionSource<TResult> tcs, Task source)
{
if (source.Status == TaskStatus.Canceled) return tcs.TrySetCanceled();
diff --git a/NewLife.Core/Threading/TimerX.cs b/NewLife.Core/Threading/TimerX.cs
index 85ebb97..8be0505 100644
--- a/NewLife.Core/Threading/TimerX.cs
+++ b/NewLife.Core/Threading/TimerX.cs
@@ -135,7 +135,7 @@ namespace NewLife.Threading
#region 辅助
/// <summary>已重载</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (Callback == null) return base.ToString();
diff --git a/NewLife.Core/Web/Link.cs b/NewLife.Core/Web/Link.cs
index 9e00306..c111ed5 100644
--- a/NewLife.Core/Web/Link.cs
+++ b/NewLife.Core/Web/Link.cs
@@ -206,7 +206,7 @@ namespace NewLife.Web
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
//return base.ToString();
//return "{0} {1} {2} {3}".F(Name, RawUrl, Version, Time);
diff --git a/NewLife.Core/Web/Modules/CompressionModule.cs b/NewLife.Core/Web/Modules/CompressionModule.cs
index d3cc4c9..c81971d 100644
--- a/NewLife.Core/Web/Modules/CompressionModule.cs
+++ b/NewLife.Core/Web/Modules/CompressionModule.cs
@@ -26,10 +26,10 @@ namespace NewLife.Web
public String WebCompressFiles { get; set; } = ".aspx,.axd,.js,.css";
#region Compression
- private const string GZIP = "gzip";
- private const string DEFLATE = "deflate";
+ private const String GZIP = "gzip";
+ private const String DEFLATE = "deflate";
- void CompressContent(object sender, EventArgs e)
+ void CompressContent(Object sender, EventArgs e)
{
var app = sender as HttpApplication;
if (!(app.Context.CurrentHandler is System.Web.UI.Page) || app.Request["HTTP_X_MICROSOFTAJAX"] != null) return;
@@ -40,7 +40,7 @@ namespace NewLife.Web
// .net 2.0没有HeadersWritten
//压缩
- String url = app.Request.Url.OriginalString.ToLower();
+ var url = app.Request.Url.OriginalString.ToLower();
if (CanCompress(url))
{
//是否支持压缩协议
@@ -73,14 +73,14 @@ namespace NewLife.Web
}
/// <summary>检查请求头,确认客户端是否支持压缩编码</summary>
- private static bool IsEncodingAccepted(string encoding)
+ private static Boolean IsEncodingAccepted(String encoding)
{
return HttpContext.Current.Request.Headers["Accept-encoding"] != null && HttpContext.Current.Request.Headers["Accept-encoding"].Contains(encoding);
}
/// <summary>添加压缩编码到响应头</summary>
/// <param name="encoding"></param>
- private static void SetEncoding(string encoding)
+ private static void SetEncoding(String encoding)
{
HttpContext.Current.Response.AppendHeader("Content-encoding", encoding);
}
diff --git a/NewLife.Core/Web/Modules/ErrorModule.cs b/NewLife.Core/Web/Modules/ErrorModule.cs
index 7a3e55a..5e3c5d9 100644
--- a/NewLife.Core/Web/Modules/ErrorModule.cs
+++ b/NewLife.Core/Web/Modules/ErrorModule.cs
@@ -56,7 +56,7 @@ namespace NewLife.Web
/// <summary>错误处理方法</summary>
/// <param name="sender"></param>
/// <param name="e"></param>
- protected virtual void OnError(object sender, EventArgs e)
+ protected virtual void OnError(Object sender, EventArgs e)
{
var Server = HttpContext.Current.Server;
var Request = HttpContext.Current.Request;
diff --git a/NewLife.Core/Web/Modules/RunTimeModule.cs b/NewLife.Core/Web/Modules/RunTimeModule.cs
index f47cfac..59b1d78 100644
--- a/NewLife.Core/Web/Modules/RunTimeModule.cs
+++ b/NewLife.Core/Web/Modules/RunTimeModule.cs
@@ -22,7 +22,7 @@ namespace NewLife.Web
context.PostReleaseRequestState += new EventHandler(WriteRunTime);
}
- void OnBeginRequest(object sender, EventArgs e)
+ void OnBeginRequest(Object sender, EventArgs e)
{
OnInit();
}
@@ -51,7 +51,7 @@ namespace NewLife.Web
{
get
{
- Object obj = Context.Items["IsWriteRunTime"];
+ var obj = Context.Items["IsWriteRunTime"];
return (obj is Boolean) ? (Boolean)obj : XTrace.Debug;
}
set { Context.Items["IsWriteRunTime"] = value; }
@@ -62,7 +62,7 @@ namespace NewLife.Web
{
get
{
- Object obj = Context.Items["HasWrite"];
+ var obj = Context.Items["HasWrite"];
return (obj is Boolean) ? (Boolean)obj : false;
}
set { Context.Items["HasWrite"] = value; }
@@ -73,7 +73,7 @@ namespace NewLife.Web
public static String RunTimeFormat { get { return _RunTimeFormat; } set { _RunTimeFormat = value; } }
/// <summary>输出运行时间</summary>
- void WriteRunTime(object sender, EventArgs e)
+ void WriteRunTime(Object sender, EventArgs e)
{
if (!IsWriteRunTime) return;
@@ -86,14 +86,14 @@ namespace NewLife.Web
HasWrite = true;
// 只处理Page页面
- Page page = Context.Handler as Page;
+ var page = Context.Handler as Page;
if (page == null) return;
- String str = Render();
+ var str = Render();
if (String.IsNullOrEmpty(str)) return;
// 尝试找到页面,并在页面上写上信息
- Literal lt = page.FindControl("RunTime") as Literal;
+ var lt = page.FindControl("RunTime") as Literal;
if (lt != null)
lt.Text = str;
else
@@ -104,7 +104,7 @@ namespace NewLife.Web
/// <returns></returns>
protected virtual String Render()
{
- TimeSpan ts = DateTime.Now - HttpContext.Current.Timestamp;
+ var ts = DateTime.Now - HttpContext.Current.Timestamp;
return String.Format(RunTimeFormat, ts.TotalMilliseconds);
}
diff --git a/NewLife.Core/Web/WebDownload.cs b/NewLife.Core/Web/WebDownload.cs
index d35c39e..89d2124 100644
--- a/NewLife.Core/Web/WebDownload.cs
+++ b/NewLife.Core/Web/WebDownload.cs
@@ -31,7 +31,7 @@ namespace NewLife.Web
public Int64 Speed { get { return _Speed; } set { _Speed = value; } }
/// <summary>是否启用浏览器缓存 默认禁用</summary>
- public bool BrowserCache { get; set; }
+ public Boolean BrowserCache { get; set; }
private TimeSpan _browserCacheMaxAge = new TimeSpan(30, 0, 0, 0);
/// <summary>浏览器最大缓存时间 默认30天。通过Cache-Control头控制max-age,直接使用浏览器缓存,不会发出Http请求,对F5无效</summary>
@@ -134,23 +134,23 @@ namespace NewLife.Web
var stream = Stream;
// 速度
- long speed = Speed;
+ var speed = Speed;
// 包大小
- int pack = 1024000;
+ var pack = 1024000;
// 计算睡眠时间
- int sleep = speed > 0 ? (int)Math.Floor(1000 * (double)pack / speed) + 1 : 0;
+ var sleep = speed > 0 ? (Int32)Math.Floor(1000 * (Double)pack / speed) + 1 : 0;
// 输出Accept-Ranges,表示支持断点
Response.AddHeader("Accept-Ranges", "bytes");
Response.Buffer = false;
- long fileLength = stream.Length;
- long startBytes = 0;
+ var fileLength = stream.Length;
+ Int64 startBytes = 0;
// 如果请求里面指定范围,表示需要断点
if (Request.Headers["Range"] != null)
{
Response.StatusCode = 206;
- string[] range = Request.Headers["Range"].Split(new char[] { '=', '-' });
+ var range = Request.Headers["Range"].Split(new Char[] { '=', '-' });
startBytes = Convert.ToInt64(range[1]);
}
// 计算真正的长度
@@ -182,15 +182,15 @@ namespace NewLife.Web
}
//stream.Seek(startBytes, SeekOrigin.Begin);
- int maxCount = (int)Math.Floor((fileLength - startBytes) / (double)pack) + 1;
+ var maxCount = (Int32)Math.Floor((fileLength - startBytes) / (Double)pack) + 1;
// 如果不足一个包,则缩小缓冲区,避免浪费内存
if (pack > stream.Length) pack = (Int32)stream.Length;
var buffer = new Byte[pack];
- for (int i = 0; i < maxCount; i++)
+ for (var i = 0; i < maxCount; i++)
{
if (!Response.IsClientConnected) break;
- Int32 count = stream.Read(buffer, 0, buffer.Length);
+ var count = stream.Read(buffer, 0, buffer.Length);
if (count == pack)
Response.BinaryWrite(buffer);
else
diff --git a/NewLife.Core/Web/WebHelper.cs b/NewLife.Core/Web/WebHelper.cs
index 0fd4947..de82d46 100644
--- a/NewLife.Core/Web/WebHelper.cs
+++ b/NewLife.Core/Web/WebHelper.cs
@@ -80,12 +80,12 @@ namespace NewLife.Web
if (control is TextBox)
{
- TextBox box = control as TextBox;
+ var box = control as TextBox;
if (!String.IsNullOrEmpty(box.Text)) return true;
}
else if (control is ListControl)
{
- ListControl box = control as ListControl;
+ var box = control as ListControl;
if (!String.IsNullOrEmpty(box.Text)) return true;
}
else
@@ -165,7 +165,7 @@ namespace NewLife.Web
//var Response = HttpContext.Current.Response;
//去掉所有列的排序
- foreach (DataControlField item in gv.Columns)
+ foreach (var item in gv.Columns)
{
if (item is DataControlField) (item as DataControlField).SortExpression = null;
}
@@ -314,12 +314,12 @@ namespace NewLife.Web
/// <summary>获取长整型参数</summary>
/// <param name="name">名称</param>
/// <returns></returns>
- public static long RequestLong(String name) { return Request[name].ToLong(); }
+ public static Int64 RequestLong(String name) { return Request[name].ToLong(); }
/// <summary>接收布尔值</summary>
/// <param name="name">名称</param>
/// <returns></returns>
- public static bool RequestBool(String name) { return Request[name].ToBoolean(); }
+ public static Boolean RequestBool(String name) { return Request[name].ToBoolean(); }
/// <summary>接收时间</summary>
/// <param name="name">名称</param>
@@ -367,7 +367,7 @@ namespace NewLife.Web
/// <param name="name">名称</param>
/// <param name="value">值</param>
/// <param name="expires">过期时间,单位秒</param>
- public static void WriteCookie(String name, String value, int expires)
+ public static void WriteCookie(String name, String value, Int32 expires)
{
var cookie = Request.Cookies[name];
if (cookie == null) cookie = new HttpCookie(name);
diff --git a/NewLife.Core/Windows/ControlHelper.cs b/NewLife.Core/Windows/ControlHelper.cs
index c29b5e7..dfa749b 100644
--- a/NewLife.Core/Windows/ControlHelper.cs
+++ b/NewLife.Core/Windows/ControlHelper.cs
@@ -317,10 +317,10 @@ namespace System.Windows.Forms
}
[DllImport("user32.dll")]
- static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
- private const int SB_TOP = 6;
- private const int SB_BOTTOM = 7;
- private const int WM_VSCROLL = 0x115;
+ static extern Int32 SendMessage(IntPtr hwnd, Int32 wMsg, Int32 wParam, Int32 lParam);
+ private const Int32 SB_TOP = 6;
+ private const Int32 SB_BOTTOM = 7;
+ private const Int32 WM_VSCROLL = 0x115;
#endregion
#region 设置控件样式
@@ -388,9 +388,9 @@ namespace System.Windows.Forms
return start;
}
- static void ChangeColor(RichTextBox rtb, Int32 start, string text, Color color)
+ static void ChangeColor(RichTextBox rtb, Int32 start, String text, Color color)
{
- int s = start;
+ var s = start;
//while ((-1 + text.Length - 1) != (s = text.Length - 1 + rtx.Find(text, s, -1, RichTextBoxFinds.WholeWord)))
while (true)
{
@@ -495,7 +495,7 @@ namespace System.Windows.Forms
else
{
// 遍历匹配组,注意0号代表整体
- for (int i = 1; i < item.Groups.Count; i++)
+ for (var i = 1; i < item.Groups.Count; i++)
{
rtb.Select(item.Groups[i].Index, item.Groups[i].Length);
rtb.SelectionColor = colors[i - 1];
diff --git a/NewLife.Core/Windows/SerialPortList.cs b/NewLife.Core/Windows/SerialPortList.cs
index f1fc1c4..7ab0bba 100644
--- a/NewLife.Core/Windows/SerialPortList.cs
+++ b/NewLife.Core/Windows/SerialPortList.cs
@@ -41,7 +41,7 @@ namespace NewLife.Windows
}
TimerX _timer;
- private void SerialPortList_Load(object sender, EventArgs e)
+ private void SerialPortList_Load(Object sender, EventArgs e)
{
LoadInfo();
@@ -55,7 +55,7 @@ namespace NewLife.Windows
}
}
- void frm_FormClosing(object sender, FormClosingEventArgs e)
+ void frm_FormClosing(Object sender, FormClosingEventArgs e)
{
SaveInfo();
@@ -176,7 +176,7 @@ namespace NewLife.Windows
/// <summary>右键菜单</summary>
public ContextMenuStrip Menu { get { return contextMenuStrip1; } }
- void On数据位Click(object sender, EventArgs e)
+ void On数据位Click(Object sender, EventArgs e)
{
SelectMenu(sender);
@@ -185,7 +185,7 @@ namespace NewLife.Windows
cfg.DataBits = (Int32)mi.Tag;
}
- void On停止位Click(object sender, EventArgs e)
+ void On停止位Click(Object sender, EventArgs e)
{
SelectMenu(sender);
@@ -194,7 +194,7 @@ namespace NewLife.Windows
cfg.StopBits = (StopBits)mi.Tag;
}
- void On校验Click(object sender, EventArgs e)
+ void On校验Click(Object sender, EventArgs e)
{
SelectMenu(sender);
@@ -203,7 +203,7 @@ namespace NewLife.Windows
cfg.Parity = (Parity)mi.Tag;
}
- void On编码Click(object sender, EventArgs e)
+ void On编码Click(Object sender, EventArgs e)
{
// 不要选其它
var mi = sender as ToolStripMenuItem;
@@ -219,7 +219,7 @@ namespace NewLife.Windows
cfg.WebEncoding = mi.Name;
}
- private void mi字符串编码_Click(object sender, EventArgs e)
+ private void mi字符串编码_Click(Object sender, EventArgs e)
{
var cfg = SerialPortConfig.Current;
//cfg.HexShow = miHEX编码接收.Checked = !mi字符串编码.Checked;
@@ -229,21 +229,21 @@ namespace NewLife.Windows
contextMenuStrip1.Hide();
}
- private void miHex自动换行_Click(object sender, EventArgs e)
+ private void miHex自动换行_Click(Object sender, EventArgs e)
{
var cfg = SerialPortConfig.Current;
//cfg.HexNewLine = ti.Tag.ToBoolean();
cfg.HexNewLine = SelectMenu(sender) == 1;
}
- private void miHEX编码发送_Click(object sender, EventArgs e)
+ private void miHEX编码发送_Click(Object sender, EventArgs e)
{
var cfg = SerialPortConfig.Current;
miHEX编码发送.Checked = !miHEX编码发送.Checked;
cfg.HexSend = miHEX编码发送.Checked;
}
- private void miDTR_Click(object sender, EventArgs e)
+ private void miDTR_Click(Object sender, EventArgs e)
{
var mi = sender as ToolStripMenuItem;
mi.Checked = !mi.Checked;
@@ -311,7 +311,7 @@ namespace NewLife.Windows
Enabled = false;
}
- void Port_Disconnected(object sender, EventArgs e)
+ void Port_Disconnected(Object sender, EventArgs e)
{
Disconnect();
}
@@ -373,7 +373,7 @@ namespace NewLife.Windows
if (mi == null) return -1;
var idx = -1;
- for (int i = 0; i < ms.Length; i++)
+ for (var i = 0; i < ms.Length; i++)
{
if (ms[i] == mi)
{
diff --git a/NewLife.Core/Xml/XmlHelper.cs b/NewLife.Core/Xml/XmlHelper.cs
index 6ee49c8..8a01dba 100644
--- a/NewLife.Core/Xml/XmlHelper.cs
+++ b/NewLife.Core/Xml/XmlHelper.cs
@@ -334,7 +334,7 @@ namespace NewLife.Xml
if (elmType != null && elmType.Name.EqualIgnoreCase(node.ChildNodes[0].Name))
{
- for (int i = 0; i < node.ChildNodes.Count; i++)
+ for (var i = 0; i < node.ChildNodes.Count; i++)
{
rs |= node.ChildNodes[i].AttachCommitInternal(elmType);
}
@@ -342,7 +342,7 @@ namespace NewLife.Xml
}
#endregion
- for (int i = 0; i < node.ChildNodes.Count; i++)
+ for (var i = 0; i < node.ChildNodes.Count; i++)
{
var curNode = node.ChildNodes[i];
diff --git a/NewLife.Cube/Areas/Admin/Index/IndexController.cs b/NewLife.Cube/Areas/Admin/Index/IndexController.cs
index de047f2..d6e3662 100644
--- a/NewLife.Cube/Areas/Admin/Index/IndexController.cs
+++ b/NewLife.Cube/Areas/Admin/Index/IndexController.cs
@@ -46,7 +46,7 @@ namespace NewLife.Cube.Admin.Controllers
ViewBag.User = ManageProvider.User;
ViewBag.Config = SysConfig.Current;
- String name = Request.ServerVariables["Server_SoftWare"];
+ var name = Request.ServerVariables["Server_SoftWare"];
if (String.IsNullOrEmpty(name)) name = Process.GetCurrentProcess().ProcessName;
// 检测集成管道,低版本.Net不支持,请使用者根据情况自行注释
@@ -70,7 +70,7 @@ namespace NewLife.Cube.Admin.Controllers
/// <summary>菜单不可见</summary>
/// <param name="menu"></param>
/// <returns></returns>
- protected override IDictionary<MethodInfo, int> ScanActionMenu(IMenu menu)
+ protected override IDictionary<MethodInfo, Int32> ScanActionMenu(IMenu menu)
{
if (menu.Visible)
{
diff --git a/NewLife.Cube/Common/ControllerBaseX.cs b/NewLife.Cube/Common/ControllerBaseX.cs
index e20ffc7..87b6386 100644
--- a/NewLife.Cube/Common/ControllerBaseX.cs
+++ b/NewLife.Cube/Common/ControllerBaseX.cs
@@ -63,7 +63,7 @@ namespace NewLife.Cube
{
// 附加的独立Action菜单,遍历所有权限位
var n = 1;
- for (int i = 0; i < 8; i++)
+ for (var i = 0; i < 8; i++)
{
var v = (PermissionFlags)n;
if (att.Permission.Has(v)) node.Permissions[n] = v.GetDescription();
diff --git a/NewLife.Cube/Common/DbRunTimeModule.cs b/NewLife.Cube/Common/DbRunTimeModule.cs
index fe08c81..fc34370 100644
--- a/NewLife.Cube/Common/DbRunTimeModule.cs
+++ b/NewLife.Cube/Common/DbRunTimeModule.cs
@@ -54,8 +54,8 @@ namespace NewLife.Cube
if (!Context.Items.Contains(_QueryTimes) || !Context.Items.Contains(_ExecuteTimes)) throw new XException("设计错误!需要在web.config中配置{0}", typeof(DbRunTimeModule).FullName);
- Int32 StartQueryTimes = (Int32)Context.Items[_QueryTimes];
- Int32 StartExecuteTimes = (Int32)Context.Items[_ExecuteTimes];
+ var StartQueryTimes = (Int32)Context.Items[_QueryTimes];
+ var StartExecuteTimes = (Int32)Context.Items[_ExecuteTimes];
var inf = String.Format(DbRunTimeFormat, DAL.QueryTimes - StartQueryTimes, DAL.ExecuteTimes - StartExecuteTimes, ts.TotalMilliseconds);
diff --git a/NewLife.Cube/Common/EntityTreeController.cs b/NewLife.Cube/Common/EntityTreeController.cs
index 3853ce7..46e1d2f 100644
--- a/NewLife.Cube/Common/EntityTreeController.cs
+++ b/NewLife.Cube/Common/EntityTreeController.cs
@@ -78,7 +78,7 @@ namespace NewLife.Cube
/// <summary>要导出Json的对象</summary>
/// <returns></returns>
- protected override object OnExportJson()
+ protected override Object OnExportJson()
{
return EntityTree<TEntity>.Root.Childs;
}
diff --git a/NewLife.Cube/Common/FieldCollection.cs b/NewLife.Cube/Common/FieldCollection.cs
index 8b58a97..1ae6992 100644
--- a/NewLife.Cube/Common/FieldCollection.cs
+++ b/NewLife.Cube/Common/FieldCollection.cs
@@ -109,7 +109,7 @@ namespace NewLife.Cube
void NoPass()
{
- for (int i = Count - 1; i >= 0; i--)
+ for (var i = Count - 1; i >= 0; i--)
{
var fi = this[i];
if (fi.IsDataObjectField && fi.Type == typeof(String))
@@ -125,7 +125,7 @@ namespace NewLife.Cube
void ProcessIP()
{
- for (int i = Count - 1; i >= 0; i--)
+ for (var i = Count - 1; i >= 0; i--)
{
if (this[i].Name.EndsWithIgnoreCase("IP", "Uri"))
{
@@ -157,7 +157,7 @@ namespace NewLife.Cube
/// <returns></returns>
public FieldCollection AddField(String oriName, String newName)
{
- for (int i = 0; i < Count; i++)
+ for (var i = 0; i < Count; i++)
{
if (this[i].Name.EqualIgnoreCase(oriName))
{
diff --git a/NewLife.Cube/Precompiled/FrontendController.cs b/NewLife.Cube/Precompiled/FrontendController.cs
index 466db54..e9c48c3 100644
--- a/NewLife.Cube/Precompiled/FrontendController.cs
+++ b/NewLife.Cube/Precompiled/FrontendController.cs
@@ -16,7 +16,7 @@ namespace NewLife.Cube.Precompiled
/// <returns></returns>
public ActionResult Default()
{
- string actionName = (RouteData.Values["viewName"] ?? "Default").ToString();
+ var actionName = (RouteData.Values["viewName"] ?? "Default").ToString();
return View(actionName);
}
}
diff --git a/NewLife.Cube/Precompiled/Pages.cs b/NewLife.Cube/Precompiled/Pages.cs
index fc1c474..ddd9ce9 100644
--- a/NewLife.Cube/Precompiled/Pages.cs
+++ b/NewLife.Cube/Precompiled/Pages.cs
@@ -15,11 +15,11 @@ namespace NewLife.Cube.Precompiled
/// <summary>路径是否存在</summary>
/// <param name="virtualPath"></param>
/// <returns></returns>
- public static bool IsExistByVirtualPath(string virtualPath)
+ public static Boolean IsExistByVirtualPath(String virtualPath)
{
if (virtualPath.StartsWith("~/"))
virtualPath = virtualPath.Substring(1); var assembly = Assembly.LoadFrom(HttpContext.Current.Server.MapPath("~/bin") + "\\Falafel.Resources.dll");
- string result = string.Empty;
+ var result = string.Empty;
virtualPath = "Falafel.Resources" + virtualPath.Replace('/', '.'); if (virtualPath.EndsWith("/"))
{
result = assembly.GetManifestResourceNames().First();
@@ -33,7 +33,7 @@ namespace NewLife.Cube.Precompiled
/// <summary>根据路径获取页面模版</summary>
/// <param name="virtualPath"></param>
/// <returns></returns>
- public static string GetByVirtualPath(string virtualPath)
+ public static String GetByVirtualPath(String virtualPath)
{
if (virtualPath.StartsWith("~/"))
virtualPath = virtualPath.Substring(1);
diff --git a/NewLife.Cube/Precompiled/ViewCacheDependency.cs b/NewLife.Cube/Precompiled/ViewCacheDependency.cs
index 16ec93f..d5a1b84 100644
--- a/NewLife.Cube/Precompiled/ViewCacheDependency.cs
+++ b/NewLife.Cube/Precompiled/ViewCacheDependency.cs
@@ -11,7 +11,7 @@ namespace NewLife.Cube.Precompiled
{
/// <summary>实例化缓存依赖</summary>
/// <param name="virtualPath"></param>
- public ViewCacheDependency(string virtualPath)
+ public ViewCacheDependency(String virtualPath)
{
base.SetUtcLastModified(DateTime.UtcNow);
}
diff --git a/NewLife.Cube/Precompiled/ViewCacheDependencyManager.cs b/NewLife.Cube/Precompiled/ViewCacheDependencyManager.cs
index 09ca2b0..803b955 100644
--- a/NewLife.Cube/Precompiled/ViewCacheDependencyManager.cs
+++ b/NewLife.Cube/Precompiled/ViewCacheDependencyManager.cs
@@ -9,9 +9,9 @@ namespace NewLife.Cube.Precompiled
/// <summary>视图缓存依赖管理</summary>
public class ViewCacheDependencyManager
{
- private static Dictionary<string, ViewCacheDependency> dependencies = new Dictionary<string, ViewCacheDependency>();
+ private static Dictionary<String, ViewCacheDependency> dependencies = new Dictionary<String, ViewCacheDependency>();
private static volatile ViewCacheDependencyManager instance;
- private static object syncRoot = new Object();
+ private static Object syncRoot = new Object();
private ViewCacheDependencyManager() { }
/// <summary>实例</summary>
@@ -36,7 +36,7 @@ namespace NewLife.Cube.Precompiled
/// <summary>获取缓存依赖</summary>
/// <param name="virtualPath"></param>
/// <returns></returns>
- public CacheDependency Get(string virtualPath)
+ public CacheDependency Get(String virtualPath)
{
if (!dependencies.ContainsKey(virtualPath))
dependencies.Add(virtualPath, new ViewCacheDependency(virtualPath));
@@ -46,7 +46,7 @@ namespace NewLife.Cube.Precompiled
/// <summary>验证</summary>
/// <param name="virtualPath"></param>
- public void Invalidate(string virtualPath)
+ public void Invalidate(String virtualPath)
{
if (dependencies.ContainsKey(virtualPath))
{
diff --git a/NewLife.Cube/Precompiled/ViewFile.cs b/NewLife.Cube/Precompiled/ViewFile.cs
index b7bbc24..650bc11 100644
--- a/NewLife.Cube/Precompiled/ViewFile.cs
+++ b/NewLife.Cube/Precompiled/ViewFile.cs
@@ -11,11 +11,11 @@ namespace NewLife.Cube.Precompiled
/// <summary>视图文件</summary>
public class ViewFile : VirtualFile
{
- private string path;
+ private String path;
/// <summary>实例化视图文件</summary>
/// <param name="virtualPath"></param>
- public ViewFile(string virtualPath)
+ public ViewFile(String virtualPath)
: base(virtualPath)
{
path = virtualPath;
diff --git a/NewLife.Cube/Precompiled/ViewPathProvider.cs b/NewLife.Cube/Precompiled/ViewPathProvider.cs
index 53c01d7..d67fd6c 100644
--- a/NewLife.Cube/Precompiled/ViewPathProvider.cs
+++ b/NewLife.Cube/Precompiled/ViewPathProvider.cs
@@ -13,7 +13,7 @@ namespace NewLife.Cube.Precompiled
/// <summary>文件是否存在</summary>
/// <param name="virtualPath"></param>
/// <returns></returns>
- public override bool FileExists(string virtualPath)
+ public override Boolean FileExists(String virtualPath)
{
return Pages.IsExistByVirtualPath(virtualPath) || base.FileExists(virtualPath);
}
@@ -21,7 +21,7 @@ namespace NewLife.Cube.Precompiled
/// <summary>获取视图文件</summary>
/// <param name="virtualPath"></param>
/// <returns></returns>
- public override VirtualFile GetFile(string virtualPath)
+ public override VirtualFile GetFile(String virtualPath)
{
if (Pages.IsExistByVirtualPath(virtualPath))
{
@@ -35,7 +35,7 @@ namespace NewLife.Cube.Precompiled
/// <param name="virtualPathDependencies"></param>
/// <param name="utcStart"></param>
/// <returns></returns>
- public override CacheDependency GetCacheDependency(string virtualPath, System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart)
+ public override CacheDependency GetCacheDependency(String virtualPath, System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart)
{
if (Pages.IsExistByVirtualPath(virtualPath))
return ViewCacheDependencyManager.Instance.Get(virtualPath);
diff --git a/NewLife.MQ/MQTest.cs b/NewLife.MQ/MQTest.cs
index 4ca123c..7178a26 100644
--- a/NewLife.MQ/MQTest.cs
+++ b/NewLife.MQ/MQTest.cs
@@ -32,7 +32,7 @@ namespace NewLife.MessageQueue
//};
await user.Subscribe("新生命团队");
- for (int i = 0; i < 3; i++)
+ for (var i = 0; i < 3; i++)
{
await client.Public("测试{0}".F(i + 1));
}
diff --git a/NewLife.Net/Application/AppTest.cs b/NewLife.Net/Application/AppTest.cs
index 285e532..712387f 100644
--- a/NewLife.Net/Application/AppTest.cs
+++ b/NewLife.Net/Application/AppTest.cs
@@ -48,7 +48,7 @@ namespace NewLife.Net.Application
}
static AutoResetEvent _are = new AutoResetEvent(true);
- static void OnReceived(object sender, ReceivedEventArgs e)
+ static void OnReceived(Object sender, ReceivedEventArgs e)
{
var session = sender as ISocketSession;
Console.WriteLine("客户端{0} 收到 [{1}]: {2}", session, e.Stream.Length, e.Stream.ToStr());
@@ -56,7 +56,7 @@ namespace NewLife.Net.Application
_are.Set();
}
- static void OnError(object sender, ExceptionEventArgs e)
+ static void OnError(Object sender, ExceptionEventArgs e)
{
Console.WriteLine("客户端{0}错误 {1}", sender, e.Exception);
}
@@ -65,7 +65,7 @@ namespace NewLife.Net.Application
{
Console.WriteLine();
- String msg = String.Format("{0}Test_{1}_{2}!", name, uri.Type, isAsync ? "异步" : "同步");
+ var msg = String.Format("{0}Test_{1}_{2}!", name, uri.Type, isAsync ? "异步" : "同步");
var client = uri.CreateRemote();
client.Error += OnError;
if (isAsync && isReceiveData)
@@ -142,7 +142,7 @@ namespace NewLife.Net.Application
static void StartDaytimeServer(Int32 port)
{
- IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, port);
+ var ep = new IPEndPoint(IPAddress.Loopback, port);
TestSends("Daytime", ep, true);
@@ -153,7 +153,7 @@ namespace NewLife.Net.Application
static void StartTimeServer(Int32 port)
{
- IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, port);
+ var ep = new IPEndPoint(IPAddress.Loopback, port);
TestSends("Time", ep, true);
@@ -164,7 +164,7 @@ namespace NewLife.Net.Application
static void StartDiscardServer(Int32 port)
{
- IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, port);
+ var ep = new IPEndPoint(IPAddress.Loopback, port);
TestSends("Discard", ep, true, false);
@@ -175,7 +175,7 @@ namespace NewLife.Net.Application
static void StartChargenServer(Int32 port)
{
- IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, port);
+ var ep = new IPEndPoint(IPAddress.Loopback, port);
TestSends("Chargen", ep, true);
@@ -210,7 +210,7 @@ namespace NewLife.Net.Application
static NetServer server = null;
static void TestServer()
{
- Int32 port = ReadInt("请输入监听端口:", 1, 65535);
+ var port = ReadInt("请输入监听端口:", 1, 65535);
// 扩大事件池
//NetEventArgs.Pool.Max = 200000;
@@ -221,7 +221,7 @@ namespace NewLife.Net.Application
server.UseSession = true;
server.Received += server_Received;
// 最大不活跃时间设为10分钟
- foreach (TcpServer item in server.Servers)
+ foreach (var item in server.Servers)
{
item.SessionTimeout = 10 * 60;
}
@@ -236,7 +236,7 @@ namespace NewLife.Net.Application
server.Dispose();
}
- static void server_Received(object sender, ReceivedEventArgs e)
+ static void server_Received(Object sender, ReceivedEventArgs e)
{
OnReceive(sender as ISocketSession, e.Stream);
}
@@ -273,10 +273,10 @@ namespace NewLife.Net.Application
{
try
{
- Int32 wt = 0;
- Int32 cpt = 0;
+ var wt = 0;
+ var cpt = 0;
ThreadPool.GetAvailableThreads(out wt, out cpt);
- Int32 threads = Process.GetCurrentProcess().Threads.Count;
+ var threads = Process.GetCurrentProcess().Threads.Count;
var color = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
@@ -320,7 +320,7 @@ namespace NewLife.Net.Application
var time = 10;
var threads = new Thread[threadcount];
- for (int i = 0; i < threadcount; i++)
+ for (var i = 0; i < threadcount; i++)
{
var th = new Thread(ClientProcess);
th.IsBackground = true;
@@ -342,11 +342,11 @@ namespace NewLife.Net.Application
var msg = String.Format("Hi I am {0}!", p.ID);
var clients = new ISocketClient[p.Count];
- for (int k = 0; k < 100; k++)
+ for (var k = 0; k < 100; k++)
{
Console.WriteLine("第{1}轮处理:{0}", p.ID, k + 1);
- for (int i = 0; i < p.Count; i++)
+ for (var i = 0; i < p.Count; i++)
{
try
{
@@ -383,7 +383,7 @@ namespace NewLife.Net.Application
else if (title[title.Length - 1] != ':')
title += ":";
- Int32 n = 0;
+ var n = 0;
while (n < min || n > max)
{
Console.Write(title);
diff --git a/NewLife.Net/Application/ChargenServer.cs b/NewLife.Net/Application/ChargenServer.cs
index cbb3460..e815cab 100644
--- a/NewLife.Net/Application/ChargenServer.cs
+++ b/NewLife.Net/Application/ChargenServer.cs
@@ -80,7 +80,7 @@ namespace NewLife.Net.Application
{
// 不断的发送数据,直到连接断开为止
//while (!hasError)
- for (int i = 0; i < 64 && !hasError; i++)
+ for (var i = 0; i < 64 && !hasError; i++)
{
try
{
@@ -103,15 +103,15 @@ namespace NewLife.Net.Application
void Send(ISocketSession session)
{
- Int32 startIndex = Index++;
+ var startIndex = Index++;
if (Index >= Length) Index = 0;
- Byte[] buffer = new Byte[Length];
+ var buffer = new Byte[Length];
// 产生数据
- for (int i = 0; i < buffer.Length; i++)
+ for (var i = 0; i < buffer.Length; i++)
{
- Int32 p = startIndex + i;
+ var p = startIndex + i;
if (p >= buffer.Length) p -= buffer.Length;
buffer[p] = (Byte)(i + 32);
}
diff --git a/NewLife.Net/Application/DaytimeServer.cs b/NewLife.Net/Application/DaytimeServer.cs
index 891cc2d..fe40494 100644
--- a/NewLife.Net/Application/DaytimeServer.cs
+++ b/NewLife.Net/Application/DaytimeServer.cs
@@ -22,7 +22,7 @@ namespace NewLife.Net.Application
{
WriteLog("Daytime {0}", session.Remote);
- Byte[] buffer = Encoding.ASCII.GetBytes(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff"));
+ var buffer = Encoding.ASCII.GetBytes(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff"));
//Send(e.Socket, buffer, 0, buffer.Length, e.RemoteEndPoint);
//session.Send(buffer, 0, buffer.Length, e.RemoteEndPoint);
session.Send(buffer);
diff --git a/NewLife.Net/Application/SerialServer.cs b/NewLife.Net/Application/SerialServer.cs
index 4e3808e..9d3d367 100644
--- a/NewLife.Net/Application/SerialServer.cs
+++ b/NewLife.Net/Application/SerialServer.cs
@@ -47,7 +47,7 @@ namespace NewLife.Net.Application
/// <summary>子类重载实现资源释放逻辑时必须首先调用基类方法</summary>
/// <param name="disposing">从Dispose调用(释放所有资源)还是析构函数调用(释放非托管资源)</param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
diff --git a/NewLife.Net/Application/TimeServer.cs b/NewLife.Net/Application/TimeServer.cs
index 5d7b90e..4ba8644 100644
--- a/NewLife.Net/Application/TimeServer.cs
+++ b/NewLife.Net/Application/TimeServer.cs
@@ -24,11 +24,11 @@ namespace NewLife.Net.Application
{
WriteLog("Time {0}", session.Remote);
- TimeSpan ts = DateTime.Now - STARTTIME;
- Int32 s = (Int32)ts.TotalSeconds;
+ var ts = DateTime.Now - STARTTIME;
+ var s = (Int32)ts.TotalSeconds;
// 因为要发往网络,这里调整网络字节序
s = IPAddress.HostToNetworkOrder(s);
- Byte[] buffer = BitConverter.GetBytes(s);
+ var buffer = BitConverter.GetBytes(s);
//Send(e.Socket, buffer, 0, buffer.Length, e.RemoteEndPoint);
//session.Send(buffer, 0, buffer.Length, e.RemoteEndPoint);
session.Send(buffer);
diff --git a/NewLife.Net/Dhcp/DhcpClient.cs b/NewLife.Net/Dhcp/DhcpClient.cs
index 0060443..625a566 100644
--- a/NewLife.Net/Dhcp/DhcpClient.cs
+++ b/NewLife.Net/Dhcp/DhcpClient.cs
@@ -35,7 +35,7 @@ namespace NewLife.Net.Dhcp
#region 构造
/// <summary>销毁</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -84,7 +84,7 @@ namespace NewLife.Net.Dhcp
}
}
- void Client_Received(object sender, ReceivedEventArgs e)
+ void Client_Received(Object sender, ReceivedEventArgs e)
{
var dhcp = new DhcpEntity();
dhcp.Read(e.Stream, null);
diff --git a/NewLife.Net/Dhcp/DhcpEntity.cs b/NewLife.Net/Dhcp/DhcpEntity.cs
index 0877ba7..cb8a7c1 100644
--- a/NewLife.Net/Dhcp/DhcpEntity.cs
+++ b/NewLife.Net/Dhcp/DhcpEntity.cs
@@ -128,7 +128,7 @@ namespace NewLife.Net.Dhcp
/// <param name="stream"></param>
/// <param name="context"></param>
/// <returns></returns>
- public override bool Read(Stream stream, Object context)
+ public override Boolean Read(Stream stream, Object context)
{
if (!base.Read(stream, context)) return false;
@@ -176,7 +176,7 @@ namespace NewLife.Net.Dhcp
/// <summary>使用字段大小</summary>
/// <param name="isRead"></param>
/// <returns></returns>
- protected override IFormatterX CreateFormatter(bool isRead)
+ protected override IFormatterX CreateFormatter(Boolean isRead)
{
var fm = base.CreateFormatter(isRead) as Binary;
fm.UseFieldSize = true;
@@ -191,7 +191,7 @@ namespace NewLife.Net.Dhcp
/// <param name="pi"></param>
/// <param name="len"></param>
/// <param name="sb"></param>
- protected override void GetMember(PropertyInfo pi, int len, StringBuilder sb)
+ protected override void GetMember(PropertyInfo pi, Int32 len, StringBuilder sb)
{
if (pi.Name == "Options")
{
@@ -210,7 +210,7 @@ namespace NewLife.Net.Dhcp
/// <summary>获取用于输出的成员值</summary>
/// <param name="pi"></param>
/// <returns></returns>
- protected override object GetMemberValue(PropertyInfo pi)
+ protected override Object GetMemberValue(PropertyInfo pi)
{
var v = base.GetMemberValue(pi);
var type = pi.PropertyType;
diff --git a/NewLife.Net/Dhcp/DhcpMessageType.cs b/NewLife.Net/Dhcp/DhcpMessageType.cs
index a1f2f1e..81a46c8 100644
--- a/NewLife.Net/Dhcp/DhcpMessageType.cs
+++ b/NewLife.Net/Dhcp/DhcpMessageType.cs
@@ -3,7 +3,7 @@
namespace NewLife.Net.Dhcp
{
/// <summary>DHCP消息类型</summary>
- public enum DhcpMessageType : byte
+ public enum DhcpMessageType : System.Byte
{
/// <summary>发现</summary>
[Description("发现")]
diff --git a/NewLife.Net/Dhcp/DhcpOption.cs b/NewLife.Net/Dhcp/DhcpOption.cs
index 4008a15..1b22c57 100644
--- a/NewLife.Net/Dhcp/DhcpOption.cs
+++ b/NewLife.Net/Dhcp/DhcpOption.cs
@@ -8,7 +8,7 @@ using NewLife.Serialization;
namespace NewLife.Net.Dhcp
{
/// <summary>DHCP选项类型</summary>
- public enum DhcpOptions : byte
+ public enum DhcpOptions : Byte
{
/// <summary></summary>
Mask = 1,
@@ -175,7 +175,7 @@ namespace NewLife.Net.Dhcp
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return Option + " " + ToStr();
}
diff --git a/NewLife.Net/DNS/BinaryDNS.cs b/NewLife.Net/DNS/BinaryDNS.cs
index 696b37d..d728e82 100644
--- a/NewLife.Net/DNS/BinaryDNS.cs
+++ b/NewLife.Net/DNS/BinaryDNS.cs
@@ -19,7 +19,7 @@ namespace NewLife.Net.DNS
Accessor = new DNSNameAccessor();
}
- public override bool Write(object value, Type type)
+ public override Boolean Write(Object value, Type type)
{
_binary.Host = Host;
@@ -43,7 +43,7 @@ namespace NewLife.Net.DNS
return false;
}
- public override bool TryRead(Type type, ref object value)
+ public override Boolean TryRead(Type type, ref Object value)
{
_binary.Host = Host;
diff --git a/NewLife.Net/DNS/DNS_MX.cs b/NewLife.Net/DNS/DNS_MX.cs
index bc6fa85..aac1e2a 100644
--- a/NewLife.Net/DNS/DNS_MX.cs
+++ b/NewLife.Net/DNS/DNS_MX.cs
@@ -45,7 +45,7 @@ namespace NewLife.Net.DNS
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return String.Format("{0} {1} {2}", Type, Preference, Host);
}
diff --git a/NewLife.Net/DNS/DNS_NB.cs b/NewLife.Net/DNS/DNS_NB.cs
index dec8e30..cad9d7e 100644
--- a/NewLife.Net/DNS/DNS_NB.cs
+++ b/NewLife.Net/DNS/DNS_NB.cs
@@ -14,10 +14,10 @@ namespace NewLife.Net.DNS
private UInt16 _flags = 0;
/// <summary></summary>
- public bool G { get { return BitHelper.GetBit(_flags, 15); } }
+ public Boolean G { get { return BitHelper.GetBit(_flags, 15); } }
/// <summary></summary>
- public ushort ONT { get { return BitHelper.GetBits(_flags, 13, 2); } }
+ public UInt16 ONT { get { return BitHelper.GetBits(_flags, 13, 2); } }
[FieldSize("_Length", -2)]
private IPAddress _Address;
diff --git a/NewLife.Net/DNS/DNSClient.cs b/NewLife.Net/DNS/DNSClient.cs
index b966cf5..8935cc8 100644
--- a/NewLife.Net/DNS/DNSClient.cs
+++ b/NewLife.Net/DNS/DNSClient.cs
@@ -160,7 +160,7 @@ namespace NewLife.Net.DNS
// 获取结果
var dic = new Dictionary<DNSClient, DNSEntity>();
- for (int i = 0; i < cs.Length; i++)
+ for (var i = 0; i < cs.Length; i++)
{
var task = ts[i];
if (task.IsOK() && task.Result != null) dic.Add(cs[i], task.Result);
diff --git a/NewLife.Net/DNS/DNSEntity.cs b/NewLife.Net/DNS/DNSEntity.cs
index 8bc6b64..eefd7e6 100644
--- a/NewLife.Net/DNS/DNSEntity.cs
+++ b/NewLife.Net/DNS/DNSEntity.cs
@@ -165,7 +165,7 @@ namespace NewLife.Net.DNS
/// <summary>创建序列化器</summary>
/// <param name="isRead"></param>
/// <returns></returns>
- protected override IFormatterX CreateFormatter(bool isRead)
+ protected override IFormatterX CreateFormatter(Boolean isRead)
{
var fm = base.CreateFormatter(isRead);
fm.Encoding = Encoding.UTF8;
@@ -227,7 +227,7 @@ namespace NewLife.Net.DNS
/// <summary>已重载。</summary>
/// <returns></returns>
[DebuggerHidden]
- public override string ToString()
+ public override String ToString()
{
var rs = Questions;
if (!Header.Response)
diff --git a/NewLife.Net/DNS/DNSHeader.cs b/NewLife.Net/DNS/DNSHeader.cs
index fcd49ac..94784e6 100644
--- a/NewLife.Net/DNS/DNSHeader.cs
+++ b/NewLife.Net/DNS/DNSHeader.cs
@@ -44,7 +44,7 @@ namespace NewLife.Net.DNS
}
/// <summary>Broadcast Flag</summary>
- public bool Broadcast
+ public Boolean Broadcast
{
get { return _D2.GetBit(4); }
set { _D2.SetBit(4, value); }
@@ -78,7 +78,7 @@ namespace NewLife.Net.DNS
#region 枚举
[Flags]
- enum D1 : byte
+ enum D1 : Byte
{
RecursionDesired = 1,
diff --git a/NewLife.Net/DNS/DNSNameAccessor.cs b/NewLife.Net/DNS/DNSNameAccessor.cs
index 87e78ec..655364c 100644
--- a/NewLife.Net/DNS/DNSNameAccessor.cs
+++ b/NewLife.Net/DNS/DNSNameAccessor.cs
@@ -60,9 +60,9 @@ namespace NewLife.Net.DNS
var keys = new List<Int32>();
var values = new List<String>();
- Int64 start = stream.Position;
- Int64 p = start;
- Int32 n = 0;
+ var start = stream.Position;
+ var p = start;
+ var n = 0;
var sb = new StringBuilder();
while (true)
{
@@ -84,7 +84,7 @@ namespace NewLife.Net.DNS
str = this[(n - 0xC0) * 256 + n2];
// 之前的每个加上str
- for (int i = 0; i < values.Count; i++) values[i] += "." + str;
+ for (var i = 0; i < values.Count; i++) values[i] += "." + str;
// 局部引用,前面还有一段本地读出来的,这样子,整个就形成了一个新的字符串
if (sb.Length > 0)
@@ -98,11 +98,11 @@ namespace NewLife.Net.DNS
break;
}
- Byte[] buffer = stream.ReadBytes(n);
+ var buffer = stream.ReadBytes(n);
str = Encoding.UTF8.GetString(buffer);
// 之前的每个加上str
- for (int i = 0; i < values.Count; i++) values[i] += "." + str;
+ for (var i = 0; i < values.Count; i++) values[i] += "." + str;
// 加入当前项。因为引用项马上就要跳出了,不会做二次引用,所以不加
if (!values.Contains(str))
@@ -115,7 +115,7 @@ namespace NewLife.Net.DNS
p = stream.Position;
}
- for (int i = 0; i < keys.Count; i++)
+ for (var i = 0; i < keys.Count; i++)
{
if (!Values.Contains(values[i]))
{
@@ -134,15 +134,15 @@ namespace NewLife.Net.DNS
var values = new List<String>();
var start = stream.Position;
- Int32 p = 0;
- Boolean isRef = false;
- String[] ss = ("" + value).Split(".");
- for (int i = 0; i < ss.Length; i++)
+ var p = 0;
+ var isRef = false;
+ var ss = ("" + value).Split(".");
+ for (var i = 0; i < ss.Length; i++)
{
isRef = false;
// 如果已存在,则写引用
- String name = String.Join(".", ss, i, ss.Length - i);
+ var name = String.Join(".", ss, i, ss.Length - i);
if (Values.Contains(name))
{
//stream.WriteByte(0xC0);
@@ -150,14 +150,14 @@ namespace NewLife.Net.DNS
// 偏移量的标准公式是:(Cn-C0)*256+偏移
// 相对位置,注意超长位移(大于0xFF)
- Int32 abp = this[name];
- Int32 ab = abp / 0xFF;
+ var abp = this[name];
+ var ab = abp / 0xFF;
abp = abp & 0xFF;
stream.WriteByte((Byte)(0xC0 + ab));
stream.WriteByte((Byte)abp);
// 之前的每个加上str
- for (int j = 0; j < values.Count; j++) values[j] += "." + name;
+ for (var j = 0; j < values.Count; j++) values[j] += "." + name;
// 使用引用的必然是最后一个
isRef = true;
@@ -168,12 +168,12 @@ namespace NewLife.Net.DNS
// 否则,先写长度,后存入引用
p = (Int32)(stream.Position - start);
- Byte[] buffer = Encoding.UTF8.GetBytes(ss[i]);
+ var buffer = Encoding.UTF8.GetBytes(ss[i]);
stream.WriteByte((Byte)buffer.Length);
stream.Write(buffer, 0, buffer.Length);
// 之前的每个加上str
- for (int j = 0; j < values.Count; j++) values[j] += "." + ss[i];
+ for (var j = 0; j < values.Count; j++) values[j] += "." + ss[i];
// 加入当前项
keys.Add((Int32)(offset + p));
@@ -181,7 +181,7 @@ namespace NewLife.Net.DNS
}
if (!isRef) stream.WriteByte((Byte)0);
- for (int i = 0; i < keys.Count; i++)
+ for (var i = 0; i < keys.Count; i++)
{
Keys.Add(keys[i]);
Values.Add(values[i]);
diff --git a/NewLife.Net/DNS/DNSOpcodeType.cs b/NewLife.Net/DNS/DNSOpcodeType.cs
index edb727d..010177b 100644
--- a/NewLife.Net/DNS/DNSOpcodeType.cs
+++ b/NewLife.Net/DNS/DNSOpcodeType.cs
@@ -6,7 +6,7 @@ namespace NewLife.Net.DNS
/// The Query Types (OPCODE) that specifies kind of query in a message.
/// (RFC 1035 4.1.1 and 1002 4.2.1.1)
/// </summary>
- public enum DNSOpcodeType : byte
+ public enum DNSOpcodeType : Byte
{
/// <summary>A standard query (QUERY); used for NetBIOS, too</summary>
Query = 0,
diff --git a/NewLife.Net/DNS/DNSQueryType.cs b/NewLife.Net/DNS/DNSQueryType.cs
index 410e579..eec4e19 100644
--- a/NewLife.Net/DNS/DNSQueryType.cs
+++ b/NewLife.Net/DNS/DNSQueryType.cs
@@ -2,7 +2,7 @@
namespace NewLife.Net.DNS
{
/// <summary>查询的资源记录类型</summary>
- public enum DNSQueryType : ushort
+ public enum DNSQueryType : System.UInt16
{
/// <summary>指定计算机 IP 地址。</summary>
A = 0x01,
@@ -78,7 +78,7 @@ namespace NewLife.Net.DNS
}
/// <summary>指定信息的协议组</summary>
- public enum DNSQueryClass : ushort
+ public enum DNSQueryClass : System.UInt16
{
/// <summary>指定 Internet 类别。</summary>
IN = 0x01,
diff --git a/NewLife.Net/DNS/DNSRecord.cs b/NewLife.Net/DNS/DNSRecord.cs
index 0d159cf..5809056 100644
--- a/NewLife.Net/DNS/DNSRecord.cs
+++ b/NewLife.Net/DNS/DNSRecord.cs
@@ -25,7 +25,7 @@ namespace NewLife.Net.DNS
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString() { return String.Format("{0} {1}", Type, Name); }
+ public override String ToString() { return String.Format("{0} {1}", Type, Name); }
#endregion
}
@@ -78,12 +78,12 @@ namespace NewLife.Net.DNS
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString() { return String.Format("{0} {1}", Type, Text ?? Name); }
+ public override String ToString() { return String.Format("{0} {1}", Type, Text ?? Name); }
#endregion
#region IMemberAccessor 成员
- bool IMemberAccessor.Read(IFormatterX fm, MemberInfo member)
+ Boolean IMemberAccessor.Read(IFormatterX fm, MemberInfo member)
{
if (member.Name == "_Type")
{
diff --git a/NewLife.Net/DNS/DNSServer.cs b/NewLife.Net/DNS/DNSServer.cs
index c4aad54..6b48366 100644
--- a/NewLife.Net/DNS/DNSServer.cs
+++ b/NewLife.Net/DNS/DNSServer.cs
@@ -68,7 +68,7 @@ namespace NewLife.Net.DNS
var list = new HashSet<String>(ps.Select(p => p.ToString()), StringComparer.OrdinalIgnoreCase);
//ps.Clear();
- for (int i = ss.Length - 1; i >= 0; i--)
+ for (var i = ss.Length - 1; i >= 0; i--)
{
try
{
@@ -130,7 +130,7 @@ namespace NewLife.Net.DNS
_Clients = null;
}
- DictionaryCache<String, DNSEntity> cache = new DictionaryCache<string, DNSEntity>() { Expire = 600, Asynchronous = true, CacheDefault = false };
+ DictionaryCache<String, DNSEntity> cache = new DictionaryCache<String, DNSEntity>() { Expire = 600, Asynchronous = true, CacheDefault = false };
/// <summary>接收处理</summary>
/// <param name="session"></param>
diff --git a/NewLife.Net/DNS/NetBIOS.cs b/NewLife.Net/DNS/NetBIOS.cs
index 046966e..7773104 100644
--- a/NewLife.Net/DNS/NetBIOS.cs
+++ b/NewLife.Net/DNS/NetBIOS.cs
@@ -11,7 +11,7 @@ namespace NewLife.Net.DNS
/// <summary>查询名称</summary>
/// <param name="name">名称</param>
/// <returns></returns>
- public IPAddress QueryName(string name)
+ public IPAddress QueryName(String name)
{
//DnsRequest request = new DnsRequest(new Question(EncodeName(name), DnsType.NB, DnsClass.IN));
var request = new DNSEntity();
@@ -34,7 +34,7 @@ namespace NewLife.Net.DNS
/// <param name="name">名称</param>
/// <param name="address"></param>
/// <returns></returns>
- public bool Register(string name, IPAddress address)
+ public Boolean Register(String name, IPAddress address)
{
//DnsRequest request = new DnsRequest(new Question(EncodeName(name), DnsType.NB, DnsClass.IN));
var request = new DNSEntity();
@@ -57,20 +57,20 @@ namespace NewLife.Net.DNS
return true;
}
- static string EncodeName(string domain)
+ static String EncodeName(String domain)
{
var sb = new StringBuilder();
domain = domain.PadRight(16, ' ');
//foreach (char c in domain + " ".Substring(0, 16 - domain.Length))
- foreach (char c in domain)
+ foreach (var c in domain)
{
- byte b = (byte)c;
- char x = (char)((byte)'A' + (((byte)c & 0xF0) >> 4));
+ var b = (Byte)c;
+ var x = (Char)((Byte)'A' + (((Byte)c & 0xF0) >> 4));
sb.Append(x);
- x = (char)((byte)'A' + ((byte)c & 0x0F));
+ x = (Char)((Byte)'A' + ((Byte)c & 0x0F));
sb.Append(x);
}
@@ -80,14 +80,14 @@ namespace NewLife.Net.DNS
DNSEntity Invoke(DNSEntity request) { return Invoke(request, true); }
- private static readonly int _maxRetryAttemps = 2;
- internal DNSEntity Invoke(DNSEntity request, bool isQuery)
+ private static readonly Int32 _maxRetryAttemps = 2;
+ internal DNSEntity Invoke(DNSEntity request, Boolean isQuery)
{
- int attempts = 0;
+ var attempts = 0;
while (attempts <= _maxRetryAttemps)
{
- byte[] bytes = request.GetStream(false).ReadBytes();
+ var bytes = request.GetStream(false).ReadBytes();
if (bytes.Length > 512)
throw new ArgumentException("RFC 1035 2.3.4 states that the maximum size of a UDP datagram is 512 octets (bytes).");
@@ -108,12 +108,12 @@ namespace NewLife.Net.DNS
// Messages carried by UDP are restricted to 512 bytes (not counting the IP
// or UDP headers). Longer messages are truncated and the TC bit is set in
// the header. (RFC 1035 4.2.1)
- byte[] responseMessage = new byte[512];
+ var responseMessage = new Byte[512];
//int numBytes = socket.Receive(responseMessage);
- EndPoint ep = (EndPoint)new IPEndPoint(new IPAddress(4294967295), 137);
- int numBytes = socket.ReceiveFrom(responseMessage, ref ep);
+ var ep = (EndPoint)new IPEndPoint(new IPAddress(4294967295), 137);
+ var numBytes = socket.ReceiveFrom(responseMessage, ref ep);
if (numBytes == 0 || numBytes > 512)
throw new Exception("RFC 1035 2.3.4 states that the maximum size of a UDP datagram is 512 octets (bytes).");
diff --git a/NewLife.Net/Flash/SandBoxServer.cs b/NewLife.Net/Flash/SandBoxServer.cs
index eb86f69..70e4994 100644
--- a/NewLife.Net/Flash/SandBoxServer.cs
+++ b/NewLife.Net/Flash/SandBoxServer.cs
@@ -9,9 +9,9 @@ namespace NewLife.Net
public class SandBoxServer : NetServer
{
#region 属性
- private string _Policy = "<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>\0";
+ private String _Policy = "<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>\0";
/// <summary>安全策略文件内容</summary>
- public string Policy { get { return _Policy; } set { _Policy = value; } }
+ public String Policy { get { return _Policy; } set { _Policy = value; } }
#endregion
/// <summary>实例化一个安全沙箱服务器</summary>
@@ -25,7 +25,7 @@ namespace NewLife.Net
/// <param name="stream"></param>
protected override void OnReceive(INetSession session, Stream stream)
{
- string sss = stream.ToStr();
+ var sss = stream.ToStr();
if (sss == "<policy-file-request/>\0")
{
session.Send(System.Text.Encoding.UTF8.GetBytes(_Policy.ToCharArray()));
diff --git a/NewLife.Net/Http/HttpCache.cs b/NewLife.Net/Http/HttpCache.cs
index 21588c2..8474c4b 100644
--- a/NewLife.Net/Http/HttpCache.cs
+++ b/NewLife.Net/Http/HttpCache.cs
@@ -18,7 +18,7 @@ namespace NewLife.Net.Http
{
get
{
- if (_Items == null) _Items = new DictionaryCache<string, HttpCacheItem>(StringComparer.OrdinalIgnoreCase) { Expire = Expriod };
+ if (_Items == null) _Items = new DictionaryCache<String, HttpCacheItem>(StringComparer.OrdinalIgnoreCase) { Expire = Expriod };
return _Items;
}
set { _Items = value; }
@@ -48,7 +48,7 @@ namespace NewLife.Net.Http
public HttpCacheItem Add(HttpHeader request, HttpHeader response)
{
- String url = request.RawUrl;
+ var url = request.RawUrl;
var item = new HttpCacheItem() { Url = url, Request = request, Response = response };
item.Stream = response.GetStream();
//lock (Items)
diff --git a/NewLife.Net/Http/HttpHeader.cs b/NewLife.Net/Http/HttpHeader.cs
index 7fae0de..9d41c28 100644
--- a/NewLife.Net/Http/HttpHeader.cs
+++ b/NewLife.Net/Http/HttpHeader.cs
@@ -201,7 +201,7 @@ namespace NewLife.Net.Http
_last = null;
}
- Int32 p = line.IndexOf(":");
+ var p = line.IndexOf(":");
if (p < 0) throw new NetException("无法处理的头部名值对!{0}", line);
Headers[line.Substring(0, p).Trim()] = line.Substring(p + 1).Trim();
}
@@ -257,7 +257,7 @@ namespace NewLife.Net.Http
/// <summary>已重载。以文本形式呈现整个头部</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (!IsResponse)
return String.Format("{0} {1} {2}", Method, RawUrl, Version);
@@ -267,9 +267,9 @@ namespace NewLife.Net.Http
/// <summary>文本形式</summary>
/// <returns></returns>
- public string ToText()
+ public String ToText()
{
- StringBuilder sb = new StringBuilder();
+ var sb = new StringBuilder();
if (!IsResponse)
sb.AppendFormat("{0} {1} {2}", Method, Url, Version);
else
diff --git a/NewLife.Net/IO/FileClient.cs b/NewLife.Net/IO/FileClient.cs
index b68377d..8ed22ff 100644
--- a/NewLife.Net/IO/FileClient.cs
+++ b/NewLife.Net/IO/FileClient.cs
@@ -16,7 +16,7 @@ namespace NewLife.Net.IO
#region 构造
/// <summary>销毁客户端</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -68,7 +68,7 @@ namespace NewLife.Net.IO
/// <param name="directoryName"></param>
public void SendDirectory(String directoryName)
{
- foreach (String item in Directory.GetFiles(directoryName, "*.*", SearchOption.AllDirectories))
+ foreach (var item in Directory.GetFiles(directoryName, "*.*", SearchOption.AllDirectories))
{
SendFile(item, directoryName);
}
diff --git a/NewLife.Net/IO/FileServer.cs b/NewLife.Net/IO/FileServer.cs
index c2821ee..259e413 100644
--- a/NewLife.Net/IO/FileServer.cs
+++ b/NewLife.Net/IO/FileServer.cs
@@ -27,7 +27,7 @@ namespace NewLife.Net.IO
/// <summary>附加服务器</summary>
/// <param name="server"></param>
/// <returns></returns>
- public override bool AttachServer(ISocketServer server)
+ public override Boolean AttachServer(ISocketServer server)
{
// 接收文件需要顺序
if (server is TcpServer)
@@ -100,7 +100,7 @@ namespace NewLife.Net.IO
/// <summary>销毁会话</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
diff --git a/NewLife.Net/Modbus/Errors.cs b/NewLife.Net/Modbus/Errors.cs
index 7f31411..1cab093 100644
--- a/NewLife.Net/Modbus/Errors.cs
+++ b/NewLife.Net/Modbus/Errors.cs
@@ -2,7 +2,7 @@
namespace NewLife.Net.Modbus
{
/// <summary>错误代码</summary>
- public enum Errors : byte
+ public enum Errors : System.Byte
{
/// <summary>错误的功能代码</summary>
FunctionCode = 1,
diff --git a/NewLife.Net/Modbus/IOHelper.cs b/NewLife.Net/Modbus/IOHelper.cs
index a7e997f..b90c7f5 100644
--- a/NewLife.Net/Modbus/IOHelper.cs
+++ b/NewLife.Net/Modbus/IOHelper.cs
@@ -76,12 +76,12 @@ namespace NewLife.Net.Modbus
/// <param name="offset">偏移</param>
/// <param name="count">数量</param>
/// <returns></returns>
- public static UInt16 Crc(this Byte[] data, Int32 offset, int count = -1)
+ public static UInt16 Crc(this Byte[] data, Int32 offset, Int32 count = -1)
{
if (data == null || data.Length < 1) return 0;
UInt16 u = 0xFFFF;
- byte b;
+ Byte b;
if (count == 0) count = data.Length - offset;
diff --git a/NewLife.Net/Modbus/MBFunction.cs b/NewLife.Net/Modbus/MBFunction.cs
index 69156c4..723526d 100644
--- a/NewLife.Net/Modbus/MBFunction.cs
+++ b/NewLife.Net/Modbus/MBFunction.cs
@@ -2,7 +2,7 @@
namespace NewLife.Net.Modbus
{
/// <summary>Modbus功能码</summary>
- public enum MBFunction : byte
+ public enum MBFunction : System.Byte
{
/// <summary>读取线圈状态。取得一组逻辑线圈的当前状态(ON/OFF) </summary>
ReadCoils = 1,
diff --git a/NewLife.Net/Modbus/ModbusEntity.cs b/NewLife.Net/Modbus/ModbusEntity.cs
index 01821f3..0c5af01 100644
--- a/NewLife.Net/Modbus/ModbusEntity.cs
+++ b/NewLife.Net/Modbus/ModbusEntity.cs
@@ -131,7 +131,7 @@ namespace NewLife.Net.Modbus
#region 辅助
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return Function.ToString();
}
diff --git a/NewLife.Net/Modbus/ModbusException.cs b/NewLife.Net/Modbus/ModbusException.cs
index 7651369..0577ce0 100644
--- a/NewLife.Net/Modbus/ModbusException.cs
+++ b/NewLife.Net/Modbus/ModbusException.cs
@@ -15,7 +15,7 @@ namespace NewLife.Net.Modbus
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return "Modbus Error " + Error;
}
diff --git a/NewLife.Net/Modbus/ModbusMaster.cs b/NewLife.Net/Modbus/ModbusMaster.cs
index 337c260..c94e6db 100644
--- a/NewLife.Net/Modbus/ModbusMaster.cs
+++ b/NewLife.Net/Modbus/ModbusMaster.cs
@@ -227,7 +227,7 @@ namespace NewLife.Net.Modbus
// 元素存放于m字节n位
var m = n = 0;
- for (int i = 0; i < flags.Length; i++)
+ for (var i = 0; i < flags.Length; i++)
{
if (flags[i]) buf[5 + m] |= (Byte)(1 << n);
@@ -302,7 +302,7 @@ namespace NewLife.Net.Modbus
if (1 + count > rs.Data.Length) count = (UInt16)(rs.Data.Length - 1);
var ds = new UInt16[count / 2];
- for (int i = 0; i < ds.Length; i++)
+ for (var i = 0; i < ds.Length; i++)
{
ds[i] = rs.Data.ReadUInt16(1 + i * 2);
}
@@ -352,7 +352,7 @@ namespace NewLife.Net.Modbus
// 字节计数
buf[4] = (Byte)(vals.Length * 2);
- for (int i = 0; i < vals.Length; i++)
+ for (var i = 0; i < vals.Length; i++)
{
buf.WriteUInt16(5 + i * 2, vals[i]);
}
diff --git a/NewLife.Net/Modbus/ModbusSlave.cs b/NewLife.Net/Modbus/ModbusSlave.cs
index 3f9a8eb..00b0ef3 100644
--- a/NewLife.Net/Modbus/ModbusSlave.cs
+++ b/NewLife.Net/Modbus/ModbusSlave.cs
@@ -62,7 +62,7 @@ namespace NewLife.Net.Modbus
if (disposing) GC.SuppressFinalize(this);
//if (Transport != null) Transport.Dispose();
- for (int i = 0; i < Transports.Length; i++)
+ for (var i = 0; i < Transports.Length; i++)
{
if (Transports[i] != null) Transports[i].Dispose();
}
@@ -77,7 +77,7 @@ namespace NewLife.Net.Modbus
if (transport == null) throw new ArgumentNullException("transport");
// 找到一个空位,放入数组
- for (int i = 0; i < Transports.Length; i++)
+ for (var i = 0; i < Transports.Length; i++)
{
if (Transports[i] == null)
{
@@ -358,7 +358,7 @@ namespace NewLife.Net.Modbus
// 元素存放于m字节n位
Int32 m = 0, n = 0;
- for (int i = 0; i < size; i++)
+ for (var i = 0; i < size; i++)
{
// 数据位于5+m字节的n位
var flag = ((data[5 + m] >> n) & 0x01) == 0x01;
@@ -485,7 +485,7 @@ namespace NewLife.Net.Modbus
//store.Write(addr, val);
var count = 0;
// 支持多字连续写入
- for (int i = 2; i + 1 < data.Length; i += 2, count++)
+ for (var i = 2; i + 1 < data.Length; i += 2, count++)
{
store.Write(addr + count, data.ReadUInt16(i));
}
@@ -523,7 +523,7 @@ namespace NewLife.Net.Modbus
WriteLine("WriteMultipleRegisters(0x" + addr.ToString("X2") + ", 0x" + size.ToString("X2") + ")");
#endif
- for (int i = 0; i < size; i++)
+ for (var i = 0; i < size; i++)
{
store.Write(addr + i, data.ReadUInt16(5 + i * 2));
}
diff --git a/NewLife.Net/MQTT/MqttType.cs b/NewLife.Net/MQTT/MqttType.cs
index c9d7408..a68caa2 100644
--- a/NewLife.Net/MQTT/MqttType.cs
+++ b/NewLife.Net/MQTT/MqttType.cs
@@ -5,7 +5,7 @@ using System.Text;
namespace NewLife.Net.MQTT
{
/// <summary>消息类型</summary>
- public enum MqttType : byte
+ public enum MqttType : Byte
{
/// <summary>保留</summary>
Reserved = 0,
diff --git a/NewLife.Net/MQTT/QualityOfService.cs b/NewLife.Net/MQTT/QualityOfService.cs
index 43348ae..760ea19 100644
--- a/NewLife.Net/MQTT/QualityOfService.cs
+++ b/NewLife.Net/MQTT/QualityOfService.cs
@@ -5,7 +5,7 @@ using System.Text;
namespace NewLife.Net.MQTT
{
/// <summary>服务质量</summary>
- public enum QualityOfService : byte
+ public enum QualityOfService : Byte
{
/// <summary>至多一次 发完即丢弃</summary>
Q0 = 0,
diff --git a/NewLife.Net/P2P/P2PClient.cs b/NewLife.Net/P2P/P2PClient.cs
index 129141b..8b2c4cb 100644
--- a/NewLife.Net/P2P/P2PClient.cs
+++ b/NewLife.Net/P2P/P2PClient.cs
@@ -82,7 +82,7 @@ namespace NewLife.Net.P2P
}
}
- void server_Received(object sender, ReceivedEventArgs e)
+ void server_Received(Object sender, ReceivedEventArgs e)
{
var session = sender as ISocketSession;
@@ -97,7 +97,7 @@ namespace NewLife.Net.P2P
IPAddress address = null;
if (!IPAddress.TryParse(ss[0], out address)) return;
- Int32 port = 0;
+ var port = 0;
if (!Int32.TryParse(ss[1], out port)) return;
var ep = new IPEndPoint(address, port);
ParterAddress = ep;
@@ -128,7 +128,7 @@ namespace NewLife.Net.P2P
while (true)
{
Console.Write("请输入要说的话:");
- String line = Console.ReadLine();
+ var line = Console.ReadLine();
if (String.IsNullOrEmpty(line)) continue;
if (line == "exit") break;
@@ -143,7 +143,7 @@ namespace NewLife.Net.P2P
}
}
- void server_Accepted(object sender, SessionEventArgs e)
+ void server_Accepted(Object sender, SessionEventArgs e)
{
var session = e.Session as ISocketSession;
WriteLog("连接到来:{0}", session.Remote);
@@ -176,7 +176,7 @@ namespace NewLife.Net.P2P
}
}
- void client_Received(object sender, ReceivedEventArgs e)
+ void client_Received(Object sender, ReceivedEventArgs e)
{
//WriteLog("数据到来:{0} {1}", e.RemoteIPEndPoint, e.GetString());
@@ -186,7 +186,7 @@ namespace NewLife.Net.P2P
IPAddress address = null;
if (!IPAddress.TryParse(ss[0], out address)) return;
- Int32 port = 0;
+ var port = 0;
if (!Int32.TryParse(ss[1], out port)) return;
var ep = new IPEndPoint(address, port);
ParterAddress = ep;
@@ -218,7 +218,7 @@ namespace NewLife.Net.P2P
}
}
- void client_Received2(object sender, ReceivedEventArgs e)
+ void client_Received2(Object sender, ReceivedEventArgs e)
{
var session = sender as ISocketSession;
WriteLog("数据到来2:{0} {1}", session.Remote, e.Stream.ToStr());
diff --git a/NewLife.Net/Proxy/HttpProxy.cs b/NewLife.Net/Proxy/HttpProxy.cs
index dc87d9f..3b40f7e 100644
--- a/NewLife.Net/Proxy/HttpProxy.cs
+++ b/NewLife.Net/Proxy/HttpProxy.cs
@@ -488,11 +488,11 @@ namespace NewLife.Net.Proxy
base.OnReceiveRemote(e);
}
- static readonly HashSet<String> cacheSuffix = new HashSet<string>(
+ static readonly HashSet<String> cacheSuffix = new HashSet<String>(
new String[] { ".htm", ".html", ".js", ".css", ".jpg", ".png", ".gif", ".swf" },
StringComparer.OrdinalIgnoreCase);
- static readonly HashSet<String> cacheContentType = new HashSet<string>(
+ static readonly HashSet<String> cacheContentType = new HashSet<String>(
new String[] { "text/css", "application/javascript", "text/javascript", "application/x-javascript", "image/jpeg", "image/png", "image/gif" },
StringComparer.OrdinalIgnoreCase);
@@ -554,7 +554,7 @@ namespace NewLife.Net.Proxy
#region 浏览器代理
struct Struct_INTERNET_PROXY_INFO
{
- public int dwAccessType;
+ public Int32 dwAccessType;
public IntPtr proxy;
public IntPtr proxyBypass;
}
@@ -566,7 +566,7 @@ namespace NewLife.Net.Proxy
/// <param name="lpdwBufferLength"></param>
/// <returns></returns>
[DllImport("wininet.dll", SetLastError = true)]
- private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);
+ private static extern Boolean InternetSetOption(IntPtr hInternet, Int32 dwOption, IntPtr lpBuffer, Int32 lpdwBufferLength);
/// <summary>获取IE代理设置</summary>
public static String GetIEProxy()
@@ -586,13 +586,13 @@ namespace NewLife.Net.Proxy
/// <summary>设置IE代理。传入空地址取消代理设置</summary>
/// <param name="proxy">地址与端口以冒号分开</param>
/// <param name="proxyOverride">代理是否跳过本地地址</param>
- public static void SetIEProxy(string proxy, Boolean proxyOverride = true)
+ public static void SetIEProxy(String proxy, Boolean proxyOverride = true)
{
- const int INTERNET_OPTION_PROXY = 38;
- const int INTERNET_OPEN_TYPE_PROXY = 3;
- const int INTERNET_OPEN_TYPE_DIRECT = 1;
+ const Int32 INTERNET_OPTION_PROXY = 38;
+ const Int32 INTERNET_OPEN_TYPE_PROXY = 3;
+ const Int32 INTERNET_OPEN_TYPE_DIRECT = 1;
- Boolean isCancel = String.IsNullOrEmpty(proxy);
+ var isCancel = String.IsNullOrEmpty(proxy);
Struct_INTERNET_PROXY_INFO info;
@@ -602,12 +602,12 @@ namespace NewLife.Net.Proxy
info.proxyBypass = Marshal.StringToHGlobalAnsi("local");
// 分配内存
- IntPtr ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf(info));
+ var ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf(info));
// 获取结构体指针
Marshal.StructureToPtr(info, ptr, true);
- RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
+ var key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
if (!isCancel)
{
key.SetValue("ProxyServer", proxy);
@@ -625,8 +625,8 @@ namespace NewLife.Net.Proxy
{
InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, ptr, Marshal.SizeOf(info));
- const int INTERNET_OPTION_REFRESH = 0x000025;
- const int INTERNET_OPTION_SETTINGS_CHANGED = 0x000027;
+ const Int32 INTERNET_OPTION_REFRESH = 0x000025;
+ const Int32 INTERNET_OPTION_SETTINGS_CHANGED = 0x000027;
InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
}
diff --git a/NewLife.Net/Proxy/HttpReverseProxy.cs b/NewLife.Net/Proxy/HttpReverseProxy.cs
index 875e07b..ed5a65d 100644
--- a/NewLife.Net/Proxy/HttpReverseProxy.cs
+++ b/NewLife.Net/Proxy/HttpReverseProxy.cs
@@ -88,7 +88,7 @@ namespace NewLife.Net.Proxy
var r = entity.Referer;
if (!String.IsNullOrEmpty(r))
{
- Uri ri = new Uri(r, UriKind.RelativeOrAbsolute);
+ var ri = new Uri(r, UriKind.RelativeOrAbsolute);
if (ri.IsAbsoluteUri && ri.Authority == RawHost)
{
r = r.Replace(RawHost, host);
diff --git a/NewLife.Net/Proxy/IProxySession.cs b/NewLife.Net/Proxy/IProxySession.cs
index ec53564..125e834 100644
--- a/NewLife.Net/Proxy/IProxySession.cs
+++ b/NewLife.Net/Proxy/IProxySession.cs
@@ -33,7 +33,7 @@ namespace NewLife.Net.Proxy
/// <param name="buffer">缓冲区</param>
/// <param name="offset">位移</param>
/// <param name="size">写入字节数</param>
- IProxySession SendRemote(byte[] buffer, int offset = 0, int size = -1);
+ IProxySession SendRemote(Byte[] buffer, Int32 offset = 0, Int32 size = -1);
/// <summary>发送数据流</summary>
/// <param name="stream"></param>
@@ -43,7 +43,7 @@ namespace NewLife.Net.Proxy
/// <summary>发送字符串</summary>
/// <param name="msg"></param>
/// <param name="encoding"></param>
- IProxySession SendRemote(string msg, Encoding encoding = null);
+ IProxySession SendRemote(String msg, Encoding encoding = null);
#endregion
}
}
\ No newline at end of file
diff --git a/NewLife.Net/Proxy/ProxySession.cs b/NewLife.Net/Proxy/ProxySession.cs
index 1439260..1667078 100644
--- a/NewLife.Net/Proxy/ProxySession.cs
+++ b/NewLife.Net/Proxy/ProxySession.cs
@@ -49,7 +49,7 @@ namespace NewLife.Net.Proxy
/// <summary>子类重载实现资源释放逻辑时必须首先调用基类方法</summary>
/// <param name="disposing">从Dispose调用(释放所有资源)还是析构函数调用(释放非托管资源)</param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -151,7 +151,7 @@ namespace NewLife.Net.Proxy
/// <param name="client"></param>
protected virtual void OnRemoteDispose(ISocketClient client) { Dispose(); }
- void Remote_Received(object sender, ReceivedEventArgs e)
+ void Remote_Received(Object sender, ReceivedEventArgs e)
{
if (Disposed) return;
@@ -201,7 +201,7 @@ namespace NewLife.Net.Proxy
/// <param name="buffer">缓冲区</param>
/// <param name="offset">位移</param>
/// <param name="size">写入字节数</param>
- public virtual IProxySession SendRemote(byte[] buffer, int offset = 0, int size = -1)
+ public virtual IProxySession SendRemote(Byte[] buffer, Int32 offset = 0, Int32 size = -1)
{
try
{
@@ -251,7 +251,7 @@ namespace NewLife.Net.Proxy
/// <summary></summary>
/// <param name="sender"></param>
/// <param name="e"></param>
- protected override void OnError(object sender, ExceptionEventArgs e)
+ protected override void OnError(Object sender, ExceptionEventArgs e)
{
if (e.Exception != null) Dispose();
}
@@ -295,7 +295,7 @@ namespace NewLife.Net.Proxy
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString() { return base.ToString() + "=>" + RemoteServerUri; }
+ public override String ToString() { return base.ToString() + "=>" + RemoteServerUri; }
#endregion
}
}
\ No newline at end of file
diff --git a/NewLife.Net/Sdp/SdpAttribute.cs b/NewLife.Net/Sdp/SdpAttribute.cs
index 95a1cb2..35b43b5 100644
--- a/NewLife.Net/Sdp/SdpAttribute.cs
+++ b/NewLife.Net/Sdp/SdpAttribute.cs
@@ -23,8 +23,8 @@ namespace NewLife.Net.Sdp
{
if (String.IsNullOrEmpty(value)) throw new ArgumentNullException("value");
- Int32 p = value.IndexOf("=");
- Int32 p2 = value.IndexOf(":", p);
+ var p = value.IndexOf("=");
+ var p2 = value.IndexOf(":", p);
var entity = new SdpAttribute();
if (p2 > 0)
@@ -40,7 +40,7 @@ namespace NewLife.Net.Sdp
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (String.IsNullOrEmpty(Value))
return String.Format("a={0}", Name);
diff --git a/NewLife.Net/Sdp/SdpConnection.cs b/NewLife.Net/Sdp/SdpConnection.cs
index c446826..696f8b4 100644
--- a/NewLife.Net/Sdp/SdpConnection.cs
+++ b/NewLife.Net/Sdp/SdpConnection.cs
@@ -33,7 +33,7 @@ namespace NewLife.Net.Sdp
value = value.Substring(2);
- string[] values = value.Split(' ');
+ var values = value.Split(' ');
if (values.Length != 3) throw new NetException("Invalid SDP Connection('c=') value '" + value + "'.");
var entity = new SdpConnection();
@@ -46,7 +46,7 @@ namespace NewLife.Net.Sdp
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return "c=" + NetType + " " + AddressType + " " + Address + "\r\n";
}
diff --git a/NewLife.Net/Sdp/SdpMediaDescription.cs b/NewLife.Net/Sdp/SdpMediaDescription.cs
index 5e325f5..f1df62b 100644
--- a/NewLife.Net/Sdp/SdpMediaDescription.cs
+++ b/NewLife.Net/Sdp/SdpMediaDescription.cs
@@ -64,12 +64,12 @@ namespace NewLife.Net.Sdp
/// <summary>分析</summary>
/// <param name="value">数值</param>
/// <returns></returns>
- public static SdpMediaDescription Parse(string value)
+ public static SdpMediaDescription Parse(String value)
{
var media = new SdpMediaDescription();
// m=<media> <port>/<number of ports> <proto> <fmt> ...
- Int32 p = value.IndexOf("=");
+ var p = value.IndexOf("=");
value = value.Substring(p + 1);
var vs = value.Split(" ");
@@ -84,7 +84,7 @@ namespace NewLife.Net.Sdp
var word = vs[1];
if (word.IndexOf('/') > -1)
{
- string[] words = word.Split('/');
+ var words = word.Split('/');
media.Port = Convert.ToInt32(words[0]);
media.NumberOfPorts = Convert.ToInt32(words[1]);
}
@@ -100,7 +100,7 @@ namespace NewLife.Net.Sdp
media.Protocol = vs[2];
//--- <fmt> ----------------------------------------------------------------
- for (int i = 3; i < vs.Length; i++)
+ for (var i = 3; i < vs.Length; i++)
{
media.MediaFormats.Add(vs[i]);
}
@@ -110,7 +110,7 @@ namespace NewLife.Net.Sdp
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
/*
m= (media name and transport address)
@@ -123,7 +123,7 @@ namespace NewLife.Net.Sdp
// m=<media> <port>/<number of ports> <proto> <fmt> ...
- StringBuilder retVal = new StringBuilder();
+ var retVal = new StringBuilder();
if (NumberOfPorts > 1)
{
retVal.Append("m=" + MediaType + " " + Port + "/" + NumberOfPorts + " " + Protocol);
@@ -132,7 +132,7 @@ namespace NewLife.Net.Sdp
{
retVal.Append("m=" + MediaType + " " + Port + " " + Protocol);
}
- foreach (string mediaFormat in MediaFormats)
+ foreach (var mediaFormat in MediaFormats)
{
retVal.Append(" " + mediaFormat);
}
diff --git a/NewLife.Net/Sdp/SdpOrigin.cs b/NewLife.Net/Sdp/SdpOrigin.cs
index 81a1e3d..2e14263 100644
--- a/NewLife.Net/Sdp/SdpOrigin.cs
+++ b/NewLife.Net/Sdp/SdpOrigin.cs
@@ -35,7 +35,7 @@ namespace NewLife.Net.Sdp
/// <summary>分析</summary>
/// <param name="value">Origin value.</param>
/// <returns>Returns parsed SDP Origin.</returns>
- public static SdpOrigin Parse(string value)
+ public static SdpOrigin Parse(String value)
{
if (value == null) throw new ArgumentNullException("value");
@@ -48,7 +48,7 @@ namespace NewLife.Net.Sdp
value = value.Substring(2);
- string[] values = value.Split(' ');
+ var values = value.Split(' ');
if (values.Length != 6) throw new NetException("Invalid SDP Origin('o=') value '" + value + "'.");
var so = new SdpOrigin();
@@ -63,7 +63,7 @@ namespace NewLife.Net.Sdp
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return "o=" + UserName + " " + SessionID + " " + SessionVersion + " " + NetType + " " + AddressType + " " + UnicastAddress + "\r\n";
}
diff --git a/NewLife.Net/Sdp/SdpTime.cs b/NewLife.Net/Sdp/SdpTime.cs
index 9aaee64..e748e66 100644
--- a/NewLife.Net/Sdp/SdpTime.cs
+++ b/NewLife.Net/Sdp/SdpTime.cs
@@ -19,7 +19,7 @@ namespace NewLife.Net.Sdp
/// <summary>分析</summary>
/// <param name="value">数值</param>
/// <returns></returns>
- public static SdpTime Parse(string value)
+ public static SdpTime Parse(String value)
{
if (value == null) throw new ArgumentNullException("value");
@@ -29,7 +29,7 @@ namespace NewLife.Net.Sdp
value = value.Substring(2);
- string[] values = value.Split(' ');
+ var values = value.Split(' ');
if (values.Length != 2) throw new NetException("Invalid SDP Time('t=') value '" + value + "'.");
var entity = new SdpTime();
@@ -40,7 +40,7 @@ namespace NewLife.Net.Sdp
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return "t=" + StartTime + " " + StopTime + "\r\n";
}
diff --git a/NewLife.Net/SGIP/SGIPBind.cs b/NewLife.Net/SGIP/SGIPBind.cs
index 48d0fcd..c7d9634 100644
--- a/NewLife.Net/SGIP/SGIPBind.cs
+++ b/NewLife.Net/SGIP/SGIPBind.cs
@@ -34,7 +34,7 @@ namespace NewLife.Net.SGIP
}
/// <summary>Bind操作,登录类型。</summary>
- public enum LoginTypes : byte
+ public enum LoginTypes : Byte
{
/// <summary>1:SP向SMG建立的连接,用于发送命令</summary>
SpToSmg = 1,
diff --git a/NewLife.Net/SGIP/SGIPClient.cs b/NewLife.Net/SGIP/SGIPClient.cs
index ae05bc5..e57dc01 100644
--- a/NewLife.Net/SGIP/SGIPClient.cs
+++ b/NewLife.Net/SGIP/SGIPClient.cs
@@ -72,7 +72,7 @@ namespace NewLife.Net.SGIP
}
catch (Exception ex)
{
- String str = IP + ":" + Port.ToString();
+ var str = IP + ":" + Port.ToString();
throw new NetException("连接网关服务器" + str + "出错,请确定网络是否畅通!" + ex.Message, ex);
}
@@ -102,7 +102,7 @@ namespace NewLife.Net.SGIP
return true;
}
- void Client_Received(object sender, ReceivedEventArgs e)
+ void Client_Received(Object sender, ReceivedEventArgs e)
{
}
#endregion
@@ -118,7 +118,7 @@ namespace NewLife.Net.SGIP
if (!target.StartsWith("86")) target = "86" + target;
var cmd = new SGIPSubmit();
- String id = SystemID;
+ var id = SystemID;
if (id.Length > 4) id = SystemID.Substring(4);
cmd.SPNumber = SPNumber + id + "4888";
cmd.ChargeNumber = new String('0', 21);
diff --git a/NewLife.Net/SGIP/SGIPDeliver.cs b/NewLife.Net/SGIP/SGIPDeliver.cs
index feaeeca..8a36b89 100644
--- a/NewLife.Net/SGIP/SGIPDeliver.cs
+++ b/NewLife.Net/SGIP/SGIPDeliver.cs
@@ -49,7 +49,7 @@ namespace NewLife.Net.SGIP
}
/// <summary>短消息的编码格式。</summary>
- public enum SGIPMessageCodings : byte
+ public enum SGIPMessageCodings : Byte
{
/// <summary>0:纯ASCII字符串</summary>
Ascii = 0,
diff --git a/NewLife.Net/SGIP/SGIPEntity.cs b/NewLife.Net/SGIP/SGIPEntity.cs
index 2d03305..cce8ace 100644
--- a/NewLife.Net/SGIP/SGIPEntity.cs
+++ b/NewLife.Net/SGIP/SGIPEntity.cs
@@ -33,7 +33,7 @@ namespace NewLife.Net.SGIP
/// <summary>实例化</summary>
public SGIPEntity()
{
- DateSequence = (uint)(DateTime.Now.Month * 100000000 +
+ DateSequence = (UInt32)(DateTime.Now.Month * 100000000 +
DateTime.Now.Day * 1000000 +
DateTime.Now.Hour * 10000 +
DateTime.Now.Minute * 100 +
@@ -135,7 +135,7 @@ namespace NewLife.Net.SGIP
}
/// <summary>指令枚举</summary>
- public enum SGIPCommands : uint
+ public enum SGIPCommands : UInt32
{
/// <summary>绑定</summary>
Bind = 0x1,
@@ -186,7 +186,7 @@ namespace NewLife.Net.SGIP
}
/// <summary>错误代码</summary>
- public enum SGIPErrorCodes : byte
+ public enum SGIPErrorCodes : Byte
{
/// <summary>无错误,命令正确接收</summary>
[Description("无错误,命令正确接收")]
diff --git a/NewLife.Net/SGIP/SGIPReport.cs b/NewLife.Net/SGIP/SGIPReport.cs
index 6b2755c..3393733 100644
--- a/NewLife.Net/SGIP/SGIPReport.cs
+++ b/NewLife.Net/SGIP/SGIPReport.cs
@@ -49,7 +49,7 @@ namespace NewLife.Net.SGIP
}
/// <summary>Report命令类型</summary>
- public enum SGIPReportTypes : byte
+ public enum SGIPReportTypes : Byte
{
/// <summary>0:对先前一条Submit命令的状态报告</summary>
Submit = 0,
@@ -58,7 +58,7 @@ namespace NewLife.Net.SGIP
}
/// <summary>该命令所涉及的短消息的当前执行状态</summary>
- public enum SGIPReportStates : byte
+ public enum SGIPReportStates : Byte
{
/// <summary>0:发送成功</summary>
Success = 0,
diff --git a/NewLife.Net/SGIP/SGIPSubmit.cs b/NewLife.Net/SGIP/SGIPSubmit.cs
index 8e7bf4a..6590940 100644
--- a/NewLife.Net/SGIP/SGIPSubmit.cs
+++ b/NewLife.Net/SGIP/SGIPSubmit.cs
@@ -117,7 +117,7 @@ namespace NewLife.Net.SGIP
}
/// <summary>代收费标志,0:应收;1:实收</summary>
- public enum SubmitAgentFlags : byte
+ public enum SubmitAgentFlags : Byte
{
/// <summary>0:应收</summary>
SouldIncome = 0,
@@ -126,7 +126,7 @@ namespace NewLife.Net.SGIP
}
/// <summary>状态报告标记</summary>
- public enum SubmitReportFlags : byte
+ public enum SubmitReportFlags : Byte
{
/// <summary>0-该条消息只有最后出错时要返回状态报告</summary>
ErrorReport = 0,
@@ -139,7 +139,7 @@ namespace NewLife.Net.SGIP
}
/// <summary>引起MT消息的原因</summary>
- public enum SubmitMorelatetoMTFlags : byte
+ public enum SubmitMorelatetoMTFlags : Byte
{
/// <summary>0-MO点播引起的第一条MT消息;</summary>
VoteFirst = 0,
@@ -152,7 +152,7 @@ namespace NewLife.Net.SGIP
}
/// <summary>计费类别定义</summary>
- public enum FeeTypes : byte
+ public enum FeeTypes : Byte
{
/// <summary>0 “短消息类型”为“发送”,对“计费用户号码”不计信息费,此类话单仅用于核减SP对称的信道费</summary>
FreeSend = 0,
diff --git a/NewLife.Net/Sip/Message/SipValueWithParams.cs b/NewLife.Net/Sip/Message/SipValueWithParams.cs
index eb801b1..86ad090 100644
--- a/NewLife.Net/Sip/Message/SipValueWithParams.cs
+++ b/NewLife.Net/Sip/Message/SipValueWithParams.cs
@@ -9,7 +9,7 @@ namespace NewLife.Net.Sip.Message
#region 属性
private Dictionary<String, String> _Parameters;
/// <summary>参数集合</summary>
- public IDictionary<String, String> Parameters { get { return _Parameters ?? (_Parameters = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)); } }
+ public IDictionary<String, String> Parameters { get { return _Parameters ?? (_Parameters = new Dictionary<String, String>(StringComparer.OrdinalIgnoreCase)); } }
#endregion
}
}
\ No newline at end of file
diff --git a/NewLife.Net/Stress/TcpStress.cs b/NewLife.Net/Stress/TcpStress.cs
index 0399a1f..771c0e9 100644
--- a/NewLife.Net/Stress/TcpStress.cs
+++ b/NewLife.Net/Stress/TcpStress.cs
@@ -55,7 +55,7 @@ namespace NewLife.Net.Stress
#region 构造
/// <summary>销毁</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -113,10 +113,10 @@ namespace NewLife.Net.Stress
try
{
- Int32 wt = 0;
- Int32 cpt = 0;
+ var wt = 0;
+ var cpt = 0;
ThreadPool.GetAvailableThreads(out wt, out cpt);
- Int32 threads = Process.GetCurrentProcess().Threads.Count;
+ var threads = Process.GetCurrentProcess().Threads.Count;
var color = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
@@ -164,7 +164,7 @@ namespace NewLife.Net.Stress
var interval = cfg.Interval;
XTrace.WriteLine("开始建立连接……");
- for (int i = 0; i < cs.Length; i++)
+ for (var i = 0; i < cs.Length; i++)
{
try
{
@@ -192,7 +192,7 @@ namespace NewLife.Net.Stress
if (_buffer != null && _buffer.Length > 0)
{
XTrace.WriteLine("开始发送数据……");
- for (int i = 0; i < cs.Length; i++)
+ for (var i = 0; i < cs.Length; i++)
{
cs[i].StartSend();
}
@@ -211,7 +211,7 @@ namespace NewLife.Net.Stress
if (cs != null)
{
XTrace.WriteLine("正在关闭连接……");
- for (int i = 0; i < cs.Length; i++)
+ for (var i = 0; i < cs.Length; i++)
{
if (cs[i] != null)
{
diff --git a/NewLife.Net/Stress/TcpStressClient.cs b/NewLife.Net/Stress/TcpStressClient.cs
index 21883c8..d52a718 100644
--- a/NewLife.Net/Stress/TcpStressClient.cs
+++ b/NewLife.Net/Stress/TcpStressClient.cs
@@ -36,7 +36,7 @@ namespace NewLife.Net.Stress
#endregion
#region 构造
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -57,7 +57,7 @@ namespace NewLife.Net.Stress
if (!socket.ConnectAsync(e)) OnConnected(this, e);
}
- private void OnConnected(object sender, SocketAsyncEventArgs e)
+ private void OnConnected(Object sender, SocketAsyncEventArgs e)
{
e.Completed -= OnConnected;
@@ -125,7 +125,7 @@ namespace NewLife.Net.Stress
if (!socket.ReceiveAsync(e)) OnReceived(this, e);
}
- void OnReceived(object sender, SocketAsyncEventArgs e)
+ void OnReceived(Object sender, SocketAsyncEventArgs e)
{
if (e.SocketError != SocketError.Success || e.BytesTransferred <= 0)
{
@@ -133,7 +133,7 @@ namespace NewLife.Net.Stress
return;
}
- if (Received != null) Received(this, new EventArgs<int>(e.BytesTransferred));
+ if (Received != null) Received(this, new EventArgs<Int32>(e.BytesTransferred));
if (!socket.ReceiveAsync(e)) OnReceived(this, e);
}
diff --git a/NewLife.Net/Stun/StunAttribute.cs b/NewLife.Net/Stun/StunAttribute.cs
index fb9bf84..94488a6 100644
--- a/NewLife.Net/Stun/StunAttribute.cs
+++ b/NewLife.Net/Stun/StunAttribute.cs
@@ -83,7 +83,7 @@ namespace NewLife.Net.Stun
if (Data == null || Data.Length < 1) return default(T);
Object value = null;
- Type t = typeof(T);
+ var t = typeof(T);
if (t == typeof(IPEndPoint))
value = EndPoint;
else if (t == typeof(String))
@@ -97,7 +97,7 @@ namespace NewLife.Net.Stun
public void SetValue<T>(T value)
{
Object v = value;
- Type t = typeof(T);
+ var t = typeof(T);
if (t == typeof(IPEndPoint))
EndPoint = (IPEndPoint)v;
else if (t == typeof(String))
@@ -133,7 +133,7 @@ namespace NewLife.Net.Stun
var port = BitConverter.ToUInt16(arr, 0);
// Address
- Byte[] ip = new Byte[4];
+ var ip = new Byte[4];
//data.CopyTo(ip, 4);
Array.Copy(data, 4, ip, 0, ip.Length);
@@ -179,7 +179,7 @@ namespace NewLife.Net.Stun
#endregion
#region 辅助
- public override string ToString()
+ public override String ToString()
{
switch (Type)
{
@@ -216,7 +216,7 @@ namespace NewLife.Net.Stun
}
/// <summary>属性类型</summary>
- enum AttributeType : ushort
+ enum AttributeType : UInt16
{
MappedAddress = 0x0001,
ResponseAddress = 0x0002,
diff --git a/NewLife.Net/Stun/StunClient.cs b/NewLife.Net/Stun/StunClient.cs
index 5adeab7..e2c0016 100644
--- a/NewLife.Net/Stun/StunClient.cs
+++ b/NewLife.Net/Stun/StunClient.cs
@@ -209,7 +209,7 @@ namespace NewLife.Net.Stun
var rto = socket.ReceiveTimeout;
// 如果原端口没有启用地址重用,则关闭它
- Object value = socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress);
+ var value = socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress);
if (!Convert.ToBoolean(value)) socket.Close();
//var sk = NetService.Container.Resolve<ISocketClient>(socket.ProtocolType);
diff --git a/NewLife.Net/Stun/StunMessage.cs b/NewLife.Net/Stun/StunMessage.cs
index 1a802ba..b11d055 100644
--- a/NewLife.Net/Stun/StunMessage.cs
+++ b/NewLife.Net/Stun/StunMessage.cs
@@ -83,14 +83,14 @@ namespace NewLife.Net.Stun
T GetAtt<T>(AttributeType type, Int32 position = 0)
{
- StunAttribute att = GetAtt(type, false);
+ var att = GetAtt(type, false);
if (att == null) return default(T);
Object v = null;
switch (type)
{
case AttributeType.ChangeRequest:
- Int32 d = att.Int;
+ var d = att.Int;
if (position == 0)
v = (d & 4) != 0;
else
@@ -98,7 +98,7 @@ namespace NewLife.Net.Stun
return (T)v;
case AttributeType.ErrorCode:
var data = att.Data;
- Type t = typeof(T);
+ var t = typeof(T);
if (t == typeof(Int32))
v = (data[2] & 0x7) * 100 + (data[3] & 0xFF);
else if (t == typeof(String))
@@ -116,8 +116,8 @@ namespace NewLife.Net.Stun
switch (type)
{
case AttributeType.ChangeRequest:
- Int32 d = att.Int;
- Boolean b = (Boolean)(Object)value;
+ var d = att.Int;
+ var b = (Boolean)(Object)value;
if (position == 0)
{
if (b)
@@ -136,7 +136,7 @@ namespace NewLife.Net.Stun
break;
case AttributeType.ErrorCode:
var data = att.Data;
- Type t = typeof(T);
+ var t = typeof(T);
if (t == typeof(Int32))
{
if (data == null)
@@ -145,7 +145,7 @@ namespace NewLife.Net.Stun
att.Data = data;
data[3] = 4;
}
- data[4] = (Byte)Math.Floor((double)((Int32)(Object)value / 100));
+ data[4] = (Byte)Math.Floor((Double)((Int32)(Object)value / 100));
data[5] = (Byte)((Int32)(Object)value & 0xFF);
}
else if (t == typeof(String))
@@ -306,7 +306,7 @@ namespace NewLife.Net.Stun
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
var tname = Type.ToString().TrimStart("Binding");
if (Atts.Count == 0) return tname;
diff --git a/NewLife.Net/Stun/StunMessageType.cs b/NewLife.Net/Stun/StunMessageType.cs
index 95a4476..746ca46 100644
--- a/NewLife.Net/Stun/StunMessageType.cs
+++ b/NewLife.Net/Stun/StunMessageType.cs
@@ -2,7 +2,7 @@
namespace NewLife.Net.Stun
{
/// <summary>STUN消息类型</summary>
- public enum StunMessageType : ushort
+ public enum StunMessageType : System.UInt16
{
/// <summary>绑定请求</summary>
BindingRequest = 0x0001,
diff --git a/NewLife.Net/Stun/StunResult.cs b/NewLife.Net/Stun/StunResult.cs
index 22dbab2..16687ef 100644
--- a/NewLife.Net/Stun/StunResult.cs
+++ b/NewLife.Net/Stun/StunResult.cs
@@ -20,7 +20,7 @@ namespace NewLife.Net.Stun
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override System.String ToString()
{
return string.Format("{0} {1}", Type, Public);
}
diff --git a/NewLife.Net/Stun/StunServer.cs b/NewLife.Net/Stun/StunServer.cs
index b2cec4b..33e0772 100644
--- a/NewLife.Net/Stun/StunServer.cs
+++ b/NewLife.Net/Stun/StunServer.cs
@@ -194,8 +194,8 @@ namespace NewLife.Net.Stun
// 找另一个
ISocketSession session2 = null;
- Int32 anotherPort = 0;
- for (int i = 0; i < Servers.Count; i++)
+ var anotherPort = 0;
+ for (var i = 0; i < Servers.Count; i++)
{
var server = Servers[i];
if (server.Local.Type == session.Local.Type && server.Local.Port != session.Local.Port)
diff --git a/NewLife.Net/TDP/TDPFlags.cs b/NewLife.Net/TDP/TDPFlags.cs
index 30c30da..d850858 100644
--- a/NewLife.Net/TDP/TDPFlags.cs
+++ b/NewLife.Net/TDP/TDPFlags.cs
@@ -4,7 +4,7 @@ namespace NewLife.Net.TDP
{
/// <summary>TDP标记</summary>
[Flags]
- public enum TDPFlags : byte
+ public enum TDPFlags : Byte
{
/// <summary>发端完成发送任务。</summary>
FIN = 1,
diff --git a/NewLife.Net/UPnP/Entities/Device.cs b/NewLife.Net/UPnP/Entities/Device.cs
index 6c85f0c..da7fe87 100644
--- a/NewLife.Net/UPnP/Entities/Device.cs
+++ b/NewLife.Net/UPnP/Entities/Device.cs
@@ -112,7 +112,7 @@ namespace NewLife.Net.UPnP
#region 方法
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
//return String.Format("{0} {1}", friendlyName, manufacturer);
return friendlyName;
@@ -138,7 +138,7 @@ namespace NewLife.Net.UPnP
foreach (var item in device.deviceList)
{
- Service service = GetService(item, serviceType);
+ var service = GetService(item, serviceType);
if (service != null) return service;
}
diff --git a/NewLife.Net/UPnP/Entities/Envelope.cs b/NewLife.Net/UPnP/Entities/Envelope.cs
index 395a2d3..51dde4b 100644
--- a/NewLife.Net/UPnP/Entities/Envelope.cs
+++ b/NewLife.Net/UPnP/Entities/Envelope.cs
@@ -57,9 +57,9 @@ namespace NewLife.Net.UPnP
/// <param name="reader"></param>
public void ReadXml(XmlReader reader)
{
- String prefix = reader.Prefix;
+ var prefix = reader.Prefix;
- String xml = reader.ReadInnerXml();
+ var xml = reader.ReadInnerXml();
if (xml.StartsWith("<Fault") || xml.StartsWith("<" + prefix + ":Fault"))
Fault = xml;
else
@@ -79,15 +79,15 @@ namespace NewLife.Net.UPnP
{
if (String.IsNullOrEmpty(Fault)) return null;
- XmlDocument doc = new XmlDocument();
+ var doc = new XmlDocument();
doc.LoadXml(Fault);
- String msg = "UPnP Error";
+ var msg = "UPnP Error";
//XmlNamespaceManager mgr = new XmlNamespaceManager(doc.NameTable);
//mgr.AddNamespace(doc.DocumentElement.Prefix, doc.DocumentElement.NamespaceURI);
//XmlNode node = doc.SelectSingleNode("//errordescription", mgr);
- XmlNode node = doc.SelectSingleNode("/*/*/*/*[last()]");
+ var node = doc.SelectSingleNode("/*/*/*/*[last()]");
if (node != null) msg = node.InnerText;
throw new XException(msg);
diff --git a/NewLife.Net/UPnP/Entities/InternetGatewayDevice.cs b/NewLife.Net/UPnP/Entities/InternetGatewayDevice.cs
index 90efd07..0eadab7 100644
--- a/NewLife.Net/UPnP/Entities/InternetGatewayDevice.cs
+++ b/NewLife.Net/UPnP/Entities/InternetGatewayDevice.cs
@@ -85,16 +85,16 @@ namespace NewLife.Net.UPnP
if (String.IsNullOrEmpty(URLBase)) return;
- Uri uri = new Uri(URLBase);
+ var uri = new Uri(URLBase);
ServerHost = uri.Host;
ServerPort = uri.Port;
}
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
- Device d = device;
+ var d = device;
if (d != null)
return String.Format("{0} {1}", d, ServerHost);
else
@@ -167,13 +167,13 @@ namespace NewLife.Net.UPnP
/// <returns></returns>
public PortMappingEntry GetMapByPortAndProtocol(String remoteHost, Int32 externalPort, String protocol)
{
- PortMappingEntry entity = new PortMappingEntry();
+ var entity = new PortMappingEntry();
entity.Name = "GetSpecificPortMappingEntry";
entity.RemoteHost = remoteHost;
entity.ExternalPort = externalPort;
entity.Protocol = protocol;
- PortMappingEntry response = Request<PortMappingEntry>(entity);
+ var response = Request<PortMappingEntry>(entity);
return response;
}
@@ -182,11 +182,11 @@ namespace NewLife.Net.UPnP
/// <returns></returns>
public PortMappingEntry GetMapByIndex(Int32 index)
{
- PortMappingEntryRequest entity = new PortMappingEntryRequest();
+ var entity = new PortMappingEntryRequest();
entity.Name = "GetGenericPortMappingEntry";
entity.NewPortMappingIndex = index;
- PortMappingEntry response = Request<PortMappingEntry>(entity);
+ var response = Request<PortMappingEntry>(entity);
return response;
}
@@ -194,7 +194,7 @@ namespace NewLife.Net.UPnP
/// <returns></returns>
public IEnumerable<PortMappingEntry> GetMapByIndexAll()
{
- Int32 n = 0;
+ var n = 0;
while (true)
{
PortMappingEntry item;
@@ -220,15 +220,15 @@ namespace NewLife.Net.UPnP
{
if (device == null || action == null) return null;
- Service service = device.GetWANIPService();
+ var service = device.GetWANIPService();
if (service == null) return null;
- Uri uri = new Uri(String.Format("http://{0}:{1}{2}", ServerHost, ServerPort, service.controlURL));
+ var uri = new Uri(String.Format("http://{0}:{1}{2}", ServerHost, ServerPort, service.controlURL));
- String xml = action.ToSoap(service.serviceType);
+ var xml = action.ToSoap(service.serviceType);
xml = SOAPRequest(uri, service.serviceType + "#" + action.Name, xml);
- TResponse response = UPnPAction<TResponse>.FromXml(xml);
+ var response = UPnPAction<TResponse>.FromXml(xml);
return response;
}
@@ -260,7 +260,7 @@ namespace NewLife.Net.UPnP
static String SOAPRequest(Uri uri, String action, String xml)
{
//String body = String.Format(SOAP_BODY, xml);
- String header = String.Format(SOAP_HEADER, uri.PathAndQuery, uri.Host + ":" + uri.Port, action, Encoding.UTF8.GetByteCount(xml));
+ var header = String.Format(SOAP_HEADER, uri.PathAndQuery, uri.Host + ":" + uri.Port, action, Encoding.UTF8.GetByteCount(xml));
var client = new TcpSession();
var session = client as ISocketSession;
@@ -271,10 +271,10 @@ namespace NewLife.Net.UPnP
client.Remote.Port = uri.Port;
session.Send(header + xml);
- String response = session.ReceiveString();
+ var response = session.ReceiveString();
if (String.IsNullOrEmpty(response)) return null;
- Int32 p = response.IndexOf("\r\n\r\n");
+ var p = response.IndexOf("\r\n\r\n");
if (p < 0) return null;
response = response.Substring(p).Trim();
diff --git a/NewLife.Net/UPnP/Entities/PortMappingEntry.cs b/NewLife.Net/UPnP/Entities/PortMappingEntry.cs
index 250b975..a028248 100644
--- a/NewLife.Net/UPnP/Entities/PortMappingEntry.cs
+++ b/NewLife.Net/UPnP/Entities/PortMappingEntry.cs
@@ -94,7 +94,7 @@ namespace NewLife.Net.UPnP
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return String.Format("{0} {1}://{2}:{3} {4}", Description, Protocol, InternalClient, InternalPort, ExternalPort);
}
diff --git a/NewLife.Net/UPnP/Entities/Service.cs b/NewLife.Net/UPnP/Entities/Service.cs
index 34000d8..9863f7a 100644
--- a/NewLife.Net/UPnP/Entities/Service.cs
+++ b/NewLife.Net/UPnP/Entities/Service.cs
@@ -47,7 +47,7 @@ namespace NewLife.Net.UPnP
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
if (!String.IsNullOrEmpty(serviceId))
{
diff --git a/NewLife.Net/UPnP/UPnPAction.cs b/NewLife.Net/UPnP/UPnPAction.cs
index 247cfd2..9d30293 100644
--- a/NewLife.Net/UPnP/UPnPAction.cs
+++ b/NewLife.Net/UPnP/UPnPAction.cs
@@ -19,7 +19,7 @@ namespace NewLife.Net.UPnP
var doc = new XmlDocument();
doc.LoadXml(xml);
- TEntity entity = new TEntity();
+ var entity = new TEntity();
//TypeX tx = TypeX.Create(typeof(TEntity));
foreach (var item in typeof(TEntity).GetProperties(true))
diff --git a/NewLife.Net/UPnP/UPnPClient.cs b/NewLife.Net/UPnP/UPnPClient.cs
index 5437762..0dba887 100644
--- a/NewLife.Net/UPnP/UPnPClient.cs
+++ b/NewLife.Net/UPnP/UPnPClient.cs
@@ -71,7 +71,7 @@ namespace NewLife.Net.UPnP
#region 构造
/// <summary>释放资源</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -129,7 +129,7 @@ namespace NewLife.Net.UPnP
}
//List<String> process = new List<String>();
- void Udp_Received(object sender, ReceivedEventArgs e)
+ void Udp_Received(Object sender, ReceivedEventArgs e)
{
var content = e.Stream.ToStr();
if (String.IsNullOrEmpty(content)) return;
@@ -141,11 +141,11 @@ namespace NewLife.Net.UPnP
WriteLog("发现UPnP设备:{0}", remote);
//分析数据并反序列化
- String sp = "LOCATION:";
- Int32 p = content.IndexOf(sp);
+ var sp = "LOCATION:";
+ var p = content.IndexOf(sp);
if (p <= 0) return;
- String url = content.Substring(p + sp.Length);
+ var url = content.Substring(p + sp.Length);
p = url.IndexOf(Environment.NewLine);
if (p <= 0) return;
@@ -156,11 +156,11 @@ namespace NewLife.Net.UPnP
try
{
//下载IGD.XML
- WebClient client = new WebClient();
- String xml = client.DownloadString(url);
+ var client = new WebClient();
+ var xml = client.DownloadString(url);
if (xml != null) xml = xml.Trim();
- Uri uri = new Uri(url);
+ var uri = new Uri(url);
if (CacheGateway) File.WriteAllText(GetCacheFile(uri.Host), xml);
AddGateway(uri.Host, xml, false);
@@ -191,7 +191,7 @@ namespace NewLife.Net.UPnP
}
//}
- if (OnNewDevice != null) OnNewDevice(this, new EventArgs<InternetGatewayDevice, bool>(device, isCache));
+ if (OnNewDevice != null) OnNewDevice(this, new EventArgs<InternetGatewayDevice, Boolean>(device, isCache));
}
/// <summary>发现新设备时触发。参数(设备,是否来自缓存)</summary>
@@ -202,16 +202,16 @@ namespace NewLife.Net.UPnP
/// <summary>检查缓存的网关</summary>
void CheckCacheGateway()
{
- String p = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, XTrace.TempPath);
+ var p = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, XTrace.TempPath);
p = Path.Combine(p, "UPnP");
if (!Directory.Exists(p)) return;
- String[] ss = Directory.GetFiles(p, cacheKey + "*.xml", SearchOption.TopDirectoryOnly);
+ var ss = Directory.GetFiles(p, cacheKey + "*.xml", SearchOption.TopDirectoryOnly);
if (ss == null || ss.Length < 1) return;
- foreach (String item in ss)
+ foreach (var item in ss)
{
- String ip = Path.GetFileNameWithoutExtension(item).Substring(cacheKey.Length).Trim(new Char[] { '_' });
+ var ip = Path.GetFileNameWithoutExtension(item).Substring(cacheKey.Length).Trim(new Char[] { '_' });
AddGateway(ip, File.ReadAllText(item), true);
}
diff --git a/Test/Program.cs b/Test/Program.cs
index f14721d..bf45405 100644
--- a/Test/Program.cs
+++ b/Test/Program.cs
@@ -34,7 +34,7 @@ namespace Test
{
public class Program
{
- private static void Main(string[] args)
+ private static void Main(String[] args)
{
//Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
@@ -45,7 +45,7 @@ namespace Test
#endif
while (true)
{
- Stopwatch sw = new Stopwatch();
+ var sw = new Stopwatch();
sw.Start();
#if !DEBUG
try
@@ -65,7 +65,7 @@ namespace Test
//Thread.Sleep(5000);
GC.Collect();
GC.WaitForPendingFinalizers();
- ConsoleKeyInfo key = Console.ReadKey(true);
+ var key = Console.ReadKey(true);
if (key.Key != ConsoleKey.C) break;
}
}
@@ -190,11 +190,11 @@ namespace Test
var count = Rand.Next(10, 100);
XTrace.WriteLine("正在生成{0}个大文件……", count);
var total = 0;
- for (int i = 0; i < count; i++)
+ for (var i = 0; i < count; i++)
{
var sb = new StringBuilder();
var lines = Rand.Next(100, 10000);
- for (int k = 0; k < lines; k++)
+ for (var k = 0; k < lines; k++)
{
if (Rand.Next(4) > 0)
sb.AppendLine("学无先后达者为师!");
diff --git a/XTemplate/Templating/Template.cs b/XTemplate/Templating/Template.cs
index 4488c4c..17dd4d6 100644
--- a/XTemplate/Templating/Template.cs
+++ b/XTemplate/Templating/Template.cs
@@ -81,7 +81,7 @@ namespace XTemplate.Templating
{
if (_Assembly == null && !String.IsNullOrEmpty(AssemblyName))
{
- String file = AssemblyName;
+ var file = AssemblyName;
if (!Path.IsPathRooted(file)) file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, file);
if (!File.Exists(file)) file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.Combine("Bin", AssemblyName));
if (File.Exists(file)) _Assembly = Assembly.LoadFile(file);
@@ -113,12 +113,12 @@ namespace XTemplate.Templating
{
if (!String.IsNullOrEmpty(AssemblyName))
{
- String name = Path.GetFileNameWithoutExtension(AssemblyName);
+ var name = Path.GetFileNameWithoutExtension(AssemblyName);
_NameSpace = name;
}
else
{
- String namespaceName = GetType().Namespace;
+ var namespaceName = GetType().Namespace;
namespaceName += "s";
_NameSpace = namespaceName;
@@ -134,7 +134,7 @@ namespace XTemplate.Templating
#endregion
#region 创建
- private static DictionaryCache<String, Template> cache = new DictionaryCache<string, Template>();
+ private static DictionaryCache<String, Template> cache = new DictionaryCache<String, Template>();
/// <summary>根据名称和模版创建模版实例,带缓存,避免重复编译</summary>
/// <param name="name">名称</param>
/// <param name="templates">模版</param>
@@ -143,7 +143,7 @@ namespace XTemplate.Templating
{
if (templates == null || templates.Length < 1) throw new ArgumentNullException("templates");
- var dic = new Dictionary<string, string>();
+ var dic = new Dictionary<String, String>();
var prefix = !String.IsNullOrEmpty(name) ? name : "Class";
@@ -153,7 +153,7 @@ namespace XTemplate.Templating
}
else
{
- for (int i = 0; i < templates.Length; i++)
+ for (var i = 0; i < templates.Length; i++)
{
dic.Add(prefix + (i + 1), templates[i]);
}
@@ -195,7 +195,7 @@ namespace XTemplate.Templating
/// <summary>释放提供者</summary>
/// <param name="disposing"></param>
- protected override void OnDispose(bool disposing)
+ protected override void OnDispose(Boolean disposing)
{
base.OnDispose(disposing);
@@ -277,7 +277,7 @@ namespace XTemplate.Templating
if (Status >= TemplateStatus.Process) return;
- for (int i = 0; i < Templates.Count; i++)
+ for (var i = 0; i < Templates.Count; i++)
{
Process(Templates[i]);
}
@@ -383,7 +383,7 @@ namespace XTemplate.Templating
var directives = new String[] { "template", "assembly", "import", "include", "var" };
- for (Int32 i = 0; i < item.Blocks.Count; i++)
+ for (var i = 0; i < item.Blocks.Count; i++)
{
var block = item.Blocks[i];
if (block.Type != BlockType.Directive) continue;
@@ -422,7 +422,7 @@ namespace XTemplate.Templating
#region 包含include
if (directive.Name.EqualIgnoreCase("include"))
{
- String name = directive.GetParameter("name");
+ var name = directive.GetParameter("name");
// 可能采用了相对路径
if (!File.Exists(name)) name = Path.Combine(Path.GetDirectoryName(item.Name), name);
@@ -456,7 +456,7 @@ namespace XTemplate.Templating
if (directive.Name.EqualIgnoreCase("assembly"))
{
- String name = directive.GetParameter("name");
+ var name = directive.GetParameter("name");
if (!AssemblyReferences.Contains(name)) AssemblyReferences.Add(name);
}
else if (directive.Name.EqualIgnoreCase("import"))
@@ -803,7 +803,7 @@ namespace XTemplate.Templating
if (sb.Length > 0) sb.AppendLine();
sb.Append(item.Source);
}
- String key = Hash(sb.ToString());
+ var key = Hash(sb.ToString());
Assembly assembly = null;
if (asmCache.TryGetValue(key, out assembly)) return assembly;
@@ -858,7 +858,7 @@ namespace XTemplate.Templating
var name = item.Name.EndsWithIgnoreCase(".cs") ? item.Name : item.ClassName;
// 猜测后缀
- Int32 p = name.LastIndexOf("_");
+ var p = name.LastIndexOf("_");
if (p > 0 && name.Length - p <= 5)
name = name.Substring(0, p) + "." + name.Substring(p + 1, name.Length - p - 1);
else if (!name.EndsWithIgnoreCase(".cs"))
@@ -908,7 +908,7 @@ namespace XTemplate.Templating
if (!error.IsWarning)
{
- String msg = error.ToString();
+ var msg = error.ToString();
if (sb.Length < 1)
{
String code = null;
@@ -1131,7 +1131,7 @@ namespace XTemplate.Templating
/// <param name="sender"></param>
/// <param name="args"></param>
/// <returns></returns>
- private static Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
+ private static Assembly currentDomain_AssemblyResolve(Object sender, ResolveEventArgs args)
{
var name = args.Name;
if (name.IsNullOrWhiteSpace()) return null;
diff --git a/XTemplate/Templating/Template2.cs b/XTemplate/Templating/Template2.cs
index a277c76..656d7ee 100644
--- a/XTemplate/Templating/Template2.cs
+++ b/XTemplate/Templating/Template2.cs
@@ -17,7 +17,7 @@ namespace XTemplate.Templating
{
if (String.IsNullOrEmpty(str)) return null;
- MD5 md5 = MD5.Create();
+ var md5 = MD5.Create();
return BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(str))).Replace("-", null);
}
@@ -27,7 +27,7 @@ namespace XTemplate.Templating
/// <returns></returns>
public static String GetClassName(String fileName)
{
- String name = fileName;
+ var name = fileName;
//if (name.Contains(".")) name = name.Substring(0, name.LastIndexOf("."));
//name = name.Replace(@"\", "_").Replace(@"/", "_").Replace(".", "_").Replace("-", "_");
foreach (var item in _Filter)
@@ -43,7 +43,7 @@ namespace XTemplate.Templating
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return String.Format("{0} [{1}]", AssemblyName ?? NameSpace, Templates.Count);
//return base.ToString();
@@ -108,7 +108,7 @@ namespace XTemplate.Templating
{
if (String.IsNullOrEmpty(item.Location)) continue;
- String name = Path.GetFileName(item.Location);
+ var name = Path.GetFileName(item.Location);
if (!String.IsNullOrEmpty(name)) name = name.ToLower();
if (names.Contains(name)) continue;
names.Add(name);
@@ -186,7 +186,7 @@ namespace XTemplate.Templating
// 遍历所有公开类,导入它们的所有命名空间
foreach (var type in asm.GetTypes())
{
- String name = type.Namespace;
+ var name = type.Namespace;
if (String.IsNullOrEmpty(name)) continue;
//if (!name.StartsWith("XCode") && !name.StartsWith("NewLife")) continue;
if (!list.Contains(name)) list.Add(name);
diff --git a/XTemplate/Templating/TemplateBase.cs b/XTemplate/Templating/TemplateBase.cs
index ad86fef..8263ff4 100644
--- a/XTemplate/Templating/TemplateBase.cs
+++ b/XTemplate/Templating/TemplateBase.cs
@@ -41,10 +41,10 @@ namespace XTemplate.Templating
/// <returns></returns>
public String RemoveIndent()
{
- String str = "";
+ var str = "";
if (indentLengths.Count > 0)
{
- Int32 num = indentLengths[indentLengths.Count - 1];
+ var num = indentLengths[indentLengths.Count - 1];
indentLengths.RemoveAt(indentLengths.Count - 1);
if (num > 0)
{
@@ -200,7 +200,7 @@ namespace XTemplate.Templating
/// <returns></returns>
protected T GetData<T>(String name)
{
- Object obj = GetData(name);
+ var obj = GetData(name);
if (obj == null) return default(T);
return obj.ChangeType<T>();
diff --git a/XTemplate/Templating/TemplateItem.cs b/XTemplate/Templating/TemplateItem.cs
index bbb225c..08c27c8 100644
--- a/XTemplate/Templating/TemplateItem.cs
+++ b/XTemplate/Templating/TemplateItem.cs
@@ -50,7 +50,7 @@ namespace XTemplate.Templating
#region 方法
/// <summary>已重载。</summary>
/// <returns></returns>
- public override string ToString()
+ public override String ToString()
{
return Name;
}
diff --git a/XTemplate/Templating/TemplateParser.cs b/XTemplate/Templating/TemplateParser.cs
index e447dff..5f3d0fe 100644
--- a/XTemplate/Templating/TemplateParser.cs
+++ b/XTemplate/Templating/TemplateParser.cs
@@ -21,7 +21,7 @@ namespace XTemplate.Templating
{
if (match.Success && match.Value != null)
{
- Int32 length = (Int32)Math.Floor((double)match.Value.Length / 2.0);
+ var length = (Int32)Math.Floor((Double)match.Value.Length / 2.0);
return match.Value.Substring(0, length);
}
return String.Empty;
@@ -56,12 +56,12 @@ namespace XTemplate.Templating
{
//if (content == null) throw new ArgumentNullException("content");
- List<Block> blocks = new List<Block>();
+ var blocks = new List<Block>();
if (String.IsNullOrEmpty(content)) return blocks;
foreach (Match match in templateParsingRegex.Matches(content))
{
- Block item = new Block();
+ var item = new Block();
Group group = null;
if ((group = match.Groups["text"]).Success)
item.Type = BlockType.Text;
@@ -83,7 +83,7 @@ namespace XTemplate.Templating
}
InsertPosition(blocks);
- foreach (Block block in blocks)
+ foreach (var block in blocks)
{
if (unescapedTagFindingRegex.Match(block.Text).Success) throw new TemplateException(block, "不可识别的标记!可能有未编码的字符,比如\\<#。");
}
@@ -97,9 +97,9 @@ namespace XTemplate.Templating
/// <param name="blocks"></param>
private static void InsertPosition(List<Block> blocks)
{
- Int32 i = 1;
- Int32 j = 1;
- foreach (Block block in blocks)
+ var i = 1;
+ var j = 1;
+ foreach (var block in blocks)
{
// 类成员以<#!开始,指令以<#@开始,表达式以<#=开始,所以它们的列数加3
if (block.Type == BlockType.Member ||
@@ -117,7 +117,7 @@ namespace XTemplate.Templating
block.StartColumn = j;
// 计算换行
- MatchCollection matchs = newlineFindingRegex.Matches(block.Text);
+ var matchs = newlineFindingRegex.Matches(block.Text);
i += matchs.Count;
if (matchs.Count > 0)
{
@@ -142,9 +142,9 @@ namespace XTemplate.Templating
/// <param name="blocks"></param>
private static void StripEscapeCharacters(List<Block> blocks)
{
- for (Int32 i = 0; i < blocks.Count; i++)
+ for (var i = 0; i < blocks.Count; i++)
{
- Block block = blocks[i];
+ var block = blocks[i];
block.Text = escapeFindingRegex.Replace(block.Text, escapeReplacingEvaluator);
if (i != (blocks.Count - 1))
{
@@ -232,10 +232,10 @@ namespace XTemplate.Templating
/// <returns></returns>
private static Boolean ValidateDirectiveString(Block block)
{
- Match match = nameValidatingRegex.Match(block.Text);
+ var match = nameValidatingRegex.Match(block.Text);
if (!match.Success) return false;
- Int32 length = match.Length;
+ var length = match.Length;
var matchs = paramValueValidatingRegex.Matches(block.Text);
if (matchs.Count == 0) return false;
@@ -265,14 +265,14 @@ namespace XTemplate.Templating
/// <param name="blocks"></param>
internal static void StripExtraNewlines(List<Block> blocks)
{
- for (Int32 i = 0; i < blocks.Count; i++)
+ for (var i = 0; i < blocks.Count; i++)
{
- Block block = blocks[i];
+ var block = blocks[i];
if (block.Type != BlockType.Text) continue;
if (i > 0)
{
- Block last = blocks[i - 1];
+ var last = blocks[i - 1];
if (last.Type != BlockType.Expression && last.Type != BlockType.Text)
{
// 占位符块,不是第一块,前一块又不是表达式和占位符时,忽略一个换行
@@ -286,7 +286,7 @@ namespace XTemplate.Templating
}
if (i < blocks.Count - 1)
{
- Block next = blocks[i + 1];
+ var next = blocks[i + 1];
if (next.Type != BlockType.Expression && next.Type != BlockType.Text)
{
// 占位符块,不是最后一块,下一块又不是表达式和占位符时,忽略一个换行
@@ -294,7 +294,7 @@ namespace XTemplate.Templating
}
}
}
- Predicate<Block> match = delegate(Block b)
+ Predicate<Block> match = delegate (Block b)
{
// 类成员代码块可能需要空的结束符
if (b.Type == BlockType.Member) return false;