Beispiel #1
0
        public override bool Compatible(BuildComponent a, BuildComponent b)
        {
            if (a.Item == null || b.Item == null)
            {
                return(true);
            }

            if (SecondValue == null || FirstValue == null)
            {
                return(false);
            }

            var m1 = Regex.Match(FirstValue, "([\\d\\.]+)").Groups[1].Value;
            var m2 = Regex.Match(SecondValue, "([\\d\\.]+)").Groups[1].Value;

            if (float.TryParse(m1, out float f1) && float.TryParse(m2, out float f2))
            {
                switch (Mode)
                {
                case CompareMode.LessThan:
                    return(f1 < f2);

                case CompareMode.LessThanOrEqual:
                    return(f1 <= f2);

                case CompareMode.Equal:
                    return(f1 == f2);

                case CompareMode.GreaterThanOrEqual:
                    return(f1 >= f2);

                case CompareMode.GreaterThan:
                    return(f1 > f2);
                }
            }

            return(false);
        }
 public abstract bool Compatible(BuildComponent a, BuildComponent b);
 public BuildComponent?Other(BuildComponent comp) => First == comp ? Second : First;
 public bool Applicable(BuildComponent first, BuildComponent second)
 {
     return((FirstType == first.Type && SecondType == second.Type) ||
            (FirstType == second.Type && SecondType == first.Type));
 }