出于某种原因,我无法在IE 8.0中监控我的asp.net页面对本地主机的请求/响应.
我使用小提琴手,我修改了他的网址 - 通过在分号前添加一个点 -
http://localhost.:52749/JQuery/Chapter16-AJAX/PersonEditor.aspx
我收到此错误:
[Fiddler]连接到localhost.失败.异常文本:无法建立连接,因为目标计算机主动拒绝它:: 1:52749
谢谢
我想编写一个单元测试来测试一个名为UploadedFile的类的功能.
我面临的问题是这个类的静态构造函数使用HttpContext.Current属性,因为我从类库运行我的单元测试,我在测试时没有HttpContext.
看看我的静态构造函数:
static UploadedFile()
{
if (HttpContext.Current == null)
throw new Exception("web server not available");
HttpServerUtility server = HttpContext.Current.Server;
// SET UploadedFileMappingFile Names:
_resourceFileNames = new StringDictionary();
_resourceFileNames[_suppoertedFileStructures] = server.MapPath(SupportedUploadedFileStructures);
_resourceFileNames[_supportedFileStructuresXSD] = server.MapPath(SupportedUploadedFileStructuresXSD);
_resourceFileNames[UploadedFileEnum.UploadedFileFormatENUM.CSV.ToString()] = server.MapPath(UploadedFileColumnMap);
}
Run Code Online (Sandbox Code Playgroud)
我应该在我的测试环境中做什么,这样才HttpContext.Current不会为null,我可以成功设置它:
HttpServerUtility server = HttpContext.Current.Server;
Run Code Online (Sandbox Code Playgroud) 我可以将其他参数传递给谓词函数吗?
我实际上在排序过程中需要它。
public void Sort(
Comparison<T> comparison
)
Run Code Online (Sandbox Code Playgroud)
我想以Comparison这种形式使用谓词的地方:
public delegate int Comparison<T>(
T x,
T y,
object extraParameter
)
Run Code Online (Sandbox Code Playgroud)
这可能吗?
我在从Excel工作表中读取DateColumns时遇到问题.
有时人们会使用不同的日期格式,这会带来问题.假设我07/26/2010从Excel列中得到的结果26-Jul-2010是因为用户已更改其日期格式.
我用它Microsoft.Jet.OLEDB来读取xls表格DataTable.
我可以以某种方式强制OleDb读取器,无论在XLS上设置DateFormat,将所有日期转换为MM/DD/YYYY格式?
我用这段代码来读取Excel文件:
string strConn;
strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + uploadedFileInfo.FullName + ";" +
@"Extended Properties=""Excel 8.0;HDR=NO;""";
using (OleDbConnection connToExcel = new OleDbConnection(strConn))
{
//You must use the $ after the object you reference in the spreadsheet
connToExcel.Open();
string firstSheetName = ExcelUploadedFileReaderBuilder
.GetFirstExcelSheetName(connToExcel);
OleDbDataAdapter myCommand
= new OleDbDataAdapter(String.Format("SELECT * FROM [{0}]", firstSheetName), connToExcel);
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet, "uploadedExcelTable");
DataTable dtUploadedExcel = myDataSet.Tables["uploadedExcelTable"];
lineCount = GetLineNumberWhereNULLRowOccured(dtUploadedExcel) + …Run Code Online (Sandbox Code Playgroud) 就是想...
有没有理由不使用受保护的属性?
我的意思是代替使用它:
public abstract class Foo
{
protected Bar { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
使用这个:
public abstract class Foo
{
private Bar _bar;
protected Foo(Bar bar)
{
_bar = bar;
}
protected GetBar()
{
return _bar;
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个母版页,在更新面板中有一些用户控件.
我想在此页面中放置一个属性,以使内容页面能够启用/禁用异步回发方式来处理此页面.
我能以编程方式实现吗?
谢谢
你能用一个简单的现实生活例子非常简单地解释一下CodeDOM的用途和用途吗?
一个简单的例子,说明在什么情况下我为什么需要它作为开发人员呢?
谢谢
如何在RhinoMocks中强制执行存根对象以在其上返回void方法的void?
举个例子:
public interface ICar
{
string Model {get;set;}
void Horn();
}
ICar stubCar= MockRepository.GenerateStub<ICar>();
stubCar.Expect(c=>c.Horn()).Return( //now what so that
// it returns nothing as the meth. returns void ?
Run Code Online (Sandbox Code Playgroud) 我遵循命名惯例
MethodName_Condition_ExpectedBehaviour
在命名我的单元测试时,测试特定的方法.
例如:
[TestMethod]
public void GetCity_TakesParidId_ReturnsParis(){...}
Run Code Online (Sandbox Code Playgroud)
但是当我需要重命名测试方法时,像ReSharper这样的工具不能让我重命名那些测试.
有没有办法防止重命名后出现这种情况?比如更改ReSharper设置或遵循更好的单元测试命名约定等?
我正在从我的App.config中读取一个值; 这是:
<add key="someValue" value="0.05"/>
Run Code Online (Sandbox Code Playgroud)
我尝试通过以下方式将其转换为双倍:
var d = double.Parse(ConfigurationManager.AppSettings["someValue"]);
Run Code Online (Sandbox Code Playgroud)
而我获得5.0而不是0.05.
你能建议吗?我该怎么做错了,我应该如何解析这个?
c# ×7
.net ×4
unit-testing ×3
asp.net ×2
ajax ×1
asp.net-ajax ×1
codedom ×1
date ×1
double ×1
excel ×1
fiddler ×1
httpcontext ×1
mocking ×1
oledb ×1
parameters ×1
parsing ×1
predicate ×1
protected ×1
resharper ×1
rhino-mocks ×1
sorting ×1
tdd ×1
updatepanel ×1