using skyscraper5.Data.PostgreSql;
using skyscraper5.Skyscraper.Scraper.Storage.InMemory;
using skyscraper8.EPGCollectorPort.SkyscraperSide.MediaHighway2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.EPGCollectorPort.SkyscraperSide.OpenTV
{
	internal interface IOpenTvDataStorage
	{
		bool TestForTitles(int skyscraperContextCurrentNetworkId, int skyscraperContextCurrentTransportStreamId, int titleDataEventId, DateTime titleDataStartTime);
	}

	internal class OpenTvDataStorageImpl : IOpenTvDataStorage
	{
		private IOpenTvDataStorage _storageEngine;

		public OpenTvDataStorageImpl(object[] getPluginConnector)
		{
			object o = getPluginConnector[0];
			switch (o)
			{
				case InMemoryPluginToken t1:
					_storageEngine = new OpenTvDataStorageMemory();
					break;
				case PostgresqlToken t2:
					_storageEngine = new OpenTvDataStoragePostgresql(t2);
					break;
				default:
					throw new NotImplementedException(o.GetType().FullName);
			}
		}

		public bool TestForTitles(int skyscraperContextCurrentNetworkId, int skyscraperContextCurrentTransportStreamId,
			int titleDataEventId, DateTime titleDataStartTime)
		{
			return _storageEngine.TestForTitles(skyscraperContextCurrentNetworkId, skyscraperContextCurrentTransportStreamId, titleDataEventId, titleDataStartTime);
		}
	}

	internal class OpenTvDataStorageMemory : IOpenTvDataStorage
	{
		public bool TestForTitles(int skyscraperContextCurrentNetworkId, int skyscraperContextCurrentTransportStreamId,
			int titleDataEventId, DateTime titleDataStartTime)
		{
			throw new NotImplementedException();
		}
	}

	internal class OpenTvDataStoragePostgresql : IOpenTvDataStorage
	{
		private readonly PostgresqlToken _postgresql;

		public OpenTvDataStoragePostgresql(PostgresqlToken postgresql)
		{
			_postgresql = postgresql;
		}

		public bool TestForTitles(int skyscraperContextCurrentNetworkId, int skyscraperContextCurrentTransportStreamId,
			int titleDataEventId, DateTime titleDataStartTime)
		{
			throw new NotImplementedException();
		}
	}
}
