sそこには、MethodBase.GetCurrentMethodに相当するポータブルクラスライブラリがありますか?MethodBase.GetCurrentMethodに相当するポータブルクラスライブラリ
私はPCLを初めて使いました。私は間違いなく、Silverlightの上で使用され、他の場所で使用することができるいくつかのクライアントコードを保持するために、PCLを使用できるかどうかを検討していjustingです。ソースをスキャンすると、PCLには存在しないようなMethodBase.GetCurrentMethodをたくさん呼び出すことができます。
** 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) }
)
);
}
}
}
PCLを必要とするデバイスは、2013年夏までは表示されません。サポートされていない方法をあきらめる方法を理解するのに十分な時間ですか? GetCurrentMethod()は決して重要な省略であってはなりません。 –