/// <summary>
        /// Returns a Service.GoogleSearchResult data set that is valid
        /// according to web service guidelines
        /// </summary>
        /// <param name="pageSize">page size of the Service.GoogleSearchResult set</param>
        /// <returns>Service.GoogleSearchResult instance with Service.resultElement
        /// entries present according to page size</returns>
        public static Service.GoogleSearchResult GetGoogleSearchResults(int pageSize)
        {
            Service.GoogleSearchResult result = new Service.GoogleSearchResult();

            result.estimatedTotalResultsCount = TotalResultsCount;
            result.estimateIsExact            = true;
            result.documentFiltering          = false;
            result.startIndex             = 1;
            result.endIndex               = pageSize;
            result.searchTime             = 0.09;
            result.searchQuery            = "Result Control";
            result.searchComments         = "";
            result.searchTips             = "";
            result.directoryCategories    = new Service.DirectoryCategory[1];
            result.directoryCategories[0] = ResultDummyDataSource.GetDirectoryCategory();

            // fill up 10 result elements
            result.resultElements = new Service.ResultElement[pageSize];
            for (int i = 0; i < pageSize; i++)
            {
                result.resultElements[i] = GetResultElement(i);
            }

            return(result);
        }
 /// <summary>
 /// Returns a valid Service.ResultElement instance
 /// </summary>
 /// <param name="index">Index to help create title and url</param>
 /// <returns>Fully populated Service.ResultElement instance</returns>
 public static Service.ResultElement GetResultElement(int index)
 {
     Service.ResultElement elem = new Service.ResultElement();
     elem.title      = "Result Control " + index;
     elem.URL        = "http://apress.com/resultcontrol" + index;
     elem.summary    = "Summary";
     elem.snippet    = "Snippet";
     elem.hostName   = "apress";
     elem.cachedSize = "2k";
     elem.relatedInformationPresent = false;
     elem.directoryTitle            = "Test";
     elem.directoryCategory         = ResultDummyDataSource.GetDirectoryCategory();
     return(elem);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Provides HTML for the visual designer to display
        /// </summary>
        /// <returns>HTML string based on rendering the control with a dummy data source</returns>
        public override string GetDesignTimeHtml()
        {
            Result control        = (Result)Component;
            string designTimeHTML = null;

            // bind Result control to dummy data source
            // that has the appropriate page size
            control.DataSource =
                ResultDummyDataSource.GetGoogleSearchResults(control.PageSize);
            control.DataBind();

            // let base class designer call Render() on
            // data-bound control to get HTML
            designTimeHTML = base.GetDesignTimeHtml();

            return(designTimeHTML);
        }