거기 PortableBase.GetCurrentMethod와 동등한 Portable Class Library?MethodBase.GetCurrentMethod와 동등한 포터블 클래스 라이브러리
저는 PCL을 처음 사용합니다. PCL을 사용하여 Silverlight에서 사용할 클라이언트 코드를 보유 할 수 있는지 여부를 조사하고 있습니다. 다른 곳에서도 사용할 수 있습니다. 소스를 스캔하면 PCL에 존재하지 않는 것 같이 보이는 MethodBase.GetCurrentMethod에 대한 많은 호출을 볼 수 있습니다.
** 수정 ** 내가 문제의 라이브러리에서이 샘플을 찢어했습니다
. 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) }
)
);
}
}
}
PCL이 필요한 장치는 2013 년 여름까지 표시되지 않습니다. 지원되지 않는 방법을 포기하는 방법을 파악하기에 충분한 시간입니까? GetCurrentMethod()가 중요한 생략 일 수는 없습니다. –