我想使用XML文档中的高性能XML元素进行过滤.
以带有联系人的XML文件为例:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="asistentes.xslt"?>
<contactlist evento="Cena Navidad 2010" empresa="company">
<contact type="1" id="1">
<name>Name1</name>
<email>xxxx@zzzz.es</email>
<confirmado>SI</confirmado>
</contact>
<contact type="1" id="2">
<name>Name2</name>
<email>xxxxxxxxx@zzzze.es</email>
<confirmado>Sin confirmar</confirmado>
</contact>
</contaclist>
Run Code Online (Sandbox Code Playgroud)
我目前要从此XML文档中过滤的代码:
using System;
using System.Xml.Linq;
class Test
{
static void Main()
{
string xml = @" the xml above";
XDocument doc = XDocument.Parse(xml);
foreach (XElement element in doc.Descendants("contact")) {
Console.WriteLine(element);
var id = element.Attribute("id").Value;
var valor = element.Descendants("confirmado").ToList()[0].Value;
var email = element.Descendants("email").ToList()[0].Value;
var name = element.Descendants("name").ToList()[0].Value;
if (valor.ToString() == "SI") { …Run Code Online (Sandbox Code Playgroud) 当我使用TestServer调用MVC端点来检查视图呈现时,它会导致HTTP 500内部服务器错误响应.
错误是:
在编译处理此请求所需的资源期间发生错误.请查看以下特定错误详细信息并相应地修改源代码.
/CustomSubfolder/Views/_ViewImports.cshtml
缺少一个或多个编译引用.可能的原因包括应用程序的project.json中'buildOptions'下缺少'preserveCompilationContext'属性.
类型或命名空间名称myNameSpace对象'不存在命名空间"Company.App"存在(是否缺少程序集引用?)
测试代码:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace MvcProject.Tests
{
[TestClass]
public class ControllerTests
{
protected TestServer Server { get; }
protected HttpClient Client { get; }
public ControllerTests()
{
Server = new TestServer(new WebHostBuilder()
.UseContentRoot("../../../../MvcProject")
.UseStartup<Startup>());
Client = Server.CreateClient();
}
[TestMethod]
public async Task Action_Valid_Renders()
{
HttpResponseMessage response = await Client.GetAsync("http://localhost/");
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用面向.NET Framework 4.6.1的ASP.NET Core 1.1,我的MSTest .csproj文件如下所示:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework> …Run Code Online (Sandbox Code Playgroud) 在.NET项目中,我需要验证字符串是否是有效的Microsoft SQL Server 2005参数标识符.
例: SELECT * FROM table WHERE column = @parameter
是否有运行时类方法来验证字符串是否为参数,或者是否有正则表达式来验证规则?(见下文)
从标识符文档中,参数应符合以下通用标识符规则:
- 第一个字符必须是以下之一:*Unicode标准3.2定义的字母.字母的Unicode定义包括从a到z,从A到Z的拉丁字符,以及来自其他语言的字母字符.*下划线(_),符号(@)或数字符号(#).
标识符开头的某些符号在SQL Server中具有特殊含义.以at符号开头的常规标识符始终表示局部变量或参数,不能用作任何其他类型对象的名称.以数字符号开头的标识符表示临时表或过程.以双数字符号(##)开头的标识符表示全局临时对象.虽然数字符号或双数字符号可用于开始其他类型对象的名称,但我们不建议使用此做法.某些Transact-SQL函数的名称以符号(@@)的double开头.为避免与这些功能混淆,不应使用以@@开头的名称.- 后续字符可包括以下内容:*Unicode标准3.2中定义的字母.*来自Basic Latin或其他国家脚本的十进制数字.*at符号,美元符号($),数字符号或下划线.
- 标识符不能是Transact-SQL保留字.SQL Server保留保留字的大写和小写版本.
- 不允许使用嵌入空格或特殊字符.
- 不允许使用补充字符.
在Transact-SQL语句中使用标识符时,不符合这些规则的标识符必须用双引号或括号分隔.
由于我只想验证参数,因此标识符必须以@符号开头,并且不得分隔.
安装Azure SDK 2.7时,我遇到Web Platform Installer无法安装Windows Azure存储模拟器4.1.
在错误日志中,我可以找到以下消息:
CAQuietExec: "C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" init -forcecreate -autodetect
CAQuietExec: Windows Azure Storage Emulator 4.1.0.0 command line tool
CAQuietExec: Error: Cannot create database.
Run Code Online (Sandbox Code Playgroud) .net ×1
asp.net-core ×1
asp.net-mvc ×1
azure ×1
c# ×1
linq ×1
linq-to-xml ×1
razor ×1
regex ×1
sql-server ×1
t-sql ×1
xml ×1