mlaumcherb/Mlaumcherb.Client.Avalonia/классы/Буржуазия/Rules.cs
2024-11-06 00:04:12 +05:00

40 lines
1.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Mlaumcherb.Client.Avalonia.холопы;
namespace Mlaumcherb.Client.Avalonia.классы;
public static class Rules
{
public static bool Check(ICollection<Rule>? rules, ICollection<string> features)
{
if(rules is null || rules.Count == 0)
return true;
bool allowed = false;
foreach (var r in rules)
{
if (r.os != null && !PlatformHelper.CheckOs(r.os))
continue;
if (r.features == null)
allowed = r.action == "allow";
else
{
foreach (var feature in features)
{
if (r.features.TryGetValue(feature, out bool is_enabled))
{
if (is_enabled)
{
allowed = r.action == "allow";
}
}
}
}
if(allowed)
break;
}
return allowed;
}
}