Refactor the format of saved app associations
This commit is contained in:
parent
41696d2078
commit
a6d438d9c2
1 changed files with 7 additions and 0 deletions
|
@ -28,10 +28,17 @@ $null = New-Module {
|
||||||
|
|
||||||
$association.ProgId = $progId;
|
$association.ProgId = $progId;
|
||||||
$association.ApplicationName = $applicationName;
|
$association.ApplicationName = $applicationName;
|
||||||
|
[AppAssociations]::SaveAssociations($associations);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SaveAssociations([xml] $associations) {
|
||||||
|
$defaultAssociations = $associations.SelectNodes([AppAssociations]::associationSelector);
|
||||||
|
$defaultAssociations | ForEach-Object { $associations.RemoveChild($_); } | Sort-Object -Property "Identifier" | ForEach-Object { $associations.AppendChild($_); };
|
||||||
|
|
||||||
$configFile = New-TemporaryFile;
|
$configFile = New-TemporaryFile;
|
||||||
$writerSettings = [System.Xml.XmlWriterSettings]::new();
|
$writerSettings = [System.Xml.XmlWriterSettings]::new();
|
||||||
$writerSettings.Indent = $true;
|
$writerSettings.Indent = $true;
|
||||||
|
$writerSettings.IndentChars = " ";
|
||||||
$writerSettings.Encoding = [System.Text.UTF8Encoding]::new();
|
$writerSettings.Encoding = [System.Text.UTF8Encoding]::new();
|
||||||
$writer = [System.Xml.XmlWriter]::Create($configFile.FullName, $writerSettings);
|
$writer = [System.Xml.XmlWriter]::Create($configFile.FullName, $writerSettings);
|
||||||
$associations.Save($writer);
|
$associations.Save($writer);
|
||||||
|
|
Loading…
Reference in a new issue