Example #1
0
        /// <summary>
        /// 初始化提供程序。
        /// </summary>
        /// <param name="name">该提供程序的友好名称。</param>
        /// <param name="config">名称/值对的集合,表示在配置中为该提供程序指定的、提供程序特定的属性。</param>
        public override void Initialize(string name, NameValueCollection config)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = "AspNetSession";
            }

            var address        = config["address"];
            var password       = config["password"];
            var defaultAddress = RedisManager.DefaultAddress;

            if (address != null)
            {
                var sp = address.Split(':');
                if (sp.Length != 2)
                {
                    throw new ArgumentException("非法的 Redis 的连接地址 {0}。".Fmt(address));
                }
                defaultAddress = new Net.SocketInfo(sp[0], int.Parse(sp[1]));
            }
            this._redisManager = new RedisManager(defaultAddress, password);

            var sessionConfig = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState");

            this._sessionTimeout = sessionConfig.Timeout;

            base.Initialize(name, config);
        }
        /// <summary>
        /// 初始化提供程序。
        /// </summary>
        /// <param name="name">该提供程序的友好名称。</param>
        /// <param name="config">名称/值对的集合,表示在配置中为该提供程序指定的、提供程序特定的属性。</param>
        public override void Initialize(string name, NameValueCollection config)
        {
            if(string.IsNullOrWhiteSpace(name)) name = "AspNetSession";

            var address = config["address"];
            var password = config["password"];
            var defaultAddress = RedisManager.DefaultAddress;
            if(address != null)
            {
                var sp = address.Split(':');
                if(sp.Length != 2) throw new ArgumentException("非法的 Redis 的连接地址 {0}。".Fmt(address));
                defaultAddress = new Net.SocketInfo(sp[0], int.Parse(sp[1]));
            }
            this._redisManager = new RedisManager(defaultAddress, password);

            var sessionConfig = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState");
            this._sessionTimeout = sessionConfig.Timeout;

            base.Initialize(name, config);
        }