Там есть Portable Class Library, эквивалентная MethodBase.GetCurrentMethod?
Я новичок в PCL. Я просто смотрю, могу ли я использовать PCL для хранения клиентского кода, который определенно будет использоваться в Silverlight и может быть использован где-то еще. Просканировав источник, я вижу множество вызовов MethodBase.GetCurrentMethod, которых, похоже, нет в PCL.
** EDIT **
Я скопировал этот образец из рассматриваемой библиотеки. IsNullOrEmpty () использовал String.IsNullOrWhiteSpace (String), который, похоже, недоступен, так что этот бит - выдумка.
using System;
using System.Linq;
using System.Reflection;
using System.Linq.Expressions;
namespace LinqToLdap.PCL
{
public static class QueryableExtensions
{
internal static bool IsNullOrEmpty(this String str)
{
return string.IsNullOrEmpty(str);
}
public static IQueryable<TSource> FilterWith<TSource>(this IQueryable<TSource> source, string filter)
{
if (source == null) throw new ArgumentNullException("source");
if (filter.IsNullOrEmpty()) throw new Exception("Filters cannot be null, empty, or white-space.");
if (!filter.StartsWith("("))
{
filter = "(" + filter + ")";
}
return source.Provider.CreateQuery<TSource>(
Expression.Call(
null,
((MethodInfo)MethodBase.GetCurrentMethod())
.MakeGenericMethod(new[] { typeof(TSource) }),
new[] { source.Expression, Expression.Constant(filter) }
)
);
}
}
}