FilterAttribute[] GetFilters(string alias) { if (!Descriptions.ContainsKey(alias) || Descriptions[alias].IsNullOrEmpty()) { return new FilterAttribute[] { new FilterAttribute(FilterType.None, DeclensionCase.NotDefind) } } ; return(Descriptions[alias]); }
public static bool CompareFullCriticalOnly(VulpesSMARTInfo a, VulpesSMARTInfo b) { if (a.PNPDeviceID != b.PNPDeviceID || a.Caption != b.Caption || a.FirmwareRevision != b.FirmwareRevision || a.InterfaceType != b.InterfaceType || a.Model != b.Model || a.Name != b.Name || a.PredictFailure != b.PredictFailure || a.SerialNumber != b.SerialNumber || a.Size != b.Size || a.Status != b.Status) { return(true); } if (a.Attributes == null && b.Attributes == null) { return(true); } foreach (KeyValuePair <int, VulpesSMARTAttribute> kvp in a.Attributes) { if (b.Attributes.ContainsKey(kvp.Key) == false) { continue; } if (kvp.Value.FailureImminent != b.Attributes[kvp.Key].FailureImminent || kvp.Value.Flags != b.Attributes[kvp.Key].Flags || kvp.Value.ID != b.Attributes[kvp.Key].ID || kvp.Value.Threshold != b.Attributes[kvp.Key].Threshold || kvp.Value.Value != b.Attributes[kvp.Key].Value || kvp.Value.Vendordata != b.Attributes[kvp.Key].Vendordata || kvp.Value.Worst != b.Attributes[kvp.Key].Worst) { if (Descriptions.ContainsKey(kvp.Key) == false) { continue; } if (Descriptions[kvp.Key].Ideal == SMARTDescriptionEnum.Critical) { return(false); } } } return(true); }
internal void AddUnitsNetDescription(UnitsNetDescription description, string unitsCoreName = null) { lock (_lock) { var unitsCoreUnit = GetUnit(unitsCoreName ?? description.Name); if (unitsCoreUnit is null) { IUnit uppers = null, downers = null; foreach (var bd in description.BaseDimensions?.Where(i => i.Value < 0) ?? Enumerable.Empty <KeyValuePair <string, int> >()) { var a = Metadata.Basedimensions.Bases[bd.Key]; var n = bd.Value * -1; while (--n >= 0) { if (downers is null) { downers = a; } else { downers = new BinaryCompositUnit(downers, BinaryOperator.TIMES, a); } } } foreach (var bd in description.BaseDimensions?.Where(i => i.Value > 0) ?? Enumerable.Empty <KeyValuePair <string, int> >()) { var a = Metadata.Basedimensions.Bases[bd.Key]; var n = bd.Value; while (--n >= 0) { if (uppers is null) { uppers = a; } else { uppers = new BinaryCompositUnit(uppers, BinaryOperator.TIMES, a); } } } unitsCoreUnit = downers is null? uppers?.Rename(unitsCoreName ?? description.Name) ?? Scalar.Get: new BinaryCompositUnit(uppers ?? Scalar.Get, BinaryOperator.OVER, downers, unitsCoreName ?? description.Name, false); if (!Units.Add(unitsCoreUnit)) { var old = Units.First(i => i.Equals(unitsCoreUnit)); if (old.Name.Length > unitsCoreUnit.Name.Length) { Units.Remove(old); Units.Add(unitsCoreUnit); } } } if (Descriptions.ContainsKey(unitsCoreUnit)) { Descriptions[unitsCoreUnit].Add(description); } else { Descriptions.Add(unitsCoreUnit, new List <UnitsNetDescription> { description }); } var adds = description.Units .ToMesurmentUnits(unitsCoreUnit) .Select(this.MesurmentUnits.Add) .ToList(); } }