Пример #1
0
        public EqualityResolver(
            EqualityContext context,
            MembersProvider membersProvider,
            IConfigurationProvider configuration)
        {
            _configuration = configuration;

            var collectionComparer = new ArrayComparisonEmitter(this, CustomEmitters.EmitCheckIfLoopsAreDone, CustomEmitters.EmitReferenceComparison);

            _comparisonFactories = new Func <IVariable, IComparisonEmitter>[] {
                variable => NullableComparison.Create(this, CustomEmitters.EmitReturnIfFalsy, CustomEmitters.EmitCheckNullablesForValue, variable),
                CeqEqualityComparison.Create,
                variable => StringsComparison.Create(StringEqualsMethod, CustomEmitters.EmitReturnIfFalsy, _configuration, variable),
                OperatorEqualityComparison.Create,
                BacisEqualityComparison.Create,
                variable => MembersComparison.Create(this, membersProvider, variable),
                variable => ArraysComparison.Create(collectionComparer, _configuration, variable),
                variable => EnumerablesComparison.Create(this, collectionComparer, CustomEmitters.EmitCheckIfLoopsAreDone, _configuration, variable),
                variable => IndirectComparison.Create(
                    CustomEmitters.EmitReturnIfFalsy,
                    context.GetStaticEqualsMethodInfo,
                    DelayedEquals,
                    variable)
            };
        }
        public ComparisonResolver(ComparerContext context, MembersProvider membersProvider, IConfigurationProvider configuration)
        {
            _configuration = configuration;

            var collectionComparer = new ArrayComparisonEmitter(this, CustomEmitters.EmitCheckIfLoopsAreDone, CustomEmitters.EmitReferenceComparison);

            _comparisonFactories = new Func <IVariable, IComparisonEmitter>[] {
                variable => NullableComparison.Create(this, CustomEmitters.EmitReturnIfTruthy, CustomEmitters.EmitCheckNullablesForValue, variable),
                IntegralsComparison.Create,
                variable => StringsComparison.Create(StringCompareMethod, CustomEmitters.EmitReturnIfTruthy, _configuration, variable),
                ComparablesComparison.Create,
                variable => MembersComparison.Create(this, membersProvider, variable),
                variable => ArraysComparison.Create(collectionComparer, _configuration, variable),
                variable => EnumerablesComparison.Create(this, collectionComparer, CustomEmitters.EmitCheckIfLoopsAreDone, _configuration, variable),
                variable => IndirectComparison.Create(
                    CustomEmitters.EmitReturnIfTruthy,
                    variableType => context.GetStaticCompareMethodInfo(variableType),
                    DelayedCompare,
                    variable)
            };
        }