我正在尝试学习ASP.NET 5.我在Mac OS X上使用它.此时,我有一个如下所示的config.json文件:
config.json
{
"AppSettings": {
"Environment":"dev"
},
"DbSettings": {
"AppConnectionString": "..."
},
"EmailSettings": {
"EmailApiKey": "..."
},
}
Run Code Online (Sandbox Code Playgroud)
我试图弄清楚如何将这些设置加载到Startup.cs中的配置文件中.目前,我有一个看起来像这样的文件:
Configuration.cs
public class AppConfiguration
{
public AppSettings AppSettings { get; set; }
public DbSettings DbSettings { get; set; }
public EmailSettings EmailSettings { get; set; }
}
public class AppSettings
{
public string Environment { get; set; }
}
public class DbSettings
{
public string AppConnectionString { get; set; }
}
public class EmailSettings
{
public string MandrillApiKey …Run Code Online (Sandbox Code Playgroud) 我正在调用第三方API,其方法如下所示:
myServiceClient.Discover(key, OnCompletionCallback);
public bool OnCompletionCallback(string response)
{
// my code
}
Run Code Online (Sandbox Code Playgroud)
我的挑战是,我必须打电话,Discover因为它做了一些我需要的工作.同时,Discover在运行自定义代码之前,我必须等待完成.更复杂的是,我不能把我的代码放在OnCompletionCallback处理程序中,因为我需要从Func委托调用上面的代码.简而言之,我想这样做:
Func<SystemTask> myFunction = async () =>
{
await myServiceClient.Discover(key);
// my code
}
Run Code Online (Sandbox Code Playgroud)
但是,我不能这样做,因为第三方API使用回调方法而不是async/await方法.
有没有办法让回调方法在异步/等待世界中运行?
我有一个Azure DevOps构建管道,该管道具有两个单独的PowerShell脚本。在第一个脚本中,我从XML文件中获取一个值,并将其设置在环境变量中。在第二个脚本中,我想使用环境变量中的值。不幸的是,我没有看到环境变量被设置。目前,我有:
脚本1:
$myXml = [xml](Get-Content ./MyXml.xml)
$departmentId = $myXml.Department.Id
Write-Host ##vso[task.setvariable variable=DepartmentId;]$departmentId
Write-Host "Set environment variable to ($env:DepartmentId)"
Get-ChildItem Env:
Write-Host "Department Id ($departmentId)"
Run Code Online (Sandbox Code Playgroud)
运行脚本1时,我看到:
Set environment variable to ()
[All of the environment variable BUT, I DO NOT SEE ONE NAMED "DepartmentId"]
Department Id (1)
Run Code Online (Sandbox Code Playgroud)
注意:1)该$env:DepartmentId值未在“设置环境变量”语句中打印,并且2)该DepartmentId值未在环境变量列表中列出。我的意图是DepartmentId在第二个脚本中使用它,如下所示:
脚本2:
Write-Host "Using Department: $(env:DepartmentId)"
Run Code Online (Sandbox Code Playgroud)
此时,脚本仅显示:
env:DepartmentId : The term 'env:DepartmentId' is not recognized as the name of a cmdlet, function, script file, or operable program. …Run Code Online (Sandbox Code Playgroud) 我有一个Vue.js应用程序.这个应用程序使用Vuex进行状态管理.我的商店看起来像这样:
const store = new Vuex.Store({
state: {
items: []
},
mutations: {
MUTATE_ITEMS: (state, items) => {
state.items = items;
}
},
actions: {
loadItems: (context, items) => {
context.commit('MUTATE_ITEMS', items);
}
}
})
;
Run Code Online (Sandbox Code Playgroud)
在我的Vue实例中,我有以下方法:
loadItems() {
let items = [];
for (let I=0; I<10; I++) {
items.push({ id:(I+1), name: 'Item #' + (I+1) });
}
this.$store.dispatch('loadItems', items);
},
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我注意到我的子组件中的项目列表没有得到更新.我怀疑这是因为Vue.js中的反应模型.但是,我不确定如何更新整个阵列.另外,我不确定是否需要Vue.set在我的商店突变,存储操作或Vue实例方法本身中使用.我有点困惑.
零件:
<template>
<div>
<h1>Items ({{ items.length }})</h1>
<table>
<tbody>
<tr v-for="item in items" :key="item.id">
<td>{{ item.id …Run Code Online (Sandbox Code Playgroud) 我正在学习NativeScript.作为这项工作的一部分,我正在尝试创建一个向用户显示对话框的页面.当用户单击按钮时,我需要向他们显示一个对话框,允许他们输入两个值(名字和姓氏).
NativeScript中的对话框模块提供了几个内置选项.但是,据我所知,这些选项都不允许您创建一个显示两个字段的对话框.如何在NativeScript中创建一个对话框,允许我提示用户输入名字和姓氏?目前,我的页面如下所示:
page.xml
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<GridLayout rows="auto, *">
<Border borderWidth="1" borderColor="#000" width="28" height="28" cornerRadius="14" tap="addPersonButton_Tap">
<Label text="add person" />
</Border>
</GridLayout>
</Page>
Run Code Online (Sandbox Code Playgroud)
page.js
var viewModel = new MyPageViewModel();
function pageLoaded(args) {
var page = args.object;
page.bindingContext = viewModel;
}
exports.pageLoaded = pageLoaded;
function addPersonButton_Tap(args) {
console.log('new person');
/*
* Dialog open code goes here. Yet, the following definitaly is not correct.
dialogs.prompt({
title: "Add New Person",
message: "First Name",
okButtonText: "Save",
cancelButtonText: "Cancel",
inputType: dialogs.inputType.text …Run Code Online (Sandbox Code Playgroud) 我有一个 PowerShell 脚本,我想在多个构建管道中重复使用该脚本。我的问题是,有没有办法可以在项目或组织范围内“存储”或“保存”我的 PowerShell 脚本,以便我可以在其他构建管道中使用它?如果是这样,怎么办?我似乎找不到办法做到这一点。不过这会非常方便。
该向导有3个步骤.我想为3个步骤之间的过渡设置动画.在第一步,用户可以单击"下一步"按钮.当他们这样做时,按下步骤1的内容并显示步骤2.步骤2还有一个"下一步"按钮,用户可以单击该按钮.单击时,翻转步骤1和步骤2的内容以显示步骤3中的内容.
如果我使用绝对高度,我已经成功地将卡片在Safari中翻转.我已经能够container在Safari中根据需要动态增长.但是,我无法让这两件事在Safari中一起工作.我能够在Chrome和Firefox中这样做.
目前,我有以下Bootply.其具有以下结构:
<section class="container">
<div id="card">
<figure class="front">
<div class="step-2-default" id="step2" style="overflow-x:hidden; padding:0.0rem 1.0rem;">
<label>Step 2</label>
<p>These are the details of the second step</p>
<button id="nextButton2">next</button>
</div>
<div class="step-1-default" id="step1">
<label>Step 1</label>
<p>These are the details of the first step</p>
<button id="nextButton1">next</button>
</div>
</figure>
<figure class="back">
<div id="step3">
<label>Step 3</label>
<p>Thank you for using this wizard</p>
</div>
</figure>
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
在这个Bootply中,卡片翻转起作用.但是,container没有正确渲染.我正试图让卡背后的浅灰色背景随着卡的增长而增长.当第2步显露时,背景应该会增长.但事实并非如此.我无法使用绝对高度,因为每个步骤中的内容都是动态的.
我已经能够获得动态增长的背景.或者,我已经能够让卡正常翻转.但是,我不能让他们在Safari中一起工作.
任何帮助表示赞赏.
我有一个Vue.js应用。该应用是使用Vue-Cli创建的。目前,这是一个基本的“ hello world”应用程序。我在本地计算机上运行了此应用程序。我通过使用npm run serveVisual Studio Code中的“终端”窗口来运行它。我现在正尝试将此应用程序从Visual Studio代码部署到Azure应用程序服务。
我创建了一个Azure应用服务。我还安装了Azure App Service Visual Studio Code扩展。在Visual Studio Code的“终端”窗口中,输入“ npm run build”。这创建了一个名为“ dist”的目录。然后,我右键单击该目录,然后选择“部署到Web App ...”。然后,选择我的订阅和应用程序服务名称,然后选择“部署”。我看到提示“ Deployment to”的提示,然后单击“ Browse Website”按钮。这将启动一个浏览器窗口。在浏览器中,我看到一个初始屏幕,显示“ Hey Node developers!”,但是,我期望来查看我的Node.js应用程序。我想念什么?
为了尝试部署此应用程序,我npm run build从“终端”窗口运行。这创建了一个“ dist”目录。
我有一个基本的Azure Function应用。当我尝试发布该应用程序时,收到一条错误消息:“错误:尝试通过https:// ...发布ZIP文件的操作失败,并显示HTTP状态代码RequestTimeout。”。
该应用程序是.NET Standard应用程序。我按照这里的指示进行。区别在于,我的应用程序具有事件中心触发器,而不是文档中显示的Http触发器。我不明白为什么在部署期间会出现超时。我也不知道该如何克服。
我究竟做错了什么?
更新资料
这是日志。
1>------ Build started: Project: MyProject.Functions, Configuration: Release Any CPU ------
1>MyProject.Functions -> C:\MyProject\MyProject.Functions\bin\Release\netcoreapp2.1\bin\MyProject.Functions.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Publish Started
MyProject.Functions -> C:\MyProject\MyProject.Functions\bin\Release\netcoreapp2.1\bin\MyProject.Functions.dll
MyProject.Functions -> C:\MyProject\MyProject.Functions\obj\Release\netcoreapp2.1\PubTmp\Out\
Publishing C:\MyProject\MyProject.Functions\obj\Release\netcoreapp2.1\PubTmp\MyProject.Functions - 20181101105531356.zip to https://my-project.scm.azurewebsites.net/api/zipdeploy...
C:\Users\me\.nuget\packages\microsoft.net.sdk.functions\1.0.23\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Publish.ZipDeploy.targets(42,5): error : The attempt to publish the ZIP file through https://my-project.scm.azurewebsites.net/api/zipdeploy failed with HTTP status code RequestTimeout. [C:\MyProject\MyProject.Functions\MyProject.Functions.csproj]
Run Code Online (Sandbox Code Playgroud) 我有一个使用Winston进行记录的Node.js应用程序。我正在使用printf打印我的日志,如下所示:
winston.createLogger({
level: 'debug',
format: winston.format.combine(
winston.format.timestamp({ format: 'HH:mm:ss.SSSSS'}),
winston.format.printf(log => `[${log.level}] [${log.timestamp}] ${log.message} `)
),
transports: []
});
Run Code Online (Sandbox Code Playgroud)
除非“错误”日志,否则此方法工作正常。当日志的日志级别为“错误”时,该日志将写入一个格式如下的条目:[${log.level}] [${log.timestamp}] ${log.message}${error.message}。注意,日志消息和错误消息之间没有空格。
如果日志级别为错误,如何在日志消息和错误消息之间放置空格?
azure-devops ×2
c# ×2
javascript ×2
asp.net ×1
async-await ×1
css ×1
deployment ×1
html ×1
nativescript ×1
node.js ×1
powershell ×1
safari ×1
timeout ×1
vue-cli ×1
vue.js ×1
vuex ×1
winston ×1