You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Components/Extensions/WebUnitsExtensions.cs

19 lines
823 B

// Copyright (c) MudBlazor 2021
// MudBlazor licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Globalization;
namespace Connected.Utilities
{
public static class WebUnitsExtensions
{
public static string ToPx(this int val) => $"{val}px";
public static string ToPx(this int? val) => val != null ? val.Value.ToPx() : string.Empty;
public static string ToPx(this long val) => $"{val}px";
public static string ToPx(this long? val) => val != null ? val.Value.ToPx() : string.Empty;
public static string ToPx(this double val) => $"{val.ToString("0.##", CultureInfo.InvariantCulture)}px";
public static string ToPx(this double? val) => val != null ? val.Value.ToPx() : string.Empty;
}
}