Bump
AzureDevOpsRepository Markdown links Ticks bug fix, default to *.wc files and formatting
This commit is contained in:
82
Wafer-Counter/Helper/ParameterHelper.cs
Normal file
82
Wafer-Counter/Helper/ParameterHelper.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using OI.Metrology.Shared.Models;
|
||||
using System.Collections.Specialized;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using System.Web;
|
||||
|
||||
namespace OI.Metrology.Wafer.Counter.Helper;
|
||||
|
||||
public class ParameterHelper
|
||||
{
|
||||
|
||||
private static Dictionary<string, string?> GetKeyValuePairs(QueryString queryString)
|
||||
{
|
||||
Dictionary<string, string?> results = [];
|
||||
if (queryString.HasValue)
|
||||
{
|
||||
NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(queryString.Value);
|
||||
foreach (string? key in nameValueCollection.AllKeys)
|
||||
{
|
||||
if (key is null)
|
||||
continue;
|
||||
results.Add(key, nameValueCollection[key]);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static CharacterizationParameters? GetCharacterizationParameters(QueryString queryString)
|
||||
{
|
||||
CharacterizationParameters? result;
|
||||
Dictionary<string, string?> keyValuePairs = GetKeyValuePairs(queryString);
|
||||
string json = JsonSerializer.Serialize(keyValuePairs, new JsonSerializerOptions() { WriteIndented = true });
|
||||
result = string.IsNullOrEmpty(json) ? null : JsonSerializer.Deserialize(json, CharacterizationParametersSourceGenerationContext.Default.CharacterizationParameters);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string? GetQueryString(Stream stream)
|
||||
{
|
||||
string? result;
|
||||
if (!stream.CanRead)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
Task<string> task = new StreamReader(stream).ReadToEndAsync();
|
||||
result = task.Result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Dictionary<string, string?> GetKeyValuePairs(string? queryString)
|
||||
{
|
||||
Dictionary<string, string?> results = [];
|
||||
if (!string.IsNullOrEmpty(queryString))
|
||||
{
|
||||
NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(queryString);
|
||||
foreach (string? key in nameValueCollection.AllKeys)
|
||||
{
|
||||
if (key is null)
|
||||
continue;
|
||||
results.Add(key, nameValueCollection[key]);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static PollValue? GetPollValue(IPAddress? remoteIpAddress, Stream stream)
|
||||
{
|
||||
PollValue? result;
|
||||
string? queryString = GetQueryString(stream);
|
||||
Dictionary<string, string?> keyValuePairs = GetKeyValuePairs(queryString);
|
||||
string json = JsonSerializer.Serialize(keyValuePairs, new JsonSerializerOptions() { WriteIndented = true });
|
||||
result = string.IsNullOrEmpty(json) ? null : JsonSerializer.Deserialize(json, PollValueSourceGenerationContext.Default.PollValue);
|
||||
if (result is not null)
|
||||
{
|
||||
result = new(null, result.Id, result.Page, queryString, remoteIpAddress is null ? string.Empty : remoteIpAddress.ToString(), result.Time, result.Value);
|
||||
json = JsonSerializer.Serialize(result, PollValueSourceGenerationContext.Default.PollValue);
|
||||
result = new(json, result.Id, result.Page, queryString, remoteIpAddress is null ? string.Empty : remoteIpAddress.ToString(), result.Time, result.Value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
11
Wafer-Counter/Helper/RegexHelper.cs
Normal file
11
Wafer-Counter/Helper/RegexHelper.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace OI.Metrology.Wafer.Counter.Helper;
|
||||
|
||||
public partial class RegexHelper
|
||||
{
|
||||
|
||||
[GeneratedRegex(@"[\\,\/,\:,\*,\?,\"",\<,\>,\|]")]
|
||||
internal static partial Regex WindowsFileSystem();
|
||||
|
||||
}
|
Reference in New Issue
Block a user