0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-13 09:50:44 -05:00

53 lines
1.7 KiB
C#
Raw Normal View History

2024-06-13 08:18:16 -04:00
using AssemblyRemapper.Enums;
using AssemblyRemapper.Models;
using Mono.Cecil;
using MoreLinq;
namespace AssemblyRemapper.Remapper.Search
2024-06-13 04:56:08 -04:00
{
internal class Properties
{
2024-06-13 08:18:16 -04:00
public static EMatchResult IncludeProperties(TypeDefinition type, SearchParams parms, ScoringModel score)
{
if (parms.MatchProperties is null || parms.MatchProperties.Count == 0) return EMatchResult.Disabled;
var matches = type.Properties
.Where(property => parms.MatchProperties.Contains(property.Name))
.Count();
score.Score += matches;
return matches > 0
? EMatchResult.Match
: EMatchResult.NoMatch;
}
public static EMatchResult ExcludeProperties(TypeDefinition type, SearchParams parms, ScoringModel score)
{
if (parms.IgnorePropterties is null || parms.IgnorePropterties.Count == 0) return EMatchResult.Disabled;
var matches = type.Properties
.Where(property => parms.IgnorePropterties.Contains(property.Name))
.Count();
score.Score += matches;
return matches > 0
? EMatchResult.NoMatch
: EMatchResult.Match;
}
public static EMatchResult MatchPropertyCount(TypeDefinition type, SearchParams parms, ScoringModel score)
{
if (parms.PropertyCount is null) return EMatchResult.Disabled;
var match = type.Properties.Exactly((int)parms.PropertyCount);
if (match) { score.Score++; }
return match
? EMatchResult.Match
: EMatchResult.NoMatch;
}
2024-06-13 04:56:08 -04:00
}
}