我用Lambda做了越来越多的练习,但是我不知道为什么有时会.AsQueryable();使用IQueryable的例子,有时它会省略.AsQueryable();并使用IEnumerable.
我已经阅读了MSDN,但我不知道"执行表达式树"是否优于其他优势.
有人可以向我解释一下吗?
我对Regex不是很好,但我正在学习.
我想通过类名删除一些html标记.这是我到目前为止:
<div class="footer".*?>(.*?)</div>
Run Code Online (Sandbox Code Playgroud)
首先 .*?是因为它可能包含其他属性,第二个可能包含其他html内容.
我究竟做错了什么?我试了很多但没有成功.
在DIV内部,它可以包含多行,我正在玩Perl正则表达式.
目前,我发现能够从包含HTML的字符串中操作DOM的最佳方法是:
WebBrowser webControl = new WebBrowser();
webControl.DocumentText = html;
HtmlDocument doc = webControl.Document;
Run Code Online (Sandbox Code Playgroud)
有两个问题:
WebBrowser对象!有任何想法吗?
我正在调试打印时元素定位有问题的站点(我有一个单独的print.css文件,链接元素由media ="print"属性链接).此问题仅发生在IE7和IE8中.
我正在寻找的是一种使用打印介质类型查看页面的方法,但仍然可以使用IE8的开发人员工具来查看元素详细信息并实时编辑等.
我正在寻找的功能类似于Chris Pederick的Firefox开发人员扩展中的"按媒体类型显示CSS"功能.(但这个问题不会出现在firefox中......也不会出现在safari中,甚至在IE6中也不会出现.)
我曾经有一个数据访问层,它通过参数获取对象,并使用抽象处理所需的持久性类型.在我的新工作中,架构师正在考虑将CRUD操作(load..save..delete..update)实现到所有模型对象中.那些方法将有一个参数的对象,它将处理对象的保存.例子:加载(IPersistence持久性).我对可扩展性有一些疑问,并且每个模型对象都必须实现所有加载,保存,删除,更新方法.
什么是最好的方法?
如何将网站转换为能够处理多语言(例如:英语,法语,西班牙语)?
我不喜欢资源文件,因为我觉得有限,而且构建列表的时间很长.你有什么建议吗?
目前我们发现的最佳方法是使用XML文件和一些Xpath和get值.
有时,当类的单元测试完成并且方法在代码更改时使用_Accessor时.你编写的很多时间它仍然没有"同步"_Accessor文件.唯一有效的是关闭VS2008并重新打开它.任何"重新生成"测试访问器的技巧?
在.xaml中,它们有一个显示在屏幕上的命令列表.
<Border
Grid.Column="0"
Style="{StaticResource MainBorderStyle}"
Width="170"
>
<HeaderedContentControl
Content="{Binding Path=Commands}"
ContentTemplate="{StaticResource CommandsTemplate}"
Header="Control Panel"
Style="{StaticResource MainHCCStyle}"
/>
</Border>
Run Code Online (Sandbox Code Playgroud)
从这里,我了解DataContext已设置(此处未显示),它将显示命令集合.我不明白的是你可以在下面看到的CommandsTemplate:
<DataTemplate x:Key="CommandsTemplate">
<ItemsControl IsTabStop="False" ItemsSource="{Binding}" Margin="6,2">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Margin="2,6">pou
<Hyperlink Command="{Binding Path=Command}">
<TextBlock Text="{Binding Path=DisplayName}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
如何创建绑定?这段代码如何告诉从集合中的对象检查属性Command和DisplayName?它来自ItemsSource吗?如果是,我不明白为什么它只在{Binding}.任何人都可以解释我,DataTemplate绑定如何从ContentTemplate工作?
我有一个线程调用一个从Internet获取一些东西的对象.当此对象填满所需的所有信息时,它会引发一个具有对象的事件将所有信息.该事件由启动该线程的控制器使用.
然后将事件中返回的对象添加到通过View Model方法绑定到GUI的集合中.
问题是我不能将CheckAccess与绑定一起使用...如何解决使用从主要的其他线程创建的Object的问题?
我将对象添加到主线程集合时收到的错误是:
这种类型的CollectionView不支持从与Dispatcher线程不同的线程更改其SourceCollection.
这个控制器:
public class WebPingerController
{
private IAllQueriesViewModel queriesViewModel;
private PingerConfiguration configuration;
private Pinger ping;
private Thread threadPing;
public WebPingerController(PingerConfiguration configuration, IAllQueriesViewModel queriesViewModel)
{
this.queriesViewModel = queriesViewModel;
this.configuration = configuration;
this.ping = new Pinger(configuration.UrlToPing);
this.ping.EventPingDone += new delPingerDone(ping_EventPingDone);
this.threadPing = new Thread(new ThreadStart(this.ThreadedStart));
}
void ping_EventPingDone(object sender, QueryStatisticInformation info)
{
queriesViewModel.AddQuery(info);//ERROR HAPPEN HERE
}
public void Start()
{
this.threadPing.Start();
}
public void Stop()
{
try
{
this.threadPing.Abort();
}
catch (Exception e)
{
}
}
private …Run Code Online (Sandbox Code Playgroud) 我有一个FileSystemWatcher,可以对Changed事件做出反应.
我想打开文件,阅读其内容,将其显示在文本框中,并隐藏1秒后创建的弹出窗口.代码几乎可以工作,但隐藏弹出窗口时会出现问题.
以下是代码片段:
txtLog.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() {
this.txtLog.Text = dataToDisplay;
extendedNotifyIcon_OnShowWindow();
Thread threadToClosePopup = new Thread(new ThreadStart((Action)delegate() {
Thread.Sleep(1000);
extendedNotifyIcon_OnHideWindow();
}));
threadToClosePopup.Start();
});
Run Code Online (Sandbox Code Playgroud)
如您所见,我使用Invoke来设置文本,因为事件位于不同的线程(FileSystemWatcher)中.但是为了隐藏窗口,extendedNotifyIcon_OnHideWindow()不会在GUI的线程中执行.如何在GUI线程中执行它?