41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System;
|
|
using System.Configuration;
|
|
using System.Xml;
|
|
|
|
namespace CRM.Core.Model
|
|
{
|
|
public class RedisStringHelper
|
|
{
|
|
private static RedisConfigInfo _redisConn = null;
|
|
public static RedisConfigInfo GetConfig()
|
|
{
|
|
if (_redisConn == null)
|
|
{
|
|
_redisConn = (RedisConfigInfo)ConfigurationManager.GetSection("RedisConfig");
|
|
}
|
|
return _redisConn;
|
|
}
|
|
//public RedisClient
|
|
}
|
|
public class RedisConfigInfo : IConfigurationSectionHandler
|
|
{
|
|
public string connectionString { get; set; }
|
|
public int port { get; set; }
|
|
public string password { get; set; }
|
|
public int db { get; set; }
|
|
public object Create(object parent, object configContext, XmlNode section)
|
|
{
|
|
RedisConfigInfo config = new RedisConfigInfo()
|
|
{
|
|
connectionString = section.Attributes["connectionString"].Value,
|
|
port = section.Attributes["port"] == null ? 6379 : Convert.ToInt32(section.Attributes["port"].Value),
|
|
password = section.Attributes["password"].Value,
|
|
db = section.Attributes["db"] == null ? 0 : Convert.ToInt32(section.Attributes["db"].Value),
|
|
};
|
|
|
|
return config;
|
|
}
|
|
|
|
}
|
|
}
|