Exemplo n.º 1
0
        /// <summary>
        ///  设置上下文配置信息,当前配置在当前上下文中有效
        /// </summary>
        /// <param name="config"></param>
        public void SetContextConfig(TConfigType config)
        {
            if (_contextConfig?.Value == null)
            {
                lock (_lockObj)
                {
                    if (_contextConfig?.Value == null)
                    {
                        if (_contextConfig == null)
                        {
                            _contextConfig = new AsyncLocal <Dictionary <object, TConfigType> >();
                        }

                        _contextConfig.Value = new Dictionary <object, TConfigType>();
                    }
                }
            }

            ConfigMode = ConfigProviderMode.Context;
            if (_contextConfig.Value.ContainsKey(this))
            {
                _contextConfig.Value[this] = config;
            }
            else
            {
                _contextConfig.Value.Add(this, config);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 设置实例配置信息
 /// </summary>
 /// <param name="config"></param>
 private void SetConfig(TConfigType config)
 {
     ConfigMode = ConfigProviderMode.Instance;
     _config    = config;
 }
Exemplo n.º 3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public BaseMetaProvider()
 {
     ConfigMode = ConfigProviderMode.Default;
 }