mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-03-05 03:30:44 +01:00
- moved all files to a "source" subdirectory to tidy up the GitHub project page
- started to write a readme.md
This commit is contained in:
85
source/ChanSort.Loader.VDR/Serializer.cs
Normal file
85
source/ChanSort.Loader.VDR/Serializer.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using ChanSort.Api;
|
||||
|
||||
namespace ChanSort.Loader.VDR
|
||||
{
|
||||
class Serializer : SerializerBase
|
||||
{
|
||||
private const string ERR_FileFormat = "File uses an unknown format";
|
||||
|
||||
private readonly ChannelList allChannels = new ChannelList(SignalSource.DvbT | SignalSource.DvbC | SignalSource.DvbS | SignalSource.AnalogC | SignalSource.AnalogT | SignalSource.Tv | SignalSource.Radio, "All");
|
||||
|
||||
#region ctor()
|
||||
public Serializer(string inputFile) : base(inputFile)
|
||||
{
|
||||
DepencencyChecker.AssertVc2010RedistPackageX86Installed();
|
||||
|
||||
this.Features.ChannelNameEdit = false;
|
||||
this.DataRoot.SortedFavorites = false;
|
||||
//this.DataRoot.SupportedFavorites = new Favorites();
|
||||
|
||||
this.DataRoot.AddChannelList(this.allChannels);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override string DisplayName { get { return "VDR channels .conf Loader"; } }
|
||||
|
||||
#region Load()
|
||||
public override void Load()
|
||||
{
|
||||
this.ReadChannels();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ReadChannels()
|
||||
private void ReadChannels()
|
||||
{
|
||||
string line;
|
||||
int pos = 0;
|
||||
|
||||
using (StreamReader file = new StreamReader(this.FileName))
|
||||
{
|
||||
while ((line = file.ReadLine()) != null)
|
||||
{
|
||||
ChannelInfo channel = new Channels(pos, line, this.DataRoot);
|
||||
this.DataRoot.AddChannel(this.allChannels, channel);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Save()
|
||||
public override void Save(string tvOutputFile)
|
||||
{
|
||||
if (tvOutputFile != this.FileName)
|
||||
{
|
||||
File.Copy(this.FileName, tvOutputFile);
|
||||
this.FileName = tvOutputFile;
|
||||
}
|
||||
|
||||
using (StreamWriter file = new StreamWriter(tvOutputFile))
|
||||
{
|
||||
foreach (Channels channelInfo in this.allChannels.GetChannelsByNewOrder())
|
||||
{
|
||||
file.WriteLine(channelInfo.confLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetFileInformation()
|
||||
public override string GetFileInformation()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(base.GetFileInformation());
|
||||
return sb.ToString();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user