Skip to content

Commit 596da30

Browse files
committed
Add ReactiveUI condition
1 parent 03fc11e commit 596da30

File tree

7 files changed

+43
-5
lines changed

7 files changed

+43
-5
lines changed

STUN/Client/StunClient3489.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if ReactiveUI
12
using ReactiveUI.Fody.Helpers;
3+
#endif
24
using STUN.DnsClients;
35
using STUN.Enums;
46
using STUN.Message;
@@ -35,7 +37,9 @@ public TimeSpan Timeout
3537

3638
protected readonly IUdpProxy Proxy;
3739

40+
#if ReactiveUI
3841
[Reactive]
42+
#endif
3943
public ClassicStunResult Status { get; } = new();
4044

4145
public StunClient3489(string server, ushort port = 3478, IPEndPoint? local = null, IUdpProxy? proxy = null, IDnsQuery? dnsQuery = null)

STUN/Client/StunClient5389UDP.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if ReactiveUI
12
using ReactiveUI.Fody.Helpers;
3+
#endif
24
using STUN.DnsClients;
35
using STUN.Enums;
46
using STUN.Message;
@@ -18,7 +20,9 @@ namespace STUN.Client
1820
/// </summary>
1921
public class StunClient5389UDP : StunClient3489
2022
{
23+
#if ReactiveUI
2124
[Reactive]
25+
#endif
2226
public new StunResult5389 Status { get; } = new();
2327

2428
public StunClient5389UDP(string server, ushort port = 3478, IPEndPoint? local = null, IUdpProxy? proxy = null, IDnsQuery? dnsQuery = null)

STUN/STUN.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88

9+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
10+
<DefineConstants>TRACE;ReactiveUI</DefineConstants>
11+
</PropertyGroup>
12+
13+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
14+
<DefineConstants>TRACE;ReactiveUI</DefineConstants>
15+
</PropertyGroup>
16+
917
<ItemGroup>
10-
<PackageReference Include="ReactiveUI.Fody" Version="13.2.2" />
18+
<PackageReference Include="ReactiveUI.Fody" Version="13.2.2" Condition="$(DefineConstants.Contains('ReactiveUI'))" />
1119
</ItemGroup>
1220

1321
</Project>

STUN/StunResult/ClassicStunResult.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
#if ReactiveUI
12
using ReactiveUI.Fody.Helpers;
3+
#endif
24
using STUN.Enums;
35

46
namespace STUN.StunResult
57
{
68
public class ClassicStunResult : StunResult
79
{
10+
#if ReactiveUI
811
[Reactive]
12+
#endif
913
public NatType NatType { get; set; } = NatType.Unknown;
1014
}
1115
}

STUN/StunResult/StunResult.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1+
#if ReactiveUI
12
using ReactiveUI;
23
using ReactiveUI.Fody.Helpers;
4+
#endif
35
using System.Net;
46

57
namespace STUN.StunResult
68
{
7-
public abstract class StunResult : ReactiveObject
9+
public abstract class StunResult
10+
#if ReactiveUI
11+
: ReactiveObject
12+
#endif
813
{
14+
#if ReactiveUI
915
[Reactive]
16+
#endif
1017
public IPEndPoint? PublicEndPoint { get; set; }
1118

19+
#if ReactiveUI
1220
[Reactive]
21+
#endif
1322
public IPEndPoint? LocalEndPoint { get; set; }
1423
}
1524
}

STUN/StunResult/StunResult5389.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1+
#if ReactiveUI
12
using ReactiveUI.Fody.Helpers;
3+
#endif
24
using STUN.Enums;
35
using System.Net;
46

57
namespace STUN.StunResult
68
{
79
public class StunResult5389 : StunResult
810
{
11+
#if ReactiveUI
912
[Reactive]
13+
#endif
1014
public IPEndPoint? OtherEndPoint { get; set; }
1115

16+
#if ReactiveUI
1217
[Reactive]
18+
#endif
1319
public BindingTestResult BindingTestResult { get; set; } = BindingTestResult.Unknown;
1420

21+
#if ReactiveUI
1522
[Reactive]
23+
#endif
1624
public MappingBehavior MappingBehavior { get; set; } = MappingBehavior.Unknown;
1725

26+
#if ReactiveUI
1827
[Reactive]
28+
#endif
1929
public FilteringBehavior FilteringBehavior { get; set; } = FilteringBehavior.Unknown;
2030

2131
public void Clone(StunResult5389 result)

STUN/Utils/BitUtils.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using DynamicData.Kernel;
21
using System;
32
using System.Collections.Generic;
43
using System.Linq;
@@ -27,12 +26,12 @@ public static ushort FromBe(byte b1, byte b2)
2726

2827
public static ushort FromBe(IEnumerable<byte> b)
2928
{
30-
return BitConverter.ToUInt16(BitConverter.IsLittleEndian ? b.Reverse().AsArray() : b.AsArray(), 0);
29+
return BitConverter.ToUInt16(BitConverter.IsLittleEndian ? b.Reverse().ToArray() : b.ToArray(), 0);
3130
}
3231

3332
public static int FromBeToInt(IEnumerable<byte> b)
3433
{
35-
return BitConverter.ToInt32(BitConverter.IsLittleEndian ? b.Reverse().AsArray() : b.AsArray(), 0);
34+
return BitConverter.ToInt32(BitConverter.IsLittleEndian ? b.Reverse().ToArray() : b.ToArray(), 0);
3635
}
3736

3837
public static IEnumerable<byte> GetRandomBytes(int n)

0 commit comments

Comments
 (0)