コード例 #1
0
ファイル: ExternalShow.cs プロジェクト: Tarkeel/TVTracker
        internal ExternalShow(ExternalSource _source, Show _show)
        {
            externalSource = _source;
            show = _show;

            if (externalSource != null) { externalSource.ExternalShows.Add(this); }
            if (show != null) { show.ExternalShows.Add(this); }
        }
コード例 #2
0
 public ExternalShow GetExternalShow(ExternalSource source, string externalID)
 {
     foreach (ExternalShow _show in source.ExternalShows)
     {
         if (_show.ExternalID.Equals(externalID)) { return _show; }
     }
     return null;
 }
コード例 #3
0
 public void DeleteExternalSource(ExternalSource deleted, bool cascade = false)
 {
     if (cascade)
     {
         foreach (ExternalShow _extShow in deleted.ExternalShows) { factory.ExternalShowRepository.DeleteExternalShow(_extShow); }
     }
     if (deleted.ExternalShows.Count == 0)
     {
         cacheByID.Remove(deleted.ID);
         cacheByTitle.Remove(deleted.Title);
     }
 }
コード例 #4
0
 public ExternalShow CreateOrGetExternalShow(Show show, ExternalSource source, bool persist = true)
 {
     if (show == null || source == null)
     {
         //We can't really do this, so return null
         return null;
     }
     ExternalShow _ext;
     if (externalsByComposite.TryGetValue(BuildComposite(show, source.Title), out _ext)) { return _ext; }
     //Create a new as needed
     _ext = new ExternalShow(source, show);
     //ID
     _ext.ID = nextID++;
     //Store in cache
     externalsByComposite.Add(BuildComposite(_ext.Show, source.Title), _ext);
     externalsByID.Add(_ext.ID, _ext);
     //Add to document
     XElement element = new XElement("External",
         new XAttribute("Source", source.Title));
     (factory.ShowRepository as XMLShowRepository).FindElement(show.ID).Add(element);
     if (persist) { factory.Persist(); }
     return _ext;
 }
コード例 #5
0
        private ExternalSource Create(string title)
        {
            //Create new
            ExternalSource _ext = new ExternalSource();
            _ext.Title = title;
            _ext.ID = nextID++;
            //Find all the ExternalShows for it
            IEnumerable<XElement> externals = (from XElement in document.Descendants("External")
                                               where XElement.Attribute("Source").Value.Equals(title)
                                               select XElement);
            foreach (XElement _element in externals)
            {
                ExternalShow _extShow = (factory.ExternalShowRepository as XMLExternalShowRepository).ParseXML(_element, _ext);
                _extShow.ExternalSource = _ext;
                _ext.ExternalShows.Add(_extShow);
            }
            //Add to cache
            cacheByTitle.Add(_ext.Title, _ext);
            cacheByID.Add(_ext.ID, _ext);

            return _ext;
        }
コード例 #6
0
 public void UpdateSource(ExternalSource updated, bool persist = true)
 {
     //All the updating is done at the ExternalShow level.
 }
コード例 #7
0
 public ExternalShow GetExternalShow(Show show, ExternalSource source)
 {
     ExternalShow _ext;
     if (externalsByComposite.TryGetValue(BuildComposite(show, source.Title), out _ext)) { return _ext; }
     return null;
 }
コード例 #8
0
        internal ExternalShow ParseXML(XElement element, ExternalSource externalSource)
        {
            ExternalShow _ext;
            Show _show = (factory.ShowRepository as XMLShowRepository).Parse(element.Parent);
            //element.Parent.Attribute("Title");
            //Check cache
            if (_show != null) { externalsByComposite.TryGetValue(BuildComposite(_show, externalSource.Title), out _ext); }
            //Create a new as needed
            _ext = new ExternalShow(externalSource, _show);
            //ID
            _ext.ID = nextID++;
            //Show
            _ext.Show = _show;
            _show.ExternalShows.Add(_ext);
            //Source
            _ext.ExternalSource = externalSource;

            //External ID
            XAttribute _extID = element.Attribute("ID");
            if (_extID != null) { _ext.ExternalID = _extID.Value; }
            //Store in cache
            externalsByComposite.Add(BuildComposite(_ext.Show, _ext.ExternalSource.Title), _ext);
            externalsByID.Add(_ext.ID, _ext);
            return _ext;
        }