Мой библиотека MiscUtil содержит ProjectionComparer для создания IComparer< T> от делегата проекции. Это была бы работа 10 минут для создания ProjectionEqualityComparer, чтобы сделать то же самое.
РЕДАКТИРОВАНИЕ: вот код для ProjectionEqualityComparer:
using System;
using System.Collections.Generic;
///
/// Non-generic class to produce instances of the generic class,
/// optionally using type inference.
///
public static class ProjectionEqualityComparer
{
///
/// Creates an instance of ProjectionEqualityComparer using the specified projection.
///
/// Type parameter for the elements to be compared
/// Type parameter for the keys to be compared,
/// after being projected from the elements
/// Projection to use when determining the key of an element
/// A comparer which will compare elements by projecting
/// each element to its key, and comparing keys
public static ProjectionEqualityComparer Create(Func projection)
{
return new ProjectionEqualityComparer(projection);
}
///
/// Creates an instance of ProjectionEqualityComparer using the specified projection.
/// The ignored parameter is solely present to aid type inference.
///
/// Type parameter for the elements to be compared
/// Type parameter for the keys to be compared,
/// after being projected from the elements
/// Value is ignored - type may be used by type inference
/// Projection to use when determining the key of an element
/// A comparer which will compare elements by projecting
/// each element to its key, and comparing keys
public static ProjectionEqualityComparer Create
(TSource ignored,
Func projection)
{
return new ProjectionEqualityComparer(projection);
}
}
///
/// Class generic in the source only to produce instances of the
/// doubly generic class, optionally using type inference.
///
public static class ProjectionEqualityComparer
{
///
/// Creates an instance of ProjectionEqualityComparer using the specified projection.
///
/// Type parameter for the keys to be compared,
/// after being projected from the elements
/// Projection to use when determining the key of an element
/// A comparer which will compare elements by projecting each element to its key,
/// and comparing keys
public static ProjectionEqualityComparer Create(Func projection)
{
return new ProjectionEqualityComparer(projection);
}
}
///
/// Comparer which projects each element of the comparison to a key, and then compares
/// those keys using the specified (or default) comparer for the key type.
///
/// Type of elements which this comparer
/// will be asked to compare
/// Type of the key projected
/// from the element
public class ProjectionEqualityComparer : IEqualityComparer
{
readonly Func projection;
readonly IEqualityComparer comparer;
///
/// Creates a new instance using the specified projection, which must not be null.
/// The default comparer for the projected type is used.
///
/// Projection to use during comparisons
public ProjectionEqualityComparer(Func projection)
: this(projection, null)
{
}
///
/// Creates a new instance using the specified projection, which must not be null.
///
/// Projection to use during comparisons
/// The comparer to use on the keys. May be null, in
/// which case the default comparer will be used.
public ProjectionEqualityComparer(Func projection, IEqualityComparer comparer)
{
if (projection == null)
{
throw new ArgumentNullException("projection");
}
this.comparer = comparer ?? EqualityComparer.Default;
this.projection = projection;
}
///
/// Compares the two specified values for equality by applying the projection
/// to each value and then using the equality comparer on the resulting keys. Null
/// references are never passed to the projection.
///
public bool Equals(TSource x, TSource y)
{
if (x == null && y == null)
{
return true;
}
if (x == null || y == null)
{
return false;
}
return comparer.Equals(projection(x), projection(y));
}
///
/// Produces a hash code for the given value by projecting it and
/// then asking the equality comparer to find the hash code of
/// the resulting key.
///
public int GetHashCode(TSource obj)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
return comparer.GetHashCode(projection(obj));
}
}
И вот демонстрационное использование:
var f3 = f1.Except(f2, ProjectionEqualityComparer.Create(a => a.key));
Как насчет этого?
https://maps.google.com/?q=1200 Pennsylvania Ave SE, Вашингтон, округ Колумбия, 20003
https://maps.google.com/?q=term
Если у вас есть широта- long, затем используйте ниже URL
https://maps.google.com/?ll=latitude,longitude
Пример: maps.google.com/?ll=38.882147,-76.99017
ОБНОВЛЕНИЕ
По состоянию на 2017 год у Google теперь есть официальный способ создания кроссплатформенного Google URL-адреса карт:
https://developers.google.com/maps/documentation/urls/guide
Вы можете использовать такие ссылки, как
https://www.google.com/maps/search/?api=1&query=1200%20Pennsylvania%20Ave%20SE%2C%20Washington%2C%20District%20of%20Columbia%2C%2020003