我有一个用c#编写的小应用程序作为我想用来发送电子邮件的控制台应用程序.我计划将电子邮件存储在xml文件中以及消息需要的其他信息(如主题).但是,似乎存在问题,因为XML文件不喜欢</br>字符.
我想知道我应该怎么做才能存储一个HTML电子邮件,我只需要在一个单独的html文件中保存正文html,然后将每行读入StreamReader对象?
为什么这段代码会返回true?
要匹配的字符串: ab
图案: /^a|b$/
但是当我把括号放在这样的时候:
图案: /^(a|b)$/
然后它会回来false.
我基本上有这样的布局:
<body>
<div style="height: 150px; width: 200px; background: green">
<div style="overflow: auto; max-height: 100px; background: blue">
some content <br/>
some content<br/>
some content<br/>
some content<br/>
some content<br/>
some content<br/>
some content
</div>
<div style="overflow: auto; background: red">
some more content<br/>
some content<br/>
some content<br/>
some content<br/>
some content
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
现在,我希望第二个div填充父div的所有剩余高度,并显示滚动条,如果需要更多空间.我怎样才能做到这一点?目前,第二个div从不显示滚动条,只是使用它所需的空间,即使它超过了父母的总高度......
更新:
请测试您提供的解决方案:-)
我有IAudioProcessor一个单一方法的接口IEnumerable<Sample> Process(IEnumerable<Sample> samples).虽然它不是接口本身的要求,但我想确保我的所有实现遵循一些通用规则,例如:
为这些创建测试并不难,但我必须为每个实现复制并粘贴这些测试.我想避免这种情况.
我想做这样的事情(注意属性GenericTest和类型参数):
[GenericTest(typeof(AudioProcessorImpl1Factory))]
[GenericTest(typeof(AudioProcessorImpl2Factory))]
[GenericTest(typeof(AudioProcessorImpl3Factory))]
public class when_processed_audio_is_returned<TSutFactory>
where TSutFactory : ISutFactory<IAudioProcessor>, new()
{
static IAudioProcessor Sut = new TSutFactory().CreateSut();
protected static Context _ = new Context();
Establish context = () => _.Original = Substitute.For<IEnumerable<ISample>>();
Because of = () => Sut.Process(_.Original);
It should_not_have_enumerated_the_original_samples = () =>
{
_.Original.DidNotReceive().GetEnumerator();
((IEnumerable)_.Original).DidNotReceive().GetEnumerator();
};
}
Run Code Online (Sandbox Code Playgroud)
这样的事情可能吗?
我正在尝试创建一个自定义,允许我指定不应填充不在某个名称空间中的类型的属性.
基本上,我试图改变这个:
fixture.Customize<Window>(c => c.OmitAutoProperties());
fixture.Customize<ContentControl>(c => c.OmitAutoProperties());
fixture.Customize<TextBlock>(c => c.OmitAutoProperties());
// Many many more...
Run Code Online (Sandbox Code Playgroud)
对此:
fixture.Customize(t => !t.Namespace.StartsWith("MyProject"),
c => c.OmitAutoProperties());
Run Code Online (Sandbox Code Playgroud)
怎么做到这一点?
我实际上只关心结果,而不是这里显示的虚构API,所以实现我自己ISpecimenBuilder或ICustomization不是问题.
我希望有人已经这样做了.我正在尝试为我的一个角度2项目建立一个团队城市的连续构建.完成一些研究后,我按照以下步骤操作:
任何帮助,将不胜感激.
谢谢.
我正在使用此代码通过yahoo SMTP服务器发送SMTP电子邮件,它是我正在编写的个人项目.
using System.Net.Mail;
using System.Net;
SmtpClient theClient = new SmtpClient("smtp.mail.yahoo.com", 465);
theClient.UseDefaultCredentials = false;
theClient.Credentials = new NetworkCredential("username", "password");
theClient.EnableSsl = true;
MailMessage theMessage = new MailMessage("username@yahoo.com",
"to.someone@gmail.com");
theMessage.Subject = "Dave test from C# subject";
theMessage.Body = "Dave test from C# body";
theClient.Send(theMessage);
Run Code Online (Sandbox Code Playgroud)
这是发送SMTP电子邮件的所有标准代码,但是...服务器似乎抛出错误.它强行终止连接.如果我使用其他SMTP服务器(如Gmail,Windows Live或其他各种ISP Smtp服务器),则不会发生这种情况.
这是异常和堆栈跟踪:
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at ConsoleApplication1.Program.Main(String[] args) in E:\dev\ARCSoftware.FTPProcessor\ConsoleApplication1\Program.cs:line 28
Run Code Online (Sandbox Code Playgroud)
我知道问题不是环境问题,因为我可以使用Outlook Express将这些确切的设置发送到同一台服务器.我想知道我是否需要发送证书或其他什么?
如果您或您认识的任何人对此有任何想法,我将非常感谢您的帮助.
是否可以在Resharper的模式目录中创建搜索模式以查找具有3个以上参数的所有构造函数?
如果是这样,怎么样?
我的问题是我不知道如何告诉Resharper只有构造函数定义才能匹配.
想象一下简单的控制器动作IEnumerable<BaseType> Get().它返回所有派生自BaseType的不同类型的枚举.
当客户端请求XML时,结果如下:
<ArrayOfBaseType>
<BaseType i:type="DerivedType1"><A>value</A></BaseType>
<BaseType i:type="DerivedType2"><B>value</B></BaseType>
<BaseType i:type="DerivedType3"><C>value</C></BaseType>
</ArrayOfBaseType>
Run Code Online (Sandbox Code Playgroud)
如您所见,派生类的类型在i:type属性中传输.
但是,如果客户端请求JSON,则缺少此信息:
[
{"A":"value"},
{"B":"value"},
{"C":"value"}
]
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
我有一个名为的变量allowedZHs.ZH是域特定的缩写.ZHs是它的复数形式.我想继续使用复数形式.我发现它比"正确"形式更具表现力" Zhs".
我试图通过添加代码分析字典来告诉代码分析.这适用于单数形式" ZH",但它不适用于复数形式.
我仍然收到警告CA1704.
我尝试将其添加为一个公认的单词并将其添加为首字母缩略词:
<Dictionary>
<Words>
<Recognized>
<Word>ZHs</Word>
</Recognized>
</Words>
<Acronyms>
<CasingExceptions>
<Acronym>ZHs</Acronym>
</CasingExceptions>
</Acronyms>
</Dictionary>
Run Code Online (Sandbox Code Playgroud)
我有什么想法我做错了吗?
c# ×6
.net ×4
html ×2
angularjs ×1
asp.net ×1
autofixture ×1
bdd ×1
css ×1
email ×1
javascript ×1
mailmessage ×1
mspec ×1
node.js ×1
php ×1
regex ×1
resharper ×1
rest ×1
smtp ×1
smtpclient ×1
teamcity ×1
unit-testing ×1
web-services ×1
xml ×1
yahoo ×1