当前位置: 首页>>代码示例>>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;未经允许,请勿转载。