当前位置: 首页>>代码示例>>C#>>正文


C# Expression.MapsTo方法代码示例

本文整理汇总了C#中Expression.MapsTo方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.MapsTo方法的具体用法?C# Expression.MapsTo怎么用?C# Expression.MapsTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Expression的用法示例。


在下文中一共展示了Expression.MapsTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestIdenticality

        /// <summary>
        /// Tests a pair of expressions for identicality using the equality definitions defined in this class.
        /// </summary>
        /// <param name="E1">The first expression to test</param>
        /// <param name="E2">The second expression to test</param>
        public static bool TestIdenticality(Expression E1, Expression E2)
        {
            //Test for "null" arguments
            if ((E1 as object) == null && (E2 as object) == null) return true;
            if ((E1 as object) == null || (E2 as object) == null) return false;

            //To be identical, they must have the same type
            if (E1.GetType() != E2.GetType()) return false;

            //If E1 maps to E2
            if (E1.MapsTo(E2)) return true;

            //Fast tests amoungst operands
            if ((E1 is Irreducible) && (E2 is Irreducible)) return TestIdenticality_FastTests_Operands(E1, E2);

            //Test for identicality amoungst binary operations
            if (((E1 is Operation) && (E1 as Operation).Arity == 2) && ((E2 is Operation) && (E2 as Operation).Arity == 2)) return TestEquality(E1, E2, BinaryOperations);

            //If we couldn't determine that they are equal:
            return false;
        }
开发者ID:HarrisonTotty,项目名称:Simplex.Math,代码行数:26,代码来源:EqualityDefinitions.cs

示例2: TestEquality

        /// <summary>
        /// Tests a pair of expressions for equality using the equality definitions defined in this class.
        /// </summary>
        /// <param name="E1">The first expression to test</param>
        /// <param name="E2">The second expression to test</param>
        public static bool TestEquality(Expression E1, Expression E2)
        {
            //Test for "null" arguments
            if ((E1 as object) == null && (E2 as object) == null) return true;
            if ((E1 as object) == null || (E2 as object) == null) return false;

            //If E1 maps to E2
            if (E1.MapsTo(E2)) return true;

            //Fast tests amoungst operands
            if ((E1 is Irreducible) && (E2 is Irreducible)) return TestEquality_FastTests_Operands(E1, E2);

            //Test for equality amoungst operands - OLD
            //if (((E1 is Irreducible) || (E1 is IntrinsicIrreducible)) && ((E2 is Irreducible) || (E2 is IntrinsicIrreducible))) return TestEquality(E1, E2, Operands);

            //Test for equality amoungst binary operations
            if (((E1 is Operation) && (E1 as Operation).Arity == 2) && ((E2 is Operation) && (E2 as Operation).Arity == 2)) if (TestEquality(E1, E2, BinaryOperations)) return true;

            //Test for equality via grouping operations
            //if (TestEquality(E1, E2, Groupings)) return true;

            //If we couldn't determine that they are equal:
            return false;
        }
开发者ID:HarrisonTotty,项目名称:Simplex.Math,代码行数:29,代码来源:EqualityDefinitions.cs


注:本文中的Expression.MapsTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。