Skip to content

Commit

Permalink
Merge pull request #47 from PaciStardust/RegexReplacementTest
Browse files Browse the repository at this point in the history
Merging regex features and fixes
  • Loading branch information
PaciStardust authored Mar 26, 2023
2 parents 7780bc0 + 3310ee5 commit f8fbeaf
Show file tree
Hide file tree
Showing 28 changed files with 821 additions and 700 deletions.
642 changes: 18 additions & 624 deletions OscMultitool/Config.cs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions OscMultitool/Hoscy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<UseWPF>true</UseWPF>
<ApplicationIcon>Resources\hoscy_circle.ico</ApplicationIcon>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyVersion>0.6.8</AssemblyVersion>
<FileVersion>0.6.8</FileVersion>
<AssemblyVersion>0.7</AssemblyVersion>
<FileVersion>0.7</FileVersion>
<RepositoryUrl>https://github.com/PaciStardust/HOSCY</RepositoryUrl>
<PackageProjectUrl>https://github.com/PaciStardust/HOSCY</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down Expand Up @@ -78,7 +78,7 @@
<Compile Update="Ui\Windows\ModifyCountersWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Ui\Windows\ModifyReplacementsWindow.xaml.cs">
<Compile Update="Ui\Windows\ModifyReplacementDataWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Ui\Windows\ModifyOscRoutingFiltersWindow.xaml.cs">
Expand Down Expand Up @@ -117,7 +117,7 @@
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Ui\Windows\ModifyReplacementsWindow.xaml">
<Page Update="Ui\Windows\ModifyReplacementDataWindow.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
Expand Down
75 changes: 75 additions & 0 deletions OscMultitool/Models/ApiPresetModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System.Collections.Generic;
using System.Net.Http.Headers;

namespace Hoscy.Models
{
internal class ApiPresetModel
{
public string Name
{
get => _name;
set => _name = string.IsNullOrWhiteSpace(value) ? "Unnamed Preset" : value;
}
private string _name = "Unnamed Preset";

public string SentData { get; set; } = @"{""data"" : ""[T]""}";
public Dictionary<string, string> HeaderValues { get; set; } = new();
public string ContentType { get; set; } = "application/json";
public string ResultField { get; set; } = "result";

public string TargetUrl
{
get => _targetUrl;
set
{
_targetUrl = value;
_fullTargetUrl = value.StartsWith("h") ? value : "https://" + value;
}
}
private string _targetUrl = string.Empty;
private string _fullTargetUrl = string.Empty;

public string Authorization
{
get => _authorization;
set
{
_authorization = string.Empty;
_authenticationHeader = null;

if (string.IsNullOrWhiteSpace(value))
return;

try
{
_authorization = value;
var authSplit = value.Split(' ');

if (authSplit.Length == 1)
_authenticationHeader = new(authSplit[0]);
else if (authSplit.Length > 1)
_authenticationHeader = new(authSplit[0], string.Join(' ', authSplit[1..]));
}
catch { }
}
}
private string _authorization = string.Empty;
private AuthenticationHeaderValue? _authenticationHeader = null;

public int ConnectionTimeout
{
get => _connectionTimeout;
set => _connectionTimeout = Utils.MinMax(value, 25, 60000);
}
private int _connectionTimeout = 3000;

internal string FullTargetUrl() => _fullTargetUrl;
internal AuthenticationHeaderValue? AuthenticationHeader() => _authenticationHeader;

internal bool IsValid()
=> !string.IsNullOrWhiteSpace(TargetUrl)
&& !string.IsNullOrWhiteSpace(SentData)
&& !string.IsNullOrWhiteSpace(ResultField)
&& !string.IsNullOrWhiteSpace(ContentType);
}
}
Loading

0 comments on commit f8fbeaf

Please sign in to comment.