private void GetOrCreateFieldInfos(out List <FieldInfo> objFields, System.Type type) { FieldInfoStored.TryGetValue(type.GetHashCode(), out objFields); if (objFields == null) { objFields = new List <FieldInfo>(type.GetFields()); FieldInfoStored[type.GetHashCode()] = objFields; } }
/// <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; }
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; }
/// <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; } } }
public SpecializationKey(Type entityType, FileType fileType) { FileType = fileType; SpecializationType = entityType; hash = entityType.GetHashCode() ^ fileType.GetHashCode(); }
public ProxyCacheEntry(System.Type baseType, System.Type[] interfaces) { if (baseType == null) { throw new ArgumentNullException(nameof(baseType)); } BaseType = baseType; _uniqueInterfaces = new HashSet <System.Type>(interfaces ?? new System.Type[0]); if (_uniqueInterfaces.Count == 0) { _hashCode = baseType.GetHashCode(); return; } var allTypes = new List <System.Type>(_uniqueInterfaces) { baseType }; _hashCode = 59; foreach (System.Type type in allTypes) { // This simple implementation is nonsensitive to list order. If changing it for a sensitive one, // take care of ordering the list. _hashCode ^= type.GetHashCode(); } }
public static ExtendProperty GetProperty(Type ownerType, string propertyName) { int propertyKey = ownerType.GetHashCode() ^ propertyName.GetHashCode(); var property = ExtendPropertysProvider.Get(propertyKey); property.OwnerType = ownerType; return property; }
public ProxyCacheEntry(System.Type baseType, System.Type[] interfaces) { if (baseType == null) { throw new ArgumentNullException("baseType"); } BaseType = baseType; Interfaces = interfaces ?? new System.Type[0]; if (Interfaces.Length == 0) { hashCode = baseType.GetHashCode(); return; } // duplicated type exclusion var set = new HashSet <System.Type>(Interfaces) { baseType }; hashCode = 59; foreach (System.Type type in set) { hashCode ^= type.GetHashCode(); } }
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(); } }
public static int RegisterNodeClass(System.Type wrappedType, System.Type type) { if (typeMap == null) { typeMap = new Dictionary <Type, List <ReactNodeType> >(1024); } List <ReactNodeType> clist; if (!typeMap.TryGetValue(wrappedType, out clist)) { typeMap[wrappedType] = clist = new List <ReactNodeType>(); } var rnt = new ReactNodeType() { type = type, menuPath = GetMenuPath(type), niceName = GetNiceName(type), signature = GetSignature(type) }; clist.Add(rnt); return(type.GetHashCode()); }
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")); }
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)); }
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); }
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); }
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; }
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; } }
public ProxyCacheEntry(System.Type baseType, System.Type[] interfaces) { BaseType = baseType ?? throw new ArgumentNullException(nameof(baseType)); var uniqueInterfaces = new HashSet <System.Type>(); if (interfaces != null && interfaces.Length > 0) { uniqueInterfaces.UnionWith(interfaces.Where(i => i != null)); } _uniqueInterfaces = uniqueInterfaces; _hashCode = 59 ^ baseType.GetHashCode(); if (_uniqueInterfaces.Count == 0) { return; } foreach (var type in _uniqueInterfaces) { // This simple implementation is nonsensitive to list order. If changing it for a sensitive one, // take care of ordering the list. _hashCode ^= type.GetHashCode(); } }
public TableReaderSignature(Type tableType, IList<string> columns) { this.tableType = tableType; this.columns = columns; hash = tableType.GetHashCode(); foreach (var column in columns) hash ^= column.GetHashCode(); }
public static XmlSerializer GetSerializer(Type t) { var typeHash = t.GetHashCode(); if (!SerializerDict.ContainsKey(typeHash)) SerializerDict.Add(typeHash, new XmlSerializer(t)); return SerializerDict[typeHash]; }
//public GameStateBase CreateNewStateFromData() //{ // GameStateBase newState = (GameStateBase)System.Activator.CreateInstance(key); // Debug.Log("New State = " + newState.GetType().ToString()); // return newState; //} public override int GetHashCode() { // Note on hash code overriding: https://www.baeldung.com/java-hashcode //return 17 + 31 * CurrentState.GetHashCode() + 31 * Command.GetHashCode(); int returnHashCode = 17; returnHashCode = returnHashCode * 23 + key.GetHashCode(); return(returnHashCode); }
public static XmlSerializer GetSerializer(Type t) { int hashCode = t.GetHashCode(); if (!serializer_dict.ContainsKey(hashCode)) { serializer_dict.Add(hashCode, new XmlSerializer(t)); } return serializer_dict[hashCode]; }
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]; }
public ServiceKey(Type factoryType, string serviceName) { FactoryType = factoryType; Name = serviceName; hash = factoryType.GetHashCode(); if (serviceName != null) hash ^= serviceName.GetHashCode(); }
private DependencyProperty(string name, Type propertyName, Type ownerType, object defaultValue) { this.Name = name; this.Value = defaultValue; this.HashCode = name.GetHashCode() ^ ownerType.GetHashCode(); PorpertypeMetadata metadata = new PorpertypeMetadata(defaultValue) {Type = ownerType}; _metadataMap.Add(metadata); _defaultMetadata = metadata; }
/// <summary> /// Adds or updates a generic definition in the repository. /// </summary> /// <param name="typeKey">The key type.</param> /// <param name="registration">The registration.</param> /// <param name="nameKey">The name of the registration.</param> public void AddOrUpdateGenericDefinition(Type typeKey, IServiceRegistration registration, string nameKey) { var immutableTree = ImmutableTree<IServiceRegistration>.Empty; var newTree = immutableTree.AddOrUpdate(nameKey.GetHashCode(), registration); lock (this.syncObject) { this.genericDefinitionRepository = this.genericDefinitionRepository.AddOrUpdate(typeKey.GetHashCode(), newTree, (oldValue, newValue) => newValue); } }
public static TypeMapping GetTypeMapping(Type type) { TypeMapping result = null; if (!Mapping.TryGetValue(type.GetHashCode(), out result)) { result = new TypeMapping(type); Mapping.AddOrUpdate(result.Hash, result, (x, y) => result); } return result; }
private static IWebPropertyAccessor GetPropertyAccessor(Type type, string propertyName) { if ((s_accessorGenerator == null) || (s_accessorCache == null)) { lock (s_lockObject) { if ((s_accessorGenerator == null) || (s_accessorCache == null)) { s_accessorGenerator = new FastPropertyAccessor(); s_accessorCache = new Hashtable(); } } } int num = HashCodeCombiner.CombineHashCodes(type.GetHashCode(), propertyName.GetHashCode()); IWebPropertyAccessor accessor = (IWebPropertyAccessor) s_accessorCache[num]; if (accessor == null) { Type type2; FieldInfo fieldInfo = null; PropertyInfo propInfo = null; GetPropertyInfo(type, propertyName, out propInfo, out fieldInfo, out type2); int num2 = 0; if (type2 != type) { num2 = HashCodeCombiner.CombineHashCodes(type2.GetHashCode(), propertyName.GetHashCode()); accessor = (IWebPropertyAccessor) s_accessorCache[num2]; if (accessor != null) { lock (s_accessorCache.SyncRoot) { s_accessorCache[num] = accessor; } return accessor; } } if (accessor == null) { Type type3; lock (s_accessorGenerator) { type3 = s_accessorGenerator.GetPropertyAccessorTypeWithAssert(type2, propertyName, propInfo, fieldInfo); } accessor = (IWebPropertyAccessor) HttpRuntime.CreateNonPublicInstance(type3); } lock (s_accessorCache.SyncRoot) { s_accessorCache[num] = accessor; if (num2 != 0) { s_accessorCache[num2] = accessor; } } } return accessor; }
public static int GetHashCode(System.Type @return, System.Type[] arguments) { var s = @return.GetHashCode() * -2; for (int i = 0; i < arguments.Length; i++) { var curr = arguments[i].GetHashCode() << i; s += curr; } return(s); }
private static int GetHashCode(Type typeDef, Type[] arguments) { unchecked { int hashCode = typeDef.GetHashCode(); var length = arguments.Length; for (int i = 0; i < length; ++i) hashCode = (hashCode * 397) ^ arguments[i].GetHashCode(); return hashCode; } }
public TypeMapping(Type type) { this.Hash = type.GetHashCode(); this.CurrentType = type; this.Properties = new Dictionary<string, PropertyInfo>(); PropertyInfo[] properties = type.GetProperties(); this.Properties = new Dictionary<string, PropertyInfo>(); foreach (PropertyInfo info in properties) { this.Properties.Add(info.Name, info); } }
private static int CalculateHashCode(Type type, string property) { unchecked { int result = type.GetHashCode(); if (!string.IsNullOrEmpty(property)) { result = result*397 + property.GetHashCode(); } return result; } }
/// <summary> /// 移除监听 /// </summary> public void RemoveListener(System.Type eventType, System.Action <IEventMessage> listener) { int eventId = eventType.GetHashCode(); if (_listeners.ContainsKey(eventId)) { if (_listeners[eventId].Contains(listener)) { _listeners[eventId].Remove(listener); } } }
public TypeDescription(Type/*!*/ baseType, IList<ITypeFeature/*!*/>/*!*/ features) { Assert.NotNull(baseType); Assert.NotNull(features); _baseType = baseType; _features = features; _hash = _baseType.GetHashCode(); for (int i = 0; i < features.Count; i++) { _hash ^= features[i].GetHashCode(); } }
/// <summary> /// 添加监听 /// </summary> public void AddListener(System.Type eventType, System.Action <IEventMessage> listener) { int eventId = eventType.GetHashCode(); if (_listeners.ContainsKey(eventId) == false) { _listeners.Add(eventId, new List <Action <IEventMessage> >()); } if (_listeners[eventId].Contains(listener) == false) { _listeners[eventId].Add(listener); } }
public static XmlSerializer GetSerializer(Type t) { int type_hash = t.GetHashCode(); if (!serializer_dict.ContainsKey(type_hash)) { //note:因为SortedList,Dictionary均实现了IDictionary接口,会造成XmlSerializer出现异常 if (t.FullName.IndexOf("SortedList") >= 0 || t.FullName.IndexOf("Dictionary") >= 0) serializer_dict.Add(type_hash, null); else serializer_dict.Add(type_hash, new XmlSerializer(t)); } return serializer_dict[type_hash]; }
public Relation(Type @from, Type to, Declared declaredAs) { if (from == null) { throw new ArgumentNullException("from"); } if (to == null) { throw new ArgumentNullException("to"); } From = from; To = to; DeclaredAs = declaredAs; hashCode = (37 * from.GetHashCode()) ^ to.GetHashCode(); }
public TypeDescriptor( Type type ) { if (type.IsGenericType) { myHashCode = type.GetGenericTypeDefinition().GetHashCode(); } else { myHashCode = type.GetHashCode(); } Id = myHashCode.ToString(); Name = type.Name; // TODO: fullname might be null!!! FullName = type.FullName; }
public static int ForcedDifCompareValue(Type x, Type y) { int hashCode = x.GetHashCode(); int num = hashCode.CompareTo(y.GetHashCode()); if (num == 0) { num = x.AssemblyQualifiedName.CompareTo(y.AssemblyQualifiedName); if (num == 0) { long num1 = x.TypeHandle.Value.ToInt64(); num = num1.CompareTo(y.TypeHandle.Value); if (num == 0) { throw new InvalidProgramException(); } } } return num; }
/// <summary> /// Gets the property. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public static DependencyProperty GetProperty(Type type) { DependencyProperty tProp; if (!_dependencyProperties.TryGetValue(type, out tProp)) { var tType2 = type.IsValueType && (!type.IsGenericType || type.GetGenericTypeDefinition() != typeof (Nullable<>)) ? typeof (Nullable<>).MakeGenericType(type) : type; tProp = DependencyProperty.Register(string.Format("SilverConvert_{0}", type.GetHashCode()), tType2, typeof (SilverConverterFE), new PropertyMetadata(null)); _dependencyProperties[type] = tProp; } return tProp; }
/// <seealso cref="java.lang.Object.hashCode()"> /// </seealso> public override int GetHashCode() { int result = 17; /** * note we skip the null test for methodName and params * due to the earlier test in the constructor */ for (int i = 0; i < params_Renamed.Length; ++i) { System.Type param = params_Renamed[i]; if (param != null) { result = result * 37 + param.GetHashCode(); } } result = result * 37 + methodName.GetHashCode(); return(result); }
public static Event_ Pop(System.Type t) { if (!t.IsSubclassOf(defaultType)) { return(defaultEvent); } if (t == defaultType) { return(Pop()); } var hash = t.GetHashCode(); var p = m_eventPool.Get(hash); if (p == null) { p = new Pool <Event_>(20, t); m_eventPool.Add(hash, p); } return(p.Pop()); }
protected static LogicObject _Create(string name = null, System.Type type = null, bool initialize = true) { var hash = type.GetHashCode(); var p = m_pool.Get(hash); if (p == null) { p = new Pool <LogicObject>(256, type); m_pool.Add(hash, p); } var obj = p.Pop(); obj.name = name ?? string.Empty; if (initialize) { obj.Initialize(); } ObjectManager.AddObject(obj); return(obj); }
protected HQLQueryPlanKey(System.Type queryTypeDiscriminator, string query, bool shallow, IDictionary <string, IFilter> enabledFilters) { this.queryTypeDiscriminator = queryTypeDiscriminator; this.query = query; this.shallow = shallow; if (enabledFilters == null || (enabledFilters.Count == 0)) { filterNames = new HashSet <string>(); } else { filterNames = new HashSet <string>(enabledFilters.Keys); } unchecked { var hash = query.GetHashCode(); hash = 29 * hash + (shallow ? 1 : 0); hash = 29 * hash + CollectionHelper.GetHashCode(filterNames); hash = 29 * hash + queryTypeDiscriminator.GetHashCode(); hashCode = hash; } }
public ulong GetHash() { return((ulong)(uint)_a.GetHashCode()); }
public override int GetHashCode() { return(_resultClass.GetHashCode()); }
public override int GetHashCode() { return(enumClass.GetHashCode()); }
public override int GetHashCode() { unchecked { return((name != null ? name.GetHashCode() : 0) ^ (BindingType != null ? BindingType.GetHashCode() : 0)); } }
public override int GetHashCode() { return(entityType.GetHashCode()); }
public static void Snapshot(object o, BindingFlags bindingFlags, Object context, string prefix, string suffix) { StringBuilder buffer = Utility.GetBuffer(); buffer.Length = 0; buffer.Append(InternalNGDebug.DataStartChar); if (o != null) { System.Type type = o.GetType(); if (prefix != null) { buffer.Append(prefix); } buffer.Append(type.Name); if (suffix != null) { buffer.Append(suffix); } if (type.IsPrimitive() == true || type == typeof(string) || type == typeof(decimal)) { buffer.Append("="); buffer.Append(o); } else { FieldInfo[] fields; int hash = type.GetHashCode() + bindingFlags.GetHashCode(); if (NGDebug.cachedFieldInfos.TryGetValue(hash, out fields) == false) { fields = type.GetFields(bindingFlags); NGDebug.cachedFieldInfos.Add(hash, fields); } for (int i = 0; i < fields.Length; i++) { NGDebug.SubSnap(buffer, fields[i].FieldType, fields[i].Name, fields[i].GetValue(o)); } PropertyInfo[] properties; if (NGDebug.cachedPropertiesInfos.TryGetValue(hash, out properties) == false) { properties = type.GetProperties(bindingFlags); List <PropertyInfo> filteredProperties = new List <PropertyInfo>(properties.Length); for (int i = 0; i < properties.Length; i++) { if (properties[i].CanRead == false || properties[i].GetGetMethod(false) == null || properties[i].GetIndexParameters().Length != 0) { continue; } filteredProperties.Add(properties[i]); } properties = filteredProperties.ToArray(); NGDebug.cachedPropertiesInfos.Add(hash, properties); } for (int i = 0; i < properties.Length; i++) { try { NGDebug.SubSnap(buffer, properties[i].PropertyType, properties[i].Name, properties[i].GetValue(o)); } catch (System.Exception ex) { InternalNGDebug.VerboseLogException(ex); } } } } else { buffer.Append("NULL"); } buffer.Append(InternalNGDebug.DataEndChar); Debug.Log(Utility.ReturnBuffer(buffer), context); }
/// <summary> /// 添加监听 /// </summary> public void AddListener(System.Type eventType, System.Action <IEventMessage> listener) { int eventId = eventType.GetHashCode(); AddListener(eventId, listener); }
public override int GetHashCode() { return(associatedClass.GetHashCode()); }
public static int GetPathAndTypeID(string path, System.Type type) { return((path.GetHashCode() * 0x1b) ^ type.GetHashCode()); }
public override int GetHashCode() => Type.GetHashCode();
public CustomLogLevelAttribute(ELogLevel eLogLevel, System.Type eEnumValue) { p_eLogLevel = eLogLevel; p_iLogLevelGroup_HashCode = eEnumValue.GetHashCode(); }
public static void StaticSnapshot(System.Type type) { BindingFlags bindingFlags = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public; FieldInfo[] fields; int hash = type.GetHashCode() + bindingFlags.GetHashCode(); StringBuilder buffer = Utility.GetBuffer(); buffer.Length = 0; buffer.Append(InternalNGDebug.DataStartChar); buffer.Append(type.Name); if (NGDebug.cachedFieldInfos.TryGetValue(hash, out fields) == false) { fields = type.GetFields(bindingFlags); NGDebug.cachedFieldInfos.Add(hash, fields); } for (int i = 0; i < fields.Length; i++) { NGDebug.SubSnap(buffer, fields[i].FieldType, fields[i].Name, fields[i].GetValue(null)); } PropertyInfo[] properties; if (NGDebug.cachedPropertiesInfos.TryGetValue(hash, out properties) == false) { properties = type.GetProperties(bindingFlags); List <PropertyInfo> filteredProperties = new List <PropertyInfo>(properties.Length); for (int i = 0; i < properties.Length; i++) { if (properties[i].CanRead == false || properties[i].GetGetMethod(false) == null || properties[i].GetIndexParameters().Length != 0) { continue; } filteredProperties.Add(properties[i]); } properties = filteredProperties.ToArray(); NGDebug.cachedPropertiesInfos.Add(hash, properties); } for (int i = 0; i < properties.Length; i++) { try { NGDebug.SubSnap(buffer, properties[i].PropertyType, properties[i].Name, properties[i].GetValue(null)); } catch (System.Exception ex) { InternalNGDebug.VerboseLogException(ex); } } buffer.Append(InternalNGDebug.DataEndChar); Debug.Log(Utility.ReturnBuffer(buffer)); }
private int GetDictionaryKey(System.Type type) { return(type.GetHashCode() & dictionaryMask); }
public bool TryGetResolver <T>(ShortKey type, object tag, out Resolver <T> resolver, out Exception error, IContainer resolvingContainer = null) { FullKey key; int hashCode; if (tag == null) { hashCode = type.GetHashCode(); resolver = (Resolver <T>)ResolversByType.GetByRef(hashCode, type); if (resolver != default(Resolver <T>)) // found in resolvers by type { error = default(Exception); return(true); } key = new FullKey(type); } else { key = new FullKey(type, tag); hashCode = key.GetHashCode(); resolver = (Resolver <T>)Resolvers.Get(hashCode, key); if (resolver != default(Resolver <T>)) // found in resolvers { error = default(Exception); return(true); } } // tries finding in dependencies bool hasDependency; lock (_eventSubject) { hasDependency = TryGetDependency(key, hashCode, out var dependencyEntry); if (hasDependency) { // tries creating resolver resolvingContainer = resolvingContainer ?? this; resolvingContainer = dependencyEntry.Lifetime?.SelectResolvingContainer(this, resolvingContainer) ?? resolvingContainer; if (!dependencyEntry.TryCreateResolver(key, resolvingContainer, _registrationTracker.Builders, _registrationTracker.AutowiringStrategy, out var resolverDelegate, out error)) { resolver = default(Resolver <T>); return(false); } resolver = (Resolver <T>)resolverDelegate; } } if (!hasDependency) { // tries finding in parent if (!_parent.TryGetResolver(type, tag, out resolver, out error, resolvingContainer ?? this)) { resolver = default(Resolver <T>); return(false); } } // If it is resolving container only if (resolvingContainer == null || resolvingContainer == this) { // Add resolver to tables lock (_eventSubject) { Resolvers = Resolvers.Set(hashCode, key, resolver); if (tag == null) { ResolversByType = ResolversByType.Set(hashCode, type, resolver); } } } error = default(Exception); return(true); }