对于你们中的一些人,我的问题可能显得非常愚蠢,但我不得不问......抱歉..
I don't really understand principles of unit testing.. How can you test classes of your business classes or Data access layer without modify your database? I explain, i have a functionality who update a field in a database.. Nothing so amazing.. The Business layer class is instantiated and the method BLL.Update() makes some controls and finally instantiate a DAL class who launch a stored procedure in the database with the correct parameters.
Its works but my question is..
To …
Can anyone enlighten me as to why this bit of code spits back that the X is unsafe in 'try', well I know why, but more so how to fix it.
try X = lists:append(lists:zipwith3(fun(X, Y, Z) -> [X, Y, Z] end, Data1, Data2, Data3)) of
MP -> X
catch K -> (X = 0)
end.
%MP = [lists:zipwith3(X, Y, Z) || X, Y, Z <- [Data1, Data2, Data3]],
P = X
Run Code Online (Sandbox Code Playgroud) In my script, I need to iterate through a range of dates given the start date and end date. How can I do this in Perl?
您好我想将一些来自silverlight的数据发布到网站上.
我找到了以下链接,它的工作原理......
但......这个例子非常详细,让我的眼睛受伤了.
另外.. flex示例更清洁/更少代码..
我会说必须有更好的解决方案......
供参考..我们发布2个变量(字符串)并读出结果(字符串).
来自链接的解决方案:
1. // C#
2. // Create a request object
3. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(POST_ADDRESS, UriKind.Absolute));
4. request.Method = "POST";
5. // don't miss out this
6. request.ContentType = "application/x-www-form-urlencoded";
7. request.BeginGetRequestStream(new AsyncCallback(RequestReady), request);
8.
9. // Sumbit the Post Data
10. void RequestReady(IAsyncResult asyncResult)
11. {
12. HttpWebRequest request = asyncResult.AsyncState as HttpWebRequest;
13. Stream stream = request.EndGetRequestStream(asyncResult);
14.
15. // Hack for solving multi-threading problem
16. // …
Run Code Online (Sandbox Code Playgroud) 我有很多日期字符串Mon, 16 Aug 2010 24:00:00
,其中一些是00-23
小时格式,其中一些是01-24
小时格式.我想获得它们的日期对象列表,但是当我尝试将示例字符串转换为日期对象时,我必须将其转换Mon, 16 Aug 2010 24:00:00
为Tue, 17 Aug 2010 00:00:00
.什么是最简单的方法?
Nutshell中的C#4(强烈推荐的btw)使用以下代码来演示MemoryBarrier的概念(假设A和B在不同的线程上运行):
class Foo{
int _answer;
bool complete;
void A(){
_answer = 123;
Thread.MemoryBarrier(); // Barrier 1
_complete = true;
Thread.MemoryBarrier(); // Barrier 2
}
void B(){
Thread.MemoryBarrier(); // Barrier 3;
if(_complete){
Thread.MemoryBarrier(); // Barrier 4;
Console.WriteLine(_answer);
}
}
}
Run Code Online (Sandbox Code Playgroud)
他们提到障碍1和4阻止这个例子写0和障碍2和3提供新鲜度保证:他们确保如果B在A之后运行,读_complete将评估为真.
我不是真的得到它.我想我明白为什么壁垒1和4是必要的:我们不想在写_answer进行优化,并放置在写后_complete(屏障1),我们需要确保_answer没有被缓存(光栅4) .我也认为我理解为什么Barrier 3是必要的:如果A在写完_complete = true之后才运行,B仍然需要刷新_complete以读取正确的值.
我不明白为什么我们需要障碍2!我的一部分说这是因为可能线程2(运行B)已经运行直到(但不包括)if(_complete),因此我们需要确保_complete被刷新.
但是,我不知道这有多大帮助.是不是仍然可以在A 中将_complete设置为true但是B方法会看到_complete的缓存(错误)版本?即,如果线程2运行方法B直到第一个MemoryBarrier之后,然后线程1运行方法A直到_complete = true但没有进一步,然后线程1恢复并测试是否(_complete) - 如果不导致错误 …
c# multithreading thread-safety shared-memory memory-barriers
我尝试用Ninject创建应用程序.我有一个MainForm
用于设置的对话框表单.我应该如何实现这个?应该MainForm
有一个Kernel
实例,然后SettingsForm
用Get<SettingsForm>()
方法创建?或者MainForm
构造函数应该具有SettingsForm
实例参数?
我尝试用ninject找到一些WinForm应用程序的例子,但我发现只有一些ASP.NET应用程序在Visual C#2008 express中没用.
我刚刚开始使用cakePHP,我看到其中有一个AJAX Helper.
我的问题很简单:我应该使用这个帮助器,还是应该继续使用jQuery进行AJAX?我应该在现有的jQuery AJAX调用中执行任何更改吗?
谢谢
有关函数重载的规则是什么?
我有以下代码:
public T genericFunc<T>() where T : Component, new()
{
T result = new T();
overloadedFunction( result );
}
private overloadedFunction ( Component c ) // catch all function
private overloadedFunction ( DerivedFromComponent dfc) // specific function
Run Code Online (Sandbox Code Playgroud)
当我用以下代码调用上面的代码时:
genericFunc<DerivedFromComponent>();
Run Code Online (Sandbox Code Playgroud)
我希望调用更具体的overloadedFunction,但是会调用catch all函数,为什么会这样?单步执行上面的代码时,类型T确实是DerivedFromComponent,我认为CLR在运行时选择了最佳匹配!
c# ×5
ajax ×1
cakephp ×1
clr ×1
constructor ×1
datetime ×1
erlang ×1
helper ×1
http ×1
java ×1
jquery ×1
ninject ×1
overloading ×1
perl ×1
python ×1
silverlight ×1
try-catch ×1
unit-testing ×1
windows ×1
winforms ×1