Esempio n. 1
0
        internal static ReactModuleInfo GetOrAddModuleInfo(Type moduleType, ReactModuleAttribute moduleAttribute)
        {
            lock (s_moduleInfoMutex)
            {
                if (s_moduleInfos is null)
                {
                    s_moduleInfos = new Dictionary <Type, ReactModuleInfo>();
                }

                if (s_moduleInfos.TryGetValue(moduleType, out ReactModuleInfo moduleInfo))
                {
                    return(moduleInfo);
                }

                moduleInfo = new ReactModuleInfo(moduleType, moduleAttribute);
                s_moduleInfos.Add(moduleType, moduleInfo);
                return(moduleInfo);
            }
        }
Esempio n. 2
0
        public ReactModuleInfo(Type moduleType, ReactModuleAttribute moduleAttribute)
        {
            ModuleType       = moduleType;
            ModuleName       = GetModuleName(moduleType, moduleAttribute);
            EventEmitterName = moduleAttribute.EventEmitterName ?? "RCTDeviceEventEmitter";
            ModuleProvider   = (IReactModuleBuilder moduleBuilder) =>
            {
                object module = Activator.CreateInstance(moduleType);
                AddModuleMembers(moduleBuilder, module);
                return(module);
            };

            m_initializerInfos      = new Lazy <List <ReactInitializerInfo> >(InitInitializerInfos, LazyThreadSafetyMode.PublicationOnly);
            m_constantInfos         = new Lazy <List <ReactConstantInfo> >(InitConstantInfos, LazyThreadSafetyMode.PublicationOnly);
            m_constantProviderInfos = new Lazy <List <ReactConstantProviderInfo> >(InitConstantProviderInfos, LazyThreadSafetyMode.PublicationOnly);
            m_methodInfos           = new Lazy <List <ReactMethodInfo> >(InitMethodInfos, LazyThreadSafetyMode.PublicationOnly);
            m_syncMethodInfos       = new Lazy <List <ReactSyncMethodInfo> >(InitSyncMethodInfos, LazyThreadSafetyMode.PublicationOnly);
            m_functionInfos         = new Lazy <List <ReactFunctionInfo> >(InitFunctionInfos, LazyThreadSafetyMode.PublicationOnly);
            m_eventInfos            = new Lazy <List <ReactEventInfo> >(InitEventInfos, LazyThreadSafetyMode.PublicationOnly);
        }
Esempio n. 3
0
 public static string GetModuleName(Type moduleType, ReactModuleAttribute moduleAttribute)
 {
     return(moduleAttribute.ModuleName ?? moduleType.Name);
 }