private void CollectType(Type type) { NativeComponentAttribute nativeComponentAttribute = type.GetCustomAttribute <NativeComponentAttribute>(); ComponentAttribute componentAttr = type.GetCustomAttribute <ComponentAttribute>(); if (componentAttr is null && nativeComponentAttribute is null) { return; } BaseComponentAttribute baseAttr = nativeComponentAttribute; if (baseAttr is null) { baseAttr = componentAttr; } ComponentInfo componentInfo = new ComponentInfo(); componentInfo.IsNative = componentAttr is null; componentInfo.Type = baseAttr.InterfaceType ?? type; componentInfo.ImplType = type; componentInfo.Ctor = new TypeExtractor(type).CollectOnlyCtor(); componentInfo.HashCode = nativeComponentAttribute?.HashCode ?? 0u; KeyValuePair <Type, ComponentInfo> componentPair = new KeyValuePair <Type, ComponentInfo>(baseAttr.InterfaceType ?? type, componentInfo); if (componentInfo.IsNative) { KeyValuePair <uint, ComponentInfo> pair = new KeyValuePair <uint, ComponentInfo>(nativeComponentAttribute.HashCode, componentInfo); lock (_syncNativeObj) { _nativeComponents.Add(pair); } } lock (_syncManagedObj) _components.Add(componentPair); }
public bool TryGetNativeComponentInfo(uint hashCode, out ComponentInfo componentInfo) { return(_nativeComponents.TryGetValue(hashCode, out componentInfo)); }
public bool TryGetComponentInfo(Type type, out ComponentInfo componentInfo) { return(_components.TryGetValue(type, out componentInfo)); }