mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-22 06:17:48 +00:00
fix serialization issue.
Apparently the JSON parser uses this same serialization method under the hood to create objects from JSON.
This commit is contained in:
parent
fd71ceeab5
commit
71aadcbecb
@ -13,18 +13,18 @@ namespace WinUI
|
|||||||
{
|
{
|
||||||
protected NetworkRoute(SerializationInfo info, StreamingContext ctx)
|
protected NetworkRoute(SerializationInfo info, StreamingContext ctx)
|
||||||
{
|
{
|
||||||
Target = info.GetString("Target");
|
Target = info.GetString("target");
|
||||||
Via = info.GetString("Via");
|
Via = info.GetString("via");
|
||||||
Flags = info.GetInt32("Flags");
|
Flags = info.GetInt32("flags");
|
||||||
Metric = info.GetInt32("Metric");
|
Metric = info.GetInt32("metric");
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void GetObjectData(SerializationInfo info, StreamingContext ctx)
|
public virtual void GetObjectData(SerializationInfo info, StreamingContext ctx)
|
||||||
{
|
{
|
||||||
info.AddValue("Target", Target);
|
info.AddValue("target", Target);
|
||||||
info.AddValue("Via", Via);
|
info.AddValue("via", Via);
|
||||||
info.AddValue("Flags", Flags);
|
info.AddValue("flags", Flags);
|
||||||
info.AddValue("Metric", Metric);
|
info.AddValue("metric", Metric);
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty("target")]
|
[JsonProperty("target")]
|
||||||
|
@ -13,45 +13,49 @@ namespace WinUI
|
|||||||
{
|
{
|
||||||
protected ZeroTierNetwork(SerializationInfo info, StreamingContext ctx)
|
protected ZeroTierNetwork(SerializationInfo info, StreamingContext ctx)
|
||||||
{
|
{
|
||||||
NetworkId = info.GetString("NetworkId");
|
try
|
||||||
MacAddress = info.GetString("MacAddress");
|
{
|
||||||
NetworkName = info.GetString("NetworkName");
|
NetworkId = info.GetString("nwid");
|
||||||
NetworkStatus = info.GetString("NetworkStatus");
|
MacAddress = info.GetString("mac");
|
||||||
NetworkType = info.GetString("NetworkType");
|
NetworkName = info.GetString("name");
|
||||||
MTU = info.GetInt32("MTU");
|
NetworkStatus = info.GetString("status");
|
||||||
DHCP = info.GetBoolean("DHCP");
|
NetworkType = info.GetString("type");
|
||||||
Bridge = info.GetBoolean("Bridge");
|
MTU = info.GetInt32("mtu");
|
||||||
BroadcastEnabled = info.GetBoolean("BroadcastEnabled");
|
DHCP = info.GetBoolean("dhcp");
|
||||||
PortError = info.GetInt32("PortError");
|
Bridge = info.GetBoolean("bridge");
|
||||||
NetconfRevision = info.GetInt32("NetconfRevision");
|
BroadcastEnabled = info.GetBoolean("broadcastEnabled");
|
||||||
AssignedAddresses = (string[])info.GetValue("AssignedAddresses", typeof(string[]));
|
PortError = info.GetInt32("portError");
|
||||||
Routes = (NetworkRoute[])info.GetValue("Routes", typeof(NetworkRoute[]));
|
NetconfRevision = info.GetInt32("netconfRevision");
|
||||||
DeviceName = info.GetString("DeviceName");
|
AssignedAddresses = (string[])info.GetValue("assignedAddresses", typeof(string[]));
|
||||||
AllowManaged = info.GetBoolean("AllowManaged");
|
Routes = (NetworkRoute[])info.GetValue("routes", typeof(NetworkRoute[]));
|
||||||
AllowGlobal = info.GetBoolean("AllowGlobal");
|
DeviceName = info.GetString("portDeviceName");
|
||||||
AllowDefault = info.GetBoolean("AllowDefault");
|
AllowManaged = info.GetBoolean("allowManaged");
|
||||||
|
AllowGlobal = info.GetBoolean("allowGlobal");
|
||||||
|
AllowDefault = info.GetBoolean("allowDefault");
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
IsConnected = false;
|
IsConnected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void GetObjectData(SerializationInfo info, StreamingContext ctx)
|
public virtual void GetObjectData(SerializationInfo info, StreamingContext ctx)
|
||||||
{
|
{
|
||||||
info.AddValue("NetworkId", NetworkId);
|
info.AddValue("nwid", NetworkId);
|
||||||
info.AddValue("MacAddress", MacAddress);
|
info.AddValue("mac", MacAddress);
|
||||||
info.AddValue("NetworkName", NetworkName);
|
info.AddValue("name", NetworkName);
|
||||||
info.AddValue("NetworkStatus", NetworkStatus);
|
info.AddValue("status", NetworkStatus);
|
||||||
info.AddValue("NetworkType", NetworkType);
|
info.AddValue("type", NetworkType);
|
||||||
info.AddValue("MTU", MTU);
|
info.AddValue("mtu", MTU);
|
||||||
info.AddValue("DHCP", DHCP);
|
info.AddValue("dhcp", DHCP);
|
||||||
info.AddValue("Bridge", Bridge);
|
info.AddValue("bridge", Bridge);
|
||||||
info.AddValue("BroadcastEnabled", BroadcastEnabled);
|
info.AddValue("broadcastEnabled", BroadcastEnabled);
|
||||||
info.AddValue("PortError", PortError);
|
info.AddValue("portError", PortError);
|
||||||
info.AddValue("NetconfRevision", NetconfRevision);
|
info.AddValue("netconfRevision", NetconfRevision);
|
||||||
info.AddValue("AssignedAddresses", AssignedAddresses);
|
info.AddValue("assignedAddresses", AssignedAddresses);
|
||||||
info.AddValue("Routes", Routes);
|
info.AddValue("routes", Routes);
|
||||||
info.AddValue("DeviceName", DeviceName);
|
info.AddValue("portDeviceName", DeviceName);
|
||||||
info.AddValue("AllowManaged", AllowManaged);
|
info.AddValue("allowManaged", AllowManaged);
|
||||||
info.AddValue("AllowGlobal", AllowGlobal);
|
info.AddValue("allowGlobal", AllowGlobal);
|
||||||
info.AddValue("AllowDefault", AllowDefault);
|
info.AddValue("allowDefault", AllowDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -126,11 +130,17 @@ namespace WinUI
|
|||||||
|
|
||||||
public bool Equals(ZeroTierNetwork network)
|
public bool Equals(ZeroTierNetwork network)
|
||||||
{
|
{
|
||||||
|
if (NetworkId == null || network == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
return NetworkId.Equals(network.NetworkId);
|
return NetworkId.Equals(network.NetworkId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CompareTo(ZeroTierNetwork network)
|
public int CompareTo(ZeroTierNetwork network)
|
||||||
{
|
{
|
||||||
|
if (NetworkId == null || network == null)
|
||||||
|
return -1;
|
||||||
|
|
||||||
UInt64 thisNwid = UInt64.Parse(NetworkId, System.Globalization.NumberStyles.HexNumber);
|
UInt64 thisNwid = UInt64.Parse(NetworkId, System.Globalization.NumberStyles.HexNumber);
|
||||||
UInt64 otherNwid = UInt64.Parse(network.NetworkId, System.Globalization.NumberStyles.HexNumber);
|
UInt64 otherNwid = UInt64.Parse(network.NetworkId, System.Globalization.NumberStyles.HexNumber);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user