コード例 #1
0
        /// <summary>
        ///   Produces the <see cref="ComparisonOperator"/> that is logically opposite another.
        /// </summary>
        /// <param name="self">
        ///   The <see cref="ComparisonOperator"/> on which the extension method is invoked.
        /// </param>
        /// <returns>
        ///   The logical opposite of <paramref name="self"/>.
        /// </returns>
        public static ComparisonOperator Negation(this ComparisonOperator self)
        {
            Debug.Assert(self.IsValid());

            return(self switch {
                ComparisonOperator.EQ => ComparisonOperator.NE,
                ComparisonOperator.NE => ComparisonOperator.EQ,
                ComparisonOperator.LT => ComparisonOperator.GTE,
                ComparisonOperator.GT => ComparisonOperator.LTE,
                ComparisonOperator.LTE => ComparisonOperator.GT,
                ComparisonOperator.GTE => ComparisonOperator.LT,
                _ => throw new ApplicationException($"Switch statement over {nameof(ComparisonOperator)} exhausted"),
            });