예제 #1
0
        public ConstructionKey(AssembledTypeID typeID, Type delegateType, bool allowNonPublic)
        {
            ArgumentUtility.DebugCheckNotNull("delegateType", delegateType);

            _typeID         = typeID;
            _delegateType   = delegateType;
            _allowNonPublic = allowNonPublic;

            // Pre-compute hash code.
            _hashCode = EqualityUtility.GetRotatedHashCode(_typeID.GetHashCode(), delegateType, allowNonPublic);
        }
예제 #2
0
        public AssembledTypeID(Type requestedType, object[] parts)
        {
            ArgumentUtility.DebugCheckNotNull("requestedType", requestedType);
            ArgumentUtility.DebugCheckNotNull("parts", parts);

            _requestedType = requestedType;
            _parts         = parts;

            // Pre-compute hash code.
            _hashCode = requestedType.GetHashCode() ^ EqualityUtility.GetRotatedHashCode(_parts);
        }
예제 #3
0
        protected new int GetHashCode()
        {
            var fieldValues = new object[s_targetFields.Length];

            for (int i = 0; i < fieldValues.Length; ++i)
            {
                fieldValues[i] = s_targetFields[i].GetValue(Target);
            }

            return(EqualityUtility.GetRotatedHashCode(fieldValues));
        }
        public CustomAttributeDataCacheKey(ICustomAttributeProvider attributeTarget, bool inherit)
        {
            ArgumentUtility.DebugCheckNotNull("attributeTarget", attributeTarget);
            Assertion.DebugAssert(!(attributeTarget is IMutableMember));

            _attributeTarget = attributeTarget;
            _inherit         = inherit;

            // Pre-compute hash code.
            _hashCode = EqualityUtility.GetRotatedHashCode(RuntimeHelpers.GetHashCode(attributeTarget), inherit);
        }
예제 #5
0
        public ConstructorForAssembledTypeCacheKey(Type assembledType, Type delegateType, bool allowNonPublic)
        {
            ArgumentUtility.DebugCheckNotNull("assembledType", assembledType);
            ArgumentUtility.DebugCheckNotNull("delegateType", delegateType);

            _assembledType  = assembledType;
            _delegateType   = delegateType;
            _allowNonPublic = allowNonPublic;

            // Pre-compute hash code.
            _hashCode = EqualityUtility.GetRotatedHashCode(_assembledType.GetHashCode(), delegateType, allowNonPublic);
        }
예제 #6
0
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(
                _dataInfo,
                _selectProjection,
                _whereCondition,
                _topExpression,
                _isDistinctQuery,
                _rowNumberSelector,
                _currentRowNumberOffset,
                _groupByExpression)
            ^ EqualityUtility.GetRotatedHashCode(_sqlTables)
            ^ EqualityUtility.GetRotatedHashCode(_orderings));
 }
예제 #7
0
        public void GetRotatedHashCode_ForEnumerable()
        {
            IEnumerable objects1 = new int[] { 1, 2, 3 };
            IEnumerable objects2 = new int[] { 1, 2, 3 };

            Assert.That(EqualityUtility.GetRotatedHashCode(objects2), Is.EqualTo(EqualityUtility.GetRotatedHashCode(objects1)));

            IEnumerable objects3 = new int[] { 3, 2, 1 };

            Assert.That(EqualityUtility.GetRotatedHashCode(objects3), Is.Not.EqualTo(EqualityUtility.GetRotatedHashCode(objects1)));

            IEnumerable objects4 = new int[] { 1, 2, 17 };

            Assert.That(EqualityUtility.GetRotatedHashCode(objects4), Is.Not.EqualTo(EqualityUtility.GetRotatedHashCode(objects1)));
        }
예제 #8
0
        public void GetRotatedHashCode_Nulls()
        {
            var array1 = new object[] { 1, null, 2 };
            var array2 = new object[] { 1, null, 2 };
            var array3 = new object[] { 1, null, null, 2 };

            Assert.That(EqualityUtility.GetRotatedHashCode(array1), Is.EqualTo(EqualityUtility.GetRotatedHashCode(array2)));
            Assert.That(EqualityUtility.GetRotatedHashCode(array1), Is.Not.EqualTo(EqualityUtility.GetRotatedHashCode(array3)));

            Assert.That(EqualityUtility.GetRotatedHashCode((IEnumerable)array1), Is.EqualTo(EqualityUtility.GetRotatedHashCode((IEnumerable)array2)));
            Assert.That(EqualityUtility.GetRotatedHashCode((IEnumerable)array1), Is.Not.EqualTo(EqualityUtility.GetRotatedHashCode((IEnumerable)array3)));

            Assert.That(EqualityUtility.GetRotatedHashCode(array1), Is.EqualTo(EqualityUtility.GetRotatedHashCode((IEnumerable)array1)));
            Assert.That(EqualityUtility.GetRotatedHashCode(array3), Is.EqualTo(EqualityUtility.GetRotatedHashCode((IEnumerable)array3)));
        }
 private SecurityContext(
     Type classType,
     string owner,
     string ownerGroup,
     string ownerTenant,
     bool isStateless,
     Dictionary <string, EnumWrapper> states,
     EnumWrapper[] abstractRoles)
 {
     _class         = TypeUtility.GetPartialAssemblyQualifiedName(classType);
     _owner         = StringUtility.EmptyToNull(owner);
     _ownerGroup    = StringUtility.EmptyToNull(ownerGroup);
     _ownerTenant   = StringUtility.EmptyToNull(ownerTenant);
     _isStateless   = isStateless;
     _states        = states;
     _abstractRoles = abstractRoles;
     _hashCode      = EqualityUtility.GetRotatedHashCode(_class, _owner, _ownerGroup, _ownerTenant);
 }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MixinContext"/> class.
        /// </summary>
        /// <param name="mixinKind">The kind of relationship the configured mixin has with its target class.</param>
        /// <param name="mixinType">The mixin type represented by this <see cref="MixinContext"/>.</param>
        /// <param name="introducedMemberVisibility">The default visbility of introduced members.</param>
        /// <param name="explicitDependencies">The explicit dependencies of the mixin.</param>
        /// <param name="origin">
        /// A description of where the <see cref="MixinContext"/> originates from. Note that <paramref name="origin"/> is not considered when comparing
        /// <see cref="MixinContext"/> objects for equality.
        /// </param>
        public MixinContext(
            MixinKind mixinKind,
            Type mixinType,
            MemberVisibility introducedMemberVisibility,
            IEnumerable <Type> explicitDependencies,
            MixinContextOrigin origin)
        {
            ArgumentUtility.CheckNotNull("mixinType", mixinType);
            ArgumentUtility.CheckNotNull("explicitDependencies", explicitDependencies);
            ArgumentUtility.CheckNotNull("origin", origin);

            _mixinType = mixinType;
            _mixinKind = mixinKind;
            _introducedMemberVisibility = introducedMemberVisibility;
            _explicitDependencies       = new HashSet <Type> (explicitDependencies).AsReadOnly();
            _origin = origin;

            _cachedHashCode = EqualityUtility.GetRotatedHashCode(
                _mixinKind,
                _mixinType,
                EqualityUtility.GetXorHashCode(ExplicitDependencies),
                IntroducedMemberVisibility);
        }
예제 #11
0
 /// <summary>
 /// Returns a hash code based on the members of the <see cref="IEnumerable{T}"/>.
 /// </summary>
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(_enumerable));
 }
예제 #12
0
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(_item1, _item2, _item3));
 }
예제 #13
0
 public override int GetHashCode()
 {
     return(PropertyType.GetHashCode() ^ EqualityUtility.GetRotatedHashCode(IndexParameterTypes));
 }
예제 #14
0
 public override int GetHashCode()
 {
     return(_genericTypeDefinition.GetHashCode() ^ EqualityUtility.GetRotatedHashCode(_typeArguments));
 }
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(_group, _position));
 }
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(SchemaName, EntityName));
 }
예제 #17
0
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(_user, _role, _substitutedUser, _substitutedRole));
 }
예제 #18
0
        /// <summary>
        /// <see cref="GetHashCode"/> implementation using all the <see cref="object"/>|s in the array returned by the <see cref="Func{T,TResult}"/>.
        /// </summary>
        /// <remarks>
        /// Returned hash code uses the <see cref="EqualityUtility.GetRotatedHashCode(object[])"/> method.
        /// </remarks>
        public int GetHashCode(T x)
        {
            var equalityParticipantsX = _equalityParticipantsProvider(x);

            return(EqualityUtility.GetRotatedHashCode(equalityParticipantsX));
        }
예제 #19
0
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(_elementType, _rank));
 }
예제 #20
0
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(PropertyIdentifier, ClassDefinition));
 }
예제 #21
0
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(s_globalKey, _localKey));
 }
예제 #22
0
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(_name, _value, _parameterType));
 }
 public override int GetHashCode()
 {
     return(EqualityUtility.GetRotatedHashCode(_kind, _assembly, _location));
 }
        public int GetHashCode(MemberInfo obj)
        {
            ArgumentUtility.CheckNotNull("obj", obj);

            return(EqualityUtility.GetRotatedHashCode(obj.Name, _signatureComparer.GetHashCode(obj)));
        }