InstallerSwitches.cs (4572B)
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.Preview 8 { 9 using System; 10 11 /// <summary> 12 /// Class that contains different types of installer switches like Default, Silent and Verbose. 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 Language installer switch. 38 /// </summary> 39 public string Language { 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 /// Override op_Equality. 53 /// </summary> 54 /// <param name="lhs">left hand side.</param> 55 /// <param name="rhs">right hand side.</param> 56 /// <returns>boolean indicating if the objects are equals.</returns> 57 public static bool operator ==(InstallerSwitches lhs, InstallerSwitches rhs) 58 { 59 return Equals(lhs, rhs); 60 } 61 62 /// <summary> 63 /// Override op_Inequality. 64 /// </summary> 65 /// <param name="lhs">left hand side.</param> 66 /// <param name="rhs">right hand side.</param> 67 /// <returns>boolean indicating if the objects are not equals.</returns> 68 public static bool operator !=(InstallerSwitches lhs, InstallerSwitches rhs) 69 { 70 return !Equals(lhs, rhs); 71 } 72 73 /// <summary> 74 /// Override object.Equals. 75 /// </summary> 76 /// <param name="other">other object.</param> 77 /// <returns>boolean indicating if the objects are equals.</returns> 78 public override bool Equals(object other) 79 { 80 return (other is InstallerSwitches) && this.Equals(other as InstallerSwitches); 81 } 82 83 /// <summary> 84 /// Implemented IEquitable. 85 /// </summary> 86 /// <param name="other">other object.</param> 87 /// <returns>boolean indicating if the objects are equals.</returns> 88 public bool Equals(InstallerSwitches other) 89 { 90 // If parameter is null, return false. 91 if (ReferenceEquals(other, null)) 92 { 93 return false; 94 } 95 96 // Optimization for a common success case. 97 if (ReferenceEquals(this, other)) 98 { 99 return true; 100 } 101 102 // If run-time types are not exactly the same, return false. 103 if (this.GetType() != other.GetType()) 104 { 105 return false; 106 } 107 108 return (this.Custom == other.Custom) && 109 (this.Silent == other.Silent) && 110 (this.SilentWithProgress == other.SilentWithProgress) && 111 (this.Interactive == other.Interactive) && 112 (this.Language == other.Language) && 113 (this.Log == other.Log) && 114 (this.InstallLocation == other.InstallLocation); 115 } 116 117 /// <summary> 118 /// Override object.GetHashCode. Implement if needed. 119 /// to create the hash. 120 /// </summary> 121 /// <returns>resulting hash.</returns> 122 public override int GetHashCode() 123 { 124 return (this.Custom, 125 this.Silent, 126 this.SilentWithProgress, 127 this.Interactive, 128 this.Language, 129 this.Log, 130 this.InstallLocation).GetHashCode(); 131 } 132 } 133 }