tanghai пре 10 година
родитељ
комит
1bbb40aee0
56 измењених фајлова са 239 додато и 191 уклоњено
  1. 1 1
      CSharp/App/Editor/Bootstrapper.cs
  2. 5 2
      CSharp/Exe/Profile/Properties/AssemblyInfo.cs
  3. 3 2
      CSharp/Game/Controller/ConfigCategory/ServerInfoCategory.cs
  4. 3 2
      CSharp/Game/Controller/Controller.csproj
  5. 2 1
      CSharp/Game/Controller/Event/MessageAction.cs
  6. 4 3
      CSharp/Game/Controller/Message/CMsgLoginEvent.cs
  7. 1 1
      CSharp/Game/Controller/MessageType.cs
  8. 5 2
      CSharp/Game/Controller/Properties/AssemblyInfo.cs
  9. 1 1
      CSharp/Game/Model/AEventAttribute.cs
  10. 1 2
      CSharp/Game/Model/BehaviorTree/BehaviorTreeFactory.cs
  11. 7 7
      CSharp/Game/Model/Component/ActorComponent.cs
  12. 2 2
      CSharp/Game/Model/Component/BuffComponent.cs
  13. 2 2
      CSharp/Game/Model/Component/ChannelUnitInfoComponent.cs
  14. 4 6
      CSharp/Game/Model/Component/EventComponent.cs
  15. 2 1
      CSharp/Game/Model/Component/NetworkComponent.cs
  16. 2 3
      CSharp/Game/Model/Component/TimerComponent.cs
  17. 2 2
      CSharp/Game/Model/Config/ServerInfoConfig.cs
  18. 2 2
      CSharp/Game/Model/ConfigAttribute.cs
  19. 2 2
      CSharp/Game/Model/IConfigLoader.cs
  20. 2 2
      CSharp/Game/Model/IStart.cs
  21. 1 1
      CSharp/Game/Model/IUpdate.cs
  22. 1 2
      CSharp/Game/Model/MessageAttribute.cs
  23. 2 2
      CSharp/Game/Model/Model.csproj
  24. 1 1
      CSharp/Game/Model/Options.cs
  25. 5 2
      CSharp/Game/Model/Properties/AssemblyInfo.cs
  26. 1 1
      CSharp/Game/Model/ServerType.cs
  27. 3 3
      CSharp/Game/Model/World.cs
  28. 5 4
      CSharp/Platform/Common/Base/Entity.cs
  29. 3 3
      CSharp/Platform/Common/Base/TimerManager.cs
  30. 2 3
      CSharp/Platform/Common/Common.csproj
  31. 1 2
      CSharp/Platform/Common/Helper/StringHelper.cs
  32. 2 1
      CSharp/Platform/Common/Network/AChannel.cs
  33. 5 2
      CSharp/Platform/Common/Properties/AssemblyInfo.cs
  34. 5 2
      CSharp/Platform/TNet/Properties/AssemblyInfo.cs
  35. 3 4
      CSharp/Platform/TNet/TBuffer.cs
  36. 9 7
      CSharp/Platform/TNet/TChannel.cs
  37. 4 3
      CSharp/Platform/TNet/TNet.csproj
  38. 3 3
      CSharp/Platform/TNet/TPoller.cs
  39. 2 2
      CSharp/Platform/TNet/TService.cs
  40. 0 2
      CSharp/Platform/TNet/TSocket.cs
  41. 5 2
      CSharp/Platform/UNet/Properties/AssemblyInfo.cs
  42. 2 1
      CSharp/Platform/UNet/UChannel.cs
  43. 12 3
      CSharp/Platform/UNet/UNet.csproj
  44. 1 1
      CSharp/Platform/UNet/UPacket.cs
  45. 8 8
      CSharp/Platform/UNet/UPoller.cs
  46. 2 2
      CSharp/Platform/UNet/UService.cs
  47. 9 4
      CSharp/Test/ModelTest/ModelTest.csproj
  48. 5 14
      CSharp/Test/ModelTest/MongoDBTest.cs
  49. 5 2
      CSharp/Test/ModelTest/Properties/AssemblyInfo.cs
  50. 5 2
      CSharp/Test/TNetTest/Properties/AssemblyInfo.cs
  51. 24 22
      CSharp/Test/TNetTest/TServiceTest.cs
  52. 5 2
      CSharp/Test/UNetTest/Properties/AssemblyInfo.cs
  53. 25 24
      CSharp/Test/UNetTest/UServiceTest.cs
  54. 12 5
      CSharp/ThirdParty/Nuget/Nuget.csproj
  55. 5 2
      CSharp/ThirdParty/Nuget/Properties/AssemblyInfo.cs
  56. 3 1
      CSharp/ThirdParty/Nuget/packages.config

+ 1 - 1
CSharp/App/Editor/Bootstrapper.cs

@@ -27,7 +27,7 @@ namespace Editor
 		{
 			IRegionBehaviorFactory factory = base.ConfigureDefaultRegionBehaviors();
 			factory.AddIfMissing("AutoPopulateExportedViewsBehavior",
-			                     typeof (AutoPopulateExportedViewsBehavior));
+					typeof (AutoPopulateExportedViewsBehavior));
 			return factory;
 		}
 

+ 5 - 2
CSharp/Exe/Profile/Properties/AssemblyInfo.cs

@@ -1,10 +1,10 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的常规信息通过以下
 // 特性集控制。更改这些特性值可修改
 // 与程序集关联的信息。
+
 [assembly: AssemblyTitle("Profile")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
 // 将 ComVisible 设置为 false 使此程序集中的类型
 // 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
 // 则将该类型上的 ComVisible 特性设置为 true。
+
 [assembly: ComVisible(false)]
 
 // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+
 [assembly: Guid("784e44fc-7993-457c-ab57-28b174b9bca5")]
 
 // 程序集的版本信息由下面四个值组成: 
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
 // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
 // 方法是按如下所示使用“*”: 
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 3 - 2
CSharp/Game/Controller/ConfigCategory/ServerInfoCategory.cs

@@ -4,9 +4,10 @@ using Model;
 namespace Controller
 {
 	[Config(ServerType.All)]
-	public class ServerInfoCategory : ACategory<ServerInfoConfig>
+	public class ServerInfoCategory: ACategory<ServerInfoConfig>
 	{
-		public Dictionary<string, ServerInfoConfig> NameServerInfoConfigs = new Dictionary<string, ServerInfoConfig>();
+		public Dictionary<string, ServerInfoConfig> NameServerInfoConfigs =
+				new Dictionary<string, ServerInfoConfig>();
 
 		public override void EndInit()
 		{

+ 3 - 2
CSharp/Game/Controller/Controller.csproj

@@ -30,8 +30,9 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="MongoDB.Bson">
-      <HintPath>..\..\packages\mongocsharpdriver.1.10.0-rc1\lib\net35\MongoDB.Bson.dll</HintPath>
+    <Reference Include="MongoDB.Bson, Version=2.0.0.788, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\MongoDB.Bson.2.0.0-rc0\lib\net45\MongoDB.Bson.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />

+ 2 - 1
CSharp/Game/Controller/Event/MessageAction.cs

@@ -2,10 +2,11 @@
 using System.Threading.Tasks;
 using Common.Network;
 using Model;
+
 namespace Controller
 {
 	[Event(EventType.MessageAction)]
-	public class MessageAction : IEventAsync
+	public class MessageAction: IEventAsync
 	{
 		public async Task RunAsync(Env env)
 		{

+ 4 - 3
CSharp/Game/Controller/Message/CMsgLoginEvent.cs

@@ -1,6 +1,6 @@
 using Common.Helper;
-using Model;
 using Common.Network;
+using Model;
 
 namespace Controller.Message
 {
@@ -20,9 +20,10 @@ namespace Controller.Message
 			Unit unit = World.Instance.GetComponent<FactoryComponent<Unit>>().Create(UnitType.GatePlayer, 1);
 
 			AChannel channel = env.Get<AChannel>(EnvKey.Channel);
-			ChannelUnitInfoComponent channelUnitInfoComponent = channel.AddComponent<ChannelUnitInfoComponent>();
+			ChannelUnitInfoComponent channelUnitInfoComponent =
+					channel.AddComponent<ChannelUnitInfoComponent>();
 			channelUnitInfoComponent.Account = cmsg.Account;
 			channelUnitInfoComponent.PlayerId = unit.Id;
 		}
 	}
-}
+}

+ 1 - 1
CSharp/Game/Controller/MessageType.cs

@@ -4,4 +4,4 @@
 	{
 		public const int CMsgLogin = 1;
 	}
-}
+}

+ 5 - 2
CSharp/Game/Controller/Properties/AssemblyInfo.cs

@@ -1,10 +1,10 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的常规信息通过以下
 // 特性集控制。更改这些特性值可修改
 // 与程序集关联的信息。
+
 [assembly: AssemblyTitle("Controller")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
 // 将 ComVisible 设置为 false 使此程序集中的类型
 // 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
 // 则将该类型上的 ComVisible 特性设置为 true。
+
 [assembly: ComVisible(false)]
 
 // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+
 [assembly: Guid("d9d1f906-81a1-48c8-b901-93e2aede657c")]
 
 // 程序集的版本信息由下面四个值组成: 
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
 // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
 // 方法是按如下所示使用“*”: 
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 1 - 1
CSharp/Game/Model/AEventAttribute.cs

@@ -21,7 +21,7 @@ namespace Model
 
 		public bool Contains(ServerType serverType)
 		{
-			if ((this.ServerType & (int)serverType) == 0)
+			if ((this.ServerType & (int) serverType) == 0)
 			{
 				return false;
 			}

+ 1 - 2
CSharp/Game/Model/BehaviorTree/BehaviorTreeFactory.cs

@@ -38,8 +38,7 @@ namespace Model
 
 				Type classType = type;
 				this.dictionary.Add(attribute.NodeType,
-				                    config =>
-						                    (Node) Activator.CreateInstance(classType, new object[] { config }));
+						config => (Node) Activator.CreateInstance(classType, new object[] { config }));
 			}
 		}
 

+ 7 - 7
CSharp/Game/Model/Component/ActorComponent.cs

@@ -6,17 +6,17 @@ using Common.Logger;
 
 namespace Model
 {
-	public class ActorComponent : Component<Unit>
+	public class ActorComponent: Component<Unit>
 	{
 		private readonly Queue<Env> msgEnvQueue = new Queue<Env>();
 
-		private Action msgAction = () => {};
+		private Action msgAction = () => { };
 
 		private Env Env { get; set; }
 
 		public ActorComponent()
 		{
-			Start();
+			this.Start();
 		}
 
 		private async void Start()
@@ -41,7 +41,7 @@ namespace Model
 		public void Add(Env msgEnv)
 		{
 			this.msgEnvQueue.Enqueue(msgEnv);
-			msgAction();
+			this.msgAction();
 		}
 
 		private Task<Env> Get()
@@ -54,9 +54,9 @@ namespace Model
 			}
 			else
 			{
-				msgAction = () =>
+				this.msgAction = () =>
 				{
-					msgAction = () => { };
+					this.msgAction = () => { };
 					Env msg = this.msgEnvQueue.Dequeue();
 					tcs.SetResult(msg);
 				};
@@ -64,4 +64,4 @@ namespace Model
 			return tcs.Task;
 		}
 	}
-}
+}

+ 2 - 2
CSharp/Game/Model/Component/BuffComponent.cs

@@ -49,13 +49,13 @@ namespace Model
 			if (this.buffs.Contains(buff))
 			{
 				throw new ArgumentException(string.Format("already exist same buff, Id: {0} ConfigId: {1}",
-				                                          buff.Id, buff.Config.Id));
+						buff.Id, buff.Config.Id));
 			}
 
 			if (this.idBuff.ContainsKey(buff.Id))
 			{
 				throw new ArgumentException(string.Format("already exist same buff, Id: {0} ConfigId: {1}",
-				                                          buff.Id, buff.Config.Id));
+						buff.Id, buff.Config.Id));
 			}
 
 			Env env = new Env();

+ 2 - 2
CSharp/Game/Model/Component/ChannelUnitInfoComponent.cs

@@ -7,9 +7,9 @@ namespace Model
 	/// <summary>
 	/// channel中保存Unit一些信息,例如帐号
 	/// </summary>
-	public class ChannelUnitInfoComponent : Component<AChannel>
+	public class ChannelUnitInfoComponent: Component<AChannel>
 	{
 		public byte[] Account { get; set; }
 		public ObjectId PlayerId { get; set; }
 	}
-}
+}

+ 4 - 6
CSharp/Game/Model/Component/EventComponent.cs

@@ -28,7 +28,7 @@ namespace Model
 					continue;
 				}
 
-				AEventAttribute aEventAttribute = (AEventAttribute)attrs[0];
+				AEventAttribute aEventAttribute = (AEventAttribute) attrs[0];
 				if (!aEventAttribute.Contains(serverType))
 				{
 					continue;
@@ -58,8 +58,7 @@ namespace Model
 					continue;
 				}
 
-				throw new Exception(
-					string.Format("event not inherit IEventSync or IEventAsync interface: {0}",
+				throw new Exception(string.Format("event not inherit IEventSync or IEventAsync interface: {0}",
 						obj.GetType().FullName));
 			}
 		}
@@ -69,8 +68,7 @@ namespace Model
 			List<IEventSync> iEventSyncs = null;
 			if (!this.eventSyncs.TryGetValue(type, out iEventSyncs))
 			{
-				throw new Exception(
-					string.Format("no event handler, AttributeType: {0} type: {1}",
+				throw new Exception(string.Format("no event handler, AttributeType: {0} type: {1}",
 						typeof (AttributeType).Name, type));
 			}
 
@@ -91,7 +89,7 @@ namespace Model
 			if (iEventSyncs == null && iEventAsyncs == null)
 			{
 				throw new Exception(string.Format("no event handler, AttributeType: {0} type: {1}",
-					typeof(AttributeType).Name, type));
+						typeof (AttributeType).Name, type));
 			}
 
 			if (iEventSyncs != null)

+ 2 - 1
CSharp/Game/Model/Component/NetworkComponent.cs

@@ -29,7 +29,8 @@ namespace Model
 
 		public void Start()
 		{
-			this.Accept(World.Instance.Options.Host, World.Instance.Options.Port, World.Instance.Options.Protocol);
+			this.Accept(World.Instance.Options.Host, World.Instance.Options.Port,
+					World.Instance.Options.Protocol);
 		}
 
 		public void Update()

+ 2 - 3
CSharp/Game/Model/Component/TimerComponent.cs

@@ -5,7 +5,7 @@ using MongoDB.Bson;
 
 namespace Model
 {
-	public class TimerComponent : Component<World>, IUpdate
+	public class TimerComponent: Component<World>, IUpdate
 	{
 		private class Timer
 		{
@@ -72,8 +72,7 @@ namespace Model
 						continue;
 					}
 					this.Remove(id);
-					World.Instance.GetComponent<EventComponent<EventAttribute>>()
-							.Run(timer.CallbackId, timer.Env);
+					World.Instance.GetComponent<EventComponent<EventAttribute>>().Run(timer.CallbackId, timer.Env);
 				}
 			}
 		}

+ 2 - 2
CSharp/Game/Model/Config/ServerInfoConfig.cs

@@ -1,6 +1,6 @@
 namespace Model
 {
-	public class ServerInfoConfig : AConfig
+	public class ServerInfoConfig: AConfig
 	{
 		public string Zone { get; set; }
 		public string Name { get; set; }
@@ -8,4 +8,4 @@
 		public int Port { get; set; }
 		public ServerType ServerType { get; set; }
 	}
-}
+}

+ 2 - 2
CSharp/Game/Model/ConfigAttribute.cs

@@ -11,13 +11,13 @@ namespace Model
 		{
 			foreach (ServerType serverType in serverTypes)
 			{
-				this.ServerType |= (int)serverType;
+				this.ServerType |= (int) serverType;
 			}
 		}
 
 		public bool Contains(ServerType serverType)
 		{
-			if ((this.ServerType & (int)serverType) == 0)
+			if ((this.ServerType & (int) serverType) == 0)
 			{
 				return false;
 			}

+ 2 - 2
CSharp/Game/Model/IConfigLoader.cs

@@ -2,8 +2,8 @@
 
 namespace Model
 {
-	interface IConfigLoader
+	internal interface IConfigLoader
 	{
 		void Load(Assembly assembly);
 	}
-}
+}

+ 2 - 2
CSharp/Game/Model/IStart.cs

@@ -3,8 +3,8 @@
 	/// <summary>
 	/// World的Componet实现该接口后,会在World.Start时调用该Start方法
 	/// </summary>
-	interface IStart
+	internal interface IStart
 	{
 		void Start();
 	}
-}
+}

+ 1 - 1
CSharp/Game/Model/IUpdate.cs

@@ -7,4 +7,4 @@
 	{
 		void Update();
 	}
-}
+}

+ 1 - 2
CSharp/Game/Model/MessageAttribute.cs

@@ -5,8 +5,7 @@
 	/// </summary>
 	public class MessageAttribute: AEventAttribute
 	{
-		public MessageAttribute(int type, params ServerType[] serverTypes)
-			: base(type, serverTypes)
+		public MessageAttribute(int type, params ServerType[] serverTypes): base(type, serverTypes)
 		{
 		}
 	}

+ 2 - 2
CSharp/Game/Model/Model.csproj

@@ -34,10 +34,10 @@
       <HintPath>..\..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
     </Reference>
     <Reference Include="MongoDB.Bson">
-      <HintPath>..\..\packages\mongocsharpdriver.1.10.0-rc1\lib\net35\MongoDB.Bson.dll</HintPath>
+      <HintPath>..\..\packages\MongoDB.Bson.2.0.0-rc0\lib\net45\MongoDB.Bson.dll</HintPath>
     </Reference>
     <Reference Include="MongoDB.Driver">
-      <HintPath>..\..\packages\mongocsharpdriver.1.10.0-rc1\lib\net35\MongoDB.Driver.dll</HintPath>
+      <HintPath>..\..\packages\MongoDB.Driver.2.0.0-rc0\lib\net45\MongoDB.Driver.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />

+ 1 - 1
CSharp/Game/Model/Options.cs

@@ -34,4 +34,4 @@ namespace Model
 			return usage.ToString();
 		}
 	}
-}
+}

+ 5 - 2
CSharp/Game/Model/Properties/AssemblyInfo.cs

@@ -1,10 +1,10 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的常规信息通过以下
 // 特性集控制。更改这些特性值可修改
 // 与程序集关联的信息。
+
 [assembly: AssemblyTitle("Model")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
 // 将 ComVisible 设置为 false 使此程序集中的类型
 // 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
 // 则将该类型上的 ComVisible 特性设置为 true。
+
 [assembly: ComVisible(false)]
 
 // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+
 [assembly: Guid("b506d89a-5985-4165-93b4-e58e5c8718c3")]
 
 // 程序集的版本信息由下面四个值组成: 
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
 // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
 // 方法是按如下所示使用“*”: 
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 1 - 1
CSharp/Game/Model/ServerType.cs

@@ -11,4 +11,4 @@ namespace Model
 		City = 4,
 		All = int.MaxValue,
 	}
-}
+}

+ 3 - 3
CSharp/Game/Model/World.cs

@@ -46,7 +46,7 @@ namespace Model
 
 		public void Start()
 		{
-			Load();
+			this.Load();
 
 			foreach (Component<World> component in this.GetComponents())
 			{
@@ -64,7 +64,7 @@ namespace Model
 			}
 
 			// loop
-			while (!isStop)
+			while (!this.isStop)
 			{
 				Thread.Sleep(1);
 				foreach (IUpdate update in this.iUpdates)
@@ -76,7 +76,7 @@ namespace Model
 
 		public void Stop()
 		{
-			isStop = true;
+			this.isStop = true;
 		}
 	}
 }

+ 5 - 4
CSharp/Platform/Common/Base/Entity.cs

@@ -20,13 +20,14 @@ namespace Common.Base
 
 		public K AddComponent<K>() where K : Component<T>, new()
 		{
-			K component = new K { Owner = (T) this };
+			K component = (K) Activator.CreateInstance(typeof (K));
+			component.Owner = (T) this;
 
 			if (this.componentDict.ContainsKey(component.GetComponentType()))
 			{
 				throw new Exception(
 						string.Format("AddComponent, component already exist, id: {0}, component: {1}", this.Id,
-						              typeof (K).Name));
+								typeof (K).Name));
 			}
 
 			if (this.components == null)
@@ -45,7 +46,7 @@ namespace Common.Base
 			{
 				throw new Exception(
 						string.Format("AddComponent, component already exist, id: {0}, component: {1}", this.Id,
-						              component.GetComponentType().Name));
+								component.GetComponentType().Name));
 			}
 
 			if (this.components == null)
@@ -63,7 +64,7 @@ namespace Common.Base
 			{
 				throw new Exception(
 						string.Format("RemoveComponent, component not exist, id: {0}, component: {1}", this.Id,
-						              typeof (K).Name));
+								typeof (K).Name));
 			}
 
 			this.components.Remove(component);

+ 3 - 3
CSharp/Platform/Common/Base/TimerManager.cs

@@ -51,12 +51,12 @@ namespace Common.Base
 				{
 					break;
 				}
-				timeoutTimer.Enqueue(time);
+				this.timeoutTimer.Enqueue(time);
 			}
 
-			while (timeoutTimer.Count > 0)
+			while (this.timeoutTimer.Count > 0)
 			{
-				long key = timeoutTimer.Dequeue();
+				long key = this.timeoutTimer.Dequeue();
 				ObjectId[] timeoutIds = this.timeGuid.GetAll(key);
 				foreach (ObjectId id in timeoutIds)
 				{

+ 2 - 3
CSharp/Platform/Common/Common.csproj

@@ -30,9 +30,8 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="MongoDB.Bson, Version=1.10.0.52, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\packages\mongocsharpdriver.1.10.0\lib\net35\MongoDB.Bson.dll</HintPath>
+    <Reference Include="MongoDB.Bson">
+      <HintPath>..\..\packages\MongoDB.Bson.2.0.0-rc0\lib\net45\MongoDB.Bson.dll</HintPath>
     </Reference>
     <Reference Include="NLog, Version=3.2.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>

+ 1 - 2
CSharp/Platform/Common/Helper/StringHelper.cs

@@ -24,8 +24,7 @@ namespace Common.Helper
 			if (hexString.Length % 2 != 0)
 			{
 				throw new ArgumentException(String.Format(CultureInfo.InvariantCulture,
-				                                          "The binary key cannot have an odd number of digits: {0}",
-				                                          hexString));
+						"The binary key cannot have an odd number of digits: {0}", hexString));
 			}
 
 			var hexAsBytes = new byte[hexString.Length / 2];

+ 2 - 1
CSharp/Platform/Common/Network/AChannel.cs

@@ -18,7 +18,8 @@ namespace Common.Network
 		/// <summary>
 		/// 发送消息
 		/// </summary>
-		public abstract void SendAsync(byte[] buffer, byte channelID = 0, PacketFlags flags = PacketFlags.Reliable);
+		public abstract void SendAsync(
+				byte[] buffer, byte channelID = 0, PacketFlags flags = PacketFlags.Reliable);
 
 		/// <summary>
 		/// 接收消息

+ 5 - 2
CSharp/Platform/Common/Properties/AssemblyInfo.cs

@@ -1,10 +1,10 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的常规信息通过以下
 // 特性集控制。更改这些特性值可修改
 // 与程序集关联的信息。
+
 [assembly: AssemblyTitle("Common")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
 // 将 ComVisible 设置为 false 使此程序集中的类型
 // 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
 // 则将该类型上的 ComVisible 特性设置为 true。
+
 [assembly: ComVisible(false)]
 
 // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+
 [assembly: Guid("38372c8f-df2b-4735-9620-d997a155cd6e")]
 
 // 程序集的版本信息由下面四个值组成: 
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
 // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
 // 方法是按如下所示使用“*”: 
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 5 - 2
CSharp/Platform/TNet/Properties/AssemblyInfo.cs

@@ -1,10 +1,10 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的常规信息通过以下
 // 特性集控制。更改这些特性值可修改
 // 与程序集关联的信息。
+
 [assembly: AssemblyTitle("TNet")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
 // 将 ComVisible 设置为 false 使此程序集中的类型
 // 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
 // 则将该类型上的 ComVisible 特性设置为 true。
+
 [assembly: ComVisible(false)]
 
 // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+
 [assembly: Guid("ea27beb7-2529-483e-966d-b207a76b9857")]
 
 // 程序集的版本信息由下面四个值组成: 
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
 // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
 // 方法是按如下所示使用“*”: 
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 3 - 4
CSharp/Platform/TNet/TBuffer.cs

@@ -68,8 +68,7 @@ namespace TNet
 		{
 			if (this.Count < buffer.Length || buffer.Length == 0)
 			{
-				throw new Exception(
-					string.Format("bufferList size < n, bufferList: {0} buffer length: {1}",
+				throw new Exception(string.Format("bufferList size < n, bufferList: {0} buffer length: {1}",
 						this.Count, buffer.Length));
 			}
 			int alreadyCopyCount = 0;
@@ -85,7 +84,7 @@ namespace TNet
 				else
 				{
 					Array.Copy(this.bufferList.First.Value, this.FirstIndex, buffer, alreadyCopyCount,
-						ChunkSize - this.FirstIndex);
+							ChunkSize - this.FirstIndex);
 					alreadyCopyCount += ChunkSize - this.FirstIndex;
 					this.FirstIndex = 0;
 					this.bufferList.RemoveFirst();
@@ -114,7 +113,7 @@ namespace TNet
 				else
 				{
 					Array.Copy(buffer, alreadyCopyCount, this.bufferList.Last.Value, this.LastIndex,
-					           ChunkSize - this.LastIndex);
+							ChunkSize - this.LastIndex);
 					alreadyCopyCount += ChunkSize - this.LastIndex;
 					this.LastIndex = ChunkSize;
 				}

+ 9 - 7
CSharp/Platform/TNet/TChannel.cs

@@ -2,8 +2,8 @@
 using System.Threading.Tasks;
 using Common.Helper;
 using Common.Logger;
-using MongoDB.Bson;
 using Common.Network;
+using MongoDB.Bson;
 
 namespace TNet
 {
@@ -61,7 +61,8 @@ namespace TNet
 			GC.SuppressFinalize(this);
 		}
 
-		public override void SendAsync(byte[] buffer, byte channelID = 0, PacketFlags flags = PacketFlags.Reliable)
+		public override void SendAsync(
+				byte[] buffer, byte channelID = 0, PacketFlags flags = PacketFlags.Reliable)
 		{
 			byte[] size = BitConverter.GetBytes(buffer.Length);
 			this.sendBuffer.SendTo(size);
@@ -130,8 +131,8 @@ namespace TNet
 					{
 						sendSize = this.sendBuffer.Count;
 					}
-					int n = await this.socket.SendAsync(
-						this.sendBuffer.First, this.sendBuffer.FirstIndex, sendSize);
+					int n =
+							await this.socket.SendAsync(this.sendBuffer.First, this.sendBuffer.FirstIndex, sendSize);
 
 					this.sendBuffer.FirstIndex += n;
 					if (this.sendBuffer.FirstIndex == TBuffer.ChunkSize)
@@ -155,9 +156,10 @@ namespace TNet
 			{
 				while (true)
 				{
-					int n = await this.socket.RecvAsync(
-						this.recvBuffer.Last, this.recvBuffer.LastIndex,
-						TBuffer.ChunkSize - this.recvBuffer.LastIndex);
+					int n =
+							await
+									this.socket.RecvAsync(this.recvBuffer.Last, this.recvBuffer.LastIndex,
+											TBuffer.ChunkSize - this.recvBuffer.LastIndex);
 					if (n == 0)
 					{
 						break;

+ 4 - 3
CSharp/Platform/TNet/TNet.csproj

@@ -30,11 +30,12 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="MongoDB.Bson, Version=2.0.0.788, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\MongoDB.Bson.2.0.0-rc0\lib\net45\MongoDB.Bson.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
-    <Reference Include="MongoDB.Bson">
-      <HintPath>..\..\packages\mongocsharpdriver.1.10.0-rc1\lib\net35\MongoDB.Bson.dll</HintPath>
-    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="IPoller.cs" />

+ 3 - 3
CSharp/Platform/TNet/TPoller.cs

@@ -25,12 +25,12 @@ namespace TNet
 				{
 					break;
 				}
-				localQueue.Enqueue(action);
+				this.localQueue.Enqueue(action);
 			}
 
-			while (localQueue.Count > 0)
+			while (this.localQueue.Count > 0)
 			{
-				Action a = localQueue.Dequeue();
+				Action a = this.localQueue.Dequeue();
 				a();
 			}
 		}

+ 2 - 2
CSharp/Platform/TNet/TService.cs

@@ -47,9 +47,9 @@ namespace TNet
 
 			if (disposing)
 			{
-				foreach (ObjectId id in idChannels.Keys.ToArray())
+				foreach (ObjectId id in this.idChannels.Keys.ToArray())
 				{
-					TChannel channel = idChannels[id];
+					TChannel channel = this.idChannels[id];
 					channel.Dispose();
 				}
 				this.acceptor.Dispose();

+ 0 - 2
CSharp/Platform/TNet/TSocket.cs

@@ -2,8 +2,6 @@
 using System.Net;
 using System.Net.Sockets;
 using System.Threading.Tasks;
-using Common.Helper;
-using Common.Logger;
 
 namespace TNet
 {

+ 5 - 2
CSharp/Platform/UNet/Properties/AssemblyInfo.cs

@@ -1,10 +1,10 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的常规信息通过以下
 // 特性集控制。更改这些特性值可修改
 // 与程序集关联的信息。
+
 [assembly: AssemblyTitle("UNet")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
 // 将 ComVisible 设置为 false 使此程序集中的类型
 // 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
 // 则将该类型上的 ComVisible 特性设置为 true。
+
 [assembly: ComVisible(false)]
 
 // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+
 [assembly: Guid("c7b48d91-aa58-4781-b82e-4f0ffa2e1521")]
 
 // 程序集的版本信息由下面四个值组成: 
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
 // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
 // 方法是按如下所示使用“*”: 
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 2 - 1
CSharp/Platform/UNet/UChannel.cs

@@ -45,7 +45,8 @@ namespace UNet
 			GC.SuppressFinalize(this);
 		}
 
-		public override void SendAsync(byte[] buffer, byte channelID = 0, PacketFlags flags = PacketFlags.Reliable)
+		public override void SendAsync(
+				byte[] buffer, byte channelID = 0, PacketFlags flags = PacketFlags.Reliable)
 		{
 			this.socket.SendAsync(buffer, channelID, flags);
 		}

+ 12 - 3
CSharp/Platform/UNet/UNet.csproj

@@ -32,11 +32,20 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="MongoDB.Bson, Version=2.0.0.788, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\MongoDB.Bson.2.0.0-rc0\lib\net45\MongoDB.Bson.dll</HintPath>
+    </Reference>
+    <Reference Include="MongoDB.Driver, Version=2.0.0.788, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\MongoDB.Driver.2.0.0-rc0\lib\net45\MongoDB.Driver.dll</HintPath>
+    </Reference>
+    <Reference Include="MongoDB.Driver.Core, Version=2.0.0.788, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\MongoDB.Driver.Core.2.0.0-rc0\lib\net45\MongoDB.Driver.Core.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
-    <Reference Include="MongoDB.Bson">
-      <HintPath>..\..\packages\mongocsharpdriver.1.10.0-rc1\lib\net35\MongoDB.Bson.dll</HintPath>
-    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Library.cs" />

+ 1 - 1
CSharp/Platform/UNet/UPacket.cs

@@ -77,7 +77,7 @@ namespace UNet
 			get
 			{
 				ENetPacket enetPacket = this.Struct;
-				var bytes = new byte[(long)enetPacket.DataLength];
+				var bytes = new byte[(long) enetPacket.DataLength];
 				Marshal.Copy(enetPacket.Data, bytes, 0, (int) enetPacket.DataLength);
 				return bytes;
 			}

+ 8 - 8
CSharp/Platform/UNet/UPoller.cs

@@ -33,8 +33,8 @@ namespace UNet
 		{
 			UAddress address = new UAddress(hostName, port);
 			ENetAddress nativeAddress = address.Struct;
-			this.host = NativeMethods.ENetHostCreate(
-				ref nativeAddress, NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, 0, 0, 0);
+			this.host = NativeMethods.ENetHostCreate(ref nativeAddress,
+					NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, 0, 0, 0);
 
 			if (this.host == IntPtr.Zero)
 			{
@@ -46,8 +46,8 @@ namespace UNet
 
 		public UPoller()
 		{
-			this.host = NativeMethods.ENetHostCreate(
-				IntPtr.Zero, NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, 0, 0, 0);
+			this.host = NativeMethods.ENetHostCreate(IntPtr.Zero, NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID,
+					0, 0, 0);
 
 			if (this.host == IntPtr.Zero)
 			{
@@ -123,7 +123,7 @@ namespace UNet
 			ENetAddress nativeAddress = address.Struct;
 
 			IntPtr ptr = NativeMethods.ENetHostConnect(this.host, ref nativeAddress,
-			                                           NativeMethods.ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT, 0);
+					NativeMethods.ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT, 0);
 			USocket socket = new USocket(ptr);
 			if (socket.PeerPtr == IntPtr.Zero)
 			{
@@ -175,12 +175,12 @@ namespace UNet
 				{
 					break;
 				}
-				localQueue.Enqueue(action);
+				this.localQueue.Enqueue(action);
 			}
 
-			while (localQueue.Count > 0)
+			while (this.localQueue.Count > 0)
 			{
-				Action a = localQueue.Dequeue();
+				Action a = this.localQueue.Dequeue();
 				a();
 			}
 		}

+ 2 - 2
CSharp/Platform/UNet/UService.cs

@@ -42,9 +42,9 @@ namespace UNet
 
 			if (disposing)
 			{
-				foreach (ObjectId id in idChannels.Keys.ToArray())
+				foreach (ObjectId id in this.idChannels.Keys.ToArray())
 				{
-					UChannel channel = idChannels[id];
+					UChannel channel = this.idChannels[id];
 					channel.Dispose();
 				}
 				this.poller.Dispose();

+ 9 - 4
CSharp/Test/ModelTest/ModelTest.csproj

@@ -30,11 +30,16 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="MongoDB.Bson">
-      <HintPath>..\..\packages\mongocsharpdriver.1.10.0-rc1\lib\net35\MongoDB.Bson.dll</HintPath>
+    <Reference Include="MongoDB.Bson, Version=2.0.0.788, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\MongoDB.Bson.2.0.0-rc0\lib\net45\MongoDB.Bson.dll</HintPath>
     </Reference>
-    <Reference Include="MongoDB.Driver">
-      <HintPath>..\..\packages\mongocsharpdriver.1.10.0\lib\net35\MongoDB.Driver.dll</HintPath>
+    <Reference Include="MongoDB.Driver, Version=2.0.0.788, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\MongoDB.Driver.2.0.0-rc0\lib\net45\MongoDB.Driver.dll</HintPath>
+    </Reference>
+    <Reference Include="MongoDB.Driver.Core">
+      <HintPath>..\..\packages\MongoDB.Driver.Core.2.0.0-rc0\lib\net45\MongoDB.Driver.Core.dll</HintPath>
     </Reference>
     <Reference Include="nunit.framework">
       <HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>

+ 5 - 14
CSharp/Test/ModelTest/MongoDBTest.cs

@@ -1,8 +1,6 @@
-using System;
-using Common.Helper;
+using Common.Helper;
 using Model;
 using MongoDB.Driver;
-using MongoDB.Driver.Builders;
 using NUnit.Framework;
 
 namespace MongoDBTest
@@ -11,13 +9,12 @@ namespace MongoDBTest
 	public class MongoDBTest
 	{
 		[Test]
-		public void TestMongoDB()
+		public async void TestMongoDB()
 		{
 			const string connectionString = "mongodb://localhost";
 			MongoClient client = new MongoClient(connectionString);
-			MongoServer server = client.GetServer();
-			MongoDatabase database = server.GetDatabase("test");
-			MongoCollection<Unit> collection = database.GetCollection<Unit>("Unit");
+			IMongoDatabase database = client.GetDatabase("test");
+			IMongoCollection<Unit> collection = database.GetCollection<Unit>("Unit");
 
 			World world = World.Instance;
 
@@ -34,13 +31,7 @@ namespace MongoDBTest
 			Unit player1 = world.GetComponent<FactoryComponent<Unit>>().Create(UnitType.GatePlayer, 1);
 			player1["hp"] = 10;
 
-			collection.Insert(player1);
-
-			IMongoQuery query = Query<Unit>.EQ(e => e.Id, player1.Id);
-			Unit player2 = collection.FindOne(query);
-
-			Console.WriteLine(MongoHelper.ToJson(player2));
-			Assert.AreEqual(MongoHelper.ToJson(player1), MongoHelper.ToJson(player2));
+			await collection.InsertOneAsync(player1);
 
 			Unit player3 = player1.Clone();
 

+ 5 - 2
CSharp/Test/ModelTest/Properties/AssemblyInfo.cs

@@ -1,10 +1,10 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的常规信息通过以下
 // 特性集控制。更改这些特性值可修改
 // 与程序集关联的信息。
+
 [assembly: AssemblyTitle("ModelTest")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
 // 将 ComVisible 设置为 false 使此程序集中的类型
 // 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
 // 则将该类型上的 ComVisible 特性设置为 true。
+
 [assembly: ComVisible(false)]
 
 // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+
 [assembly: Guid("f120341f-2199-4f30-9f50-23789d5ab3b2")]
 
 // 程序集的版本信息由下面四个值组成: 
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
 // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
 // 方法是按如下所示使用“*”: 
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 5 - 2
CSharp/Test/TNetTest/Properties/AssemblyInfo.cs

@@ -1,10 +1,10 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的常规信息通过以下
 // 特性集控制。更改这些特性值可修改
 // 与程序集关联的信息。
+
 [assembly: AssemblyTitle("TNetTest")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
 // 将 ComVisible 设置为 false 使此程序集中的类型
 // 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
 // 则将该类型上的 ComVisible 特性设置为 true。
+
 [assembly: ComVisible(false)]
 
 // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+
 [assembly: Guid("eda665c1-8001-4071-a2d2-4a0e5c09a5e6")]
 
 // 程序集的版本信息由下面四个值组成: 
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
 // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
 // 方法是按如下所示使用“*”: 
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 24 - 22
CSharp/Test/TNetTest/TServiceTest.cs

@@ -49,38 +49,40 @@ namespace TNetTest
 		{
 			const string hostName = "127.0.0.1";
 			const ushort port = 8889;
-			using(IService clientService = new TService())
-			using (IService serverService = new TService(hostName, 8889))
+			using (IService clientService = new TService())
 			{
-				Task task1 = Task.Factory.StartNew(() =>
+				using (IService serverService = new TService(hostName, 8889))
 				{
-					while (!isClientStop)
+					Task task1 = Task.Factory.StartNew(() =>
 					{
-						clientService.Update();
-					}
-				}, TaskCreationOptions.LongRunning);
+						while (!this.isClientStop)
+						{
+							clientService.Update();
+						}
+					}, TaskCreationOptions.LongRunning);
 
-				Task task2 = Task.Factory.StartNew(() =>
-				{
-					while (!isServerStop)
+					Task task2 = Task.Factory.StartNew(() =>
 					{
-						serverService.Update();
-					}
-				}, TaskCreationOptions.LongRunning);
+						while (!this.isServerStop)
+						{
+							serverService.Update();
+						}
+					}, TaskCreationOptions.LongRunning);
 
-				// 往server host线程增加事件,accept
-				serverService.Add(() => this.ServerEvent(serverService));
+					// 往server host线程增加事件,accept
+					serverService.Add(() => this.ServerEvent(serverService));
 
-				Thread.Sleep(1000);
+					Thread.Sleep(1000);
 
-				// 往client host线程增加事件,client线程连接server
-				clientService.Add(() => this.ClientEvent(clientService, hostName, port));
+					// 往client host线程增加事件,client线程连接server
+					clientService.Add(() => this.ClientEvent(clientService, hostName, port));
 
-				this.barrier.SignalAndWait();
+					this.barrier.SignalAndWait();
 
-				serverService.Add(() => { isServerStop = true; });
-				clientService.Add(() => { isClientStop = true; });
-				Task.WaitAll(task1, task2);
+					serverService.Add(() => { this.isServerStop = true; });
+					clientService.Add(() => { this.isClientStop = true; });
+					Task.WaitAll(task1, task2);
+				}
 			}
 		}
 	}

+ 5 - 2
CSharp/Test/UNetTest/Properties/AssemblyInfo.cs

@@ -1,10 +1,10 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的常规信息通过以下
 // 特性集控制。更改这些特性值可修改
 // 与程序集关联的信息。
+
 [assembly: AssemblyTitle("UNetTest")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
 // 将 ComVisible 设置为 false 使此程序集中的类型
 // 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
 // 则将该类型上的 ComVisible 特性设置为 true。
+
 [assembly: ComVisible(false)]
 
 // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+
 [assembly: Guid("83642fc3-a7f2-46a5-8522-a5343c8857ac")]
 
 // 程序集的版本信息由下面四个值组成: 
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
 // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
 // 方法是按如下所示使用“*”: 
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 25 - 24
CSharp/Test/UNetTest/UServiceTest.cs

@@ -2,7 +2,6 @@
 using System.Threading;
 using System.Threading.Tasks;
 using Common.Helper;
-using Common.Logger;
 using Common.Network;
 using NUnit.Framework;
 using UNet;
@@ -28,7 +27,7 @@ namespace UNetTest
 				byte[] bytes = await channel.RecvAsync();
 				CollectionAssert.AreEqual("9876543210".ToByteArray(), bytes);
 			}
-			barrier.RemoveParticipant();
+			this.barrier.RemoveParticipant();
 		}
 
 		private async void ServerEvent(IService service)
@@ -49,36 +48,38 @@ namespace UNetTest
 			const string hostName = "127.0.0.1";
 			const ushort port = 8889;
 			using (IService clientService = new UService(hostName, 8888))
-			using (IService serverService = new UService(hostName, 8889))
-			{	
-				Task task1 = Task.Factory.StartNew(() =>
+			{
+				using (IService serverService = new UService(hostName, 8889))
 				{
-					while (!isClientStop)
+					Task task1 = Task.Factory.StartNew(() =>
 					{
-						clientService.Update();
-					}
-				}, TaskCreationOptions.LongRunning);
+						while (!this.isClientStop)
+						{
+							clientService.Update();
+						}
+					}, TaskCreationOptions.LongRunning);
 
-				Task task2 = Task.Factory.StartNew(() =>
-				{
-					while (!isServerStop)
+					Task task2 = Task.Factory.StartNew(() =>
 					{
-						serverService.Update();
-					}
-				}, TaskCreationOptions.LongRunning);
+						while (!this.isServerStop)
+						{
+							serverService.Update();
+						}
+					}, TaskCreationOptions.LongRunning);
 
-				// 往server host线程增加事件,accept
-				serverService.Add(() => this.ServerEvent(serverService));
+					// 往server host线程增加事件,accept
+					serverService.Add(() => this.ServerEvent(serverService));
 
-				Thread.Sleep(1000);
+					Thread.Sleep(1000);
 
-				// 往client host线程增加事件,client线程连接server
-				clientService.Add(() => this.ClientEvent(clientService, hostName, port));
-				barrier.SignalAndWait();
+					// 往client host线程增加事件,client线程连接server
+					clientService.Add(() => this.ClientEvent(clientService, hostName, port));
+					this.barrier.SignalAndWait();
 
-				serverService.Add(() => { isServerStop = true; });
-				clientService.Add(() => { isClientStop = true; });
-				Task.WaitAll(task1, task2);
+					serverService.Add(() => { this.isServerStop = true; });
+					clientService.Add(() => { this.isClientStop = true; });
+					Task.WaitAll(task1, task2);
+				}
 			}
 		}
 	}

+ 12 - 5
CSharp/ThirdParty/Nuget/Nuget.csproj

@@ -59,11 +59,16 @@
     <Reference Include="Microsoft.Practices.ServiceLocation">
       <HintPath>..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
     </Reference>
-    <Reference Include="MongoDB.Bson">
-      <HintPath>..\..\packages\mongocsharpdriver.1.10.0\lib\net35\MongoDB.Bson.dll</HintPath>
+    <Reference Include="MongoDB.Bson, Version=2.0.0.788, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\MongoDB.Bson.2.0.0-rc0\lib\net45\MongoDB.Bson.dll</HintPath>
     </Reference>
-    <Reference Include="MongoDB.Driver">
-      <HintPath>..\..\packages\mongocsharpdriver.1.10.0\lib\net35\MongoDB.Driver.dll</HintPath>
+    <Reference Include="MongoDB.Driver, Version=2.0.0.788, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\MongoDB.Driver.2.0.0-rc0\lib\net45\MongoDB.Driver.dll</HintPath>
+    </Reference>
+    <Reference Include="MongoDB.Driver.Core">
+      <HintPath>..\..\packages\MongoDB.Driver.Core.2.0.0-rc0\lib\net45\MongoDB.Driver.Core.dll</HintPath>
     </Reference>
     <Reference Include="NLog">
       <HintPath>..\..\packages\NLog.3.2.0.0\lib\net45\NLog.dll</HintPath>
@@ -87,7 +92,9 @@
   </ItemGroup>
   <ItemGroup>
     <None Include="app.config" />
-    <None Include="packages.config" />
+    <None Include="packages.config">
+      <SubType>Designer</SubType>
+    </None>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />

+ 5 - 2
CSharp/ThirdParty/Nuget/Properties/AssemblyInfo.cs

@@ -1,10 +1,10 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的常规信息通过以下
 // 特性集控制。更改这些特性值可修改
 // 与程序集关联的信息。
+
 [assembly: AssemblyTitle("Nuget")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
 // 将 ComVisible 设置为 false 使此程序集中的类型
 // 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
 // 则将该类型上的 ComVisible 特性设置为 true。
+
 [assembly: ComVisible(false)]
 
 // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+
 [assembly: Guid("5101651d-5db1-4fd3-86ce-114561811256")]
 
 // 程序集的版本信息由下面四个值组成: 
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
 // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
 // 方法是按如下所示使用“*”: 
 // [assembly: AssemblyVersion("1.0.*")]
+
 [assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 3 - 1
CSharp/ThirdParty/Nuget/packages.config

@@ -2,7 +2,9 @@
 <packages>
   <package id="CommandLineParser" version="1.9.71" targetFramework="net45" />
   <package id="CommonServiceLocator" version="1.3" targetFramework="net45" />
-  <package id="mongocsharpdriver" version="1.10.0" targetFramework="net45" />
+  <package id="MongoDB.Bson" version="2.0.0-rc0" targetFramework="net45" />
+  <package id="MongoDB.Driver" version="2.0.0-rc0" targetFramework="net45" />
+  <package id="MongoDB.Driver.Core" version="2.0.0-rc0" targetFramework="net45" />
   <package id="NLog" version="3.2.0.0" targetFramework="net45" />
   <package id="NUnit" version="2.6.4" targetFramework="net45" />
   <package id="Prism" version="5.0.0" targetFramework="net45" />