System.Type.GetHashCode()

Here are the examples of the csharp api System.Type.GetHashCode() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

533 Examples 7

19 Source : EntityMapperProvider.cs
with Apache License 2.0
from 1448376744

public override int GetHashCode()
            {
                return Type.GetHashCode();
            }

19 Source : ReaderCache.cs
with Apache License 2.0
from aadreja

static int GetParameterHash(object dynamicObject)
        {
            unchecked
            {
                int hash = 31; //any prime number
                PropertyInfo[] propertyInfo = dynamicObject.GetType().GetProperties();
                for (int i = 0; i < propertyInfo.Length; i++)
                {
                    object propertyName = propertyInfo[i].Name;
                    //dynamic property will always return System.Object as property type. Get Type from the value
                    Type propertyType = GetTypeOfDynamicProperty(propertyInfo[i], dynamicObject);

                    //prime numbers to generate hash
                    hash = (-97 * ((hash * 29) + propertyName.GetHashCode())) + propertyType.GetHashCode();
                }
                return hash;
            }
        }

19 Source : ConversionHelper.cs
with MIT License
from abdullin

public override int GetHashCode()
			{
				// note: we cannot just xor both hash codes, because if left and right are the same, we will return 0
				int h = this.Left.GetHashCode();
				h = (h >> 13) | (h << 19);
				h ^= this.Right.GetHashCode();
				return h;
			}

19 Source : XmlSerializableDataContractExtensions.cs
with MIT License
from actions

public override int GetHashCode()
            {
                int hashCode = 7443; // "large" prime to start the seed
                
                // Bitshifting and subtracting once is an efficient way to multiply by our second "large" prime, 0x7ffff = 524287
                hashCode = (hashCode << 19) - hashCode + (RootNamespace?.GetHashCode() ?? 0);
                hashCode = (hashCode << 19) - hashCode + ElementName.GetHashCode();
                hashCode = (hashCode << 19) - hashCode + ElementType.GetHashCode();

                return hashCode;
            }

19 Source : VssConnection.cs
with MIT License
from actions

public int GetHashCode(ClientCacheKey obj)
                {
                    return obj.Type.GetHashCode() ^ obj.ServiceIdentifier.GetHashCode();
                }

19 Source : CrmOnlineOrganizationService.cs
with MIT License
from Adoxio

protected virtual bool IsReadRequest(object request)
		{
			return request != null && Array.BinarySearch(_cachedRequestsSorted, request.GetType().GetHashCode()) >= 0;
		}

19 Source : NarrowPhase.cs
with The Unlicense
from aeroson

public override int GetHashCode()
        {
            //TODO: Use old hash code system?
            return A.GetHashCode() + B.GetHashCode();
        }

19 Source : ConvertUtils.cs
with MIT License
from akaskela

public override int GetHashCode()
            {
                return _initialType.GetHashCode() ^ _targetType.GetHashCode();
            }

19 Source : DefaultContractResolver.cs
with MIT License
from akaskela

public override int GetHashCode()
        {
            return _resolverType.GetHashCode() ^ _contractType.GetHashCode();
        }

19 Source : Uncapsulator.cs
with MIT License
from albahari

public override int GetHashCode () => Type.GetHashCode () + 37 * base.GetHashCode ();

19 Source : Uncapsulator.cs
with MIT License
from albahari

public override int GetHashCode () => Type.GetHashCode () + 37 * Name.GetHashCode ();

19 Source : ExpressionComparer.cs
with MIT License
from albyho

protected virtual int CompareType(Type x, Type y)
        {
            if (x == y) return 0;

            if (CompareNull(x, y, out var result)) return result;

            result = x.GetHashCode() - y.GetHashCode();
            if (result != 0) return result;

            result = String.Compare(x.Name, y.Name, StringComparison.Ordinal);
            if (result != 0) return result;

            return x.replacedemblyQualifiedName.CompareTo(y.replacedemblyQualifiedName);
        }

19 Source : GraphCommand.cs
with MIT License
from alelievr

public override int GetHashCode()
		{
			return position.GetHashCode()
				+ type.GetHashCode()
				+ forcePositon.GetHashCode()
				+ name.GetHashCode()
				+ nodeType.GetHashCode()
				+ fromNodeName.GetHashCode()
				+ toNodeName.GetHashCode();
		}

19 Source : Entity.cs
with MIT License
from alexandrebeato

public override int GetHashCode()
        {
            return (GetType().GetHashCode() * 451) + Id.GetHashCode();
        }

19 Source : ThreadsafeTypeKeyHashTable.cs
with Apache License 2.0
from allenai

private bool AddToBuckets(Entry[] buckets, Type newKey, Entry newEntryOrNull, Func<Type, TValue> valueFactory, out TValue resultingValue)
        {
            var h = (newEntryOrNull != null) ? newEntryOrNull.Hash : newKey.GetHashCode();
            if (buckets[h & (buckets.Length - 1)] == null)
            {
                if (newEntryOrNull != null)
                {
                    resultingValue = newEntryOrNull.Value;
                    VolatileWrite(ref buckets[h & (buckets.Length - 1)], newEntryOrNull);
                }
                else
                {
                    resultingValue = valueFactory(newKey);
                    VolatileWrite(ref buckets[h & (buckets.Length - 1)], new Entry { Key = newKey, Value = resultingValue, Hash = h });
                }
            }
            else
            {
                Entry searchLastEntry = buckets[h & (buckets.Length - 1)];
                while (true)
                {
                    if (searchLastEntry.Key == newKey)
                    {
                        resultingValue = searchLastEntry.Value;
                        return false;
                    }

                    if (searchLastEntry.Next == null)
                    {
                        if (newEntryOrNull != null)
                        {
                            resultingValue = newEntryOrNull.Value;
                            VolatileWrite(ref searchLastEntry.Next, newEntryOrNull);
                        }
                        else
                        {
                            resultingValue = valueFactory(newKey);
                            VolatileWrite(ref searchLastEntry.Next, new Entry { Key = newKey, Value = resultingValue, Hash = h });
                        }

                        break;
                    }

                    searchLastEntry = searchLastEntry.Next;
                }
            }

            return true;
        }

19 Source : ThreadsafeTypeKeyHashTable.cs
with Apache License 2.0
from allenai

[MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool TryGetValue(Type key, out TValue value)
        {
            Entry[] table = this.buckets;
            var hash = key.GetHashCode();
            Entry entry = table[hash & table.Length - 1];

            while (entry != null)
            {
                if (entry.Key == key)
                {
                    value = entry.Value;
                    return true;
                }

                entry = entry.Next;
            }

            value = default(TValue);
            return false;
        }

19 Source : TypeCachingKey.cs
with MIT License
from aloneguid

public override int GetHashCode()
      {
         return 31 * ClreplacedType.GetHashCode() + Field.GetHashCode();
      }

19 Source : DynamicInvoker.cs
with MIT License
from amolines

private static int Hash(Type type, string methodname, object[] args)
        {
            var hash = 23;
            hash = hash * 31 + type.GetHashCode();
            hash = hash * 31 + methodname.GetHashCode();
            for (var index = 0; index < args.Length; index++)
            {
                var argtype = args[index].GetType();
                hash = hash * 31 + argtype.GetHashCode();
            }
            return hash;
        }

19 Source : Entity.cs
with MIT License
from Andyhacool

public override int GetHashCode()
        {
            return (GetType().GetHashCode() * 907) + Id.GetHashCode();
        }

19 Source : HelpPageSampleKey.cs
with GNU General Public License v3.0
from andysal

public override int GetHashCode()
        {
            int hashCode = ControllerName.ToUpperInvariant().GetHashCode() ^ ActionName.ToUpperInvariant().GetHashCode();
            if (MediaType != null)
            {
                hashCode ^= MediaType.GetHashCode();
            }
            if (SampleDirection != null)
            {
                hashCode ^= SampleDirection.GetHashCode();
            }
            if (ParameterType != null)
            {
                hashCode ^= ParameterType.GetHashCode();
            }
            foreach (string parameterName in ParameterNames)
            {
                hashCode ^= parameterName.ToUpperInvariant().GetHashCode();
            }

            return hashCode;
        }

19 Source : Entity.cs
with Apache License 2.0
from aneshas

public override int GetHashCode()
        {
            if (Id.Equals(default(TIdenreplacedy)))
            {
                return base.GetHashCode();
            }

            return GetType().GetHashCode() ^ Id.GetHashCode();
        }

19 Source : ConversionSupport.cs
with Apache License 2.0
from apache

protected void SetHashCode()
            {
                long th = TargetType.GetHashCode();
                long sh = SourceType.GetHashCode();
                // Cantor pairing
                hash = (int)((th + sh) * (th + sh + 1) / 2 + sh);
            }

19 Source : TypeImplementation.cs
with MIT License
from apexsharp

public int hashCode() => Type.GetHashCode();

19 Source : TypeConstraintAttribute.cs
with MIT License
from arimger

public override int GetHashCode()
        {
            unchecked
            {
                var result = 0;
                result = (result * 397) ^ replacedemblyType.GetHashCode();
                result = (result * 397) ^ AllowAbstract.GetHashCode();
                result = (result * 397) ^ AllowObsolete.GetHashCode();
                return result;
            }
        }

19 Source : TargetedType.cs
with MIT License
from azist

public override int GetHashCode() => Type.GetHashCode();

19 Source : ServiceClientHub.Inner.cs
with MIT License
from azist

public override int GetHashCode()
      {
        return m_Contract.GetHashCode();
      }

19 Source : SemanticContext.cs
with MIT License
from Azure

public override int GetHashCode()
            {
                return MurmurHash.HashCode(opnds, typeof(SemanticContext.AND).GetHashCode());
            }

19 Source : SemanticContext.cs
with MIT License
from Azure

public override int GetHashCode()
            {
                return MurmurHash.HashCode(opnds, typeof(SemanticContext.OR).GetHashCode());
            }

19 Source : TypeEqualityComparer.cs
with GNU Lesser General Public License v3.0
from Barsonax

public int GetHashCode(T obj)
        {
            return obj.GetType().GetHashCode();
        }

19 Source : SerializableSystemType.cs
with MIT License
from Baste-RainGames

public override int GetHashCode()
        {
            return SystemType.GetHashCode();
        }

19 Source : ReflectionCache.cs
with MIT License
from bbepis

public override int GetHashCode()
         {
            return Type.GetHashCode() + MemberName.GetHashCode();
         }

19 Source : TemplateDefinition.cs
with MIT License
from beakona

public override int GetHashCode()
        {
            return this.GetType().GetHashCode() + this.Language.GetHashCode() + this.Body.GetHashCode();
        }

19 Source : DynamicInvoker.cs
with MIT License
from binarymash

private static int Hash(Type type, string methodname, object[] args)
        {
            var hash = 23;
            hash = (hash * 31) + type.GetHashCode();
            hash = (hash * 31) + methodname.GetHashCode();
            for (var index = 0; index < args.Length; index++)
            {
                var argtype = args[index].GetType();
                hash = (hash * 31) + argtype.GetHashCode();
            }

            return hash;
        }

19 Source : DomainEventHandlerInfo.cs
with MIT License
from bing-framework

public override int GetHashCode() => _type.GetHashCode();

19 Source : System_TypeWrap.cs
with MIT License
from bjfumac

[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int GetHashCode(IntPtr L)
	{
		try
		{
			ToLua.CheckArgsCount(L, 1);
			System.Type obj = ToLua.CheckMonoType(L, 1);
			int o = obj.GetHashCode();
			LuaDLL.lua_pushinteger(L, o);
			return 1;
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}

19 Source : ComponentKey.cs
with MIT License
from BlazorComponent

public override int GetHashCode()
        {
            return Name != null ? Type.GetHashCode() ^ Name.GetHashCode() : Type.GetHashCode();
        }

19 Source : TypeComparer.cs
with GNU General Public License v3.0
from blqw

public int GetHashCode(Type obj)
        {
            if (obj != null && obj.GetType() != _runtimeType && obj.IsGenericType)
            {
                var hashcode = obj.GetGenericTypeDefinition().GetHashCode();
                if (!obj.IsGenericTypeDefinition)
                {
                    foreach (var item in obj.GetGenericArguments())
                    {
                        hashcode ^= item.GetHashCode();
                    }
                }
                return hashcode;
            }
            return obj?.GetHashCode() ?? 0;
        }

19 Source : MyType.cs
with GNU General Public License v3.0
from blqw

public override int GetHashCode() => GenericTypeDefinition.GetHashCode();

19 Source : Notification.cs
with GNU General Public License v3.0
from BramDC3

public override int GetHashCode()
            {
                return typeof(T).GetHashCode() ^ 8510;
            }

19 Source : NodeInfo.cs
with MIT License
from BrunoS3D

public override int GetHashCode()
        {
            if (this.IsEmpty)
            {
                return 0;
            }

            const int P = 16777619;

            unchecked
            {
                return (int)2166136261
                    ^ ((this.Name == null ? 12321 : this.Name.GetHashCode()) * P)
                    ^ (this.Id * P)
                    ^ ((this.Type == null ? 1423 : this.Type.GetHashCode()) * P)
                    ^ ((this.IsArray ? 124124 : 43234) * P)
                    ^ ((this.IsEmpty ? 872934 : 27323) * P);
            }
        }

19 Source : ObjectMapper.cs
with Apache License 2.0
from busterwood

public override int GetHashCode()
        {
            unchecked
            {
                return (In.GetHashCode() * 397) ^ Out.GetHashCode();
            }
        }

19 Source : Things.cs
with Apache License 2.0
from busterwood

public override int GetHashCode()
        {
            unchecked { return name.GetHashCode() * type.GetHashCode(); }
        }

19 Source : TypePair.cs
with Apache License 2.0
from busterwood

public override int GetHashCode() => From == null ? 0 : From.GetHashCode() + To.GetHashCode() + MissingMethods.GetHashCode();

19 Source : SemanticContext.cs
with MIT License
from Butjok

public override int GetHashCode()
            {
                return MurmurHash.HashCode(opnds, typeof(SemanticContext.AND).GetHashCode());
            }

19 Source : SemanticContext.cs
with MIT License
from Butjok

public override int GetHashCode()
            {
                return MurmurHash.HashCode(opnds, typeof(SemanticContext.OR).GetHashCode());
            }

19 Source : CMInputCallbackInstaller.cs
with GNU General Public License v2.0
from Caeden117

public override int GetHashCode() => InterfaceType.GetHashCode();

19 Source : SubscriptionDataConfig.cs
with Apache License 2.0
from Capnode

public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = _sid.GetHashCode();
                hashCode = (hashCode*397) ^ Type.GetHashCode();
                hashCode = (hashCode*397) ^ (int) TickType;
                hashCode = (hashCode*397) ^ (int) Resolution;
                hashCode = (hashCode*397) ^ FillDataForward.GetHashCode();
                hashCode = (hashCode*397) ^ ExtendedMarketHours.GetHashCode();
                hashCode = (hashCode*397) ^ IsInternalFeed.GetHashCode();
                hashCode = (hashCode*397) ^ IsCustomData.GetHashCode();
                hashCode = (hashCode*397) ^ DataTimeZone.Id.GetHashCode();// timezone hash is expensive, use id instead
                hashCode = (hashCode*397) ^ ExchangeTimeZone.Id.GetHashCode();// timezone hash is expensive, use id instead
                hashCode = (hashCode*397) ^ IsFilteredSubscription.GetHashCode();
                return hashCode;
            }
        }

19 Source : PositionGroupBuyingPowerModel.cs
with Apache License 2.0
from Capnode

public override int GetHashCode()
        {
            return GetType().GetHashCode();
        }

19 Source : EasyProxyGenerator.cs
with MIT License
from ch00486259

private static Type CreateProxyType()
        {
            var interfaceType = InterfaceType;
            var typeName = string.Format("{0}_{1}_Imp_{2}", typeof(EasyProxyGenerator<T>).Name, interfaceType.Name, interfaceType.GetHashCode());

            TypeBuilder typeBuilder = ModuleBuilder.DefineType(typeName, TypeAttributes.Public | TypeAttributes.Clreplaced | TypeAttributes.Sealed, typeof(ProxyBase));
            typeBuilder.AddInterfaceImplementation(interfaceType);

            MethodInfo interceptMethodInfo = typeof(IInterceptor).GetMethod("Proceed", BindingFlags.Instance | BindingFlags.Public);
            FieldBuilder fieldBuilder = DynamicProxyHelper.DefineField(typeBuilder, "interceptor", typeof(IInterceptor), FieldAttributes.Private);

            DynamicProxyHelper.DefineConstructor(typeBuilder, fieldBuilder);
            DynamicProxyHelper.DefineMethods(typeBuilder, fieldBuilder, interfaceType, interceptMethodInfo);

            return typeBuilder.CreateTypeInfo().AsType();
        }

19 Source : VRTK_SDKInfo.cs
with MIT License
from charles-river-analytics

public override int GetHashCode()
        {
            return type.GetHashCode();
        }

See More Examples