using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Xml.Linq;
|
|
namespace Eventech.DynPicture.Model
|
{
|
/// <summary>
|
/// xml配置信息类
|
/// </summary>
|
public class XmlConfigInfo
|
{
|
//默认xml配置文件名称
|
private const string _xmlConfigFileName = "DynamicPictureDefaultConfig.xml";
|
|
//获取xml配置文件全路径名称
|
private static string GetXmlConfigFileName()
|
{
|
return System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, _xmlConfigFileName);
|
}
|
|
/// <summary>
|
/// 配置信息
|
/// </summary>
|
public static ConfigInfo ConfigInfo
|
{
|
get
|
{
|
if (_configInfo == null)
|
{
|
var fileFullName = GetXmlConfigFileName();
|
if (!System.IO.File.Exists(fileFullName))
|
{
|
_configInfo = new ConfigInfo();
|
var xele = _configInfo.ToXElement();
|
xele.Save(fileFullName);
|
}
|
else
|
{
|
var xele = XElement.Load(fileFullName);
|
_configInfo = ConfigInfo.GetConfigInfo(xele);
|
}
|
}
|
return _configInfo;
|
}
|
}
|
private static ConfigInfo _configInfo;
|
|
/// <summary>
|
/// 设置配置
|
/// </summary>
|
/// <param name="xmlInfo"></param>
|
public static void SetConfig(ConfigInfo xmlInfo)
|
{
|
_configInfo = xmlInfo;
|
var fileFullName = GetXmlConfigFileName();
|
var xele = xmlInfo.ToXElement();
|
xele.Save(fileFullName);
|
}
|
|
}
|
}
|