예제 #1
0
        public Catagory GetCatagory(string providerName, string catagoryName)
        {
            // load xml từ StreamReader
            XmlDocument xml = new XmlDocument();
            StreamReader sr = new StreamReader(ContentTreeController.TREE_DATA_PATH, Encoding.Unicode);
            xml.Load(sr);

            // lấy toàn bộ node của file xml
            XmlNodeList providers = xml.GetElementsByTagName("provider");

            // duyệt các node để lấy dữ liệu
            for (int i = 0; i < providers.Count; i++)
            {
                XmlNodeList children = providers[i].ChildNodes;

                if (providers[i].Attributes["name"].Value.Trim().ToLower() == providerName.Trim().ToLower()) {

                    // duyệt lấy thông tin từ node con
                    for (int j = 0; j < children.Count; j++)
                    {
                        if (children[j].Attributes["name"].Value.Trim().ToLower() == catagoryName.Trim().ToLower())
                        {
                            _catagory = new Catagory();
                            _catagory.Name = catagoryName;
                            _catagory.Uri = new Uri(children[j].InnerText);
                            ContentProviderController cpc = new ContentProviderController();
                            cpc.LoadProviders();
                            _catagory.Provider = cpc.GetProviderByName(providerName); 
                        }
                    } // end for loop
                }

            }

            sr.Close(); // đóng luồng 

            return _catagory;
        }
예제 #2
0
 public CatagoryController()
 {
     _catagory = new Model.Catagory();
     _articles = new List<Article>();
 }