有没有人在Mighty Moose/ContinuousTests中遇到过Here Be Dragons警告?

这被置于一个私有方法旁边,可能是因为它是私有的,因此不容易测试 - 你可能需要魔法盔甲才能进行测试.无论如何,我也在一个属性的设置者身上找到了这个,所以我试图重现它.现在我根本不再看到代码旁边的任何测试运行指示器了.
我该怎么办?出现的条件是什么?提前致谢!
我只想稍微使用WPF SpellCheck,但是虽然设置了Attached Property,但我没有任何下划线.
SpellCheck.IsEnabled="True"
Run Code Online (Sandbox Code Playgroud)
如果我没记错的话,SpellCheck也应该向我的ContextMenu添加菜单项,不是吗?这也不会发生......
顺便说一句,我的机器正在运行.Net4.
我是否必须在全球范围内启用此功能?所有教程等等都只提到设置SpellCheck.IsEnabled让你去...
从来没有见过这个.这是样本:
using System;
namespace Testing
{
public class Test
{
public event Action ActionRequired;
}
public class ChildTest : Test
{
public void DoSomething()
{
if (this.ActionRequired != null)
this.ActionRequired();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,错误是我只能从基类访问事件.
四处逛逛并不困难(向基类添加一个受保护的方法,既检查事件的调用又从子类调用该方法),但我真的想知道这个限制背后的想法是什么?
干杯,
SEBI
大部分的工作作为一个.NET开发人员的时间给了我们自由地浪费时间在我们的高级别的抽象世界,但有时现实踢你的私处,并告诉你找到一个男人谁真正理解.
我刚刚有过这样的经历之一.我认为将角落数据列为项目列表就足以让您了解我们的内容:
Run Code Online (Sandbox Code Playgroud)System.ComponentModel.Win32Exception (0x80004005): Not enough quota is available to process this command at MS.Win32.UnsafeNativeMethods.PostMessage(HandleRef hwnd, WindowMessage msg, IntPtr wparam, IntPtr lparam) at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet) at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam) at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam) at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate …
在我的WPF UI中,我通过以下代码使用我在xaml中引用的RoutedCommands:
Command="viewModel:MessageListViewModel.DeleteMessagesCommand"
Run Code Online (Sandbox Code Playgroud)
我不喜欢这个到我的ViewModel类的静态链接,我认为这不如创建自定义ICommand实现那样好,并使用如下语法
Command="{Binding DeleteMessagesCommand}"
Run Code Online (Sandbox Code Playgroud)
创建一个后,我注意到我所做的一个主要缺点:RoutedCommands使用CommandManager并且(以某种方式对我来说完全不透明)触发CommandManager.RequerySuggested事件,以便自动重新获取它们的CanExecute方法.至于我的自定义实现,CanExecute只在启动时触发一次,之后再也不会再触发.
有没有人有这个优雅的解决方案?
在周末开始之前,请快点...
我有一个带有以下签名的方法,我需要调用:
public interface IObjectProvider<T>
{
T Get(Predicate<T> condition);
}
Run Code Online (Sandbox Code Playgroud)
这将为我提供T符合谓词标准的任何来源.
现在,必须从我所拥有的上下文中调用以下内容:
//the actual predicate that's going to be evaluated
var predicate = predicateProperty.GetValue(invocation.InvocationTarget, null);
//The type that should go into the call as type param
Type relationTargetType = relationDefinition.RelatedType;
Run Code Online (Sandbox Code Playgroud)
正如您可能猜到的,编译器不会让我使用predicate变量作为参数.我需要做的是将此对象转换为谓词,但是泛型类型参数必须是编译时常量,因此这不起作用.
我已经开始搞乱这个,但到目前为止没有成功:
Type genericPredicateType = typeof(Predicate<>);
Type specificPredicateType= genericPredicateType.MakeGenericType(relationTargetType);
Convert.ChangeType(predicate, specificPredicateType)
Run Code Online (Sandbox Code Playgroud)
我怎么能把它捣碎呢?
编辑:我认为这是一个与用例无关的问题,但显然我错了.所以,既然对我所做的事情,我拥有的以及为什么以及诸如此类的事情有如此大惊小怪,这里有更多的背景信息.我试图解决代理(城堡动态代理)中的对象之间的关系.以下代码片段应该解释我想要描述的那种关系:
public class Order
{
public virtual int Id { get; set; } // OR-Mapped
public virtual DateTime OrderDate { get; set; } …Run Code Online (Sandbox Code Playgroud) 我使用NHibernate查询我的数据库.现在我需要使用谓词来限制所选择的数据.到目前为止,我发现(Google驱动开发的最佳状态)使用Expressions和NHibernate.Linq可以实现这样的功能.
这是我试过的:
public IList<Bestellung> GetAll(Predicate<Order> predicate)
{
Expression<Func<Order, bool>> restriction = x => predicate(x);
ISession session = SessionService.GetSession();
IList<Order> bestellungen = session.Query<Order>()
.Where(restriction).ToList();
return bestellungen;
}
Run Code Online (Sandbox Code Playgroud)
这导致无法将类型为'NHibernate.Hql.Ast.HqlCast'的对象强制转换为'NHibernate.Hql.Ast.HqlBooleanExpression'.只需快速检查它的位置:将方法体的第一行更改为
Expression<Func<Order, bool>> restriction = x => x.Id!=1;
Run Code Online (Sandbox Code Playgroud)
令人惊叹的结果是一切正常.
如何在表达式中执行我的Predicate?
在以下情形中,我们在VS2010 WPF设计器中的各种机器上遇到崩溃:
要重现错误,请创建新的WPF解决方案,执行以下操作:
没有数据/命令绑定,没有引用FluentNHibernate功能的代码或任何高度复杂的代码,只是在MainWindow.xaml中使用以下XAML的新WPF解决方案:
<Window x:Class="testWpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Title="MainWindow" Height="350" >
<Grid>
<TextBox Text="yxcydfdssdfsdfdsfsdsddsasdyxcasd" />
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
这是完整的Stacktrace:
System.Reflection.TargetInvocationException
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean …Run Code Online (Sandbox Code Playgroud) 这次只是一个快速而短暂的.Func<T,TResult> 是逆变的(编辑:类型参数T是).现在,我不与之合作Func<T,TResult>,而是与之合作Expression<Func<T,TResult>>,似乎已经走到了尽头.更新 - 完整代码示例:
public interface IColoredObject
{
string Color { get; }
}
public class Item : IColoredObject
{
public string Color { get; set; }
public double Price { get; set; }
}
public partial class MainWindow : Window
{
private IList<Item> _items;
public IList<Item> Items
{
get
{
if (_items == null)
{
_items = new List<Item>();
_items.Add(new Item() { Color = "black" });
_items.Add(new Item() { Color …Run Code Online (Sandbox Code Playgroud) c# ×5
wpf ×5
.net ×3
binding ×1
caret ×1
covariance ×1
crash ×1
designer ×1
dynamic ×1
events ×1
generics ×1
icommand ×1
inheritance ×1
mightymoose ×1
nhibernate ×1
performance ×1
styles ×1
textbox ×1
variance ×1
winapi ×1