示例#1
0
        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);
        }
示例#2
0
 public bool TryGetNativeComponentInfo(uint hashCode, out ComponentInfo componentInfo)
 {
     return(_nativeComponents.TryGetValue(hashCode, out componentInfo));
 }
示例#3
0
 public bool TryGetComponentInfo(Type type, out ComponentInfo componentInfo)
 {
     return(_components.TryGetValue(type, out componentInfo));
 }