public override int GetHashCode()
            {
                if (!_hashCode.HasValue)
                {
                    unchecked
                    {
                        int hashCode = ObjectUtil.CombineHashCodes(
                            OwnerType == null ? 0 : OwnerType.GetHashCode(),
                            Options.GetHashCode()
                            );

                        for (int i = 0; i < Imports.Length; i++)
                        {
                            hashCode = ObjectUtil.CombineHashCodes(hashCode, Imports[i].GetHashCode());
                        }

                        for (int i = 0; i < IdentifierTypes.Length; i++)
                        {
                            if (IdentifierTypes[i] != null)
                            {
                                hashCode = ObjectUtil.CombineHashCodes(hashCode, IdentifierTypes[i].GetHashCode());
                            }
                        }

                        _hashCode = hashCode;
                    }
                }

                return(_hashCode.Value);
            }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DependencyProperty"/> class.
        /// </summary>
        /// <param name="declaringType">The type which declares the property.</param>
        /// <param name="ownerType">The type which can own this property.</param>
        /// <param name="propertyType">The type of the property.</param>
        /// <param name="name">The name of the property.</param>
        /// <param name="defaultBindingMode">The default <see cref="BindingMode"/> for this property.</param>
        /// <param name="isAttachement">Specifies if the property is a attachement.</param>
        /// <param name="isReadonly">Specifies if the property is readonly and a key is required to write the property.</param>
        /// <param name="isUsingValueFactory">Specifies if the property is using a value factory for the initial value.</param>
        /// <param name="isFastProperty">Specifies if the property is accessed in a special behaviour.</param>
        internal DependencyProperty(TypeInfo declaringType, TypeInfo ownerType, TypeInfo propertyType, String name, BindingMode defaultBindingMode, Boolean isAttachement, Boolean isUsingValueFactory)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(nameof(name) + "cannot be null, empty or whitespace");
            }
            // TODO : defaultBindingMode -> Enum check


            DeclaringType       = declaringType ?? throw new ArgumentNullException(nameof(declaringType));
            PropertyType        = propertyType ?? throw new ArgumentNullException(nameof(propertyType));
            OwnerType           = ownerType ?? throw new ArgumentNullException(nameof(ownerType));
            Name                = name;
            DefaultBindingMode  = defaultBindingMode;
            IsAttachement       = isAttachement;
            IsUsingValueFactory = isUsingValueFactory;

            // Get the DependencyType for the current property and register the property
            DependencyType = DependencyType.GetDependencyType(declaringType, !isAttachement);
            DependencyType.Register(this);

            unchecked
            {
                // Precalculate the hash code if the depencency property
                _HashCode = 17;
                _HashCode = _HashCode * 23 + DeclaringType.GetHashCode();
                _HashCode = _HashCode * 23 + OwnerType.GetHashCode();
                _HashCode = _HashCode * 23 + PropertyType.GetHashCode();
                _HashCode = _HashCode * 23 + Name.GetHashCode();
            }
        }
Exemplo n.º 3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = OwnerType.GetHashCode();
         hashCode = (hashCode * 397) ^ PropertyType.GetHashCode();
         hashCode = (hashCode * 397) ^ Name.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = OwnerType?.GetHashCode() ?? 0;
         result = (result * 397) ^ (Property?.GetHashCode() ?? 0);
         result = (result * 397) ^ (RawValue?.GetHashCode() ?? 0);
         result = (result * 397) ^ (Format?.GetHashCode() ?? 0);
         return(result);
     }
 }
Exemplo n.º 5
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (OwnerType != null ? OwnerType.GetHashCode() : 0);
         result = (result * 397) ^ (Property != null ? Property.GetHashCode() : 0);
         result = (result * 397) ^ (RawValue != null ? RawValue.GetHashCode() : 0);
         result = (result * 397) ^ (Format != null ? Format.GetHashCode() : 0);
         return(result);
     }
 }
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     return(OwnerType.GetHashCode());
 }
Exemplo n.º 7
0
 public override int GetHashCode()
 {
     return(Name.GetHashCode() ^ PropertyType.GetHashCode() ^ OwnerType.GetHashCode());
 }