/// <summary>
        /// Gets the next link based on the traversal type
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public string dequeueWebpageUrl(TraversalStyle type, WebCache cache)
        {
            string link = String.Empty;

            if (type == TraversalStyle.DEFAULT_TRAVERSAL_SEARCH)
            {
                webpageUrlQueue.tryRelease(out link);
            }
            else if (type == TraversalStyle.STRICT_RELEVANCE_SEARCH)
            {
                webpageUrlQueue.tryRelease(out link);
            }
            else if (type == TraversalStyle.PRECENTAGE_SHIFT_SEARCH)
            {
                link = precentageShiftDequeue(link);
            }
            else if (type == TraversalStyle.RANDOM_HALF_SEARCH)
            {
                link = randomHalfDequeue(link);
            }
            else if (type == TraversalStyle.NEXT_DIFFERING_SEARCH)
            {
                link = nextDifferingDequeue(cache, link);
            }
            if (link == String.Empty)
            {
                webpageUrlQueue.tryRelease(out link);
            }
            return(link);
        }
        public SearchContext(ConfiguredSettings configs, ConcurrentQueue <string> mainQueue, ConcurrentQueue <string> secondaryQueue, string id) : base(mainQueue, secondaryQueue)
        {
            contextualId       = id;
            configuredSettings = configs;

            bool isUsingQueue = configs.get(ConfiguredConstants.USE_QUEUE_LBL).ToBoolean();

            if (sharedSearchContext == null)
            {
                sharedSearchContext = new SharedSearchContextState(isUsingQueue);
                sharedSearchContext.getContextInfo().addThreadId(contextualId);
            }
            else
            {
                sharedSearchContext.getContextInfo().addThreadId(contextualId);
            }
            maxPageSearchLimit = StringExtensionMethods.ToInteger(configs.get(ConfiguredConstants.SEARCH_LIMIT_LBL));
            traversalStyle     = TraversalStyle.getTraversalType(configs.get(ConfiguredConstants.TRAVERSAL_STYLE_LBL));
            currentUrl         = StringExtensionMethods.URLifyParseAddition(configs.get(ConfiguredConstants.ENTRY_POINT_LBL), configs.get(ConfiguredConstants.SEARCH_PHRASE_LBL));
        }
 private string dequeueWebpageUrl(TraversalStyle style, WebCache cache)
 {
     return(sharedSearchContext.dequeueWebpageUrl(style, cache));
 }
        /// <summary>
        /// populates the map of configured parameters
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        private ConfiguredSettings constructConfiguredSettings(string query)
        {
            Dictionary <string, ConfiguredParameter> settings = new Dictionary <string, ConfiguredParameter>();
            // get the entry point, this is must have a value
            string parameterValue = getWellFormedAndContainedParamter(query, ConfiguredConstants.ENTRY_POINT_LBL);

            if (parameterValue != null)
            {
                string attemptedConversion = tryConvertEntryPoint(parameterValue);
                settings.Add(ConfiguredConstants.ENTRY_POINT_LBL, new ConfiguredParameter(ConfiguredConstants.ENTRY_POINT_DESC, attemptedConversion));
            }
            else
            {
                settings.Add(ConfiguredConstants.ENTRY_POINT_LBL, new ConfiguredParameter(ConfiguredConstants.ENTRY_POINT_DESC, defaultEntrySearchEngines[getRandomEntryPointKey()]));
            }
            // a term to search for is required, or else its just looking up this programs name "into the aether"
            parameterValue = getWellFormedAndContainedParamter(query, ConfiguredConstants.SEARCH_PHRASE_LBL);
            if (parameterValue != null)
            {
                settings.Add(ConfiguredConstants.SEARCH_PHRASE_LBL, new ConfiguredParameter(ConfiguredConstants.SEARCH_PHRASE_DESC, parameterValue));
            }
            else
            {
                settings.Add(ConfiguredConstants.SEARCH_PHRASE_LBL, new ConfiguredParameter(ConfiguredConstants.SEARCH_PHRASE_DESC, ApplicationConstants.APPLICATION_NAME));
            }
            // gets the collection for traversals to use
            parameterValue = getWellFormedAndContainedParamter(query, ConfiguredConstants.USE_QUEUE_LBL);
            if (parameterValue != null)
            {
                settings.Add(ConfiguredConstants.USE_QUEUE_LBL, new ConfiguredParameter(ConfiguredConstants.USE_QUEUE_DESC, parameterValue.ToBoolean().ToString()));
            }
            else
            {
                settings.Add(ConfiguredConstants.USE_QUEUE_LBL, new ConfiguredParameter(ConfiguredConstants.USE_QUEUE_DESC, bool.TrueString));
            }

            // changes the traversal style to either
            parameterValue = getWellFormedAndContainedParamter(query, ConfiguredConstants.TRAVERSAL_STYLE_LBL);
            if (parameterValue != null)
            {
                string temp = TraversalStyle.getTraversalType(parameterValue).getName();
                settings.Add(ConfiguredConstants.TRAVERSAL_STYLE_LBL, new ConfiguredParameter(ConfiguredConstants.TRAVERSAL_STYLE_DESC, temp));
            }
            else
            {
                settings.Add(ConfiguredConstants.TRAVERSAL_STYLE_LBL, new ConfiguredParameter(ConfiguredConstants.TRAVERSAL_STYLE_DESC, TraversalStyle.DEFAULT_TRAVERSAL_SEARCH.getName()));
            }

            // get the amount of searches
            parameterValue = getWellFormedAndContainedParamter(query, ConfiguredConstants.SEARCH_LIMIT_LBL);
            if (parameterValue != null && parameterValue.Length < 6 && parameterValue.IsNumeric())
            {
                settings.Add(ConfiguredConstants.SEARCH_LIMIT_LBL, new ConfiguredParameter(ConfiguredConstants.SEARCH_LIMIT_DESC, parameterValue));
            }
            else
            {
                settings.Add(ConfiguredConstants.SEARCH_LIMIT_LBL, new ConfiguredParameter(ConfiguredConstants.SEARCH_LIMIT_DESC, ApplicationConstants.GREATER_STORAGE_LIMIT + ""));
            }
            // determines the amount of threads the user wants to use, seriously, no more than 10 threads, even this is meh
            parameterValue = getWellFormedAndContainedParamter(query, ConfiguredConstants.THREADLING_COUNT_LBL);
            if (parameterValue != null && parameterValue.IsNumeric() && Int32.Parse(parameterValue) > 0 && Int32.Parse(parameterValue) < 10)
            {
                settings.Add(ConfiguredConstants.THREADLING_COUNT_LBL, new ConfiguredParameter(ConfiguredConstants.THREADLING_COUNT_DESC, Int32.Parse(parameterValue) + ""));
            }
            else
            {
                settings.Add(ConfiguredConstants.THREADLING_COUNT_LBL, new ConfiguredParameter(ConfiguredConstants.THREADLING_COUNT_DESC, "1"));
            }

            // determines if the user wants the raw gathered information
            parameterValue = getWellFormedAndContainedParamter(query, ConfiguredConstants.USE_FILTER_LBL);
            if (parameterValue != null)
            {
                settings.Add(ConfiguredConstants.USE_FILTER_LBL, new ConfiguredParameter(ConfiguredConstants.USE_FILTER_DESC, parameterValue.ToBoolean().ToString()));
            }
            else
            {
                settings.Add(ConfiguredConstants.USE_FILTER_LBL, new ConfiguredParameter(ConfiguredConstants.USE_FILTER_DESC, Boolean.TrueString));
            }

            return(new ConfiguredSettings(settings));
        }