當前位置: 首頁>>代碼示例>>C#>>正文


C# Type.GetHashCode方法代碼示例

本文整理匯總了C#中System.Type.GetHashCode方法的典型用法代碼示例。如果您正苦於以下問題:C# Type.GetHashCode方法的具體用法?C# Type.GetHashCode怎麽用?C# Type.GetHashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Type的用法示例。


在下文中一共展示了Type.GetHashCode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetEntity2Info

        /// <summary>
        /// Get the <see cref="EntityInfo"/> object from the cache.
        /// </summary>
        /// If the <paramref name="type"/> has no <see cref="EntityInfo"/> then it will add the and return the <see cref="EntityInfo"/>.
        /// <param name="type"></param>
        /// <returns></returns>
        public static SimpleAccess.Core.Entity.EntityInfo<OracleSqlBuilder, OracleParameter> GetEntity2Info(Type type)
        {
            Core.Entity.EntityInfo<OracleSqlBuilder, OracleParameter> entityInfo = null;
            if (Entity2Infos.TryGetValue(type.GetHashCode(), out entityInfo))
                return entityInfo;

            entityInfo = new Core.Entity.EntityInfo<OracleSqlBuilder, OracleParameter>(type);
            Entity2Infos.Add(type.GetHashCode(), entityInfo);

            return entityInfo;
        }
開發者ID:sheryever,項目名稱:simple-access-orm,代碼行數:17,代碼來源:RepositorySetting.cs

示例2: GetEntityInfo

        public static EntityInfo GetEntityInfo(Type type)
        {
            EntityInfo entityInfo = null;
            if (EntityInfos.TryGetValue(type.GetHashCode(), out entityInfo))
                return entityInfo;

            entityInfo = new EntityInfo(type);
            EntityInfos.Add(type.GetHashCode(), entityInfo);

            return entityInfo;
        }
開發者ID:sheryever,項目名稱:simple-access-orm,代碼行數:11,代碼來源:RepositorySetting.cs

示例3: GetDiscriminatingTypeForCached

 /// <summary>
 /// Retrieves type discriminators from cache to avoid calling Type.IsDefined(), 
 /// which needs to be called very often (walking the hierarchy) and is quite 
 /// expensive per call.
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 private static Type GetDiscriminatingTypeForCached(Type type)
 {
     lock (DiscriminatorCacheSyncRoot)
     {
         if (DiscriminatorDictionary.Contains(type.GetHashCode()))
             return (Type)(DiscriminatorDictionary[type.GetHashCode()]);
         else
         {
             Type result = GetDiscriminatingTypeForInternal(type);
             DiscriminatorDictionary.Add(type.GetHashCode(), result);
             return result;
         }
     }
 }
開發者ID:cmenge,項目名稱:NoRM,代碼行數:21,代碼來源:MongoDiscriminatedAttribute.cs

示例4:

 internal TypeReflector this[Type type]
 {
     get
     {
         int index = type.GetHashCode() % this.table.Length;
         for (TypeReflector reflector = this.table[index]; reflector != null; reflector = reflector.next)
         {
             if (reflector.type == type)
             {
                 return reflector;
             }
         }
         return null;
     }
     set
     {
         if (++this.count >= this.threshold)
         {
             this.Rehash();
         }
         int index = (int) (value.hashCode % this.table.Length);
         value.next = this.table[index];
         this.table[index] = value;
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:25,代碼來源:TRHashtable.cs

示例5: CompareTypes

 static void CompareTypes(Type firstType, Type secondType)
 {
     var firstHashCode = firstType.GetHashCode();
     var secondHashCode = secondType.GetHashCode();
     Console.WriteLine("{0}    !=    {1}    ?", firstHashCode, secondHashCode);
     Assert.That(firstHashCode, Is.Not.EqualTo(secondHashCode));
 }
開發者ID:RichieYang,項目名稱:Cirqus,代碼行數:7,代碼來源:TestTypeHashCodes.cs

示例6: GetProperty

 public static ExtendProperty GetProperty(Type ownerType, string propertyName)
 {
     int propertyKey = ownerType.GetHashCode() ^ propertyName.GetHashCode();
     var property = ExtendPropertysProvider.Get(propertyKey);
     property.OwnerType = ownerType;
     return property;
 }
開發者ID:yaozd,項目名稱:YOYOFx,代碼行數:7,代碼來源:ExtendProperty.cs

示例7: SpecializationKey

        public SpecializationKey(Type entityType, FileType fileType)
        {
            FileType = fileType;
            SpecializationType = entityType;

            hash = entityType.GetHashCode() ^ fileType.GetHashCode();
        }
開發者ID:scottmuc,項目名稱:Secretary.Net,代碼行數:7,代碼來源:SpecializationKey.cs

示例8: ProxyCacheEntry

        public ProxyCacheEntry(Type baseType, Type[] interfaces)
        {
            if (baseType == null)
            {
                throw new ArgumentNullException("baseType");
            }
            BaseType = baseType;
            Interfaces = interfaces;

            if (interfaces == null || interfaces.Length == 0)
            {
                hashCode = baseType.GetHashCode();
                return;
            }

            // duplicated type exclusion
            Dictionary<Type, object> set = new Dictionary<Type, object>(interfaces.Length + 1);
            set[baseType] = null;
            foreach (Type type in interfaces)
            {
                if (type != null)
                    set[type] = null;
            }

            hashCode = 0;
            foreach (Type type in set.Keys)
            {
                hashCode ^= type.GetHashCode();
            }
        }
開發者ID:Vernathic,項目名稱:ic-AutoTest.NET4CTDD,代碼行數:30,代碼來源:ProxyCacheEntry.cs

示例9: FromName

 public static DependencyProperty FromName(string propertyName, Type ownerType)
 {
     if (propertyName == null)
     {
         throw new ArgumentNullException("propertyName");
     }
     if (ownerType == null)
     {
         throw new ArgumentNullException("ownerType");
     }
     DependencyProperty property = null;
     while ((property == null) && (ownerType != null))
     {
         RuntimeHelpers.RunClassConstructor(ownerType.TypeHandle);
         int key = propertyName.GetHashCode() ^ ownerType.GetHashCode();
         lock (((ICollection) dependencyProperties).SyncRoot)
         {
             if (dependencyProperties.ContainsKey(key))
             {
                 property = dependencyProperties[key];
             }
         }
         ownerType = ownerType.BaseType;
     }
     return property;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:26,代碼來源:DependencyProperty.cs

示例10: Generate

        public static string Generate(Type type)
        {
            const string format = "{0}::{1}-{2}#{3}";

            if (type == null)
                throw new ArgumentNullException("type");

            var hashCode = type.GetHashCode();

            var attributes =
                type.GetMembers().SelectMany(x => x.GetCustomAttributes(true)).Concat(type.GetCustomAttributes(true));

            var nonPublicMembers = type.GetMembers(BindingFlags.NonPublic | BindingFlags.Instance);
            var statics = type.GetMembers(BindingFlags.Static | BindingFlags.Public);

            var items = type.GetMembers().Concat(attributes).Concat(nonPublicMembers).Concat(statics).ToArray();

            var typeCode = items.First().GetHashCode();
            typeCode = items.Skip(1).Aggregate(typeCode, (current, item) => current ^ item.GetHashCode());

            var asmDate = File.GetLastWriteTime(type.Assembly.Location);

            return String.Format(format, hashCode.ToString("X"), typeCode, items.Count(),
                asmDate.Ticks.ToString("X"));
        }
開發者ID:MatanShahar,項目名稱:IntelliSun,代碼行數:25,代碼來源:SignatureStringProvider.cs

示例11: ReflectedType

 public ReflectedType(Type type)
 {
     UnderlyingType = type;
     TypeName = type.GetFriendlyName();
     FullTypeName = type.FullName;
     var interfaceType = Reflector.GetInterface(type);
     if (interfaceType != null)
     {
         InterfaceType = interfaceType;
         InterfaceTypeName = interfaceType.FullName;
     }
     IsArray = type.IsArray;
     IsList = Reflector.IsList(type);
     IsDictionary = Reflector.IsDictionary(type);
     IsSimpleList = Reflector.IsSimpleList(type);
     IsDataEntity = Reflector.IsDataEntity(type) || (!Reflector.IsSimpleType(type) && !IsArray && !IsList && !IsDictionary);
     Type elementType;
     IsDataEntityList = Reflector.IsDataEntityList(type, out elementType);
     ElementType = elementType;
     if (IsDataEntityList)
     {
         IsPolymorphicList = elementType != null && elementType.IsAbstract && (!elementType.IsInterface || !Reflector.IsDataEntity(elementType));
         IsListInterface = type.GetGenericTypeDefinition() == typeof(IList<>);
     }
     IsSimpleType = Reflector.IsSimpleType(type);
     IsNullableType = Reflector.IsNullableType(type);
     IsMarkerInterface = Reflector.IsMarkerInterface(type);
     HashCode = type.GetHashCode();
     IsGenericType = type.IsGenericType;
     IsInterface = type.IsInterface;
     IsAnonymous = Reflector.IsAnonymousType(type);
     IsEmitted = Reflector.IsEmitted(type);
 }
開發者ID:stepaside,項目名稱:Nemo,代碼行數:33,代碼來源:ReflectedType.cs

示例12: ReflectedType

 internal ReflectedType(Type type)
 {
     TypeName = type.Name;
     FullTypeName = type.FullName;
     var interfaceType = Reflector.ExtractInterface(type);
     if (interfaceType != null)
     {
         InterfaceTypeName = interfaceType.FullName;
     }
     IsArray = type.IsArray;
     IsSimpleList = Reflector.IsSimpleList(type);
     IsDataEntity = Reflector.IsDataEntity(type);
     Type elementType;
     IsDataEntityList = Reflector.IsDataEntityList(type, out elementType);
     ElementType = elementType;
     if (IsDataEntityList)
     {
         IsListInterface = type.GetGenericTypeDefinition() == typeof(IList<>);
     }
     IsSimpleType = Reflector.IsSimpleType(type);
     IsList = Reflector.IsList(type);
     IsDictionary = Reflector.IsDictionary(type);
     IsNullableType = Reflector.IsNullableType(type);
     IsMarkerInterface = Reflector.IsMarkerInterface(type);
     HashCode = type.GetHashCode();
     IsGenericType = type.IsGenericType;
     IsInterface = type.IsInterface;
     IsAnonymous = Reflector.IsAnonymousType(type);
 }
開發者ID:ulrakhma,項目名稱:Nemo,代碼行數:29,代碼來源:ReflectedType.cs

示例13: TableReaderSignature

            public TableReaderSignature(Type tableType, IList<string> columns)
            {
                this.tableType = tableType;
                this.columns = columns;
				hash = tableType.GetHashCode();
                foreach (var column in columns)
                    hash ^= column.GetHashCode();
            }
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:8,代碼來源:QueryCache.cs

示例14: GetSerializer

        public static XmlSerializer GetSerializer(Type t)
        {
            int type_hash = t.GetHashCode();

            if (!serializer_dict.ContainsKey(type_hash))
                serializer_dict.Add(type_hash, new XmlSerializer(t));

            return serializer_dict[type_hash];
        }
開發者ID:dayuhan,項目名稱:NETWORK,代碼行數:9,代碼來源:SerializationHelper.cs

示例15: GetSerializer

        public static XmlSerializer GetSerializer(Type t)
        {
            var typeHash = t.GetHashCode();

            if (!SerializerDict.ContainsKey(typeHash))
                SerializerDict.Add(typeHash, new XmlSerializer(t));

            return SerializerDict[typeHash];
        }
開發者ID:the404,項目名稱:yqblog,代碼行數:9,代碼來源:SerializationHelper.cs


注:本文中的System.Type.GetHashCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。