Click here to Skip to main content
15,894,106 members
Articles / Programming Languages / C#

LINQ To Google Image and Google Groups

Rate me:
Please Sign up or sign in to vote.
5.00/5 (17 votes)
8 May 200710 min read 91.6K   400   48  
A LINQ Implementation for Google Images/Groups Search
using System;
using System.Collections.Generic;
using System.Text;

using System.Linq;
using System.Linq.Expressions;

using MChen.Linq.GoogleSearch.Common;

namespace MChen.Linq.GoogleSearch.Images
{
    /// <summary>
    /// Represent the format of the image
    /// </summary>
    public enum ImageFormat {
        Any, JPG, PNG, GIF
    }

    /// <summary>
    /// The size of Image
    /// </summary>
    public enum ImageSize {
        Any, Large, Medium, Small
    }

    /// <summary>
    /// Color format of the image
    /// </summary>
    public enum ImageColor
    {
        Any, BlackWhite, Greyscale, Color
    }

    public class Image : Result
    {
        public ImageFormat Format { get; internal set; }
        public ImageSize Size { get; internal set; }
        public ImageColor Color { get; internal set; }

        public int Width { get; internal set; }
        public int Height { get; internal set; }

        public int FileSize { get; internal set; }

        public string ThumbnailURL { get; internal set; }
        public int ThumbnailWidth { get; internal set; }
        public int ThumbnailHeight { get; internal set; }

        public bool RelatesTo(string key)
        {
            throw new ApplicationException("This method is not intended to be called in your code.");
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("{9} --> {0}\n\tUrl:            {1}\n\tSize:           " +
                            "{2} X {3}\n\tThumbnail:      {4}\n\tThumbnail Size: {5} X {6}\n\t" + 
                            "Format:         {7}\n\tDomain:         {8}", 
                Description,
                Url,
                Width,
                Height,
                ThumbnailURL,
                ThumbnailWidth,
                ThumbnailHeight,
                Format,
                Domain,
                Rank);
            return sb.ToString();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States

Comments and Discussions