コード例 #1
0
 public ParseHTMLStrategy(AbstractProvider provider, ConfigurationWrapper someConfiguration)
 {
     theProvider      = provider;
     theConfiguration = someConfiguration;
     setSearchRegExp(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.REGEX_PARSE_SEARCH_RESULTS_KEY));
     setSearchResultsUrl(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.SEARCH_RESULTS_URL_KEY));
     setSearchUrl(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.SEARCH_URL_KEY));
     setSeriesUrl(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.SERIES_URL_KEY));
     setSearchRemove(theConfiguration.getMultiStringProperty(ParseHTMLStrategyProperties.SEARCH_REMOVE_KEY));
     setSearchStart(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.SEARCH_START_KEY));
     setSearchEnd(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.SEARCH_END_KEY));
     setNotFoundUrl(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.NOT_FOUND_URL_KEY));
     setEncoding(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.ENCODING_KEY));
     setLanguage(theConfiguration.getEnumProperty <Language>(ParseHTMLStrategyProperties.LANGUAGE_KEY));
     setSearchRightToLeft(theConfiguration.getSingleBoolProperty(ParseHTMLStrategyProperties.SEARCH_RIGHT_TO_LEFT_KEY));
     setSearchResultsBlacklist(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.REGEX_SEARCH_RESULTS_BLACKLIST_KEY));
     setRelationsRemove(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.RELATIONS_REMOVE_KEY));
 }
コード例 #2
0
 public ParseHTMLStrategy(AbstractProvider provider, ConfigurationWrapper someConfiguration)
 {
     theProvider = provider;
     theConfiguration = someConfiguration;
     setSearchRegExp(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.REGEX_PARSE_SEARCH_RESULTS_KEY));
     setSearchResultsUrl(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.SEARCH_RESULTS_URL_KEY));
     setSearchUrl(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.SEARCH_URL_KEY));
     setSeriesUrl(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.SERIES_URL_KEY));
     setSearchRemove(theConfiguration.getMultiStringProperty(ParseHTMLStrategyProperties.SEARCH_REMOVE_KEY));
     setSearchStart(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.SEARCH_START_KEY));
     setSearchEnd(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.SEARCH_END_KEY));
     setNotFoundUrl(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.NOT_FOUND_URL_KEY));
     setEncoding(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.ENCODING_KEY));
     setLanguage(theConfiguration.getEnumProperty<Language>(ParseHTMLStrategyProperties.LANGUAGE_KEY));
     setSearchRightToLeft(theConfiguration.getSingleBoolProperty(ParseHTMLStrategyProperties.SEARCH_RIGHT_TO_LEFT_KEY));
     setSearchResultsBlacklist(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.REGEX_SEARCH_RESULTS_BLACKLIST_KEY));
     setRelationsRemove(theConfiguration.getSingleStringProperty(ParseHTMLStrategyProperties.RELATIONS_REMOVE_KEY));
 }
コード例 #3
0
 public List <string> getMovieTagsToRemove()
 {
     return(wrappedConfiguration.getMultiStringProperty(AppProperties.MOVIES_TAGS_TO_REMOVE_LIST_KEY));
 }
コード例 #4
0
        /// <summary>
        /// Writes the <see cref="someConfiguration"/> to the given path.
        /// </summary>
        /// <param name="someConfiguration">the configuration to save to disk</param>
        /// <param name="filepath">Path where config file should be stored to.</param>
        public static void writeConfiguration(ConfigurationWrapper someConfiguration, string filepath)
        {
            if (someConfiguration == null) {
                return;
            }
            StreamWriter fileWriter = null;
            string tempfilepath = filepath + AppConstants.TEMPFILE_EXTENSION;
            try {
                FileStream writeStream = File.Open(tempfilepath, FileMode.Create, FileAccess.ReadWrite);
                fileWriter = new StreamWriter(writeStream);
                fileWriter.AutoFlush = true;
                writePropertyComment(fileWriter, AppPropertyComments.INITIAL_COMMENT_KEY);
                foreach (string propertyName in someConfiguration.getPropertyNames()) {
                    if (someConfiguration.isSingleValueProperty(propertyName)) {
                        string value = someConfiguration.getSingleStringProperty(propertyName);
                        writeProperty(fileWriter, propertyName, value);
                        continue;

                    }
                    if (someConfiguration.isMultiValueProperty(propertyName)) {
                        List<string> values = someConfiguration.getMultiStringProperty(propertyName);
                        writeMultiValueProperty(fileWriter, propertyName, values);
                        continue;
                    }
                    log.Warn("Configuration property " + propertyName + " not written - non-valid value");
                }
                if (File.Exists(filepath)) {
                    File.Delete(filepath);
                }
                fileWriter.Close();
                File.Move(tempfilepath, filepath);
            } catch (Exception ex) {
                log.Error("Couldn't write configuration to " + filepath + "\nError:\n" + ex.Message);
            } finally {
                if (fileWriter != null) {
                    fileWriter.Close();
                    File.Delete(tempfilepath);
                }
            }
        }