我试图通过这行代码抑制SA1300的Style Cope警告.
[SuppressMessage("StyleCop.CSharp.NamingRules","SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Reviewed.")]
Run Code Online (Sandbox Code Playgroud)
它在类级别工作(即如果我把它放在有警告然后工作的类中)但是如果我把它放在GlobalSuppressions.cs类中则不行.我想要抑制整个程序集的SA1300警告,所以我把这行放在GlobalSuppressions.cs中,但它没有用.
[assembly: SuppressMessage("StyleCop.CSharp.NamingRules","SA1300:ElementMustBeginWithUpperCaseLetter", MessageId = "Ctl", Scope = "namespace", Target = "Assembly name"))]
Run Code Online (Sandbox Code Playgroud)
是否可以在"GlobalSuppressions.cs"中执行此操作?它也不适用于"SA1600"
我想转换一个XML文档,但是有一个问题。
我的XSLT看起来像这样:
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:strip-space elements="*" />
<xsl:template match="/">
<xsl:apply-templates select="address" />
</xsl:template>
<xsl:template match="address">
<xsl:value-of select="@street" />
<xsl:value-of select="@housenr" />
<xsl:value-of select="@zipcode" />
<xsl:value-of select="@city" />
<xsl:value-of select="@country" />
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
我要转换的XML文档如下所示:
<address id="4" type="1"
typename="Postadres"
street="pak street"
housenr="420"
zipcode="42000"
city="Nill"
country="Lahore"
kix="" />
Run Code Online (Sandbox Code Playgroud)
这是我编写的代码:
public static string Transform(XmlDocument doc, XmlDocument stylesheet)
{
var transform = new System.Xml.Xsl.XslCompiledTransform();
XmlDocument domOutput = new XmlDocument();
stylesheet.PreserveWhitespace = false;
transform.Load(stylesheet); // compiled stylesheet
MemoryStream oStream …Run Code Online (Sandbox Code Playgroud) 我有一个字符串格式的日期(即荷兰语),如"7 juli 2013".我想用英文格式转换它."Convert.toDateTime(strValue)抛出异常,因为它只转换英文格式.我也试试这个
string strValue = "7 juli 2013";
CultureInfo ci = new CultureInfo("en-US");
strValue = strValue.ToString(ci);
Run Code Online (Sandbox Code Playgroud)
但这不起作用.转换它的方法是什么?