提交 6b9da7a2 编写于 作者: T tanghai

减少IpEndpoint的创建

上级 54688918
......@@ -46,3 +46,4 @@ _ReSharper.CSharp/
/Unity/Assets/StreamingAssets.meta
.DS_Store
Server/.DS_Store
/Server/.vscode/
......@@ -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;
}
}
}
......
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;
}
}
}
......
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;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册