using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Day_网络_电视精灵
{
//频道父类
public abstract class ChannelBase
{
public string Type { get; set; }//频道类型
public string ChannelName { get; set; }//频道名称
public string Path { get; set; }//频道路径
public List<TVprogram> ProgremList=new List<TVprogram>();
public abstract void Cb();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace Day_网络_电视精灵
{
//频道管理类
public class ChannelManager
{
public List<ChannelBase> list = new List<ChannelBase>();
public void ResolveChannel()
{
XmlDocument xd=new XmlDocument();
xd.Load("FullChannels.xml");
XmlNode root = xd.DocumentElement;
foreach (XmlNode item in root.ChildNodes)
{
ChannelBase channel = Factory.Fc(item["channelType"].InnerText);
channel.Type = item["channelType"].InnerText;
channel.ChannelName = item["tvChannel"].InnerText;
channel.Path = item["path"].InnerText;
list.Add(channel);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Day_网络_电视精灵
{
public class Factory
{
//创建一个工厂类
public static ChannelBase Fc(string type)
{
ChannelBase types = null;
switch (type)
{
case "TypeA":
types = new TypeA();
break;
case "TypeB":
types=new TypeB();
break;
}
return types;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Day_网络_电视精灵
{
public class TVprogram
{
//时间
public DateTime PlayTime { get; set; }
//时段
public string Meridien { get; set; }
//节目名称
public string ProgramName { get; set; }
//视频路径
public string Path { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace Day_网络_电视精灵
{
public class TypeA:ChannelBase
{
public override void Cb()
{
XmlDocument xd = new XmlDocument();
xd.Load("北京电视台.xml");
XmlNode root = xd.DocumentElement;
foreach (XmlNode item in root.ChildNodes)
{
if (item.Name.Equals("tvProgramTable"))
{
foreach (XmlNode item2 in item.ChildNodes)
{
TVprogram tp=new TVprogram();
tp.PlayTime = Convert.ToDateTime(item2["playTime"].InnerText);
tp.Meridien = item2["meridien"].InnerText;
tp.ProgramName = item2["programName"].InnerText;
tp.Path = item2["path"].InnerText;
ProgremList.Add(tp);
}
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace Day_网络_电视精灵
{
public class TypeB:ChannelBase
{
public override void Cb()
{
XmlDocument xd = new XmlDocument();
xd.Load("凤凰卫视.xml");
XmlNode root = xd.DocumentElement;
foreach (XmlNode item in root.ChildNodes)
{
if (item.Name.Equals("ProgramList"))
{
foreach (XmlNode item2 in item.ChildNodes)
{
TVprogram tp = new TVprogram();
tp.PlayTime = Convert.ToDateTime(item2["playTime"].InnerText);
tp.ProgramName = item2["name"].InnerText;
tp.Path = item2["path"].InnerText;
ProgremList.Add(tp);
}
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Day_网络_电视精灵
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMain());
}
}
}
电视网络精灵
最新推荐文章于 2018-04-21 20:51:00 发布