我必须使用具有相同参数的构造函数替换~250个对象初始值设定项实例。
这是我的对象初始化程序的一个示例:
throw new FaultException<DTFaultDetail>(new DTFaultDetail
{
IsUserWarning = true,
HttpStatusCode = (int)HttpStatusCode.Forbidden,
Category = (int)FaultCategory.User,
ErrorCode = (int)FaultCode.Jobs_TimesheetOverlapsExisting,
UserMessage = UserStrings.TimesheetOverlapsExisting,
DebugMessage = $"",
TicksUsedBeforeFailure = DbContext.RequestInfo.TotalTicksUsed,
Origin = new DTFaultDetail.FaultOrigin
{
Session = Session,
ThreadID = Thread.CurrentThread.ManagedThreadId,
Source = $"{FullNameOfThisClass}.{MethodBase.GetCurrentMethod()})"
}
});
我必须用这个替换它:
throw new FaultException<DTFaultDetail>(new DTFaultDetail(
isUserWarning: true,
httpStatusCode: (int)HttpStatusCode.Forbidden,
category: (int)FaultCategory.User,
errorCode: (int)FaultCode.Jobs_TimesheetOverlapsExisting,
userMessage: UserStrings.TimesheetOverlapsExisting,
debugMessage: $"",
ticksUsedBeforeFailure: DbContext.RequestInfo.TotalTicksUsed,
origin: new DTFaultDetail.FaultOrigin
{
Session = Session,
ThreadID = Thread.CurrentThread.ManagedThreadId,
Source = $"{FullNameOfThisClass}.{MethodBase.GetCurrentMethod()})"
}));
如何使用Visual Studio(2015)的内置功能快速完成?
当然,除了手动更换外。