mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-27 10:07:10 +00:00
76 lines
4.5 KiB
PowerShell
76 lines
4.5 KiB
PowerShell
function Add-ToolFolder([System.String] $folder)
|
||
{
|
||
$flattenedValue = Get-ExtenderPropertyValue
|
||
|
||
$allFolders = New-Object "System.Collections.Generic.List``1[System.String]"
|
||
|
||
if($flattenedValue.Length -gt 0)
|
||
{
|
||
$allFolders.AddRange($flattenedValue.Split(';'))
|
||
}
|
||
|
||
if( -not $allFolders.Contains($folder) )
|
||
{
|
||
$allFolders.Add($folder)
|
||
|
||
$flattenedValue = [System.String]::Join(';', $allFolders.ToArray())
|
||
Set-ExtenderPropertyValue($flattenedValue)
|
||
}
|
||
}
|
||
|
||
function Remove-ToolFolder([System.String] $folder)
|
||
{
|
||
$flattenedValue = Get-ExtenderPropertyValue
|
||
|
||
$allFolders = New-Object "System.Collections.Generic.List``1[System.String]"
|
||
|
||
if($flattenedValue.Length -gt 0)
|
||
{
|
||
$allFolders.AddRange($flattenedValue.Split(';'))
|
||
}
|
||
|
||
if( $allFolders.Remove($folder) )
|
||
{
|
||
$flattenedValue = [System.String]::Join(';', $allFolders.ToArray())
|
||
Set-ExtenderPropertyValue($flattenedValue)
|
||
}
|
||
}
|
||
|
||
|
||
function Get-ExtenderPropertyValue
|
||
{
|
||
if( $dte.Solution.Globals.VariableExists("EnterpriseLibraryConfigurationToolBinariesPath") -and $dte.Solution.Globals.VariablePersists("EnterpriseLibraryConfigurationToolBinariesPath") )
|
||
{
|
||
return $dte.Solution.Globals.VariableValue("EnterpriseLibraryConfigurationToolBinariesPath")
|
||
}
|
||
|
||
|
||
return ""
|
||
}
|
||
|
||
function Set-ExtenderPropertyValue([System.String] $value)
|
||
{
|
||
if( [System.String]::IsNullOrWhiteSpace($value) )
|
||
{
|
||
if( $dte.Solution.Globals.VariableExists("EnterpriseLibraryConfigurationToolBinariesPath") )
|
||
{
|
||
$dte.Solution.Globals.VariablePersists("EnterpriseLibraryConfigurationToolBinariesPath") = $False
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$dte.Solution.Globals.VariableValue("EnterpriseLibraryConfigurationToolBinariesPath") = $value
|
||
$dte.Solution.Globals.VariablePersists("EnterpriseLibraryConfigurationToolBinariesPath") = $True
|
||
}
|
||
}
|
||
|
||
function Get-RelativePath([System.String] $basePath, [System.String] $targetPath)
|
||
{
|
||
# not a general purpose relative path calculation algorithm
|
||
|
||
return ($targetPath.Substring($basePath.Length)).TrimStart([System.Io.Path]::DirectorySeparatorChar)
|
||
}
|
||
|
||
function Cleanup
|
||
{
|
||
}
|