-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from PaciStardust/RegexReplacementTest
Merging regex features and fixes
- Loading branch information
Showing
28 changed files
with
821 additions
and
700 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.