Parcourir la source

修改了dispose方法,清理了一下不需要用到的工程引用

tanghai il y a 13 ans
Parent
commit
733b36e548

+ 2 - 2
CSharp/App/Editor/Editor.csproj

@@ -106,7 +106,7 @@
       <Name>Infrastructure</Name>
     </ProjectReference>
     <ProjectReference Include="..\Modules\BehaviorTree\BehaviorTree.csproj">
-      <Project>{6CD185D1-08E0-4729-A999-2D5B57BA8193}</Project>
+      <Project>{6cd185d1-08e0-4729-a999-2d5b57ba8193}</Project>
       <Name>BehaviorTree</Name>
     </ProjectReference>
     <ProjectReference Include="..\Modules\Robot\Robot.csproj">
@@ -114,7 +114,7 @@
       <Name>Robot</Name>
     </ProjectReference>
     <ProjectReference Include="..\Modules\WaiGua\WaiGua.csproj">
-      <Project>{5AA48F9A-455D-4CD8-A605-A3AC38283E60}</Project>
+      <Project>{5aa48f9a-455d-4cd8-a605-a3ac38283e60}</Project>
       <Name>WaiGua</Name>
     </ProjectReference>
   </ItemGroup>

+ 0 - 1
CSharp/App/Infrastructure/Infrastructure.csproj

@@ -39,7 +39,6 @@
     <Reference Include="Microsoft.Practices.Prism, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
       <HintPath>..\..\packages\Prism.4.1.0.0\lib\NET40\Microsoft.Practices.Prism.dll</HintPath>
     </Reference>
-    <Reference Include="PresentationFramework" />
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.Composition" />
     <Reference Include="System.Core" />

+ 17 - 1
CSharp/App/Modules/Robot/RobotViewModel.cs

@@ -13,7 +13,7 @@ using Robot.Protos;
 namespace Modules.Robot
 {
 	[Export(contractType: typeof (RobotViewModel)), PartCreationPolicy(creationPolicy: CreationPolicy.NonShared)]
-	internal class RobotViewModel: NotificationObject
+	internal class RobotViewModel: NotificationObject, IDisposable
 	{
 		private readonly Host host;
 		private string logText = "";
@@ -47,6 +47,22 @@ namespace Modules.Robot
 			this.timer.Start();
 		}
 
+		~RobotViewModel()
+		{
+			this.Disposing(false);
+		}
+
+		public void Dispose()
+		{
+			this.Disposing(true);
+			GC.SuppressFinalize(this);
+		}
+
+		protected virtual void Disposing(bool disposing)
+		{	
+			this.host.Dispose();
+		}
+
 		public async void StartClient()
 		{
 			try

+ 0 - 11
CSharp/App/Modules/WaiGua/WaiGua.csproj

@@ -34,9 +34,6 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
-      <HintPath>..\..\..\packages\Prism.4.1.0.0\lib\NET40\Microsoft.Expression.Interactions.dll</HintPath>
-    </Reference>
     <Reference Include="Microsoft.Practices.Prism">
       <HintPath>..\..\..\packages\Prism.4.1.0.0\lib\NET40\Microsoft.Practices.Prism.dll</HintPath>
     </Reference>
@@ -45,11 +42,7 @@
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.Composition" />
-    <Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
-      <HintPath>..\..\..\packages\Prism.4.1.0.0\lib\NET40\System.Windows.Interactivity.dll</HintPath>
-    </Reference>
     <Reference Include="System.Xml" />
-    <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xaml">
       <RequiredTargetFramework>4.0</RequiredTargetFramework>
@@ -81,10 +74,6 @@
     <None Include="Packages.config" />
   </ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\..\..\Platform\Log\Log.csproj">
-      <Project>{72e16572-fc1f-4a9e-bc96-035417239298}</Project>
-      <Name>Log</Name>
-    </ProjectReference>
     <ProjectReference Include="..\..\Infrastructure\Infrastructure.csproj">
       <Project>{48a2e149-0dac-41b4-bb54-dfbccd6d42b3}</Project>
       <Name>Infrastructure</Name>

+ 4 - 6
CSharp/Platform/Helper/XmlHelper.cs

@@ -30,13 +30,11 @@ namespace Helper
 		{
 			T t = default(T);
 			var xmlSerializer = new XmlSerializer(typeof(T));
-			using (Stream xmlStream = new MemoryStream(Encoding.UTF8.GetBytes(xmlString)))
+			Stream xmlStream = new MemoryStream(Encoding.UTF8.GetBytes(xmlString));
+			using (var xmlReader = XmlReader.Create(xmlStream))
 			{
-				using (var xmlReader = XmlReader.Create(xmlStream))
-				{
-					Object obj = xmlSerializer.Deserialize(xmlReader);
-					t = (T)obj;
-				}
+				Object obj = xmlSerializer.Deserialize(xmlReader);
+				t = (T)obj;
 			}
 			return t;
 		}

+ 0 - 5
CSharp/Platform/Log/Log.csproj

@@ -37,11 +37,6 @@
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ALogDecorater.cs" />

+ 3 - 3
CSharp/ThirdParty/ENetCS/Address.cs

@@ -18,7 +18,7 @@ namespace ENet
 			get
 			{
 				var hostIP = new StringBuilder(256);
-				Native.enet_address_get_host_ip(ref this.address, hostIP, (uint) hostIP.Length);
+				NativeMethods.enet_address_get_host_ip(ref this.address, hostIP, (uint) hostIP.Length);
 				return hostIP.ToString();
 			}
 		}
@@ -28,12 +28,12 @@ namespace ENet
 			get
 			{
 				var hostName = new StringBuilder(256);
-				Native.enet_address_get_host(ref this.address, hostName, (uint) hostName.Length);
+				NativeMethods.enet_address_get_host(ref this.address, hostName, (uint) hostName.Length);
 				return hostName.ToString();
 			}
 			set
 			{
-				Native.enet_address_set_host(ref this.address, value);
+				NativeMethods.enet_address_set_host(ref this.address, value);
 			}
 		}
 

+ 2 - 13
CSharp/ThirdParty/ENetCS/ENetCS.csproj

@@ -35,11 +35,6 @@
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Address.cs" />
@@ -47,22 +42,16 @@
     <Compile Include="Event.cs" />
     <Compile Include="Host.cs" />
     <Compile Include="Library.cs" />
-    <Compile Include="Native.cs" />
+    <Compile Include="NativeMethods.cs" />
     <Compile Include="PeerEvent.cs" />
     <Compile Include="PeersManager.cs" />
-    <Compile Include="Structs.cs" />
+    <Compile Include="NativeStructs.cs" />
     <Compile Include="Packet.cs" />
     <Compile Include="Peer.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Properties\" />
   </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\Platform\Log\Log.csproj">
-      <Project>{72e16572-fc1f-4a9e-bc96-035417239298}</Project>
-      <Name>Log</Name>
-    </ProjectReference>
-  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 20 - 23
CSharp/ThirdParty/ENetCS/Host.cs

@@ -20,17 +20,17 @@ namespace ENet
 		private Action events;
 
 		public Host(
-				Address address, uint peerLimit = Native.ENET_PROTOCOL_MAXIMUM_PEER_ID, uint channelLimit = 0,
+				Address address, uint peerLimit = NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, uint channelLimit = 0,
 				uint incomingBandwidth = 0, uint outgoingBandwidth = 0, bool enableCrc = true)
 		{
-			if (peerLimit > Native.ENET_PROTOCOL_MAXIMUM_PEER_ID)
+			if (peerLimit > NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID)
 			{
 				throw new ArgumentOutOfRangeException("peerLimit");
 			}
 			CheckChannelLimit(channelLimit);
 
 			ENetAddress nativeAddress = address.Struct;
-			this.host = Native.enet_host_create(ref nativeAddress, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth);
+			this.host = NativeMethods.enet_host_create(ref nativeAddress, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth);
 
 			if (this.host == IntPtr.Zero)
 			{
@@ -39,21 +39,21 @@ namespace ENet
 
 			if (enableCrc)
 			{
-				Native.enet_enable_crc(this.host);
+				NativeMethods.enet_enable_crc(this.host);
 			}
 		}
 
 		public Host(
-				uint peerLimit = Native.ENET_PROTOCOL_MAXIMUM_PEER_ID, uint channelLimit = 0, uint incomingBandwidth = 0,
+				uint peerLimit = NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, uint channelLimit = 0, uint incomingBandwidth = 0,
 				uint outgoingBandwidth = 0, bool enableCrc = true)
 		{
-			if (peerLimit > Native.ENET_PROTOCOL_MAXIMUM_PEER_ID)
+			if (peerLimit > NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID)
 			{
 				throw new ArgumentOutOfRangeException("peerLimit");
 			}
 			CheckChannelLimit(channelLimit);
 
-			this.host = Native.enet_host_create(IntPtr.Zero, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth);
+			this.host = NativeMethods.enet_host_create(IntPtr.Zero, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth);
 
 			if (this.host == IntPtr.Zero)
 			{
@@ -62,7 +62,7 @@ namespace ENet
 
 			if (enableCrc)
 			{
-				Native.enet_enable_crc(this.host);
+				NativeMethods.enet_enable_crc(this.host);
 			}
 		}
 
@@ -84,17 +84,14 @@ namespace ENet
 				return;
 			}
 
-			if (disposing)
-			{
-				Native.enet_host_destroy(this.host);
-			}
+			NativeMethods.enet_host_destroy(this.host);
 
 			this.host = IntPtr.Zero;
 		}
 
 		private static void CheckChannelLimit(uint channelLimit)
 		{
-			if (channelLimit > Native.ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT)
+			if (channelLimit > NativeMethods.ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT)
 			{
 				throw new ArgumentOutOfRangeException("channelLimit");
 			}
@@ -103,7 +100,7 @@ namespace ENet
 		private int CheckEvents(out Event e)
 		{
 			var enetEv = new ENetEvent();
-			int ret = Native.enet_host_check_events(this.host, enetEv);
+			int ret = NativeMethods.enet_host_check_events(this.host, enetEv);
 			e = new Event(this, enetEv);
 			return ret;
 		}
@@ -114,32 +111,32 @@ namespace ENet
 			{
 				throw new ArgumentOutOfRangeException("timeout");
 			}
-			return Native.enet_host_service(this.host, null, (uint) timeout);
+			return NativeMethods.enet_host_service(this.host, null, (uint) timeout);
 		}
 
 		public void Broadcast(byte channelID, ref Packet packet)
 		{
-			Native.enet_host_broadcast(this.host, channelID, packet.NativePtr);
+			NativeMethods.enet_host_broadcast(this.host, channelID, packet.NativePtr);
 		}
 
 		public void CompressWithRangeEncoder()
 		{
-			Native.enet_host_compress_with_range_encoder(this.host);
+			NativeMethods.enet_host_compress_with_range_encoder(this.host);
 		}
 
 		public void DoNotCompress()
 		{
-			Native.enet_host_compress(this.host, IntPtr.Zero);
+			NativeMethods.enet_host_compress(this.host, IntPtr.Zero);
 		}
 
 		public Task<Peer> ConnectAsync(
-				Address address, uint channelLimit = Native.ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT, uint data = 0)
+				Address address, uint channelLimit = NativeMethods.ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT, uint data = 0)
 		{
 			CheckChannelLimit(channelLimit);
 
 			var tcs = new TaskCompletionSource<Peer>();
 			ENetAddress nativeAddress = address.Struct;
-			IntPtr p = Native.enet_host_connect(this.host, ref nativeAddress, channelLimit, data);
+			IntPtr p = NativeMethods.enet_host_connect(this.host, ref nativeAddress, channelLimit, data);
 			if (p == IntPtr.Zero)
 			{
 				throw new ENetException(0, "Host connect call failed.");
@@ -151,18 +148,18 @@ namespace ENet
 
 		public void Flush()
 		{
-			Native.enet_host_flush(this.host);
+			NativeMethods.enet_host_flush(this.host);
 		}
 
 		public void SetBandwidthLimit(uint incomingBandwidth, uint outgoingBandwidth)
 		{
-			Native.enet_host_bandwidth_limit(this.host, incomingBandwidth, outgoingBandwidth);
+			NativeMethods.enet_host_bandwidth_limit(this.host, incomingBandwidth, outgoingBandwidth);
 		}
 
 		public void SetChannelLimit(uint channelLimit)
 		{
 			CheckChannelLimit(channelLimit);
-			Native.enet_host_channel_limit(this.host, channelLimit);
+			NativeMethods.enet_host_channel_limit(this.host, channelLimit);
 		}
 
 		public event Action Events

+ 4 - 4
CSharp/ThirdParty/ENetCS/Library.cs

@@ -5,7 +5,7 @@
 		public static void Initialize()
 		{
 			var inits = new ENetCallbacks();
-			int ret = Native.enet_initialize_with_callbacks(Native.ENET_VERSION, ref inits);
+			int ret = NativeMethods.enet_initialize_with_callbacks(NativeMethods.ENET_VERSION, ref inits);
 			if (ret < 0)
 			{
 				throw new ENetException(ret, "Initialization failed.");
@@ -14,18 +14,18 @@
 
 		public static void Deinitialize()
 		{
-			Native.enet_deinitialize();
+			NativeMethods.enet_deinitialize();
 		}
 
 		public static uint Time
 		{
 			get
 			{
-				return Native.enet_time_get();
+				return NativeMethods.enet_time_get();
 			}
 			set
 			{
-				Native.enet_time_set(value);
+				NativeMethods.enet_time_set(value);
 			}
 		}
 	}

+ 33 - 33
CSharp/ThirdParty/ENetCS/Native.cs → CSharp/ThirdParty/ENetCS/NativeMethods.cs

@@ -4,7 +4,7 @@ using System.Text;
 
 namespace ENet
 {
-	public static class Native
+	public static class NativeMethods
 	{
 		private const string LIB = "ENet.dll";
 
@@ -20,103 +20,103 @@ namespace ENet
 		public const uint ENET_HOST_BROADCAST = 0xffffffff;
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern int enet_address_set_host(ref ENetAddress address, string hostName);
+		internal static extern int enet_address_set_host(ref ENetAddress address, string hostName);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern int enet_address_get_host(ref ENetAddress address, StringBuilder hostName, uint nameLength);
+		internal static extern int enet_address_get_host(ref ENetAddress address, StringBuilder hostName, uint nameLength);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern int enet_address_get_host_ip(ref ENetAddress address, StringBuilder hostIp, uint ipLength);
+		internal static extern int enet_address_get_host_ip(ref ENetAddress address, StringBuilder hostIp, uint ipLength);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_deinitialize();
+		internal static extern void enet_deinitialize();
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern int enet_initialize();
+		internal static extern int enet_initialize();
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern int enet_initialize_with_callbacks(uint version, ref ENetCallbacks inits);
+		internal static extern int enet_initialize_with_callbacks(uint version, ref ENetCallbacks inits);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_enable_crc(IntPtr host);
+		internal static extern void enet_enable_crc(IntPtr host);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern int enet_host_compress_with_range_encoder(IntPtr host);
+		internal static extern int enet_host_compress_with_range_encoder(IntPtr host);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern IntPtr enet_host_create(
+		internal static extern IntPtr enet_host_create(
 				ref ENetAddress address, uint peerLimit, uint channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern IntPtr enet_host_create(
+		internal static extern IntPtr enet_host_create(
 				IntPtr address, uint peerLimit, uint channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_host_destroy(IntPtr host);
+		internal static extern void enet_host_destroy(IntPtr host);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern IntPtr enet_host_connect(IntPtr host, ref ENetAddress address, uint channelCount, uint data);
+		internal static extern IntPtr enet_host_connect(IntPtr host, ref ENetAddress address, uint channelCount, uint data);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_host_broadcast(IntPtr host, byte channelID, IntPtr packet);
+		internal static extern void enet_host_broadcast(IntPtr host, byte channelID, IntPtr packet);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_host_compress(IntPtr host, IntPtr compressor);
+		internal static extern void enet_host_compress(IntPtr host, IntPtr compressor);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_host_channel_limit(IntPtr host, uint channelLimit);
+		internal static extern void enet_host_channel_limit(IntPtr host, uint channelLimit);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_host_bandwidth_limit(IntPtr host, uint incomingBandwidth, uint outgoingBandwidth);
+		internal static extern void enet_host_bandwidth_limit(IntPtr host, uint incomingBandwidth, uint outgoingBandwidth);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_host_flush(IntPtr host);
+		internal static extern void enet_host_flush(IntPtr host);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern int enet_host_check_events(IntPtr host, ENetEvent ev);
+		internal static extern int enet_host_check_events(IntPtr host, ENetEvent ev);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern int enet_host_service(IntPtr host, ENetEvent ev, uint timeout);
+		internal static extern int enet_host_service(IntPtr host, ENetEvent ev, uint timeout);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern uint enet_time_get();
+		internal static extern uint enet_time_get();
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_time_set(uint newTimeBase);
+		internal static extern void enet_time_set(uint newTimeBase);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern IntPtr enet_packet_create(string data, uint dataLength, PacketFlags flags);
+		internal static extern IntPtr enet_packet_create(string data, uint dataLength, PacketFlags flags);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_packet_destroy(IntPtr packet);
+		internal static extern void enet_packet_destroy(IntPtr packet);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern int enet_packet_resize(IntPtr packet, uint dataLength);
+		internal static extern int enet_packet_resize(IntPtr packet, uint dataLength);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_peer_throttle_configure(
+		internal static extern void enet_peer_throttle_configure(
 				IntPtr peer, uint interval, uint acceleration, uint deceleration);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern int enet_peer_send(IntPtr peer, byte channelID, IntPtr packet);
+		internal static extern int enet_peer_send(IntPtr peer, byte channelID, IntPtr packet);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern IntPtr enet_peer_receive(IntPtr peer, out byte channelID);
+		internal static extern IntPtr enet_peer_receive(IntPtr peer, out byte channelID);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_peer_reset(IntPtr peer);
+		internal static extern void enet_peer_reset(IntPtr peer);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_peer_ping(IntPtr peer);
+		internal static extern void enet_peer_ping(IntPtr peer);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_peer_disconnect_now(IntPtr peer, uint data);
+		internal static extern void enet_peer_disconnect_now(IntPtr peer, uint data);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_peer_disconnect(IntPtr peer, uint data);
+		internal static extern void enet_peer_disconnect(IntPtr peer, uint data);
 
 		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl)]
-		public static extern void enet_peer_disconnect_later(IntPtr peer, uint data);
+		internal static extern void enet_peer_disconnect_later(IntPtr peer, uint data);
 
 		public static bool memcmp(byte[] s1, byte[] s2)
 		{

+ 1 - 1
CSharp/ThirdParty/ENetCS/Structs.cs → CSharp/ThirdParty/ENetCS/NativeStructs.cs

@@ -54,7 +54,7 @@ namespace ENet
 		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
 		public delegate void no_memory_cb();
 
-		public IntPtr malloc, free, no_memory;
+		private IntPtr malloc, free, no_memory;
 	}
 
 	[StructLayout(LayoutKind.Sequential)]

+ 2 - 6
CSharp/ThirdParty/ENetCS/Packet.cs

@@ -21,7 +21,7 @@ namespace ENet
 			{
 				throw new ArgumentNullException("data");
 			}
-			this.packet = Native.enet_packet_create(data, (uint) data.Length, flags);
+			this.packet = NativeMethods.enet_packet_create(data, (uint) data.Length, flags);
 			if (this.packet == IntPtr.Zero)
 			{
 				throw new ENetException(0, "Packet creation call failed.");
@@ -46,11 +46,7 @@ namespace ENet
 				return;
 			}
 
-			if (disposing)
-			{
-				Native.enet_packet_destroy(this.packet);
-			}
-
+			NativeMethods.enet_packet_destroy(this.packet);
 			this.packet = IntPtr.Zero;
 		}
 

+ 9 - 12
CSharp/ThirdParty/ENetCS/Peer.cs

@@ -28,18 +28,15 @@ namespace ENet
 			GC.SuppressFinalize(this);
 		}
 
-		protected void Dispose(bool disposing)
+		protected virtual void Dispose(bool disposing)
 		{
 			if (this.peer == IntPtr.Zero)
 			{
 				return;
 			}
 
-			if (disposing)
-			{
-				this.host.PeersManager.Remove(this.peer);
-				Native.enet_peer_reset(this.peer);
-			}
+			this.host.PeersManager.Remove(this.peer);
+			NativeMethods.enet_peer_reset(this.peer);
 			this.peer = IntPtr.Zero;
 		}
 
@@ -81,12 +78,12 @@ namespace ENet
 
 		public void Ping()
 		{
-			Native.enet_peer_ping(this.peer);
+			NativeMethods.enet_peer_ping(this.peer);
 		}
 
 		public void ConfigureThrottle(uint interval, uint acceleration, uint deceleration)
 		{
-			Native.enet_peer_throttle_configure(this.peer, interval, acceleration, deceleration);
+			NativeMethods.enet_peer_throttle_configure(this.peer, interval, acceleration, deceleration);
 		}
 
 		public void Send(byte channelID, string data)
@@ -99,7 +96,7 @@ namespace ENet
 
 		public void Send(byte channelID, Packet packet)
 		{
-			Native.enet_peer_send(this.peer, channelID, packet.NativePtr);
+			NativeMethods.enet_peer_send(this.peer, channelID, packet.NativePtr);
 		}
 
 		public Task<Packet> ReceiveAsync()
@@ -113,7 +110,7 @@ namespace ENet
 		{
 			var tcs = new TaskCompletionSource<bool>();
 			this.PeerEvent.Disconnect += e => tcs.TrySetResult(true);
-			Native.enet_peer_disconnect(this.peer, data);
+			NativeMethods.enet_peer_disconnect(this.peer, data);
 			return tcs.Task;
 		}
 
@@ -121,13 +118,13 @@ namespace ENet
 		{
 			var tcs = new TaskCompletionSource<bool>();
 			this.PeerEvent.Disconnect += e => tcs.TrySetResult(true);
-			Native.enet_peer_disconnect_later(this.peer, data);
+			NativeMethods.enet_peer_disconnect_later(this.peer, data);
 			return tcs.Task;
 		}
 
 		public void DisconnectNow(uint data)
 		{
-			Native.enet_peer_disconnect_now(this.peer, data);
+			NativeMethods.enet_peer_disconnect_now(this.peer, data);
 		}
 	}
 }

+ 1 - 1
CSharp/Tools/ProtobufTool/ProtobufGenerator.cs

@@ -19,7 +19,7 @@ namespace ProtobufTool
 
 		protected override byte[] GenerateCode(string inputFileName, string inputFileContent)
 		{
-			using (var stream = File.Open("E:\\ProtobufTool.log", FileMode.OpenOrCreate))
+			var stream = File.Open("E:\\ProtobufTool.log", FileMode.OpenOrCreate);
 			using (var streamWriter = new StreamWriter(stream))
 			{
 				streamWriter.WriteLine("input: {0}\r\n {1}", inputFileName, inputFileContent);

+ 3 - 2
CSharp/Tools/ProtobufTool/ProtobufTool.csproj

@@ -31,7 +31,7 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <PropertyGroup>
-    <SignAssembly>true</SignAssembly>
+    <SignAssembly>false</SignAssembly>
   </PropertyGroup>
   <PropertyGroup>
     <AssemblyOriginatorKeyFile>..\..\Egametang.pfx</AssemblyOriginatorKeyFile>
@@ -65,7 +65,8 @@
     </PreBuildEvent>
   </PropertyGroup>
   <PropertyGroup>
-    <PostBuildEvent>$(ProjectDir)\register.bat $(TargetPath)</PostBuildEvent>
+    <PostBuildEvent>
+    </PostBuildEvent>
   </PropertyGroup>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.