我刚写完第一个F#程序.功能明智的代码以我想要的方式工作,但不确定代码是否有效.如果有人可以为我查看代码并指出可以改进代码的区域,我将不胜感激.
谢谢Sudaly
open System
open System.IO
open System.IO.Pipes
open System.Text
open System.Collections.Generic
open System.Runtime.Serialization
[<DataContract>]
type Quote = {
[<field: DataMember(Name="securityIdentifier") >]
RicCode:string
[<field: DataMember(Name="madeOn") >]
MadeOn:DateTime
[<field: DataMember(Name="closePrice") >]
Price:float
}
let m_cache = new Dictionary<string, Quote>()
let ParseQuoteString (quoteString:string) =
let data = Encoding.Unicode.GetBytes(quoteString)
let stream = new MemoryStream()
stream.Write(data, 0, data.Length);
stream.Position <- 0L
let ser = Json.DataContractJsonSerializer(typeof<Quote array>)
let results:Quote array = ser.ReadObject(stream) :?> Quote array
results
let RefreshCache quoteList =
m_cache.Clear()
quoteList |> Array.iter(fun result->m_cache.Add(result.RicCode, …Run Code Online (Sandbox Code Playgroud) 这是我正在尝试做的事:点击我页面上的一个按钮,这反过来使(2)事情发生:
这是ASP标记:
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="true"
UpdateMode="Always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSaveData" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlHidden" runat="server" style="display: none;">
<div>
<h1>Saving...</h1>
</div>
</asp:Panel>
<cc1:ModalPopupExtender ID="modalPopup"
BackgroundCssClass="modalBackground" runat="server"
TargetControlID="btnSaveData" PopupControlID="pnlHidden"
BehaviorID="ShowModal">
</cc1:ModalPopupExtender>
<asp:Button ID="btnSaveData" runat="server" Text="Save Data"
OnClick="btnSaveData_Click" />
</ContentTemplate>
</asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)
现在,这是我的C#代码背后的代码:
protected void btnSaveData_Click(object sender, EventArgs e)
{
UpdateUserData(GetLoggedInUser());
modalPopup.Enabled = false;
}
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?ModalPopup显示完美,但btnSaveData_Click事件永远不会触发.
更新: 第一个建议对我不起作用.我也尝试了你的第二个建议(只要它适用于我).我的一个小的区别是我的模态面板上没有按钮(pnlHidden) - 它只是一条消息.我确实尝试在客户端使用Javascript事件,这至少与我的服务器端事件并发.这是个好消息,但我似乎无法找到或获取ModalPopupExtender或其BehaviorID的句柄.这不起作用:
function showOverlay() {
var popup = $find('modalPopup');
popup.show();
}
Run Code Online (Sandbox Code Playgroud)
popup总是等于null.
最终更新: 这是我的最终解决方案(请特别注意使用OnClientClick和OnClick):
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="true"
UpdateMode="Always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSaveData" …Run Code Online (Sandbox Code Playgroud) 我想做这样的事情:
declare @temp as varchar
set @temp='Measure'
if(@temp == 'Measure')
Select Measure from Measuretable
else
Select OtherMeasure from Measuretable
Run Code Online (Sandbox Code Playgroud) 我已经使用 WordPress 钩子init在 WordPress 的早期执行自定义代码,但是还有另一个钩子比这更早执行吗?
是否有任何工具可以让我在Android设备上浏览数据库?像Sql Management Studio这样的东西 - 你知道GUI工具,它显示数据库,表格,表格中的行等.
我正在使用Eclipse进行开发(如果它对于插件建议很重要).
谢谢!
我似乎无法在任何地方找到这个,但我相信一定有答案......
iphone应用程序可以同时连接多少个HTTP连接?换句话说,如果我异步构建并运行一堆NSURLConnections,在开始排队之前有多少可以在飞行中?
此外,是否有一种方法可以通过编程方式检查可用和/或使用的线程数?
我正在尝试编写一个智能预取引擎,这些限制(如果有的话)将是有用的信息.
我可以通过以下方式成功创建迭代路径:
var commonservice = collection.GetService<ICommonStructureService>();
// create new area path and iteration path
var iterationRoot = commonservice.GetNodeFromPath("\\MyTeamProject\\Iteration");
var newIterationPath = commonservice.CreateNode("my new sprint", iterationRoot.Uri);
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试将此路径分配给工作项并保存时,该字段不会验证.
如果我再次运行测试(已经创建了迭代),则相同的代码成功.
有人知道如何使这项工作?
让我有一个方法来删除整数数组中的重复项
public int[] RemoveDuplicates(int[] elems)
{
HashSet<int> uniques = new HashSet<int>();
foreach (int item in elems)
uniques.Add(item);
elems = new int[uniques.Count];
int cnt = 0;
foreach (var item in uniques)
elems[cnt++] = item;
return elems;
}
Run Code Online (Sandbox Code Playgroud)
我如何使这个泛型,现在它接受一个字符串数组并删除它中的重复项?双阵列怎么样?我知道我可能在原始和价值类型之间混合了一些东西.供您参考,以下代码将无法编译
public List<T> RemoveDuplicates(List<T> elems)
{
HashSet<T> uniques = new HashSet<T>();
foreach (var item in elems)
uniques.Add(item);
elems = new List<T>();
int cnt = 0;
foreach (var item in uniques)
elems[cnt++] = item;
return elems;
}
Run Code Online (Sandbox Code Playgroud)
原因是所有泛型类型都应在运行时关闭.谢谢你的评论
我正在寻找一个适用于Zend Server(CE)的PHP分析器.据我所知,XDebug很难用Zend Server进行设置.虽然Zend Debugger是免费的(据我所知),但Profiler仅在Zend Studio上.
还有其他选择吗?
我在Windows XP上使用Java,并希望能够将命令发送到另一个程序,如telnet.我不想简单地执行另一个程序.我想执行它,然后在它运行后发送一系列命令.这是我想要做的代码,但它不起作用:(如果取消注释并将命令更改为"cmd",它将按预期工作.请帮助.)这是一个简化的示例.在生产中会发送更多的命令,所以请不要建议调用"telnet localhost".
try
{
Runtime rt = Runtime.getRuntime();
String command = "telnet";
//command = "cmd";
Process pr = rt.exec(command);
BufferedReader processOutput = new BufferedReader(new InputStreamReader(pr.getInputStream()));
BufferedWriter processInput = new BufferedWriter(new OutputStreamWriter(pr.getOutputStream()));
String commandToSend = "open localhost\n";
//commandToSend = "dir\n" + "exit\n";
processInput.write(commandToSend);
processInput.flush();
int lineCounter = 0;
while(true)
{
String line = processOutput.readLine();
if(line == null) break;
System.out.println(++lineCounter + ": " + line);
}
processInput.close();
processOutput.close();
pr.waitFor();
}
catch(Exception x)
{
x.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud) c# ×3
php ×2
ajax ×1
android ×1
asp.net ×1
cocoa-touch ×1
command-line ×1
f# ×1
generics ×1
hook ×1
iphone ×1
iteration ×1
java ×1
objective-c ×1
process ×1
profiler ×1
send ×1
sql ×1
sql-server ×1
sqlcommand ×1
sqlite ×1
t-sql ×1
tfs ×1
wordpress ×1
workitem ×1
zend-server ×1