namespace BLL.Manager
{
/// <summary>
/// 武功资源管理
/// </summary>
public class GestResourceManager
{
private const string CacheKey = "GestResourceManager";
private static object LockHelper = new object();
private static Hashtable htCollection = null;
private static IList<GestResourceEntity> iList_Collection = null;
private GestResourceManager()
{
htCollection = new Hashtable();
}
public IList<GestResourceEntity> Gests
{
get
{
return iList_Collection;
}
}
public GestResourceEntity this[string index]
{
get
{
if (htCollection[index] == null)
return null;
return htCollection[index] as GestResourceEntity;
}
}
public static GestResourceManager GetResource()
{
GestResourceManager manager = LRCache.Get(CacheKey) as GestResourceManager;
if (manager == null)
{
lock (LockHelper)
{
if (manager == null)
{
manager = new GestResourceManager();
manager.LoadGestResource();
LRCache.Insert(CacheKey, manager);
}
}
}
return manager;
}
/// <summary>
/// 加载武功资源
/// </summary>
private void LoadGestResource()
{
IList<GestResourceEntity> iList_GestResourceEntity = new GestBLL().GetAllGest();
if (iList_GestResourceEntity == null)
return;
iList_Collection = iList_GestResourceEntity;
foreach (GestResourceEntity resource in iList_GestResourceEntity)
{
htCollection[resource.GestID.ToString()] = resource;
}
}
}
}
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
namespace BLL.Manager
{
/// <summary>
/// 建筑参数
/// </summary>
public class BuildingParaManager
{
private const string BUILDINGPARAKEY = "BuildingPara";
private const string XMLPATH = "~/Config/Building.xml";
private const string ParentNode = "/Buildings";
private static string XMLMapPath = string.Empty;
public Hashtable BuildParaCollection = null;
public List<BuildingPara> BuildingParas = null;
private XmlDocument document = null;
private static object obj = new object();
private BuildingParaManager()
{
BuildParaCollection = new Hashtable();
BuildingParas = new List<BuildingPara>();
document = new XmlDocument();
}
public BuildingPara this[string index]
{
get
{
if (BuildParaCollection[index] == null)
return null;
return BuildParaCollection[index] as BuildingPara;
}
}
public static BuildingParaManager GetBuildingPara()
{
BuildingParaManager dll = LRCache.Get(BUILDINGPARAKEY) as BuildingParaManager;
XMLMapPath = HttpContext.Current.Server.MapPath(XMLPATH);
if (dll == null)
{
lock (obj)
{
dll = new BuildingParaManager();
dll.LoadXML();
CacheDependency dependency = new CacheDependency(XMLMapPath);
LRCache.Insert(BUILDINGPARAKEY, dll, dependency);
}
}
return dll;
}
private void LoadXML()
{
document.Load(XMLMapPath);
XmlNode parentNode = document.SelectSingleNode(ParentNode);
if (parentNode != null)
{
foreach(XmlNode node in parentNode.ChildNodes)
{
if (node.NodeType == XmlNodeType.Comment)
continue;
BuildingPara para = new BuildingPara();
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.NodeType == XmlNodeType.Comment)
continue;
if (childNode.Name == "Name")
para.Name = childNode.InnerText;
else if (childNode.Name == "Area")
para.Area = ArrayUtil.SplitStringToIntArray(childNode.InnerText, ',');
else if (childNode.Name == "BuildNeedMan")
para.BuildNeedMan = childNode.InnerText;
else if (childNode.Name == "RepairNeedMan")
para.RepairNeedMan = childNode.InnerText;
else if (childNode.Name == "Normal")
para.Normal = ArrayUtil.SplitStringToIntArray(childNode.InnerText, ',');
else if (childNode.Name == "BuildStart")
para.BuildStart = ArrayUtil.SplitStringToIntArray(childNode.InnerText, ',');
else if (childNode.Name == "Upgrading")
para.Upgrading = ArrayUtil.SplitStringToIntArray(childNode.InnerText, ',');
else if (childNode.Name == "Broken")
para.Broken = ArrayUtil.SplitStringToIntArray(childNode.InnerText, ',');
else if (childNode.Name == "NormalPath")
para.NormalPath = childNode.InnerText;
else if (childNode.Name == "BuildPath")
para.BuildPath = childNode.InnerText;
else if (childNode.Name == "UpgradingPath")
para.UpgradingPath = childNode.InnerText;
else if (childNode.Name == "BrokenPath")
para.BrokenPath = childNode.InnerText;
else if (childNode.Name == "RemovingPath")
para.RemovingPath = childNode.InnerText;
else if (childNode.Name == "RepairingPath")
para.RepairingPath = childNode.InnerText;
else if (childNode.Name == "Removing")
para.Removing = ArrayUtil.SplitStringToIntArray(childNode.InnerText, ',');
else if (childNode.Name == "Repairing")
para.Repairing = ArrayUtil.SplitStringToIntArray(childNode.InnerText, ',');
else if (childNode.Name == "PhotoPath")
para.PhotoPath = childNode.InnerText;
else if (childNode.Name == "NormalPhoto")
para.NormalPhoto = childNode.InnerText;
else if (childNode.Name == "BuildStartPhoto")
para.BuildStartPhoto = childNode.InnerText;
else if (childNode.Name == "UpgradingPhoto")
para.UpgradingPhoto = childNode.InnerText;
else if (childNode.Name == "BrokenPhoto")
para.BrokenPhoto = childNode.InnerText;
else if (childNode.Name == "RemovingPhoto")
para.RemovingPhoto = childNode.InnerText;
else if (childNode.Name == "RepairingPhoto")
para.RepairingPhoto = childNode.InnerText;
}
BuildParaCollection[node.Attributes["TypeID"].Value] = para;
BuildingParas.Add(para);
}
}
}
}
}

被折叠的 条评论
为什么被折叠?



