using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper8.DvbI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.yo3explorer
{
	internal class yo3explorerToSkyscraperContextBridge
	{
		public DateTime CurrentTime { get; internal set; }
		public ServiceListEntryPointSource Source { get; internal set; }
		public int? OriginalNetworkId { get; internal set; }
		public int? TransportStreamId { get; internal set; }
		public int PID { get; internal set; }
		public IScraperStroage DataStorage { get; internal set; }

		public long GetSourceHash()
		{
			long result = (int)Source;
			switch (Source)
			{
				case ServiceListEntryPointSource.TransportStream:
					result <<= 4;
					result += OriginalNetworkId.Value;
					result <<= 16;
					result += TransportStreamId.Value;
					result <<= 16;
					result += PID;
					return result;
				default:
					throw new NotImplementedException(Source.ToString());
			}
		}

		internal string ToHumanReadableSourceString()
		{
			switch (Source)
			{
				case ServiceListEntryPointSource.TransportStream:
					return String.Format("ONID: {0}, TSID: {1}, PID: {2}", OriginalNetworkId.Value, TransportStreamId.Value, PID);
				default:
					throw new NotImplementedException(Source.ToString());
			}
		}
	}
}
