小编Chr*_*ris的帖子

虚拟,覆盖,新密封和密封覆盖之间的区别

我是OOP的一些概念之间很困惑:virtual,override,newsealed override.谁能解释这些差异?

我很清楚,如果要使用派生类方法,可以使用override关键字,以便派生类覆盖基类方法.但我不确定new,而且sealed override.

c# oop virtual overriding new-operator

76
推荐指数
4
解决办法
9万
查看次数

使用ReSharper更新名称空间的最快方法?

我一直在做一些重构和重组,我已经移动了一堆文件.

我想更新每个文件,以便根据其新位置具有"正确"的命名空间.使用ReSharper,我可以进入每个文件,它向我显示命名空间是不正确的,但这样我必须一次完成每个文件.

无论如何更新文件夹或项目中的每个文件的命名空间?

c# resharper

75
推荐指数
2
解决办法
2万
查看次数

如何从字符串转换为XElement对象

我有一个像这样的字符串: "<Root><Child>Hey</Child></Root>"

如何将其转换为XElement对象?

c# xml xelement

33
推荐指数
1
解决办法
3万
查看次数

在NUnit 3中使用[TestCase]属性测试异常?

如何使用NUnit3测试TestCase中的异常?

假设我的方法Divide(a,b)定义如下:

public double Divide(double a, double b)
{
    if(Math.Abs(b) < double.Epsilon) throw new ArgumentException("Divider cannot be 0");
    return a/b;
}
Run Code Online (Sandbox Code Playgroud)

我想使用NUnit 3.0测试用例来测试这个方法,所以也许我有:

[TestCase(-10, 2, -5)]
[TestCase(-1, 2, -0.5)]
public void TestDivide(double a, double b, double result)
{
    Assert.That(_uut.Divide(a, b), Is.EqualTo(result));
}
Run Code Online (Sandbox Code Playgroud)

有没有办法指定一个测试用例,它会导致Divide()抛出ArgumentException,并以某种方式将其作为预期结果,例如:

[TestCase(-10, 2, -5)]
[TestCase(-1, 2, -0.5)]
[TestCase(-1, 0, ExpectedResult = TypeOf(ArgumentException)]
public void TestDivide(double a, double b, double result)
{
    Assert.That(_uut.Divide(a, b), Is.EqualTo(result));
}
Run Code Online (Sandbox Code Playgroud)

(当然我可以定义一个单独的测试方法并Assert.Throws()在此使用,所以这纯粹是出于好奇)

.net c# nunit exception testcase

29
推荐指数
2
解决办法
1万
查看次数

WPF中Horizo​​ntalAlignment和Horizo​​ntalContentAlignment有什么区别?

有什么区别:

  • HorizontalAlignment="Stretch"
  • HorizontalContentAlignment="Stretch"

在WPF的文本框中?

示例示例:

<TextBox HorizontalAlignment="Stretch"
            HorizontalContentAlignment="Stretch"
            Height="100"
            TextWrapping="Wrap"
            AcceptsReturn="True"
         ></TextBox>
Run Code Online (Sandbox Code Playgroud)

wpf wpf-controls

23
推荐指数
2
解决办法
1万
查看次数

bootstrap下拉菜单根据屏幕位置自动下拉?

我想知道你们中是否有人有我要求准备的东西,以免我摆脱困境.我正在寻找的是一个下拉菜单,根据它在屏幕上的位置自动添加dropup类 - 当用户滚动或调整窗口大小时也会自动更改.

我正在寻找的内容已经在bootstrap-select插件中实现,但插件太"重"而无法使用.

css jquery twitter-bootstrap twitter-bootstrap-3

16
推荐指数
3
解决办法
2万
查看次数

WPF:检测Ctrl + MWheelUp/Down

我可以绑定到Ctrl+CCtrl+LeftClick,但是如何绑定到鼠标/滚轮操作?

我试图做一些像增加/减少字体大小的事情,就像在浏览器中一样.

我想设置Ctrl+MWheelUp增加字体大小

wpf

14
推荐指数
1
解决办法
4837
查看次数

WPF DataBinding错误:找不到引用'RelativeSource FindAncestor'的绑定源

我从下面的代码中得到以下错误...不确定为什么(是的,它产生所有4,即使它是相同的2重复).哦,它并没有产生交替的行效果,即使在这些错误出现之前,相同的代码正在运行.

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DataGrid', AncestorLevel='1''. BindingExpression:Path=AreRowDetailsFrozen; DataItem=null; target element is 'DataGridDetailsPresenter' (Name=''); target property is 'SelectiveScrollingOrientation' (type 'SelectiveScrollingOrientation')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DataGrid', AncestorLevel='1''. BindingExpression:Path=HeadersVisibility; DataItem=null; target element is 'DataGridRowHeader' (Name=''); target property is 'Visibility' (type 'Visibility')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DataGrid', AncestorLevel='1''. BindingExpression:Path=AreRowDetailsFrozen; DataItem=null; target element is 'DataGridDetailsPresenter' (Name=''); target …
Run Code Online (Sandbox Code Playgroud)

data-binding wpf wpfdatagrid

10
推荐指数
1
解决办法
7474
查看次数

C#WPF - GridLength GridUnitType.Auto

任何人都可以解释使用之间的区别:

 GridLength length = new GridLength(0, GridUnitType.Auto) 
Run Code Online (Sandbox Code Playgroud)

 GridLength length = new GridLength(1, GridUnitType.Auto)
Run Code Online (Sandbox Code Playgroud)

我对此的有限了解使我相信这些都是相同的解决方案,因为它表示自动存在......"自动",因此使双值冗余.

我见过的大多数例子都显示GridUnitType.Auto前面有1而不是0,但在我看来,任何一个选项都是一样的吗?

是这种情况还是任何人都可以了解这些是否/如何不同

c# wpf gridlength

9
推荐指数
1
解决办法
1万
查看次数

通过UIDocumentInteractionController与Mail交互

我正在通过它与其他应用共享PDF UIDocumentInteractionController.在添加此功能之前,我有一个自定义的"发送到电子邮件"按钮使用MFMailComposeViewController- 但现在我还有一个邮件按钮UIDocumentInteractionController,我想使用它,以避免重复按钮.

我的问题是,通过旧邮件控制器,我曾经设置主题和内容文本,而如果我使用UIDocumentInteractionController- 我只收到一封带有PDF附件的空白电子邮件.有没有人知道我可以解决这个问题,并在使用时获取我的自定义主题和内容UIDocumentInteractionController

我在文档中找不到任何明显的东西,显然我不能干涉Mail应用程序以使其与我的应用程序通信 - 但是想知道是否有其他人遇到过这个问题,并且怀疑是"后门"解决方案.

以下是我目前正在创建和初始化我的代码UIDocumentInteractionController:

-(void)openDocumentIn:(NSString*)filepath
{

    //NSString * filePath = [[NSBundle mainBundle] 
                                  pathForResource:filePath ofType:@"pdf"];
    documentController = [UIDocumentInteractionController 
                         interactionControllerWithURL:[NSURL fileURLWithPath:filepath]];
    documentController.delegate = self;
    documentController.UTI = @"com.adobe.pdf";
    [documentController presentOptionsMenuFromBarButtonItem:
         [self.imageViewController exportQuote] animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

cocoa-touch ios uidocumentinteraction ios7

8
推荐指数
1
解决办法
1294
查看次数