Exemplo n.º 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)
            };
        }
 private MembersComparison(
     IResolver resolver,
     MembersProvider membersProvider,
     IVariable variable)
 {
     _variable        = variable;
     _resolver        = resolver;
     _membersProvider = membersProvider;
 }
Exemplo n.º 3
0
        protected virtual void NoSetterPoidToField(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
        {
            MemberInfo poidPropertyOrField = MembersProvider.GetEntityMembersForPoid(type).FirstOrDefault(modelInspector.IsPersistentId);

            if (MatchNoSetterProperty(poidPropertyOrField))
            {
                classCustomizer.Id(idm => idm.Access(Accessor.NoSetter));
            }
        }
Exemplo n.º 4
0
        protected virtual void NoPoidGuid(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
        {
            MemberInfo poidPropertyOrField = MembersProvider.GetEntityMembersForPoid(type).FirstOrDefault(mi => modelInspector.IsPersistentId(mi));

            if (!ReferenceEquals(null, poidPropertyOrField))
            {
                return;
            }
            classCustomizer.Id(null, idm => idm.Generator(Generators.Guid));
        }
 private MembersHasher(
     HasherResolver resolver,
     MembersProvider membersProvider,
     IConfigurationProvider configuration,
     IVariable variable)
 {
     _variable        = variable;
     _resolver        = resolver;
     _membersProvider = membersProvider;
     _configuration   = configuration;
 }
        public static MembersComparison Create(
            IResolver resolver,
            MembersProvider membersProvider,
            IVariable variable)
        {
            if (variable.VariableType == typeof(object) || !variable.VariableType.IsHierarchical() || !(variable is ArgumentVariable))
            {
                return(null);
            }

            return(new MembersComparison(resolver, membersProvider, variable));
        }
Exemplo n.º 7
0
        protected virtual void ComponentParentNoSetterToField(IModelInspector modelinspector, PropertyPath member, IComponentAttributesMapper componentMapper)
        {
            System.Type componentType = member.LocalMember.GetPropertyOrFieldType();
            IEnumerable <MemberInfo> persistentProperties =
                MembersProvider.GetComponentMembers(componentType).Where(p => ModelInspector.IsPersistentProperty(p));

            MemberInfo parentReferenceProperty = GetComponentParentReferenceProperty(persistentProperties, member.LocalMember.ReflectedType);

            if (parentReferenceProperty != null && MatchNoSetterProperty(parentReferenceProperty))
            {
                componentMapper.Parent(parentReferenceProperty, cp => cp.Access(Accessor.NoSetter));
            }
        }
        public static MembersHasher Create(
            HasherResolver resolver,
            MembersProvider membersProvider,
            IConfigurationProvider configuration,
            IVariable variable)
        {
            if (variable.VariableType == typeof(object) || !variable.VariableType.IsHierarchical() || !(variable is ArgumentVariable))
            {
                return(null);
            }

            return(new MembersHasher(resolver, membersProvider, configuration, variable));
        }
        public HasherResolver(EqualityContext context, MembersProvider membersProvider, IConfigurationProvider configuration)
        {
            _configuration = configuration;

            _hashersFactories = new Func <IVariable, IHasherEmitter>[] {
                variable => NullableHasher.Create(this, variable),
                variable => StringHasher.Create(_configuration, variable),
                BasicHasher.Create,
                variable => MembersHasher.Create(this, membersProvider, _configuration, variable),
                variable => ArrayHasher.Create(this, _configuration, variable),
                variable => EnumerablesHasher.Create(this, _configuration, variable),
                variable => IndirectHasher.Create(context, 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)
            };
        }
Exemplo n.º 11
0
    public static IEnumerable <IGrouping <object[], TValue> > GroupByKeys <TValue>(this IEnumerable <TValue> values, IEnumerable <string> keys)
    {
        var properties = MembersProvider.GetProperties(typeof(TValue), keys.ToArray());
        var comparer   = new ArrayEqualityComparer <object>();


        // jamespconnor's string as key approch - off course it will need to return IEnumerable<IGrouping<string, TValue>>

        /*return values.GroupBy(v => getters.Aggregate(
         *  "",
         *  (acc, getter) => string.Format(
         *      "{0}-{1}",
         *      acc,
         *      getter.Invoke(v, null).ToString()
         *      )
         *  )
         * );*/

        //objects array as key approch
        return(values.GroupBy(v => properties.Select(property => property.GetValue(v, null)).ToArray(), comparer));
    }