Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 
Add your own
alternative version

LINQ To Google Image and Google Groups

, 8 May 2007
A LINQ Implementation for Google Images/Groups Search
googlelinq.zip
Google
Google
bin
Release
Google.exe
Google.pdb
Google.csproj.user
Properties
expression-tree.JPG
google_linq_10.zip
Common
Google.csproj.user
Group
Image
using System;
using System.Collections.Generic;
using System.Text;

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

namespace MChen.Linq.Google
{
    public enum ImageFormat {
        Any, JPG, PNG, GIF
    }

    public enum ImageSize {
        Any, Large, Medium, Small
    }

    public enum ImageColor
    {
        Any, BlackWhite, Greyscale, Color
    }

    public class Image
    {
        public int Rank { get; internal set; }
        public Uri Url { get; internal set; }
        public string Domain { get; internal set; }
        public string Description { get; internal set; }
        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();
        }
    }

    public class ImageSearch : IQueryable<Image>
    {
        private ImageSearch() {        }

        private static ImageSearch _instance = new ImageSearch();

        public static ImageSearch Instance {
            get { return _instance; }
        }

        #region IQueryable<Image> Members

        IQueryable<S> IQueryable<Image>.CreateQuery<S>(System.Linq.Expressions.Expression expression)
        {
            if (expression == null)
            {
                throw new ArgumentException("expression");
            }
            if (!typeof(IQueryable<S>).IsAssignableFrom(expression.Type))
            {
                throw new ArgumentException("expression");
            }
            //Diagnostic.DebugExpressionTree(expression);
            Console.WriteLine("================================");
            return new ImageQuery<S>(ImageQueryBuilder.BuildQuery(expression));
        }

        public TResult Execute<TResult>(System.Linq.Expressions.Expression expression)
        {
            throw new Exception("The method or operation is not implemented.");
        }
        #endregion

        #region IEnumerable<Image> Members
        public IEnumerator<Image> GetEnumerator()
        {
            throw new Exception("The method or operation is not implemented.");
        }
        #endregion

        #region IEnumerable Members
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            throw new Exception("The method or operation is not implemented.");
        }
        #endregion

        #region IQueryable Members
        public IQueryable CreateQuery(System.Linq.Expressions.Expression expression)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public Type ElementType
        {
            get { return typeof(Image); }
        }

        public object Execute(System.Linq.Expressions.Expression expression)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public System.Linq.Expressions.Expression Expression
        {
            get { return Expression.Constant(this); }
        }
        #endregion
    }
}

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

Share

About the Author

Ming.Chen
Web Developer
United States United States

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 8 May 2007
Article Copyright 2007 by Ming.Chen
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid