winget-cli

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

ManifestInstaller.cs (4206B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="ManifestInstaller.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.WinGetUtil.Models.Preview
      8 {
      9     using System;
     10 
     11     /// <summary>
     12     /// Class that contains the elements that represent what an installer element can contain in the manifest file.
     13     /// </summary>
     14     public class ManifestInstaller
     15     {
     16         /// <summary>
     17         /// Gets or sets the architecture of the installer. Values: x86, x64, arm, arm64, all.
     18         /// </summary>
     19         public string Arch { get; set; }
     20 
     21         /// <summary>
     22         /// Gets or sets the URL of the installer.
     23         /// </summary>
     24         public string Url { get; set; }
     25 
     26         /// <summary>
     27         /// Gets or sets the SHA256 hash of the installer. Required element.
     28         /// </summary>
     29         public string Sha256 { get; set; }
     30 
     31         /// <summary>
     32         /// Gets or sets the signature SHA256 for an appx/msix. Only used by appx/msix type.
     33         /// </summary>
     34         public string SignatureSha256 { get; set; }
     35 
     36         /// <summary>
     37         /// Gets or sets the localization of the installer. Empty indicates default.
     38         /// </summary>
     39         public string Language { get; set; }
     40 
     41         /// <summary>
     42         /// Gets or sets the scope. Name to be decided.
     43         /// </summary>
     44         public string Scope { get; set; }
     45 
     46         /// <summary>
     47         /// Gets or sets the Store ProductId. Only used when InstallerType is MSStore.
     48         /// </summary>
     49         public string ProductId { get; set; }
     50 
     51         /// <summary>
     52         /// Gets or sets the installer type. If present, has more precedence than root.
     53         /// </summary>
     54         public string InstallerType { get; set; }
     55 
     56         /// <summary>
     57         /// Gets or sets the installer switches. If present, has more precedence than root.
     58         /// </summary>
     59         public InstallerSwitches Switches { get; set; }
     60 
     61         /// <summary>
     62         /// Override object.Equals.
     63         /// </summary>
     64         /// <param name="other">other object.</param>
     65         /// <returns>boolean indicating if the objects are equals.</returns>
     66         public override bool Equals(object other)
     67         {
     68             return (other is ManifestInstaller) && this.Equals(other as ManifestInstaller);
     69         }
     70 
     71         /// <summary>
     72         /// Implemented IEquitable.
     73         /// </summary>
     74         /// <param name="other">other object.</param>
     75         /// <returns>boolean indicating if the objects are equals.</returns>
     76         public bool Equals(ManifestInstaller other)
     77         {
     78             // If parameter is null, return false.
     79             if (ReferenceEquals(other, null))
     80             {
     81                 return false;
     82             }
     83 
     84             // Optimization for a common success case.
     85             if (ReferenceEquals(this, other))
     86             {
     87                 return true;
     88             }
     89 
     90             // If run-time types are not exactly the same, return false.
     91             if (this.GetType() != other.GetType())
     92             {
     93                 return false;
     94             }
     95 
     96             return (this.Arch == other.Arch) &&
     97                    (this.Url == other.Url) &&
     98                    (this.Sha256 == other.Sha256) &&
     99                    (this.SignatureSha256 == other.SignatureSha256) &&
    100                    (this.Language == other.Language) &&
    101                    (this.Scope == other.Scope) &&
    102                    (this.InstallerType == other.InstallerType) &&
    103                    (this.Switches == other.Switches);
    104     }
    105 
    106         /// <summary>
    107         /// Override object.GetHashCode.
    108         /// </summary>
    109         /// <returns>resulting hash.</returns>
    110         public override int GetHashCode()
    111         {
    112             return (this.Arch,
    113                     this.Url,
    114                     this.SignatureSha256,
    115                     this.Language,
    116                     this.Scope,
    117                     this.InstallerType,
    118                     this.Switches).GetHashCode();
    119         }
    120     }
    121 }