浏览代码

Add ReactiveUI condition

Bruce Wayne 4 年之前
父节点
当前提交
596da30167

+ 4 - 0
STUN/Client/StunClient3489.cs

@@ -1,4 +1,6 @@
+#if ReactiveUI
 using ReactiveUI.Fody.Helpers;
 using ReactiveUI.Fody.Helpers;
+#endif
 using STUN.DnsClients;
 using STUN.DnsClients;
 using STUN.Enums;
 using STUN.Enums;
 using STUN.Message;
 using STUN.Message;
@@ -35,7 +37,9 @@ namespace STUN.Client
 
 
 		protected readonly IUdpProxy Proxy;
 		protected readonly IUdpProxy Proxy;
 
 
+#if ReactiveUI
 		[Reactive]
 		[Reactive]
+#endif
 		public ClassicStunResult Status { get; } = new();
 		public ClassicStunResult Status { get; } = new();
 
 
 		public StunClient3489(string server, ushort port = 3478, IPEndPoint? local = null, IUdpProxy? proxy = null, IDnsQuery? dnsQuery = null)
 		public StunClient3489(string server, ushort port = 3478, IPEndPoint? local = null, IUdpProxy? proxy = null, IDnsQuery? dnsQuery = null)

+ 4 - 0
STUN/Client/StunClient5389UDP.cs

@@ -1,4 +1,6 @@
+#if ReactiveUI
 using ReactiveUI.Fody.Helpers;
 using ReactiveUI.Fody.Helpers;
+#endif
 using STUN.DnsClients;
 using STUN.DnsClients;
 using STUN.Enums;
 using STUN.Enums;
 using STUN.Message;
 using STUN.Message;
@@ -18,7 +20,9 @@ namespace STUN.Client
 	/// </summary>
 	/// </summary>
 	public class StunClient5389UDP : StunClient3489
 	public class StunClient5389UDP : StunClient3489
 	{
 	{
+#if ReactiveUI
 		[Reactive]
 		[Reactive]
+#endif
 		public new StunResult5389 Status { get; } = new();
 		public new StunResult5389 Status { get; } = new();
 
 
 		public StunClient5389UDP(string server, ushort port = 3478, IPEndPoint? local = null, IUdpProxy? proxy = null, IDnsQuery? dnsQuery = null)
 		public StunClient5389UDP(string server, ushort port = 3478, IPEndPoint? local = null, IUdpProxy? proxy = null, IDnsQuery? dnsQuery = null)

+ 9 - 1
STUN/STUN.csproj

@@ -6,8 +6,16 @@
     <Nullable>enable</Nullable>
     <Nullable>enable</Nullable>
   </PropertyGroup>
   </PropertyGroup>
 
 
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+    <DefineConstants>TRACE;ReactiveUI</DefineConstants>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+    <DefineConstants>TRACE;ReactiveUI</DefineConstants>
+  </PropertyGroup>
+
   <ItemGroup>
   <ItemGroup>
-    <PackageReference Include="ReactiveUI.Fody" Version="13.2.2" />
+    <PackageReference Include="ReactiveUI.Fody" Version="13.2.2" Condition="$(DefineConstants.Contains('ReactiveUI'))" />
   </ItemGroup>
   </ItemGroup>
 
 
 </Project>
 </Project>

+ 4 - 0
STUN/StunResult/ClassicStunResult.cs

@@ -1,11 +1,15 @@
+#if ReactiveUI
 using ReactiveUI.Fody.Helpers;
 using ReactiveUI.Fody.Helpers;
+#endif
 using STUN.Enums;
 using STUN.Enums;
 
 
 namespace STUN.StunResult
 namespace STUN.StunResult
 {
 {
 	public class ClassicStunResult : StunResult
 	public class ClassicStunResult : StunResult
 	{
 	{
+#if ReactiveUI
 		[Reactive]
 		[Reactive]
+#endif
 		public NatType NatType { get; set; } = NatType.Unknown;
 		public NatType NatType { get; set; } = NatType.Unknown;
 	}
 	}
 }
 }

+ 10 - 1
STUN/StunResult/StunResult.cs

@@ -1,15 +1,24 @@
+#if ReactiveUI
 using ReactiveUI;
 using ReactiveUI;
 using ReactiveUI.Fody.Helpers;
 using ReactiveUI.Fody.Helpers;
+#endif
 using System.Net;
 using System.Net;
 
 
 namespace STUN.StunResult
 namespace STUN.StunResult
 {
 {
-	public abstract class StunResult : ReactiveObject
+	public abstract class StunResult
+#if ReactiveUI
+		: ReactiveObject
+#endif
 	{
 	{
+#if ReactiveUI
 		[Reactive]
 		[Reactive]
+#endif
 		public IPEndPoint? PublicEndPoint { get; set; }
 		public IPEndPoint? PublicEndPoint { get; set; }
 
 
+#if ReactiveUI
 		[Reactive]
 		[Reactive]
+#endif
 		public IPEndPoint? LocalEndPoint { get; set; }
 		public IPEndPoint? LocalEndPoint { get; set; }
 	}
 	}
 }
 }

+ 10 - 0
STUN/StunResult/StunResult5389.cs

@@ -1,4 +1,6 @@
+#if ReactiveUI
 using ReactiveUI.Fody.Helpers;
 using ReactiveUI.Fody.Helpers;
+#endif
 using STUN.Enums;
 using STUN.Enums;
 using System.Net;
 using System.Net;
 
 
@@ -6,16 +8,24 @@ namespace STUN.StunResult
 {
 {
 	public class StunResult5389 : StunResult
 	public class StunResult5389 : StunResult
 	{
 	{
+#if ReactiveUI
 		[Reactive]
 		[Reactive]
+#endif
 		public IPEndPoint? OtherEndPoint { get; set; }
 		public IPEndPoint? OtherEndPoint { get; set; }
 
 
+#if ReactiveUI
 		[Reactive]
 		[Reactive]
+#endif
 		public BindingTestResult BindingTestResult { get; set; } = BindingTestResult.Unknown;
 		public BindingTestResult BindingTestResult { get; set; } = BindingTestResult.Unknown;
 
 
+#if ReactiveUI
 		[Reactive]
 		[Reactive]
+#endif
 		public MappingBehavior MappingBehavior { get; set; } = MappingBehavior.Unknown;
 		public MappingBehavior MappingBehavior { get; set; } = MappingBehavior.Unknown;
 
 
+#if ReactiveUI
 		[Reactive]
 		[Reactive]
+#endif
 		public FilteringBehavior FilteringBehavior { get; set; } = FilteringBehavior.Unknown;
 		public FilteringBehavior FilteringBehavior { get; set; } = FilteringBehavior.Unknown;
 
 
 		public void Clone(StunResult5389 result)
 		public void Clone(StunResult5389 result)

+ 2 - 3
STUN/Utils/BitUtils.cs

@@ -1,4 +1,3 @@
-using DynamicData.Kernel;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
@@ -27,12 +26,12 @@ namespace STUN.Utils
 
 
 		public static ushort FromBe(IEnumerable<byte> b)
 		public static ushort FromBe(IEnumerable<byte> b)
 		{
 		{
-			return BitConverter.ToUInt16(BitConverter.IsLittleEndian ? b.Reverse().AsArray() : b.AsArray(), 0);
+			return BitConverter.ToUInt16(BitConverter.IsLittleEndian ? b.Reverse().ToArray() : b.ToArray(), 0);
 		}
 		}
 
 
 		public static int FromBeToInt(IEnumerable<byte> b)
 		public static int FromBeToInt(IEnumerable<byte> b)
 		{
 		{
-			return BitConverter.ToInt32(BitConverter.IsLittleEndian ? b.Reverse().AsArray() : b.AsArray(), 0);
+			return BitConverter.ToInt32(BitConverter.IsLittleEndian ? b.Reverse().ToArray() : b.ToArray(), 0);
 		}
 		}
 
 
 		public static IEnumerable<byte> GetRandomBytes(int n)
 		public static IEnumerable<byte> GetRandomBytes(int n)