这是一个XSD:
<?xml version="1.0"?>
<xsd:schema
elementFormDefault='unqualified'
attributeFormDefault='unqualified'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
>
<xsd:simpleType name='TheSimpleType'>
<xsd:restriction base='xsd:string' />
</xsd:simpleType>
</xsd:schema>
Run Code Online (Sandbox Code Playgroud)
这是第二个包含上述XSD的XSD:
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema
elementFormDefault='unqualified'
attributeFormDefault='unqualified'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
targetNamespace='a'
xmlns='a'
>
<xsd:include schemaLocation='Include.xsd' />
<xsd:element name = "TheElement" >
<xsd:complexType>
<xsd:attribute name="Code" type="TheSimpleType" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Run Code Online (Sandbox Code Playgroud)
我需要将(第二个)XSD读入C#并且:
下面是一些要在schemata中读取的C#:
XmlSchemaSet schemaSet = new XmlSchemaSet();
foreach (string sd in Schemas)
{
using (XmlReader r = XmlReader.Create(new FileStream(sd, FileMode.Open)))
{
schemaSet.Add(XmlSchema.Read(r, null));
}
}
schemaSet.CompilationSettings = new XmlSchemaCompilationSettings();
schemaSet.Compile();
Run Code Online (Sandbox Code Playgroud)
.Compile()失败,因为"Type'a:TheSimpleType'未声明,或者不是简单类型."
但是,它适用于:
问题是:如何在不编辑架构的情况下让C#接受它? …
这似乎name是一个特殊的魔法变量,以某种方式用于我的输出目录。(这种行为有记录在任何地方吗?)
我正在尝试设置它。
鉴于编写 Azure pipeline yml 非常困难,我不太可能把它写对。在没有任何形式的调试的情况下,我想添加一个打印语句,以便我可以看到该值。
如何?
${{ if eq(variables['Build.SourceBranchName'], 'master') }}:
buildConfiguration: 'Release'
tag: ''
${{ if ne(variables['Build.SourceBranchName'], 'master') }}:
buildConfiguration: 'Debug'
tag: ${{ format('-{0}', variables['Build.SourceBranchName']) }}
# How do you do string concatenation in yml? Do I need to do `format` like above?
name: $(Build.BuildId)$(tag)
steps:
- script: echo "name is $(name)"
Run Code Online (Sandbox Code Playgroud)
但输出是
Generating script.
Script contents:
echo "name is $(name)"
...
name is $(name)"
Run Code Online (Sandbox Code Playgroud)
有可能使这项工作成功吗?如何?
是否可以?(好像不是,不支持NUnit吗?应该用什么代替?)
这是我的测试项目。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TheProjectToBeTested\TheProjectToBeTested.csproj" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
这是我的azure-pipelines.yml
pool: 'TFSBuild'
variables:
# The web app will not build because it is netcore3.1 and the server only supports netcore3.0.
solution: '**/*Build.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@0
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default …Run Code Online (Sandbox Code Playgroud) 我想调整目录中每个 jpg 的大小。
这是我找到的 gimp 脚本。对我来说看起来很明智。
(define (batch-resize pattern)
(let*
((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* (
(filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-active-drawable image)))
(cur-width (car (gimp-image-width image)))
(cur-height (car (gimp-image-height image)))
(width (* 0.25 cur-width))
(height (* 0.25 cur-height))
)
(gimp-message filename)
(gimp-image-scale-full image width height INTERPOLATION-CUBIC)
(let
((nfilename (string-append "thumb_" filename)))
(gimp-file-save RUN-NONINTERACTIVE image drawable nfilename nfilename)
)
(gimp-image-delete image)
)
(set! filelist (cdr filelist))
)
)
) …Run Code Online (Sandbox Code Playgroud) 在Microsoft.AspNetCore.Identity.SignInOptions:是什么RequireConfirmedAccount以及为什么不同RequireConfirmedEmail?
账户被确认意味着什么?
我按如下方式下载了一个网页.我想将其保存为UTF-8文本.但是怎么样?
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
{
Encoding enc = Encoding.GetEncoding(resp.CharacterSet);
Encoding utf8 = Encoding.UTF8;
using (StreamWriter w = new StreamWriter(new FileStream(pathname, FileMode.Create), utf8))
{
using (StreamReader r = new StreamReader(resp.GetResponseStream()))
{
// This works, but it's bad because you read the whole response into memory:
string s = r.ReadToEnd();
w.Write(s);
// This doesn't work :(
char[] buffer = new char[1024];
int n;
while (!r.EndOfStream)
{
n = r.ReadBlock(buffer, 0, 1024);
w.Write(utf8.GetChars(Encoding.Convert(enc, utf8, enc.GetBytes(buffer))));
}
// …Run Code Online (Sandbox Code Playgroud) 我一直在尝试创建 Azure 函数。
我怎么知道它是否正在运行?
我正在使用ILogger输出日志消息,所以我希望看到它们。
我也有点期待调用和结果的日志。
这样的东西存在吗?
在Startup.cs我添加api/到我的路线模式的开始。
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "api/{controller}/{action=Index}/{id?}");
});
Run Code Online (Sandbox Code Playgroud)
但它没有做任何事情:旧的 URL 继续工作,并且以 return 404 开头的 URL 继续工作。/api这没有任何意义!
如何让我的 API 在 下提供服务/api?
我想使用视图将信息添加到这样的表中
public class PocoTable
{
public int Id { get; set; }
}
public partial class ImportStatingRecordError : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"
CREATE VIEW PocoView
AS
SELECT Id, ISNULL(l.InterestingValue, '?') AS InterestingValue
FROM PocoTable t
LEFT JOIN OtherTable o ON t.Id = o.PocoTableId
");
}
}
public class PocoView : PocoTable
{
public string InterestingValue { get; set; }
}
public class ApplicationDbContext : DbContext
{
public DbSet<PocoTable> PocoTables { get; set; }
public DbSet<PocoView> …Run Code Online (Sandbox Code Playgroud) 我制作了一个操作一些元素的 VueJS 组件<select>。此 UI 的结果是用户选择一个值。
我在组件中有一个函数,computed用于在屏幕上显示用户选择的值。
我如何将此值传递回父 VueJS 事物?
这似乎与此有关$emit,但我没有看到我有活动。
我已经按照此处的建议筹集了一份资金,但现在还没有发生。
在组件中:
computed: {
selectedCode: function () {
var selected = '(No code selected.)';
if (this.category) { selected = this.category; }
if (this.code) { selected = this.code; }
this.$emit('selectedCode', selected);
return selected;
},
Run Code Online (Sandbox Code Playgroud)
在父 Vue 应用程序中:
<code-selector v-bind:code="code" v-on:selectedCode="codeSelect"></sic-selector>
Run Code Online (Sandbox Code Playgroud)
和
methods:
{
selectedCode: function (z) {
console.log(z);
},
Run Code Online (Sandbox Code Playgroud)