committed by
GitHub
20 changed files with 328 additions and 123 deletions
@ -0,0 +1,57 @@ |
|||
using System.Globalization; |
|||
using JetBrains.Annotations; |
|||
using Nuke.Common.Tools.DotNet; |
|||
// ReSharper disable ReturnValueOfPureMethodIsNotUsed
|
|||
|
|||
public class DotNetConfigHelper |
|||
{ |
|||
public DotNetBuildSettings Build; |
|||
public DotNetPackSettings Pack; |
|||
public DotNetTestSettings Test; |
|||
|
|||
public DotNetConfigHelper(DotNetBuildSettings s) |
|||
{ |
|||
Build = s; |
|||
} |
|||
|
|||
public DotNetConfigHelper(DotNetPackSettings s) |
|||
{ |
|||
Pack = s; |
|||
} |
|||
|
|||
public DotNetConfigHelper(DotNetTestSettings s) |
|||
{ |
|||
Test = s; |
|||
} |
|||
|
|||
public DotNetConfigHelper AddProperty(string key, bool value) => |
|||
AddProperty(key, value.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()); |
|||
public DotNetConfigHelper AddProperty(string key, string value) |
|||
{ |
|||
Build = Build?.AddProperty(key, value); |
|||
Pack = Pack?.AddProperty(key, value); |
|||
Test = Test?.AddProperty(key, value); |
|||
|
|||
return this; |
|||
} |
|||
|
|||
public DotNetConfigHelper SetConfiguration(string configuration) |
|||
{ |
|||
Build = Build?.SetConfiguration(configuration); |
|||
Pack = Pack?.SetConfiguration(configuration); |
|||
Test = Test?.SetConfiguration(configuration); |
|||
return this; |
|||
} |
|||
|
|||
public DotNetConfigHelper SetVerbosity(DotNetVerbosity verbosity) |
|||
{ |
|||
Build = Build?.SetVerbosity(verbosity); |
|||
Pack = Pack?.SetVerbostiy(verbosity); |
|||
Test = Test?.SetVerbosity(verbosity); |
|||
return this; |
|||
} |
|||
|
|||
public static implicit operator DotNetConfigHelper(DotNetBuildSettings s) => new DotNetConfigHelper(s); |
|||
public static implicit operator DotNetConfigHelper(DotNetPackSettings s) => new DotNetConfigHelper(s); |
|||
public static implicit operator DotNetConfigHelper(DotNetTestSettings s) => new DotNetConfigHelper(s); |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
using System; |
|||
using System.Globalization; |
|||
using Avalonia; |
|||
using Avalonia.Data.Converters; |
|||
|
|||
namespace ControlCatalog.Converter; |
|||
|
|||
public class HexConverter : IValueConverter |
|||
{ |
|||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
var str = value?.ToString(); |
|||
if (str == null) |
|||
return AvaloniaProperty.UnsetValue; |
|||
if (int.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int x)) |
|||
return (decimal)x; |
|||
return AvaloniaProperty.UnsetValue; |
|||
|
|||
} |
|||
|
|||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
try |
|||
{ |
|||
if (value is decimal d) |
|||
return ((int)d).ToString("X8"); |
|||
return AvaloniaProperty.UnsetValue; |
|||
} |
|||
catch |
|||
{ |
|||
return AvaloniaProperty.UnsetValue; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue