Commit 950ed1a6 authored by Manu's avatar Manu 🏅
Browse files

Upgrade to .NET 6 & Cleanup

parent 8e640def
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;
namespace DirectoTalk.Sender
{
......
......@@ -65,6 +65,9 @@ namespace DirectoTalk.Sender
}
}
public void Dispose() => StopCall();
public void Dispose()
{
StopCall();
}
}
}
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<StartupObject>DirectoTalk.Sender.App</StartupObject>
<ApplicationIcon>call.ico</ApplicationIcon>
......@@ -23,11 +23,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NAudio" Version="1.10.0" />
<PackageReference Include="NAudio" Version="2.0.1" />
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -8,7 +8,7 @@ namespace DirectoTalk.Sender
{
public class NetworkHandler : IDisposable
{
private readonly HttpClient _HttpClient = new HttpClient();
private readonly HttpClient _HttpClient = new();
private readonly string _DestinationAddress;
private readonly int _DestinationPort;
......@@ -49,21 +49,19 @@ namespace DirectoTalk.Sender
private async Task<SendResult> SendTcpPacket(byte[] data)
{
ByteArrayContent binaryContent = new ByteArrayContent(data);
ByteArrayContent binaryContent = new(data);
binaryContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
using (var httpRequest = new HttpRequestMessage())
using HttpRequestMessage httpRequest = new();
httpRequest.Content = binaryContent;
try
{
HttpResponseMessage response = await _HttpClient.SendAsync(httpRequest).ConfigureAwait(false);
return new SendResult(response.StatusCode.ToString(), await response.Content.ReadAsStringAsync().ConfigureAwait(false));
}
catch (Exception ex)
{
httpRequest.Content = binaryContent;
try
{
HttpResponseMessage response = await _HttpClient.SendAsync(httpRequest).ConfigureAwait(false);
return new SendResult(response.StatusCode.ToString(), await response.Content.ReadAsStringAsync().ConfigureAwait(false));
}
catch (Exception ex)
{
return new SendResult("Err", $"{ex.Message} {ex.InnerException?.Message}");
}
return new SendResult("Err", $"{ex.Message} {ex.InnerException?.Message}");
}
}
......
......@@ -14,10 +14,7 @@ namespace DirectoTalk.Sender.ViewModels
private string destinationAddress = "127.0.0.1";
public string DestinationAddress
{
get
{
return destinationAddress;
}
get => destinationAddress;
set
{
destinationAddress = value;
......@@ -28,10 +25,7 @@ namespace DirectoTalk.Sender.ViewModels
private int destinationPort = 42000;
public int DestinationPort
{
get
{
return destinationPort;
}
get => destinationPort;
set
{
destinationPort = value;
......@@ -42,10 +36,7 @@ namespace DirectoTalk.Sender.ViewModels
private string amountOfBytes = "Amount of Bytes will come here";
public string AmountOfBytes
{
get
{
return amountOfBytes;
}
get => amountOfBytes;
set
{
amountOfBytes = value;
......@@ -56,10 +47,7 @@ namespace DirectoTalk.Sender.ViewModels
private string audioData = "No data yet";
public string AudioData
{
get
{
return audioData;
}
get => audioData;
set
{
audioData = value;
......@@ -70,10 +58,7 @@ namespace DirectoTalk.Sender.ViewModels
private bool isCallEnabled = true;
public bool IsCallEnabled
{
get
{
return isCallEnabled;
}
get => isCallEnabled;
set
{
isCallEnabled = value;
......@@ -84,10 +69,7 @@ namespace DirectoTalk.Sender.ViewModels
private bool isHangUpEnabled = false;
public bool IsHangUpEnabled
{
get
{
return isHangUpEnabled;
}
get => isHangUpEnabled;
set
{
isHangUpEnabled = value;
......@@ -98,10 +80,7 @@ namespace DirectoTalk.Sender.ViewModels
private string currentStatusCode;
public string CurrentStatusCode
{
get
{
return currentStatusCode;
}
get => currentStatusCode;
set
{
currentStatusCode = value;
......@@ -112,10 +91,7 @@ namespace DirectoTalk.Sender.ViewModels
private string currentResponse;
public string CurrentResponse
{
get
{
return currentResponse;
}
get => currentResponse;
set
{
currentResponse = value;
......
......@@ -6,6 +6,9 @@ namespace DirectoTalk.Sender.ViewModels
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment