variables:
buildSelected: '1.0.0.1234'
steps:
- powershell: |
Write-Host "Build Selected $(buildSelected)"
Write-Host "Escaped '$(buildSelected)'"
displayName: "Escape variable"
Run Code Online (Sandbox Code Playgroud)
我希望打印值 1.0.0.1234 & '$(buildSelected)' 而不是现在打印的内容:
Build Selected 1.0.0.1234
Escaped '1.0.0.1234'
Run Code Online (Sandbox Code Playgroud) Azure DevOps YAML 中变量支持和语法的一致性差异很大。例证:
trigger:
- master
# Variable Group has $(testCategory1) with value
# 'TestCategory=bvttestonly | TestCategory=logintest'
variables:
- group: DYNAMIC_VG
jobs:
- job:
pool: 'MyPool' #Has about 10+ self hosted agents
strategy:
parallel: $[ variables['noOfVMsDynamic']]
variables:
indyx: '$(testCategories$(System.JobPositionInPhase))'
indyx2: $[ variables['indyx'] ]
testCategories: $[ variables[ 'indyx2' ] ]
steps:
- script: |
echo "indyx2 - $(indyx2)"
echo "testCategories $(testCategories)"
displayName: 'Display Test Categories'
Run Code Online (Sandbox Code Playgroud)
该步骤打印:
"indyx2 - $(testCategories1)"
"testCategories $(testCategories1)"
Run Code Online (Sandbox Code Playgroud)
我需要打印变量组中定义的 $(testCategories1) 的值:
'TestCategory=bvttestonly | TestCategory=logintest'
我有一个自托管虚拟机池(MyTestPool),其中一半专门用于安装和测试“ON”版本(打开了很少的功能)和“OFF”版本(这是默认安装)。我的所有测试代理虚拟机都具有“全部”作为用户定义的功能。其中一半也标记为“ON”,另一半标记为“OFF”。
现在,我有两个名为 DEPLOYOOFF 和 DEPLOYON 的阶段,如果变量组变量“skipDeployOffStage”或“skipDeployOnStage”设置为 true,则可以跳过这两个阶段。我想做的是,如果只测试开/关,则使用“全部”作为代理需求。如果要测试“ON”和“OFF”,则相应的阶段将需要它们各自的“ON”或“OFF”VM。
问题:${{ if }} 不起作用。
trigger: none
pr: none
pool: 'MyBuildPool'
variables:
- group: TEST_IF_VARIABLE_GROUP
- name: subPool
value: 'ON'
- name: useAllPool
value: $[ or(eq( variables.skipDeployOnStage, true), eq( variables.skipDeployOffStage, true)) ]
stages:
- stage: DEPLOYOFF
condition: ne(variables['skipDeployOffStage'], 'true')
variables:
# The test stage's subpool
${{ if variables.useAllPool }}:
subPool: 'ALL'
${{ if not(variables.useAllPool) }}:
subPool: 'OFF'
pool:
name: 'MyTestPool'
demands:
- ${{ variables.subPool }}
jobs:
- job:
steps:
- checkout: none
- pwsh: …
Run Code Online (Sandbox Code Playgroud) Image 标签可以正确呈现 SVG 文件,而 ImageButton 则不能。我究竟做错了什么?
<ImageButton Margin="0,10,10,10" Padding="0,0,0,0" CornerRadius="0" Source="cart_dark.png" HeightRequest="24" WidthRequest="24" />
<ImageButton Margin="0,10,10,10" Padding="0,0,0,0" CornerRadius="0" Source="save_dark.png" HeightRequest="24" WidthRequest="24"/>
<ImageButton Margin="0,10,10,10" Padding="0,0,0,0" CornerRadius="0" Source="settings_dark.png" HeightRequest="24" WidthRequest="24"/>
<Image Margin="0,10,10,10" Source="cart_dark.png" HeightRequest="24" WidthRequest="24"/>
<Image Margin="0,10,10,10" Source="save_dark.png" HeightRequest="24" WidthRequest="24"/>
<Image Margin="0,10,50,10" Source="settings_dark.png" HeightRequest="24" WidthRequest="24"/>
Run Code Online (Sandbox Code Playgroud)
SOA的原则之一是:"服务是自治的".我有2项服务.服务A取决于服务B.除非服务B启动并运行,否则服务A无法为客户端提供服务.我是否违反了这一宗旨?
或者,如果自治必须意味着"解耦",那么如果我有故障保护,我是否满足了这个原则(例如,如果主要实例已经关闭,那么另一个运行在其他地方的服务B的实例是连接到的).这可能满足我的可用性要求,但我不确定这如何可以减少我的依赖性.是的,故障保险甚至可以是来自第三方的服务C,在这种情况下,我确实提高了我的自主权.
或者这个原则是否意味着必须将服务设计为"fifedoms",并且具有明确定义的接口,用于获取和输出数据.然而,一些大师似乎认为你甚至需要存储你在内部收到的这些数据,以减少依赖并维持你的自主权......
如果我将服务视为具有消息传递的组件,这是一个错误吗?:)
思考?
在下面的特定方案中,如何使用Linq查找和替换属性:
public interface IPropertyBag { }
public class PropertyBag : IPropertyBag
{
public Property[] Properties { get; set; }
public Property this[string name]
{
get { return Properties.Where((e) => e.Name == name).Single(); }
//TODO: Just copying values... Find out how to find the index and replace the value
set { Properties.Where((e) => e.Name == name).Single().Value = value.Value; }
}
}
Run Code Online (Sandbox Code Playgroud)
感谢您提前帮忙.
Raymond Chen在他最近关于代码优化的帖子中有这样的说法......明显的优化 - 一个需要优化的优化 - 如果考虑所有需要考虑的话,往往会"去优化"...
在您了解更多信息后,我确信您必须遇到/甚至编码优化您感到尴尬...
小心分享?
我对C#的理解说(感谢Jeff Richter和Jon Skeet),任务是"原子的".什么不是当我们混合读写(递增/递减),因此我们需要使用Interlocked上的方法.如果只有Read&assign,那么这两个操作都是原子的吗?
public class Xyz
{
private volatile int _lastValue;
private IList<int> AvailableValues { get; set; }
private object syncRoot = new object();
private Random random = new Random();
//Accessible by multiple threads
public int GetNextValue() //and return last value once store is exhausted
{
//...
var count = 0;
var returnValue = 0;
lock (syncRoot)
{
count = AvailableValues.Count;
}
if (count == 0)
{
//Read... without locking... potential multiple reads
returnValue = _lastValue;
}
else
{
var …
Run Code Online (Sandbox Code Playgroud)