protected Dictionary <string, string> LoadUrls() { Dictionary <string, string> dic = new Dictionary <string, string>(); var fileName = AppPath.CorePath("SiteUrls"); XmlDocument doc = CreateDoc(fileName); XmlNode urls = doc.SelectSingleNode("SiteUrls/urls"); foreach (XmlNode n in urls.ChildNodes) { if (n.NodeType != XmlNodeType.Comment) { if (n.Attributes != null) { string name = n.Attributes["Name"].Value; string path = n.Attributes["Path"].Value.Replace("^", "&"); dic.Add(name, path); } } } return(dic); }
private static Hashtable LoadResource(ResourceManagerType resourceType, Hashtable target, string culture) { string filePath = AppPath.CorePath("Resource") + "{0}/{1}"; switch (resourceType) { case ResourceManagerType.CustomMessage: filePath = string.Format(filePath, culture, "Messages.xml"); break; case ResourceManagerType.String: filePath = string.Format(filePath, culture, "Resources.xml"); break; case ResourceManagerType.Help: filePath = string.Format(filePath, culture, "Help.xml"); break; default: filePath = string.Format(filePath, culture, "Resources.xml"); break; } if (!System.IO.File.Exists(filePath)) { throw new Exception(string.Format("File Doesn't Exists: {0}", filePath)); } FileInfo fileInfo = new FileInfo(filePath); long fileSize = fileInfo.Length; long prevSize = CustomCache.Get(string.Format("Core.Resource.Size.{0}", resourceType)).SafeLong(0); Hashtable resource = (Hashtable)CustomCache.Get(string.Format("Core.Resource.{0}", resourceType)); //resource.Count if (resource == null || fileSize != prevSize) { XmlDocument d = new XmlDocument(); try { d.Load(filePath); } catch { return(target); } var selectSingleNode = d.SelectSingleNode("root"); if (selectSingleNode != null) { foreach (XmlNode n in selectSingleNode.ChildNodes) { if (n.NodeType != XmlNodeType.Comment) { Message m; switch (resourceType) { case ResourceManagerType.CustomMessage: m = new Message(n); target[m.Name] = m; break; case ResourceManagerType.Help: m = new Message(n); target[m.Name] = m; break; case ResourceManagerType.String: if (target[n.Attributes["name"].Value.ToLower()] == null) { target.Add(n.Attributes["name"].Value.ToLower(), n.InnerText.Replace(">", ">").Replace("<", "<")); } else { target[n.Attributes["name"].Value.ToLower()] = n.InnerText.Replace(">", ">").Replace("<", "<"); } break; //m = new Message(n); //target[m.Name] = m; //break; } } } } CustomCache.Insert(string.Format("Core.Resource.{0}", resourceType.ToString()), target); CustomCache.Insert(string.Format("Core.Resource.Size.{0}", resourceType.ToString()), fileSize); return(target); } return(resource); }