updated nuget packages

This commit is contained in:
Holger Börchers 2020-08-28 20:55:08 +02:00
parent 1cf692547f
commit 8cd47a0252
4 changed files with 21 additions and 23 deletions

View File

@ -57,19 +57,19 @@ namespace ModernWpfPlayground
public Visibility VisibilityEnumTest public Visibility VisibilityEnumTest
{ {
get => GetProperty<Visibility>(); get => GetProperty(Visibility.Visible);
set => SetProperty(value); set => SetProperty(value);
} }
public double SliderTest public double SliderTest
{ {
get => GetProperty<double>(100); get => GetProperty(100D);
set => SetProperty(value); set => SetProperty(value);
} }
public double ValidationTest public double ValidationTest
{ {
get => GetProperty<double>(); get => GetProperty(0D);
set => SetProperty(value); set => SetProperty(value);
} }

View File

@ -9,12 +9,12 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="FastMember" Version="1.5.0" /> <PackageReference Include="FastMember" Version="1.5.0" />
<PackageReference Include="ModernWpfUI" Version="0.9.0" /> <PackageReference Include="ModernWpfUI" Version="0.9.2-preview.200803.0" />
<PackageReference Include="Prism.DryIoc" Version="8.0.0.1740-pre" /> <PackageReference Include="Prism.DryIoc" Version="8.0.0.1850-pre" />
<PackageReference Include="Prism.Wpf" Version="8.0.0.1740-pre" /> <PackageReference Include="Prism.Wpf" Version="8.0.0.1850-pre" />
<PackageReference Include="YamlDotNet" Version="8.1.2" /> <PackageReference Include="YamlDotNet" Version="8.1.2" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" /> <PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.3.0" /> <PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.4.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -16,6 +16,7 @@ namespace ModernWpfPlayground.MvvmStuff
private readonly Dictionary<string, object?> _values = new Dictionary<string, object?>(); private readonly Dictionary<string, object?> _values = new Dictionary<string, object?>();
protected readonly ObjectAccessor ObjectAccessor; protected readonly ObjectAccessor ObjectAccessor;
private readonly Dictionary<string, object?> _defaultValues = new Dictionary<string, object?>();
protected IReadOnlyDictionary<string, object?> Values => _values; protected IReadOnlyDictionary<string, object?> Values => _values;
@ -34,21 +35,21 @@ namespace ModernWpfPlayground.MvvmStuff
protected T GetProperty<T>(T defaultValue = default, [CallerMemberName] string? propertyName = null) protected T GetProperty<T>(T defaultValue = default, [CallerMemberName] string? propertyName = null)
{ {
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName)); if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
return Values.TryGetValue(propertyName, out var obj) ? (T)obj! : defaultValue; if (Values.TryGetValue(propertyName, out var obj))
{
return (T) obj!;
}
_defaultValues[propertyName] =defaultValue;
return defaultValue;
} }
protected void ResetViewModel(Func<string, bool>? predicate = null) protected void ResetViewModel()
{ {
IEnumerable<string> keys = _values.Keys.ToArray(); foreach (var (key, value) in _values.ToArray())
if (predicate != null) keys = keys.Where(predicate);
foreach (var key in keys)
{ {
var currentValue = ObjectAccessor[key]; if (_defaultValues.TryGetValue(key, out var defaultValue) && Equals(value, defaultValue)) continue;
_values.Remove(key); ObjectAccessor[key] = defaultValue;
var newValue = ObjectAccessor[key];
if (Equals(currentValue, newValue)) continue;
_values.Add(key, currentValue);
ObjectAccessor[key] = newValue;
} }
} }
@ -56,14 +57,11 @@ namespace ModernWpfPlayground.MvvmStuff
protected void LoadViewModel() protected void LoadViewModel()
{ {
var keysFromFile = new SortedSet<string>(); ResetViewModel();
foreach (var (key, value) in GetViewModelItems()) foreach (var (key, value) in GetViewModelItems())
{ {
keysFromFile.Add(key);
ObjectAccessor[key] = value; ObjectAccessor[key] = value;
} }
ResetViewModel(x => !keysFromFile.Contains(x));
} }
} }
} }

View File

@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ModernWpfUI" Version="0.9.0" /> <PackageReference Include="ModernWpfUI" Version="0.9.2-preview.200803.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" /> <PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup> </ItemGroup>