summaryrefslogtreecommitdiff
path: root/windows/WinUI
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2016-11-10 15:21:54 -0800
committerGrant Limberg <grant.limberg@zerotier.com>2016-11-10 15:21:54 -0800
commit71aadcbecb93b0a3e6bb60eaec3653c3ae9d67e8 (patch)
treea88bbcc2aae6a3121101444aa90eda285ae23c9c /windows/WinUI
parentfd71ceeab542d81b94a9ceee69faf78357e5f3f3 (diff)
downloadinfinitytier-71aadcbecb93b0a3e6bb60eaec3653c3ae9d67e8.tar.gz
infinitytier-71aadcbecb93b0a3e6bb60eaec3653c3ae9d67e8.zip
fix serialization issue.
Apparently the JSON parser uses this same serialization method under the hood to create objects from JSON.
Diffstat (limited to 'windows/WinUI')
-rw-r--r--windows/WinUI/NetworkRoute.cs16
-rw-r--r--windows/WinUI/ZeroTierNetwork.cs78
2 files changed, 52 insertions, 42 deletions
diff --git a/windows/WinUI/NetworkRoute.cs b/windows/WinUI/NetworkRoute.cs
index cd1e549a..ce26ef7d 100644
--- a/windows/WinUI/NetworkRoute.cs
+++ b/windows/WinUI/NetworkRoute.cs
@@ -13,18 +13,18 @@ namespace WinUI
{
protected NetworkRoute(SerializationInfo info, StreamingContext ctx)
{
- Target = info.GetString("Target");
- Via = info.GetString("Via");
- Flags = info.GetInt32("Flags");
- Metric = info.GetInt32("Metric");
+ Target = info.GetString("target");
+ Via = info.GetString("via");
+ Flags = info.GetInt32("flags");
+ Metric = info.GetInt32("metric");
}
public virtual void GetObjectData(SerializationInfo info, StreamingContext ctx)
{
- info.AddValue("Target", Target);
- info.AddValue("Via", Via);
- info.AddValue("Flags", Flags);
- info.AddValue("Metric", Metric);
+ info.AddValue("target", Target);
+ info.AddValue("via", Via);
+ info.AddValue("flags", Flags);
+ info.AddValue("metric", Metric);
}
[JsonProperty("target")]
diff --git a/windows/WinUI/ZeroTierNetwork.cs b/windows/WinUI/ZeroTierNetwork.cs
index 579e4e89..f8ebf9ac 100644
--- a/windows/WinUI/ZeroTierNetwork.cs
+++ b/windows/WinUI/ZeroTierNetwork.cs
@@ -13,45 +13,49 @@ namespace WinUI
{
protected ZeroTierNetwork(SerializationInfo info, StreamingContext ctx)
{
- NetworkId = info.GetString("NetworkId");
- MacAddress = info.GetString("MacAddress");
- NetworkName = info.GetString("NetworkName");
- NetworkStatus = info.GetString("NetworkStatus");
- NetworkType = info.GetString("NetworkType");
- MTU = info.GetInt32("MTU");
- DHCP = info.GetBoolean("DHCP");
- Bridge = info.GetBoolean("Bridge");
- BroadcastEnabled = info.GetBoolean("BroadcastEnabled");
- PortError = info.GetInt32("PortError");
- NetconfRevision = info.GetInt32("NetconfRevision");
- AssignedAddresses = (string[])info.GetValue("AssignedAddresses", typeof(string[]));
- Routes = (NetworkRoute[])info.GetValue("Routes", typeof(NetworkRoute[]));
- DeviceName = info.GetString("DeviceName");
- AllowManaged = info.GetBoolean("AllowManaged");
- AllowGlobal = info.GetBoolean("AllowGlobal");
- AllowDefault = info.GetBoolean("AllowDefault");
+ try
+ {
+ NetworkId = info.GetString("nwid");
+ MacAddress = info.GetString("mac");
+ NetworkName = info.GetString("name");
+ NetworkStatus = info.GetString("status");
+ NetworkType = info.GetString("type");
+ MTU = info.GetInt32("mtu");
+ DHCP = info.GetBoolean("dhcp");
+ Bridge = info.GetBoolean("bridge");
+ BroadcastEnabled = info.GetBoolean("broadcastEnabled");
+ PortError = info.GetInt32("portError");
+ NetconfRevision = info.GetInt32("netconfRevision");
+ AssignedAddresses = (string[])info.GetValue("assignedAddresses", typeof(string[]));
+ Routes = (NetworkRoute[])info.GetValue("routes", typeof(NetworkRoute[]));
+ DeviceName = info.GetString("portDeviceName");
+ AllowManaged = info.GetBoolean("allowManaged");
+ AllowGlobal = info.GetBoolean("allowGlobal");
+ AllowDefault = info.GetBoolean("allowDefault");
+ }
+ catch { }
IsConnected = false;
}
public virtual void GetObjectData(SerializationInfo info, StreamingContext ctx)
{
- info.AddValue("NetworkId", NetworkId);
- info.AddValue("MacAddress", MacAddress);
- info.AddValue("NetworkName", NetworkName);
- info.AddValue("NetworkStatus", NetworkStatus);
- info.AddValue("NetworkType", NetworkType);
- info.AddValue("MTU", MTU);
- info.AddValue("DHCP", DHCP);
- info.AddValue("Bridge", Bridge);
- info.AddValue("BroadcastEnabled", BroadcastEnabled);
- info.AddValue("PortError", PortError);
- info.AddValue("NetconfRevision", NetconfRevision);
- info.AddValue("AssignedAddresses", AssignedAddresses);
- info.AddValue("Routes", Routes);
- info.AddValue("DeviceName", DeviceName);
- info.AddValue("AllowManaged", AllowManaged);
- info.AddValue("AllowGlobal", AllowGlobal);
- info.AddValue("AllowDefault", AllowDefault);
+ info.AddValue("nwid", NetworkId);
+ info.AddValue("mac", MacAddress);
+ info.AddValue("name", NetworkName);
+ info.AddValue("status", NetworkStatus);
+ info.AddValue("type", NetworkType);
+ info.AddValue("mtu", MTU);
+ info.AddValue("dhcp", DHCP);
+ info.AddValue("bridge", Bridge);
+ info.AddValue("broadcastEnabled", BroadcastEnabled);
+ info.AddValue("portError", PortError);
+ info.AddValue("netconfRevision", NetconfRevision);
+ info.AddValue("assignedAddresses", AssignedAddresses);
+ info.AddValue("routes", Routes);
+ info.AddValue("portDeviceName", DeviceName);
+ info.AddValue("allowManaged", AllowManaged);
+ info.AddValue("allowGlobal", AllowGlobal);
+ info.AddValue("allowDefault", AllowDefault);
}
@@ -126,11 +130,17 @@ namespace WinUI
public bool Equals(ZeroTierNetwork network)
{
+ if (NetworkId == null || network == null)
+ return false;
+
return NetworkId.Equals(network.NetworkId);
}
public int CompareTo(ZeroTierNetwork network)
{
+ if (NetworkId == null || network == null)
+ return -1;
+
UInt64 thisNwid = UInt64.Parse(NetworkId, System.Globalization.NumberStyles.HexNumber);
UInt64 otherNwid = UInt64.Parse(network.NetworkId, System.Globalization.NumberStyles.HexNumber);