|
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.