mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-01 00:46:33 +01:00
47 lines
1.1 KiB
PowerShell
47 lines
1.1 KiB
PowerShell
|
[cmdletbinding()]
|
||
|
|
||
|
Param($appName, $merchantId)
|
||
|
|
||
|
# Sets a text to a given value.
|
||
|
function Update-Text()
|
||
|
{
|
||
|
param(
|
||
|
[String] $TargetFileName,
|
||
|
[String] $FindText,
|
||
|
[String] $ReplaceText)
|
||
|
|
||
|
if (-not(Test-Path -Path $TargetFileName)) {
|
||
|
Write-Host "File " + $TargetFileName + " not found!"
|
||
|
return -1
|
||
|
}
|
||
|
|
||
|
((Get-Content -path $TargetFileName -Raw) -replace $FindText, $ReplaceText) | Set-Content -Path $TargetFileName -Encoding utf8 -NoNewline
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
# Sets merchant-id for a single app to a given value.
|
||
|
function Set-MerchantId()
|
||
|
{
|
||
|
param(
|
||
|
[String] $ProjectName,
|
||
|
[String] $MerchantId)
|
||
|
|
||
|
if ($MerchantId.Length -le 2)
|
||
|
{
|
||
|
Write-Host "Merchant id api key must not be of lenght <= 2"
|
||
|
return -1
|
||
|
}
|
||
|
$fileName = Convert-Path ('.\' + $ProjectName + '\TINK\App.xaml.cs')
|
||
|
|
||
|
$retVal = Update-Text $fileName "const string MERCHANTID = `".*`"" "const string MERCHANTID = `"$MerchantId`""
|
||
|
if ($retVal -ne 0)
|
||
|
{
|
||
|
return $retVal
|
||
|
}
|
||
|
Write-Host "File `"$fileName`" updated sucessfully (.."$MerchantId.Substring($MerchantId.Length - 2, 2)")."
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
return Set-MerchantId $appName $merchantId
|
||
|
|