Exemplo n.º 1
0
 /// <summary>
 ///     Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>A hash code for the current <see cref="T:System.Object" />.</returns>
 public override int GetHashCode()
 {
     return((Architecture.GetHashCode())
            ^ (string.IsNullOrWhiteSpace(CompatibleIds) ? 0 : CompatibleIds.GetHashCode())
            ^ (string.IsNullOrWhiteSpace(ExcludeIds) ? 0 : ExcludeIds.GetHashCode())
            ^ (string.IsNullOrWhiteSpace(HardwareDescription) ? 0 : HardwareDescription.GetHashCode())
            ^ (string.IsNullOrWhiteSpace(HardwareId) ? 0 : HardwareId.GetHashCode())
            ^ (string.IsNullOrWhiteSpace(ManufacturerName) ? 0 : ManufacturerName.GetHashCode())
            ^ (string.IsNullOrWhiteSpace(ServerName) ? 0 : ServerName.GetHashCode()));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Store the hardware configuration into it's file
        /// </summary>
        /// <param name="description">the hardware description instance</param>
        public static void StoreConfiguration(HardwareDescription description)
        {
            if (!Directory.Exists(AppContext.BaseDirectory + "Data/Hardware/"))
            {
                Directory.CreateDirectory(AppContext.BaseDirectory + "Data/Hardware/");
            }

            JsonSerializer serializer = new JsonSerializer()
            {
                Formatting = Formatting.Indented
            };

            using (StreamWriter writer = new StreamWriter(string.Format("{0}/{1}", AppContext.BaseDirectory, HardwareDescriptionFile)))
                using (JsonWriter jsonWriter = new JsonTextWriter(writer))
                {
                    serializer.Serialize(jsonWriter, HardwareDataManager.Serialize(description));
                }
        }