- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否有等效于 MethodBase.GetCurrentMethod 的可移植类库?
我是 PCL 的新手。我只是在研究是否可以使用 PCL 来保存一些肯定会在 Silverlight 上使用并且可能会在其他地方使用的客户端代码。扫描了源代码后,我可以看到大量对 MethodBase.GetCurrentMethod 的调用,这在 PCL 中似乎不存在。
** 编辑 **
我已经从有问题的图书馆中删除了这个样本。 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 中公开它,因为 Windows 8 .NET 不支持 Metro 应用程序。你这个方法的用途是什么?
关于.net - 等价于 MethodBase.GetCurrentMethod 的可移植类库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8657744/
我正在从 C++ 过渡到 C#,我有一个方法调用让我感到困惑。我想我也许能猜出它的作用,但如果专家能直接告诉我,我将不胜感激: WDResult returnValue = (WDResult)Inv
public static void Main(string[] args) { Action a = () => Console.WriteLine(MethodInfo.GetCurren
我编写了一个日志类和一个函数,如下代码所示: Log(System.Reflection.MethodBase methodBase, string message) 每次我记录一些东西时,我也会记录
是否有等效于 MethodBase.GetCurrentMethod 的可移植类库? 我是 PCL 的新手。我只是在研究是否可以使用 PCL 来保存一些肯定会在 Silverlight 上使用并且可能
出于日志记录的目的,我们应用程序中的一些方法包括以下行: Dim Log As ILog = GetLog(Reflection.MethodBase.GetCurrentMethod().Decla
有什么区别以及对代码的影响? 关于性能和限制,什么更适合? 新属性: - [调用文件路径属性] - [CallerMemberName] - [来电号码] 现在它们在 .NET 4 中也可用(它很容易
我正在为try/catch语句创建一个简单的日志记录方法(没什么花哨的)。我要包括类名称和引发异常的方法。 有两种获取信息的方法。一种使用MethodBase.GetCurrentMethod()和异
我是一名优秀的程序员,十分优秀!