Visual Studio 2010中是否有键盘快捷键(我也使用ReSharper 6.1),这将允许我用大括号包围选定的文本块?我尝试了"Surround With ..." (Ctrl + K,Ctrl + S),但我没有看到列表中的选项来选择花括号作为周围元素.这个的常见用例是我将有一个if语句,如下所示:
if (conditional)
statement1;
// the rest of the program
Run Code Online (Sandbox Code Playgroud)
我会发现在if语句中需要执行一些额外的任务并添加它们:
if (conditional)
statement1;
statement2;
statement3;
// the rest of the program
Run Code Online (Sandbox Code Playgroud)
然后,我记得我需要用花括号包装所有语句,代码应该看起来像这样:
if (conditional)
{
statement1;
statement2;
statement3;
}
// the rest of the program
Run Code Online (Sandbox Code Playgroud)
我想要做的只是选择三个语句,然后点击快捷键将它们包装在花括号中.我实际上最终做的是将光标移动到条件之后的行的开头,然后键入{字符,然后删除}字符,ReSharper(无用)在{之后立即自动插入,然后将光标向下移动到结尾块的最后一个语句和输入}来完成块.
我正在构建一个分层收集类,它在空间上对磁共振图像进行排序,并根据用于生成它们的各种采集参数将它们排列成分组.用于执行分组的特定方法由类的用户提供.我已经抽象出下面示例代码中的相关功能.对于IEquatable<MyClass>
实现,我希望能够比较_myHelperDelegate
两个MyClass
实例的属性,以确定两个委托是否指向同一段代码.(_myHelperDelegate == other._myHelperDelegate)
下面的if语句中的子句显然是错误的方法(它无法编译,给出错误"预期方法名称").我的问题是,有没有办法比较两个代表,以确定他们是否引用相同的代码?如果是这样,你怎么做?
public class MyClass : IEquatable<MyClass>
{
public delegate object HelperDelegate(args);
protected internal HelperDelegate _myHelperDelegate;
public MyClass(HelperDelegate helper)
{
...
_myHelperDelegate = helper;
}
public bool Equals(MyClass other)
{
if (
(_myHelperDelegate == other._myHelperDelegate) &&
(... various other comparison criteria for equality of two class instances... )
)
return true;
return false;
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个类(DPCal_EventMove)的方法,我想限制使用角色的访问.我有一个Global.asax.cs错误处理程序和一个自定义IHttpModule错误处理程序,用于捕获未处理的异常和Server.Transfer他们GlobalExceptionHandler.aspx,它检查错误是否是源自失败的PrincipalPermission检查的SecurityExceptions.由于某种原因,由PricipalPermission修饰的方法引起的未处理异常不会通过我的任何一个错误处理程序进行路由.我的问题是:这个异常被路由到哪里以及如何捕获和处理它?
public partial class DayView : Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Do some stuff
}
[PrincipalPermission(SecurityAction.Demand, Role = "Investigator")]
[PrincipalPermission(SecurityAction.Demand, Role = "Administrator")]
protected void DPCal_EventMove(object sender, DayPilot.Web.Ui.Events.EventMoveEventArgs e)
{
// If no overlap, then save
int eventId = Convert.ToInt32(e.Value);
MembershipUser user = Membership.GetUser();
if (!CommonFunctions.IsSchedulingConflict(eventId, e.NewStart, e.NewEnd) &&
Page.User.HasEditPermission(user, eventId))
{
dbUpdateEvent(eventId, e.NewStart, e.NewEnd);
GetEvents();
DPCal.Update();
}
}
}
Run Code Online (Sandbox Code Playgroud)
下面是我的Global.asax.cs文件:
public class Global : System.Web.HttpApplication
{
protected void Application_Error(object sender, EventArgs e)
{
Server.Transfer("~/GlobalExceptionHandler.aspx?ReturnUrl=" …
Run Code Online (Sandbox Code Playgroud) 我在matlab中读取一个dicom文件并修改它的一些数据并尝试将其保存到另一个文件中,但是这样做时,私有dicom数据要么根本不写(当'WritePrivate'设置为0时)或者它是写成UINT8数组,变得难以理解和无用.我甚至试图将我从原始dicom文件中获取的数据复制到新结构并写入新的dicom文件,但即使私有数据在新结构中保持正常,它也不会在新的dicom文件中保留.有没有办法在不更改matlab dicom字典的情况下复制到新的dicom文件时保持私有数据完好无损?
我提供了以下代码来展示我正在尝试做的事情.
X=dicomread('Bad011_4CH_01.dcm');
metadata = dicominfo('Bad011_4CH_01.dcm');
metadata.PatientName.FamilyName='LastName';
metadata.PatientName.GivenName='FirstName';
birthday=metadata.PatientBirthDate;
year=birthday(1,1:4);
newyear=strcat(year,'0101');
metadata.PatientBirthDate=newyear;
names=fieldnames(metadata);
h=metadata;
dicomwrite(X,'example.dcm',h,'CreateMode','copy');
newh=dicominfo('example.dcm');
Run Code Online (Sandbox Code Playgroud)
这里newh中的数据不包含任何私有数据.如果我将代码更改为以下
dicomwrite(X,'example.dcm',h,'CreateMode','copy','WritePrivate',1);
Run Code Online (Sandbox Code Playgroud)
在这种情况下,私有数据完全变为某些UIN8数组并且无用.我的任务的理想解决方案是在不更改matlab dicom字典的情况下,将私有数据保存在新创建的dicom文件中.