protected IConfig GetConfig()
        {
            if (_config == null)
            {
                lock (Lock)
                {
                    if (_config == null)
                    {
                        _config = Namespace == null?ApolloConfigurationManager.GetAppConfig() : ApolloConfigurationManager.GetConfig(Namespace);

                        _config.ConfigChanged += Config_ConfigChanged;
                    }
                }
            }

            return(_config);
        }
Esempio n. 2
0
        protected IConfig GetConfig()
        {
            if (_config != null)
            {
                return(_config);
            }

            lock (Lock)
            {
                Interlocked.MemoryBarrier();

                if (_config != null)
                {
                    return(_config);
                }

                Task <IConfig> config;
                if (Namespaces == null || Namespaces.Count == 0)
#pragma warning disable 618
                {
                    config = ApolloConfigurationManager.GetAppConfig();
                }
#pragma warning restore 618
                else if (Namespaces.Count == 1)
#pragma warning disable 618
                {
                    config = ApolloConfigurationManager.GetConfig(Namespaces[0]);
                }
#pragma warning restore 618
                else
#pragma warning disable 618
                {
                    config = ApolloConfigurationManager.GetConfig(Namespaces);
                }
#pragma warning restore 618
                _config = config.ConfigureAwait(false).GetAwaiter().GetResult();

                _config.ConfigChanged += Config_ConfigChanged;
            }

            return(_config);
        }