winget-cli

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

InstallerSwitches.cs (4783B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="InstallerSwitches.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.WinGetUtil.Models.V1
      8 {
      9     using System;
     10 
     11     /// <summary>
     12     /// Class that contains different types of installer switches like Custom, Silent and Interactive.
     13     /// </summary>
     14     public class InstallerSwitches : IEquatable<InstallerSwitches>
     15     {
     16         /// <summary>
     17         /// Gets or sets the Custom installer switch.
     18         /// </summary>
     19         public string Custom { get; set; }
     20 
     21         /// <summary>
     22         /// Gets or sets the Silent installer switch.
     23         /// </summary>
     24         public string Silent { get; set; }
     25 
     26         /// <summary>
     27         /// Gets or sets the SilentWithProgress installer switch.
     28         /// </summary>
     29         public string SilentWithProgress { get; set; }
     30 
     31         /// <summary>
     32         /// Gets or sets the Interactive installer switch.
     33         /// </summary>
     34         public string Interactive { get; set; }
     35 
     36         /// <summary>
     37         /// Gets or sets the Upgrade installer switch.
     38         /// </summary>
     39         public string Upgrade { get; set; }
     40 
     41         /// <summary>
     42         /// Gets or sets the Log installer switch.
     43         /// </summary>
     44         public string Log { get; set; }
     45 
     46         /// <summary>
     47         /// Gets or sets the install location switch.
     48         /// </summary>
     49         public string InstallLocation { get; set; }
     50 
     51         /// <summary>
     52         /// Gets or sets the repair switch.
     53         /// </summary>
     54         public string Repair { get; set; }
     55 
     56         /// <summary>
     57         /// Override op_Equality.
     58         /// </summary>
     59         /// <param name="lhs">left hand side.</param>
     60         /// <param name="rhs">right hand side.</param>
     61         /// <returns>boolean indicating if the objects are equals.</returns>
     62         public static bool operator ==(InstallerSwitches lhs, InstallerSwitches rhs)
     63         {
     64             return Equals(lhs, rhs);
     65         }
     66 
     67         /// <summary>
     68         /// Override op_Inequality.
     69         /// </summary>
     70         /// <param name="lhs">left hand side.</param>
     71         /// <param name="rhs">right hand side.</param>
     72         /// <returns>boolean indicating if the objects are not equals.</returns>
     73         public static bool operator !=(InstallerSwitches lhs, InstallerSwitches rhs)
     74         {
     75             return !Equals(lhs, rhs);
     76         }
     77 
     78         /// <summary>
     79         /// Override object.Equals.
     80         /// </summary>
     81         /// <param name="other">other object.</param>
     82         /// <returns>boolean indicating if the objects are equals.</returns>
     83         public override bool Equals(object other)
     84         {
     85             return (other is InstallerSwitches) && this.Equals(other as InstallerSwitches);
     86         }
     87 
     88         /// <summary>
     89         /// Implemented IEquitable.
     90         /// </summary>
     91         /// <param name="other">other object.</param>
     92         /// <returns>boolean indicating if the objects are equals.</returns>
     93         public bool Equals(InstallerSwitches other)
     94         {
     95             // If parameter is null, return false.
     96             if (ReferenceEquals(other, null))
     97             {
     98                 return false;
     99             }
    100 
    101             // Optimization for a common success case.
    102             if (ReferenceEquals(this, other))
    103             {
    104                 return true;
    105             }
    106 
    107             // If run-time types are not exactly the same, return false.
    108             if (this.GetType() != other.GetType())
    109             {
    110                 return false;
    111             }
    112 
    113             return (this.Custom == other.Custom) &&
    114                    (this.Silent == other.Silent) &&
    115                    (this.SilentWithProgress == other.SilentWithProgress) &&
    116                    (this.Interactive == other.Interactive) &&
    117                    (this.Upgrade == other.Upgrade) &&
    118                    (this.Log == other.Log) &&
    119                    (this.InstallLocation == other.InstallLocation) &&
    120                    (this.Repair == other.Repair);
    121         }
    122 
    123         /// <summary>
    124         /// Override object.GetHashCode. Implement if needed.
    125         /// to create the hash.
    126         /// </summary>
    127         /// <returns>resulting hash.</returns>
    128         public override int GetHashCode()
    129         {
    130             return (this.Custom,
    131                     this.Silent,
    132                     this.SilentWithProgress,
    133                     this.Interactive,
    134                     this.Upgrade,
    135                     this.Log,
    136                     this.InstallLocation,
    137                     this.Repair).GetHashCode();
    138         }
    139     }
    140 }