public static ClientDimension FromPackageStatistic(PackageStatistics packageStatistics) { if (string.IsNullOrEmpty(packageStatistics.UserAgent)) { return Unknown; } ClientDimension result; var parsed = _parser.ParseUserAgent(packageStatistics.UserAgent); if (parsed != null) { if (string.Equals(_other, parsed.Family, StringComparison.OrdinalIgnoreCase)) { return Unknown; } result = new ClientDimension(); result.ClientName = parsed.Family; result.Major = string.IsNullOrWhiteSpace(parsed.Major) ? _zeroString : parsed.Major; result.Minor = string.IsNullOrWhiteSpace(parsed.Minor) ? _zeroString : parsed.Minor; result.Patch = string.IsNullOrWhiteSpace(parsed.Patch) ? _zeroString : parsed.Patch; } else result = Unknown; return result; }
public static ClientDimension FromPackageStatistic(PackageStatistics packageStatistics) { if (string.IsNullOrEmpty(packageStatistics.UserAgent)) { return(Unknown); } ClientDimension result; var parsed = _parser.ParseUserAgent(packageStatistics.UserAgent); if (parsed != null) { if (string.Equals(_other, parsed.Family, StringComparison.OrdinalIgnoreCase)) { return(Unknown); } result = new ClientDimension(); result.ClientName = parsed.Family; result.Major = string.IsNullOrWhiteSpace(parsed.Major) ? _zeroString : parsed.Major; result.Minor = string.IsNullOrWhiteSpace(parsed.Minor) ? _zeroString : parsed.Minor; result.Patch = string.IsNullOrWhiteSpace(parsed.Patch) ? _zeroString : parsed.Patch; } else { result = Unknown; } return(result); }