我必须实现一个函数,它接受一个字符串作为输入,并从该字符串中找到非重复的字符.
所以一个例子是如果我传递字符串str ="DHCD"它将返回"DHC"或str2 ="KLKLHHMO"它将返回"KLHMO"
我有这个:
var Test = new function() {
this.init = new function() {
alert("hello");
}
this.run = new function() {
// call init here
}
}
Run Code Online (Sandbox Code Playgroud)
我想init在跑步中打电话.我该怎么做呢?
需要有关sql server 2008中的pivot子句的帮助.我有一个包含此信息的表:
__PRE__
我想将其转换为如下所示的表:
__PRE__
是否有任何关于透视查询的方法?请写一个关于如何做的回答.
我很感激这方面的任何帮助.提前致谢.
问候!我喜欢使用MVVM轻巧的框架 - 让我的生活变得更加轻松,并且已经消除了许多难以克服的障碍......
题:
我正在尝试设置一个自定义对话框,用于编辑用户相互发送的消息.我正在尝试使用MVVM框架使用ChildWindow对象构造一个Silverlight自定义对话框.
想知道是否有任何关于如何实现这一点的建议
在我找到的对话框MVVM示例代码之后:http://mvvmlight.codeplex.com/Thread/View.aspx?ThreadId = 209338我被卡住了,因为Silverlight中的ChildWindow对话框对象是异步的,并且具有不同的Result类.
所以 - 我现在的基本思想是使用类的视图模型(在本例中为Matrix.MessageViewModel)来创建自定义对话框的实例,通过Messenger.Send <>发送它,处理已注册的消息显示对话框的视图,然后让ChildWindow对话框的Save按钮处理程序触发Messenger.Send,修改后的内容然后使用viewmodel上的Save方法存储...
看起来有点圆 - 所以想确保没有更清洁的方式....
相关代码位:
查看模型:
messageDialogBox = new MessageEditorDialog(
selectedMessage, this.SelectedSiteId, this.LoggedOnEmployee.Id, this.Projects);
DialogMessage editMessage = new DialogMessage(
this, messageDialogBox,"Edit Message", DialogMessageCallback);
Messenger.Default.Send(editMessage);
Run Code Online (Sandbox Code Playgroud)
视图:
public ViewHost()
{
InitializeComponent();
Loaded += new RoutedEventHandler(ViewHost_Loaded);
if (!ViewModelBase.IsInDesignModeStatic)
{
// Use MEF To load the View Model
CompositionInitializer.SatisfyImports(this);
}
ApplicationMessages.IsBusyMessage.Register(this, OnIsBusyChange);
Messenger.Default.Register<DialogMessage>(this, msg => ShowDialog(msg));
}
private void ShowDialog(DialogMessage msg)
{
MessageEditorDialog myDialog = (MessageEditorDialog) msg.Target;
myDialog.Show();
}
Run Code Online (Sandbox Code Playgroud)
对话保存: …
我有一个CMS系统,可以跨表格存储数据,如下所示:
Entries Table
+----+-------+------+--------+--------+
| id | title | text | index1 | index2 |
+----+-------+------+--------+--------+
Entries META Table
+----+----------+-------+-------+
| id | entry_id | value | param |
+----+----------+-------+-------+
Files Table
+----+----------+----------+
| id | entry_id | filename |
+----+----------+----------+
Entries-to-Tags Table
+----+----------+--------+
| id | entry_id | tag_id |
+----+----------+--------+
Tags Table
+----+-----+
| id | tag |
+----+-----+
Run Code Online (Sandbox Code Playgroud)
我正在尝试实施修订系统,有点像SO.如果我只是因为Entries Table我正在计划在一个单独的表中保留该表的所有更改的副本.因为我必须为至少4个表(TAGS表不需要修改)这样做,这似乎不像一个优雅的解决方案.
你们会怎么做?
请注意,元数据表是以EAV(实体属性值)建模的.
先感谢您.
mysql database version-control revision entity-attribute-value
我在查找访问Windows字体或预定义字体和大小的内容时遇到了麻烦.所以对于我的java程序,我有一个JComboBox字体,大小和颜色.问题是我需要预先输入字体,大小和颜色.我怎样才能获得预定义的字体,颜色和大小?到目前为止,这是我对这种字体的看法,但不是正确的.
if (font.equals("Arial")) {
if (size.equals("8")) {
setSize = 8;
} else if (size.equals("10")) {
setSize = 10;
} else if (size.equals("12")) {
setSize = 12;
}
if (color.equals("Black")) {
setColor = Color.BLACK;
} else if (color.equals("Blue")) {
setColor = Color.BLUE;
} else if (color.equals("Red")) {
setColor = Color.red;
}
Font font = new Font("Arial", setAttribute, setSize);
Writer.setFont(font);
Writer.setForeground(setColor);
Run Code Online (Sandbox Code Playgroud) 我试图比较三种不同的方式将委托传递给C#中的函数 - 由lambda,委托和直接引用.让我感到惊讶的是直接参考方法(即ComputeStringFunctionViaFunc(object[i].ToString))比其他方法慢六倍.有谁知道为什么会这样?
完整代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.CompilerServices;
namespace FunctionInvocationTest
{
class Program
{
static void Main(string[] args)
{
object[] objectArray = new object[10000000];
for (int i = 0; i < objectArray.Length; ++i) { objectArray[i] = new object(); }
ComputeStringFunction(objectArray[0]);
ComputeStringFunctionViaFunc(objectArray[0].ToString);
ComputeStringFunctionViaFunc(delegate() { return objectArray[0].ToString(); });
ComputeStringFunctionViaFunc(() => objectArray[0].ToString());
System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch();
s.Start();
for (int i = 0; i < objectArray.Length; ++i)
{
ComputeStringFunction(objectArray[i]);
}
s.Stop();
Console.WriteLine(s.Elapsed.TotalMilliseconds);
s.Reset();
s.Start();
for …Run Code Online (Sandbox Code Playgroud) 当我在Visual Studio 2012中分析代码覆盖率时,异步方法中的任何等待行都显示为未覆盖,即使它们显然正在执行,因为我的测试正在通过.代码覆盖率报告说,未覆盖的方法是MoveNext我的代码中没有的(也许是编译器生成的).
有没有办法修复异步方法的代码覆盖率报告?
注意:
我刚刚使用NCover运行覆盖,使用该工具覆盖数字更有意义.作为现在的解决方法,我将改用它.
在下面的代码中,传递给wrap_map的回调函数无法在外部函数中看到参数,为什么?(详见代码注释)
public static function wrap_implode($ar, $wrap, $delim){
echo "wrap is $wrap"; //wrap is ok
$res = array_map(function($val){
echo "wrap is $wrap"; //wrap is not set here!
return $wrap. $val . $wrap;
}, $ar);
return implode($delim, $res);
}
Run Code Online (Sandbox Code Playgroud) 我希望实现接近RateProduct操作的内容:http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-actions
在该教程中,它被定义为:
[HttpPost]
public int RateProduct([FromODataUri] int key, ODataActionParameters parameters)
{
// ...
}
ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<Product>("Products");
// New Code
ActionConfiguration rateProduct = modelBuilder.Entity<Product>().Action("RateProduct");
rateProduct.Parameter<int>("Rating");
rateProduct.Returns<int>();
Run Code Online (Sandbox Code Playgroud)
但是,我有一个Location实体的用例,它足够聪明,可以返回其周围某个半径范围内的其他位置.它大致应该是这样的:
[HttpPost]
public IQueryable<Location> GetLocationsWithinRadius([FromODataUri] int key, ODataActionParameters parameters)
{
// Get the Location instance intended to be the center of the radius by using the key
// Do a radius search around it using (int)parameters["radius"] as the radius
// return the IQueryable<Location> of all location found within …Run Code Online (Sandbox Code Playgroud) c# ×3
.net ×1
async-await ×1
c#-5.0 ×1
childwindow ×1
class ×1
database ×1
delegates ×1
fonts ×1
java ×1
javascript ×1
methods ×1
mstest ×1
mvvm-light ×1
mysql ×1
odata ×1
performance ×1
php ×1
php-5.3 ×1
pivot ×1
revision ×1
scope ×1
silverlight ×1
sql ×1
sql-server ×1
swing ×1