Эх сурвалжийг харах

减少IpEndpoint的创建

tanghai 8 жил өмнө
parent
commit
6b9da7a227

+ 1 - 0
.gitignore

@@ -46,3 +46,4 @@ _ReSharper.CSharp/
 /Unity/Assets/StreamingAssets.meta
 .DS_Store
 Server/.DS_Store
+/Server/.vscode/

+ 7 - 6
Server/Model/Component/Config/OuterConfig.cs

@@ -10,12 +10,13 @@ namespace Model
 		public int Port { get; set; }
 
 		[BsonIgnore]
-		public string Address
+		public IPEndPoint ipEndPoint;
+
+		public override void EndInit()
 		{
-			get
-			{
-				return $"{this.Host}:{this.Port}";
-			}
+			base.EndInit();
+
+			this.ipEndPoint = NetworkHelper.ToIPEndPoint(this.Host, this.Port);
 		}
 
 		[BsonIgnore]
@@ -23,7 +24,7 @@ namespace Model
 		{
 			get
 			{
-				return NetworkHelper.ToIPEndPoint(this.Host, this.Port);
+				return this.ipEndPoint;
 			}
 		}
 	}

+ 15 - 4
Unity/Assets/Scripts/Component/Config/ClientConfig.cs

@@ -1,4 +1,5 @@
-using MongoDB.Bson.Serialization.Attributes;
+using System.Net;
+using MongoDB.Bson.Serialization.Attributes;
 
 namespace Model
 {
@@ -6,13 +7,23 @@ namespace Model
 	{
 		public string Host = "";
 		public int Port;
-		
+
+		[BsonIgnore]
+		public IPEndPoint ipEndPoint;
+
+		public override void EndInit()
+		{
+			base.EndInit();
+
+			this.ipEndPoint = NetworkHelper.ToIPEndPoint(this.Host, this.Port);
+		}
+
 		[BsonIgnore]
-		public string Address
+		public IPEndPoint IPEndPoint
 		{
 			get
 			{
-				return $"{this.Host}:{this.Port}";
+				return this.ipEndPoint;
 			}
 		}
 	}

+ 14 - 3
Unity/Assets/Scripts/Component/Config/InnerConfig.cs

@@ -1,4 +1,5 @@
-using MongoDB.Bson.Serialization.Attributes;
+using System.Net;
+using MongoDB.Bson.Serialization.Attributes;
 
 namespace Model
 {
@@ -9,11 +10,21 @@ namespace Model
 		public int Port { get; set; }
 
 		[BsonIgnore]
-		public string Address
+		public IPEndPoint ipEndPoint;
+
+		public override void EndInit()
+		{
+			base.EndInit();
+
+			this.ipEndPoint = NetworkHelper.ToIPEndPoint(this.Host, this.Port);
+		}
+
+		[BsonIgnore]
+		public IPEndPoint IPEndPoint
 		{
 			get
 			{
-				return $"{this.Host}:{this.Port}";
+				return this.ipEndPoint;
 			}
 		}
 	}