mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 00:06:02 +00:00
添加Hashtable中Json对象的反序列化工具方法 (#36)
* 添加Hashtable中Json对象的反序列化工具方法 * ErrorType -> ErrorIPAddressType * 新增房间状态:Matching
This commit is contained in:
parent
ae4f8aa7aa
commit
5a63b97341
@ -1,4 +1,5 @@
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Collections;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
@ -56,7 +57,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
public static ErrorType IsServerAddress(string str)
|
||||
public static ErrorIPAddressType IsServerAddress(string str)
|
||||
{
|
||||
string[] strs = str.Split(':');
|
||||
string ip;
|
||||
@ -71,11 +72,11 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
ip = strs[0];
|
||||
port = Convert.ToInt32(strs[1]);
|
||||
}
|
||||
else return ErrorType.WrongFormat;
|
||||
if (IsIP(ip) && port > 0 && port < 65536) return ErrorType.None;
|
||||
else if (!IsIP(ip) && port > 0 && port < 65536) return ErrorType.IsNotIP;
|
||||
else if (IsIP(ip) && (port <= 0 || port >= 65536)) return ErrorType.IsNotPort;
|
||||
else return ErrorType.WrongFormat;
|
||||
else return ErrorIPAddressType.WrongFormat;
|
||||
if (IsIP(ip) && port > 0 && port < 65536) return ErrorIPAddressType.None;
|
||||
else if (!IsIP(ip) && port > 0 && port < 65536) return ErrorIPAddressType.IsNotIP;
|
||||
else if (IsIP(ip) && (port <= 0 || port >= 65536)) return ErrorIPAddressType.IsNotPort;
|
||||
else return ErrorIPAddressType.WrongFormat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -84,12 +85,12 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <returns></returns>
|
||||
public static ErrorType IsServerAddress(string ip, int port)
|
||||
public static ErrorIPAddressType IsServerAddress(string ip, int port)
|
||||
{
|
||||
if (IsIP(ip) && port > 0 && port < 65536) return ErrorType.None;
|
||||
else if (!IsIP(ip) && port > 0 && port < 65536) return ErrorType.IsNotIP;
|
||||
else if (IsIP(ip) && (port <= 0 || port >= 65536)) return ErrorType.IsNotPort;
|
||||
else return ErrorType.WrongFormat;
|
||||
if (IsIP(ip) && port > 0 && port < 65536) return ErrorIPAddressType.None;
|
||||
else if (!IsIP(ip) && port > 0 && port < 65536) return ErrorIPAddressType.IsNotIP;
|
||||
else if (IsIP(ip) && (port <= 0 || port >= 65536)) return ErrorIPAddressType.IsNotPort;
|
||||
else return ErrorIPAddressType.WrongFormat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -136,6 +137,18 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
{
|
||||
return Service.JsonManager.GetObject<T>(json);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化Hashtable中的Json对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="hashtable"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static T? JsonDeserializeFromHashtable<T>(Hashtable hashtable, string key)
|
||||
{
|
||||
return Service.JsonManager.GetObject<T>(hashtable, key);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -11,8 +11,9 @@
|
||||
public enum RoomState
|
||||
{
|
||||
Created,
|
||||
Closed,
|
||||
Matching,
|
||||
Gaming,
|
||||
Close,
|
||||
Complete
|
||||
}
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@
|
||||
Server
|
||||
}
|
||||
|
||||
public enum ErrorType
|
||||
public enum ErrorIPAddressType
|
||||
{
|
||||
None,
|
||||
IsNotIP,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user