winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Installer.cs (1329B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 
      4 namespace WinGetSourceCreator.Model
      5 {
      6     public abstract class Installer
      7     {
      8         public InstallerType Type { get; set; }
      9 
     10         // The name of the installer when it copied or created.
     11         public string Name { get; set; } = string.Empty;
     12 
     13         // The identifying token of the installer in the manifests.
     14         public string? HashToken { get; set; }
     15 
     16         // An optional token relevant to the installer.
     17         // If the installer is an msix, this is the token used for the appx signature hash.
     18         public string? SignatureToken { get; set; }
     19 
     20         public Signature? Signature { get; set; }
     21 
     22         public bool SkipSignature { get; set; }
     23 
     24         protected void Validate()
     25         {
     26             if (string.IsNullOrEmpty(this.Name))
     27             {
     28                 throw new ArgumentNullException(nameof(this.Name));
     29             }
     30 
     31             if (this.Signature != null)
     32             {
     33                 this.Signature.Validate();
     34             }
     35 
     36             if (this.Type != InstallerType.Msix && !string.IsNullOrEmpty(this.SignatureToken))
     37             {
     38                 throw new Exception($"{nameof(this.SignatureToken)} can only be used for MSIX");
     39             }
     40         }
     41     }
     42 }