public StandardXmlMediaHandler(XElement handlerElement)
        {
            try
            {
                Name              = handlerElement.Element("Name").Value;
                ContentDirectory  = handlerElement.Element("ContentDirectory").Value;
                SearchDirectories = new List <string>();

                //TODO: this one is volatile, make it safer
                var searchDirectoriesElement = handlerElement.Element("SearchDirectories");

                if (searchDirectoriesElement != null)
                {
                    SearchDirectories =
                        searchDirectoriesElement
                        .Elements("SearchDirectory")
                        .Select(element => element.Value).ToList();
                }
                else
                {
                    SearchDirectories = new List <string>();
                    Logging.Log.WarnFormat("No directores found for {0}", Name);
                }

                //TODO: volatile code, can easily crash. fix it
                FileActions    = new WindowsFileActions();
                ContentMatcher = HandlerXmlParser.ParseContentMatches(handlerElement.Element("MatchPatterns")).FirstOrDefault();
            }
            catch (Exception ex)
            {
                Logging.Log.Error("Failure loading showhandler", ex);
                throw;
            }
        }
        public StandardXmlMediaHandler(string name, List <string> searchDirectories, IContentMatcher contentMatcher)
        {
            ContentMatcher    = contentMatcher;
            SearchDirectories = searchDirectories;
            Name        = name;
            FileActions = new WindowsFileActions();

            Initialize();
        }
        public ShowHandler(XElement handlerElement)
        {
            try
            {
                if (handlerElement?.Element("Name") == null)
                {
                    throw new NullReferenceException(nameof(handlerElement));
                }

                Name              = handlerElement.Element("Name").Value;
                ContentDirectory  = handlerElement.Element("ContentDirectory").Value;
                SearchDirectories = new List <string>();

                //TODO: this one is volatile, make it safer
                var searchDirectoriesElement = handlerElement.Element("SearchDirectories");

                if (searchDirectoriesElement != null)
                {
                    SearchDirectories =
                        searchDirectoriesElement
                        .Elements("SearchDirectory")
                        .Select(element => element.Value).ToList();
                }
                else
                {
                    SearchDirectories = new List <string>();
                    Logging.Log.WarnFormat("No directores found for {0}", Name);
                }

                //TODO: volatile code, can easily crash. fix it
                _showMatches = new List <ShowMatcher>();
                //HandlerXmlParser.ParseContentMatches(handlerElement.Element("MatchPatterns")).Cast<ShowMatcher>().ToList();

                _showMatches = HandlerXmlParser.ParseContentMatches(handlerElement.Element("MatchPatterns")).Cast <ShowMatcher>().ToList();

                Shows = _showMatches.Select(matcher => matcher.Show).ToList();

                FileActions = new WindowsFileActions();
            }
            catch (Exception ex)
            {
                Logging.Log.Error("Failure loading showhandler", ex);
                throw;
            }
        }
 public ShowHandler(IEnumerable <string> shows)
 {
     Shows       = shows.ToList();
     FileActions = new WindowsFileActions();
 }