using System; using System.Runtime.InteropServices; namespace Foodsoft.Alpm { public class Depend : IEquatable { public enum ModType { Any = 1, Equal, GreaterThanOrEqual, LessThanOrEqual, GreaterThan, LessThan } internal unsafe Depend(IntPtr ptr) { var native = (NativeDepend*) ptr; Name = new string(native->name); Version = new string(native->version); Description = new string(native->description); NameHash = native->name_hash; Mod = native->mod; } public string Name { get; } public string Version { get; } public string Description { get; } public ulong NameHash { get; } public ModType Mod { get; } public bool Equals(Depend? other) { return !ReferenceEquals(other, null) && ReferenceEquals(this, other) && Name == other.Name && Version == other.Version && Mod == other.Mod; } public override bool Equals(object? obj) { return obj is Depend other && Equals(other); } public override int GetHashCode() { return HashCode.Combine(Name, Version, (int) Mod); } [StructLayout(LayoutKind.Sequential)] private readonly unsafe struct NativeDepend { internal readonly sbyte* name; internal readonly sbyte* version; internal readonly sbyte* description; internal readonly ulong name_hash; internal readonly ModType mod; } } }