我正在使用C#和HtmlAgilityPack,我可以选择id为foo的div
var foos = from foo in htmlDoc.DocumentNode.Descendants("div")
where foo.Id == "foo"
select foo;
Run Code Online (Sandbox Code Playgroud)
但是如何用一类条选择div呢?
我正在阅读学习WCF一书和第一个教程实验室HelloIndigo我收到以下错误.
无法连接到http:// localhost:8000/HelloIndigo/HelloIndigoService.TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝它127.0.0.1:8000.
它出现在客户端项目中的字符串s = proxy.HelloIndigo();
EndpointAddress ep = new EndpointAddress("http://localhost:8000/HelloIndigo/HelloIndigoService");
IHelloIndigoService proxy = ChannelFactory<IHelloIndigoService>.
CreateChannel(new BasicHttpBinding(), ep);
string s = proxy.HelloIndigo();
Console.WriteLine(s);
Console.WriteLine("Press <ENTER> to terminate Client");
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)
我已经深入搜索了这个,但我不是更明智的.
任何人都可以解释这个问题以及如何补救?
手动我已经映射网络驱动器Y:// 到我的系统.Drive有Manny文件夹,每个文件夹包含单个XMl文件,文件夹与文件夹相同.
在这里,我试图从网络位置读取Xml文件.但它没有找到异常目录.在Code下面我正在使用它.
Fname = txtwbs.Text;
DirectoryInfo objDir = new DirectoryInfo("Y:\\");
\\Y:\\
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
_xmlpath = objDir + "\\" + Fname + "\\" + Fname + ".xml";
if (File.Exists(_xmlpath ))
{
reader(_xmlpath);
}
}
Run Code Online (Sandbox Code Playgroud)
这里Fname是文件夹名称也是Xml名称.用户将输入文件名称.
在骨干中,什么是在作者和书籍之间存储关系(在localstorage中)的理想方式.
是否可以将集合作为属性或使用数组或......?
var book = Backbone.Model.extend({
defaults:{
title: ''
}
});
var books = Backbone.Collection.extend({
model: book
});
var author = Backbone.Model.extend({
defaults:{
firstName: '',
lastName: '',
books: new books()
}
});
var authors = Backbone.Collection.extend({
model: author,
localStorage: new Backbone.LocalStorage("authors")
});
Run Code Online (Sandbox Code Playgroud) 我有一个Linq-2-XML查询,如果我创建的谷歌站点地图的urlset元素填充了属性,但如果没有属性存在则可以正常工作.
无法查询:
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.foo.com/index.htm</loc>
<lastmod>2010-05-11</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://www.foo.com/about.htm</loc>
<lastmod>2010-05-11</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
</urlset>
Run Code Online (Sandbox Code Playgroud)
可以查询:
<?xml version="1.0" encoding="utf-8"?>
<urlset>
<url>
<loc>http://www.foo.com/index.htm</loc>
<lastmod>2010-05-11</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://www.foo.com/about.htm</loc>
<lastmod>2010-05-11</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
</urlset>
Run Code Online (Sandbox Code Playgroud)
查询:
XDocument xDoc = XDocument.Load(@"C:\Test\sitemap.xml");
var sitemapUrls = (from l in xDoc.Descendants("url")
select l.Element("loc").Value);
foreach (var item in sitemapUrls)
{
Console.WriteLine(item.ToString());
}
Run Code Online (Sandbox Code Playgroud)
这是什么原因?
我创建了一个C#windows服务,应该发送一些电子邮件,但是当我启动服务时,我收到消息'本地服务开始然后停止'......'如果他们没有工作可以自动停止某些服务'
为什么会这样?
namespace EmailService
{
public partial class EmailService : ServiceBase
{
private System.Timers.Timer _timer = null;
private DateTime _lastRun = DateTime.Now;
private int _timerIntervalValue;
public EmailService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["Timer"]))
{
throw new Exception("The timer value is not set in the app.config.");
}
else
{
_timerIntervalValue = Convert.ToInt32(ConfigurationManager.AppSettings["Timer"]);
}
_timer = new System.Timers.Timer(_timerIntervalValue);
_timer.Elapsed += OnTimedEvent;
_timer.Interval = Convert.ToInt32(_timerIntervalValue);
_timer.Enabled = true;
}
protected override void OnStop()
{
_timer.Stop();
_timer.Dispose();
}
private …Run Code Online (Sandbox Code Playgroud) 我正在通过 Contoso 示例进行一些 TDD 练习,我的检索学生测试正在通过。
我创建新学生的测试失败(尽管实际代码有效),因为我相信 DBContext 没有被嘲笑。
为了让这个测试过去,我应该重构什么?
测试失败如下:
Contoso.Tests.Controllers.StudentControllerTest.Create_HttpPost_Should_Save_New_Student:预期:9 但是:8
这是具体的 UnitOfWork
public class UnitOfWork : IUnitOfWork
{
private SchoolContext context = new SchoolContext();
private IStudentsRepository studentsRepository;
private bool disposed = false;
public IStudentsRepository StudentsRepository
{
get
{
if (this.studentsRepository == null)
{
this.studentsRepository = new StudentsRepository(context);
}
return studentsRepository;
}
}
public void Save()
{
context.SaveChanges();
}
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
context.Dispose();
}
}
this.disposed = true;
}
public …Run Code Online (Sandbox Code Playgroud) 在使用AlternateText属性的ImageButton上,向浏览器呈现alt标记.
<asp:ImageButton ID="imagebuttonStuff" runat="server" OnClick="imagebuttonStuff_Click" AlternateText="Make Stuff Happen" ImageUrl="/images/icons/stuff.png" />
<input type="image" name="imagebuttonStuff" id="imagebuttonStuff" src="/images/icons/stuff.png" alt="Make Stuff Happen" />
Run Code Online (Sandbox Code Playgroud)
如何呈现标题标签?
我正在努力学习骨干,但是要说实话,我感觉有点不知所措.在任何地方,我看都是以稍微不同的方式完成的,每个都有更多的框架和插件来学习.所以我决定放下我对Addy Osmani的信仰,并正在阅读他的Backbone Fundamentals书.我遵循了他的建议并使用了Backbone-Boilerplate.但无论出于何种原因,我无法成功安装Grunt BBB,因此无法下载工作示例.
我想要做的是遵循此路由器部分并使用视图.http://addyosmani.github.com/backbone-fundamentals/#router.js.
问题是我认为这些说明不完整.首先,collection.fetch()变量的范围是错误的,我真的不明白我需要放置视图的位置和方式.我很确定如果我能看到一个可行的例子,我可以理解它,但正如我所说,到处都是我看到的不同的实现.
有谁知道如何使用带有路由器和视图的骨干 - 样板?在任何地方都有工作示例吗?
backbone.js backbone-views backbone-routing backbone-boilerplate
c# ×5
asp.net ×2
backbone.js ×2
.net ×1
asp.net-mvc ×1
debugging ×1
html ×1
imagebutton ×1
javascript ×1
linq-to-xml ×1
moq ×1
unit-of-work ×1
unit-testing ×1
wcf ×1