我不太确定这是否可行,所以我转向你.
我想找到一个正则表达式,它将挑选掉所有引号集之外的逗号.
例如:
'foo' => 'bar',
'foofoo' => 'bar,bar'
Run Code Online (Sandbox Code Playgroud)
这将在第1行中选出单个逗号 'bar',
我真的不关心单引号和双引号.
有没有人有任何想法?我觉得这应该可以用readaheads,但我的正则表达式太弱了.
我很清楚只有两个可用的UIView转换,UIViewAnimationTransitionFlipFromLeft和UIViewAnimationTransitionFlipFromRight.我想知道是否有可以实现/模拟UIViewAnimationTransitionFlipFromTop或UIViewAnimationTransitionFlipFromBottom.
我能想到的唯一方法就是用x轴翻转x轴,但我没有看到任何关于如何做到这一点的信息.仅设置每个轴的坐标不会解决问题,因为x轴直到x轴为止.
有没有人有任何想法如何实现这一目标?
我最近一直在与crontab战斗,因为在Intrepid中gconftool使用dbus后端,这意味着当从crontab使用它时它不起作用.
为了使它工作,我必须在登录时导出相关的环境变量,以便在cron运行时找到dbus会话地址.
出于好奇,我想知道的cron什么样的环境能看到,它原来我所有的HOME,LOGNAME,PATH,SHELL,CWD和我这个新的,XDG_SESSION_COOKIE.这看起来好奇,几个谷歌搜索引发了一些错误或涉及它的其他功能请求但没有告诉我它做了什么.
我的直觉是,这个变量可以用来查找我必须导出到cron作业运行之前我来源的文件的所有内容.
因此,我的问题是a)我可以吗?b)如果是这样,怎么样?和c)它做了什么(别的)?
谢谢大家
我希望能够在WPF ListView中的每个网格列的顶部隐藏标题.
这是我的ListView的XAML:
<Window x:Class="ListViewTest.Test0.ListViewTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Empty ListView Grid" Height="216" Width="435" FlowDirection="LeftToRight" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.IsSharedSizeScope="False">
<Window.Resources>
<XmlDataProvider x:Key="CustomersDS" Source="C:\data.xml"/>
</Window.Resources>
<ListView Margin="0,0,0,50" ItemTemplate="{DynamicResource CustomerTemplate}" ItemsSource="{Binding Source={StaticResource CustomersDS}, XPath=/Customers/Customer}">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding XPath=Code}"/>
<GridViewColumn DisplayMemberBinding="{Binding XPath=Name}"/>
<GridViewColumn DisplayMemberBinding="{Binding XPath=Country}"/>
</GridView>
</ListView.View>
</ListView>
</Window>
Run Code Online (Sandbox Code Playgroud)
我绑定的数据是:
<Customers>
<Customer>
<Code>1234</Code>
<Name>EPI</Name>
<Country>Sesame Street</Country>
</Customer>
<Customer>
<Code>3234</Code>
<Name>Paul</Name>
<Country>United Kingdom</Country>
</Customer>
<Customer>
<Code>3344</Code>
<Name>Juan</Name>
<Country>Spain</Country>
</Customer>
<Customer>
<Code>4321</Code>
<Name>Dodo</Name>
<Country>Mars</Country>
</Customer>
</Customers>
Run Code Online (Sandbox Code Playgroud) List<MyParentClass> parents = new List<MyParentClass>();
var parent1 = new MyParentClass("parent1");
var parent2 = new MyParentClass("parent2");
parents.Add(parent1);
parents.Add(parent2);
var child1 = new MyChildClass("child1");
parent1.children.Add(child1);
var child2 = new MyChildClass("child2");
var child3 = new MyChildClass("child3");
parent2.children.Add(child2);
parent2.children.Add(child3);
var foo = from p in parents
select from c in p.children
select c;
Assert.IsNotNull(foo);
Assert.AreEqual(3, foo.Count());
NUnit.Framework.AssertionException:
expected: <3>
but was: <2>
Run Code Online (Sandbox Code Playgroud)
我想我正在回归伊利诺伊州的IList,但我只考虑了这三个孩子.我怎么做到的?
参考我目前正在构建的这个编程游戏.
我有一个类库(DLL)将有一个方法Run,将由以下内容组成:
public class MyRobot : Robot
{
public void Run(}
{
while (true)
{
Ahead(200); //moves the bot 200pixels
TurnLeft(90); //turns the bot by 90deg
}
}
}
Run Code Online (Sandbox Code Playgroud)
在那些方法(继承自Robot)中,系统将使用WPF(使用BeginAnimation或DispatcherTimer)来为机器人设置动画.
现在,问题是我没有在完成当前方法之前返回(即,转到下一个方法)的方法,因为这将导致动画一起发生,并且在无限循环中(如一个以上),这尤其不好.
我的问题是,在完成动画之前阻止方法返回的最佳方法是什么?
我当前bool在Robotclass(isActionRunning)中有一个标记为true动作开始运行时,然后更改为false动画回调(Completed如果使用则使用该事件BeginAnimation).
在每个方法结束时(在调用之后BeginAnimation),我放置了以下循环:
while (isActionRunning)
{
Thread.Sleep(200); //so that the thread sleeps for 200ms and then checks again if …Run Code Online (Sandbox Code Playgroud) 我正在尝试执行以下演员表
private void MyMethod(object myObject)
{
if(myObject is IEnumerable)
{
List<object> collection = (List<object>)myObject;
... do something
}
else
{
... do something
}
}
Run Code Online (Sandbox Code Playgroud)
但我总是得到以下例外:
无法转换类型为'System.Collections.Generic.List 1[MySpecificType]' to type 'System.Collections.Generic.List1 [System.Object]'的对象
我真的需要这个工作,因为这个方法需要非常通用才能接收单个对象和两个未指定类型的集合.
这是可能的,还是有另一种方法来实现这一点.
谢谢.
我正在设计课程......
有一些关键方法需要传递给它们的对象,或者它们需要能够"获取"一个对象.
所以问题是,你是否应该使用getter/setter或者直接将对象作为参数发送给方法 - 以使方法正常工作.或者,如果它们对类正确运行至关重要,是否应该通过构造函数设置对象?
重新启动我的rails应用程序时出现以下错误.我以前遇到过这个问题,在另一个服务器上有另一个应用程序,但不记得是什么问题,或者我是如何解决它的.
Rails Error: Unable to access log file. Please ensure that /apps/staging/releases/20090310162127/log/staging.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
Run Code Online (Sandbox Code Playgroud)
我正在Ubuntu上部署到带有capistrano的杂种群集.
当我做 ls -l /apps/staging/releases/20090310162127/log/staging.log
结果是:
-rw-rw-rw- 1 me grp 51 Mar 10 16:07 /apps/staging/releases/20090310162127/log/staging.log
Run Code Online (Sandbox Code Playgroud)
日志目录是link/ apps/staging/shared/log.
这是怎么回事?
我想编写一个Linq to Sql查询,它通过Username和DateTime进行计数和分组.我希望DateTime的格式如下"YYYY-MMM"(即2009年3月).
我认为这会工作,但Linq to Sql无法解析ToString"format"参数.
dc.MyTable
.GroupBy(r => new
{
Name = r.UserName,
YearMonth = r.SomeDateTime.ToString("yyyy-MMM")
})
.Select(r => new
{
Name = r.UserName,
YearMonth = r.YearMonth,
Count = r.Count()
})
.OrderBy(r => r.YearMonth)
.ThenBy(r => r.Name);
Run Code Online (Sandbox Code Playgroud)
有没有人有任何想法/建议?
谢谢.
c# ×4
.net ×2
animation ×2
linq ×2
linux ×2
wpf ×2
bash ×1
callback ×1
capistrano ×1
class-design ×1
cron ×1
gridview ×1
ilist ×1
iphone ×1
listview ×1
mongrel ×1
quotes ×1
regex ×1
sql-server ×1
transition ×1
uiview ×1
wpf-controls ×1