小编tho*_*kia的帖子

WPF Treeview数据绑定分层数据与混合类型

我对WPF Treeview Binding有一些复杂的情况.我花了最近两天的时间尝试谷歌,是我提出的关闭,但它没有解决问题.

情况如下:

我有一个看起来像这样的对象:

public class Category
{
  public string Name { get; set; }
  public List<Category> Categories { get; set; }
  public List<Product> Products { get; set; }
}

public class Product
{
  public string Name { get; set;
}
Run Code Online (Sandbox Code Playgroud)

每个类别都可以包含对象列表和子类别.我有理由这样做对我和我正在写的应用程序完全有意义.

实际的对象构造可能看起来像这样:

Category - Pharmacy
  |-Product - Aspirin
  |-Product - Tylenol
  |-Category - Tooth Paste
  |  |-Product - Crest
  |  |-Product - Colgate
  |-Category - Paper Products
   |-Category - Toilet Paper
   |  |-Product - NoName
   | …
Run Code Online (Sandbox Code Playgroud)

wpf treeview binding hierarchicaldatatemplate hierarchical-data

33
推荐指数
1
解决办法
2万
查看次数

IIS 7.5上的Mercurial和hgweb - python错误

我试图让Mercurial在IIS 7.5(Win 7 x64)上托管并继续遇到我似乎无法解决的错误.

我在这里关注了Jeremy Skinners教程:IIS7上的Mercurial

而不是hgwebdir,我使用hgweb,因为我正在使用Mercurial 1.7.2

我安装了python并正在工作.我在目录c:\ inetpub\wwwroot\hg中的http:// localhost/hg - >上为Mercurial设置了一个IIS应用程序

我将templates目录放入c:\ inetpub\wwwroot\hg我将library.zip文件解压缩到c:\ inetpub\wwwroot\hg

当我访问该网站时,我收到一个错误 - >文件"C:\ inetpub\wwwroot\hg\hgweb.cgi",第15行,来自mercurial import demandimport; demandimport.enable()ImportError:没有名为mercurial的模块".

在搜索此错误时,我找到了以下答案:https://stackoverflow.com/questions/2123798/

根据接受的答案,我改变了我的hgweb.cgi,看起来像这样:

#!c:/python/python26/python.exe
#
# An example hgweb CGI script, edit as necessary
# See also https://www.mercurial-scm.org/wiki/PublishingRepositories

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/path/to/repo/or/config"

# Uncomment and adjust if Mercurial is not installed system-wide:
import sys; sys.path.insert(0, "c:\inetpub\wwwroot\hg")

# Uncomment to send python …
Run Code Online (Sandbox Code Playgroud)

python iis mercurial hgweb

9
推荐指数
1
解决办法
7012
查看次数

如何向包含破折号的地址发送电子邮件?

是我还是System.Net.Mail中的MailAddress类中有错误?

这段代码总是会引发一个问题:

MailMessage mail = new MailMessage();
mail.From = new MailAddress("me@me.com");     
mail.To.Add("joe-blow@me.com");

mail.Subject = "Test email"
mail.IsBodyHtml = true;
mail.Body = "<b>Does not work</b>";

//Connect to server and send message.               
SmtpClient smtp = new SmtpClient();
smtp.Host = "mailserver.me.com";
smtp.Send(mail);
Run Code Online (Sandbox Code Playgroud)

我得到的例外是:

System.FormatException: The specified string is not in the form required for an
e-mail address.
Run Code Online (Sandbox Code Playgroud)

但是,根据wiki,破折号是本地部分的有效字符.

有没有人知道使用System.Net.Mail类向电子邮件地址中带破折号的人发送电子邮件的方法?

c# smtp system.net.mail

6
推荐指数
1
解决办法
4846
查看次数

如何获得特定月份和年份的所有条目?

我想做

var dt = DateTime.Now.ToString();

string query = "SELECT * FROM Gigs where Date >= '"+dt+"';";
Run Code Online (Sandbox Code Playgroud)

它似乎工作 - 除了它获得未来几个月的条目

然后我做

var dt = DateTime.Now.AddMonths(3).ToString();

string query = "SELECT * FROM Gigs where Date >= '"+dt+"';";
Run Code Online (Sandbox Code Playgroud)

我得到的结果与预期的相同

如果今天是1月1日,我想获得1月份的所有参赛作品,但是2月份没有.

这是只读数据,不关心SQL注入

c# sql

-1
推荐指数
1
解决办法
587
查看次数