示例#1
0
 public int GetHashCode(FileName obj)
 {
     return(HashCode.Combine(RuntimeHelpers.GetHashCode(obj.Parent), RuntimeHelpers.GetHashCode(obj.Name)));
 }
 public override int GetHashCode()
 {
     return(RuntimeHelpers.GetHashCode(FilterUIHint) ^
            RuntimeHelpers.GetHashCode(PresentationLayer));
 }
示例#3
0
 public int GetHashCode(object obj) => RuntimeHelpers.GetHashCode(obj);
示例#4
0
 public int GetHashCode(IRepository <TEntity, TId> obj)
 => obj is null ? 0 : RuntimeHelpers.GetHashCode(obj);
示例#5
0
 public override int GetHashCode(TItem obj) => RuntimeHelpers.GetHashCode(obj);
 public int GetHashCode(T item)
 {
     return(RuntimeHelpers.GetHashCode(item));
 }
示例#7
0
 public override int GetHashCode()
 => RuntimeHelpers.GetHashCode(this);
 public override int GetHashCode()
 {
     return(RuntimeHelpers.GetHashCode(readerKey) * FieldName.GetHashCode());
 }
 int IEqualityComparer <object> .GetHashCode(object obj)
 {
     // put objects in a bucket based on their reference
     return(RuntimeHelpers.GetHashCode(obj));
 }
示例#10
0
 public int GetHashCode(FlowKey obj)
 {
     return(RuntimeHelpers.GetHashCode(obj));
 }
        /// <summary>
        /// Tests a CacheEntry[] for indication of "insane" cache usage.
        /// <para>
        /// <b>NOTE:</b>FieldCache CreationPlaceholder objects are ignored.
        /// (:TODO: is this a bad idea? are we masking a real problem?)
        /// </para>
        /// </summary>
        public Insanity[] Check(params FieldCache.CacheEntry[] cacheEntries)
        {
            if (null == cacheEntries || 0 == cacheEntries.Length)
            {
                return(new Insanity[0]);
            }

            if (estimateRam)
            {
                for (int i = 0; i < cacheEntries.Length; i++)
                {
                    cacheEntries[i].EstimateSize();
                }
            }

            // the indirect mapping lets MapOfSet dedup identical valIds for us
            // maps the (valId) identityhashCode of cache values to
            // sets of CacheEntry instances
            MapOfSets <int, FieldCache.CacheEntry> valIdToItems = new MapOfSets <int, FieldCache.CacheEntry>(new Dictionary <int, ISet <FieldCache.CacheEntry> >(17));
            // maps ReaderField keys to Sets of ValueIds
            MapOfSets <ReaderField, int> readerFieldToValIds = new MapOfSets <ReaderField, int>(new Dictionary <ReaderField, ISet <int> >(17));

            // any keys that we know result in more then one valId
            ISet <ReaderField> valMismatchKeys = new JCG.HashSet <ReaderField>();

            // iterate over all the cacheEntries to get the mappings we'll need
            for (int i = 0; i < cacheEntries.Length; i++)
            {
                FieldCache.CacheEntry item = cacheEntries[i];
                object val = item.Value;

                // It's OK to have dup entries, where one is eg
                // float[] and the other is the Bits (from
                // getDocWithField())
                if (val is IBits)
                {
                    continue;
                }

                if (val is FieldCache.CreationPlaceholder)
                {
                    continue;
                }

                ReaderField rf = new ReaderField(item.ReaderKey, item.FieldName);

                int valId = RuntimeHelpers.GetHashCode(val);

                // indirect mapping, so the MapOfSet will dedup identical valIds for us
                valIdToItems.Put(valId, item);
                if (1 < readerFieldToValIds.Put(rf, valId))
                {
                    valMismatchKeys.Add(rf);
                }
            }

            List <Insanity> insanity = new List <Insanity>(valMismatchKeys.Count * 3);

            insanity.AddRange(CheckValueMismatch(valIdToItems, readerFieldToValIds, valMismatchKeys));
            insanity.AddRange(CheckSubreaders(valIdToItems, readerFieldToValIds));

            return(insanity.ToArray());
        }
示例#12
0
 public IdentityWeakReference(T target)
     : base(target == null ? NULL : target)
 {
     hash = RuntimeHelpers.GetHashCode(target);
 }
示例#13
0
        public void NoIdReturnsBaseHashCode()
        {
            var bar = new EntityWithGuidPrimaryKey();

            Assert.Equal(RuntimeHelpers.GetHashCode(bar), bar.GetHashCode());
        }
示例#14
0
 public int GetHashCode(Vessel foo)
 {
     return(RuntimeHelpers.GetHashCode(foo));
 }
示例#15
0
 /// <summary>
 /// Returns hash code for the this list.
 /// </summary>
 /// <returns>The hash code of this list.</returns>
 public override int GetHashCode() => source is null || mapper is null ? 0 : RuntimeHelpers.GetHashCode(source) ^ mapper.GetHashCode();
示例#16
0
        private object CloneInstance(object source)
        {
            if (source == null)
            {
                return(null);
            }

            object target;

            // check if this object has already been cloned
            // using RuntimeHelpers.GetHashCode to get object identity
            int hashCode = RuntimeHelpers.GetHashCode(source);

            if (_objectReferences.TryGetValue(hashCode, out target))
            {
                return(target);
            }

#if !SILVERLIGHT
            // using ICloneable if available
            var cloneable = source as ICloneable;
            if (cloneable != null)
            {
                target = cloneable.Clone();

                // keep track of cloned instances
                _objectReferences.Add(hashCode, target);
                return(target);
            }
#endif

            var sourceType     = source.GetType();
            var sourceAccessor = TypeAccessor.GetAccessor(sourceType);

            target = sourceAccessor.Create();
            // keep track of cloned instances
            _objectReferences.Add(hashCode, target);

            var sourceProperties = sourceAccessor.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            foreach (IMemberAccessor sourceProperty in sourceProperties)
            {
                if (!sourceProperty.HasGetter)
                {
                    continue;
                }

                var originalValue = sourceProperty.GetValue(source);
                if (originalValue == null)
                {
                    continue;
                }

                var propertyType = sourceProperty.MemberType.GetUnderlyingType();

                var interfaces = propertyType.GetInterfaces();

                if (propertyType.IsArray)
                {
                    CloneArray(sourceProperty, source, target);
                }
                else if (originalValue is IDictionary)
                {
                    CloneDictionary(sourceProperty, originalValue, target);
                }
                else if (interfaces.Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IDictionary <,>)))
                {
                    CloneGenericDictionary(sourceProperty, originalValue, target);
                }
                else if (originalValue is IList)
                {
                    CloneCollection(sourceProperty, originalValue, target);
                }
                else if (interfaces.Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList <>)))
                {
                    CloneGenericCollection(sourceProperty, originalValue, target);
                }
                else if (!propertyType.IsValueType && propertyType != typeof(string))
                {
                    CloneObject(sourceProperty, originalValue, target);
                }
                else if (sourceProperty.HasSetter)
                {
                    sourceProperty.SetValue(target, originalValue);
                }
            }

            return(target);
        }
示例#17
0
 public int GetHashCode(IValidator obj)
 {
     return(RuntimeHelpers.GetHashCode(obj));
 }
示例#18
0
 public static long identityHash(this Object clrObject)
 {
     return(RuntimeHelpers.GetHashCode(clrObject));
 }
示例#19
0
 public int GetHashCode(T value)
 {
     return(RuntimeHelpers.GetHashCode(value));
 }
示例#20
0
 public static int GetHashCode(object a)
 {
     return(RuntimeHelpers.GetHashCode(a));
 }
示例#21
0
 public override int GetHashCode(E obj)
 {
     return(RuntimeHelpers.GetHashCode(obj));
 }
示例#22
0
 // GetHashCode is intended to serve as a hash function for this object.
 // Based on the contents of the object, the hash function will return a suitable
 // value with a relatively random distribution over the various inputs.
 //
 // The default implementation returns the sync block index for this instance.
 // Calling it on the same object multiple times will return the same value, so
 // it will technically meet the needs of a hash function, but it's less than ideal.
 // Objects (& especially value classes) should override this method.
 //
 public virtual int GetHashCode()
 {
     return(RuntimeHelpers.GetHashCode(this));
 }
示例#23
0
 public int GetHashCode(T x)
 {
     return(RuntimeHelpers.GetHashCode(x));
 }
示例#24
0
 // Use reference equality because there's only one EmptySelection per text area.
 public override int GetHashCode()
 {
     return(RuntimeHelpers.GetHashCode(this));
 }
示例#25
0
文件: Units.cs 项目: zbesevic/roslyn
 public override int GetHashCode()
 {
     return(Hash.Combine(RuntimeHelpers.GetHashCode(Definition), StartLine.GetHashCode()));
 }
示例#26
0
 public override int GetHashCode()
 {
     return(RuntimeHelpers.GetHashCode(Instance));
 }
示例#27
0
 public int GetHashCode(object obj)
 {
     return(RuntimeHelpers.GetHashCode(obj));
 }
 public int GetHashCode(T value) => value is null ? 0 : RuntimeHelpers.GetHashCode(value);
示例#29
0
 // Token: 0x06003426 RID: 13350 RVA: 0x0012F883 File Offset: 0x0012DC83
 int IEqualityComparer <object> .GetHashCode(object obj)
 {
     return(RuntimeHelpers.GetHashCode(obj));
 }
示例#30
0
 // <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(RuntimeHelpers.GetHashCode(_entity));
 }