-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to .net7 New features and improvements
- Loading branch information
Showing
48 changed files
with
2,268 additions
and
1,009 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/). | ||
* Copyright (c) 2023 POQDavid | ||
* Copyright (c) contributors | ||
* | ||
* PotatoWall is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PotatoWall is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with PotatoWall. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace PotatoWall; | ||
|
||
using System.Windows; | ||
|
||
/// <copyright file="App.xaml.cs" company="POQDavid"> | ||
/// Copyright (c) POQDavid. All rights reserved. | ||
/// </copyright> | ||
/// <author>POQDavid</author> | ||
/// <summary>This is the App class.</summary> | ||
public partial class App : Application | ||
{ | ||
protected override void OnStartup(StartupEventArgs e) | ||
{ | ||
PotatoWallClient.InitializeComponent(); | ||
|
||
base.OnStartup(e); | ||
|
||
PotatoWallClient.Run(); | ||
} | ||
|
||
private void Application_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e) | ||
{ | ||
PotatoWallClient.Logger.Information("I see loaded!!!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/). | ||
* Copyright (c) 2023 POQDavid | ||
* Copyright (c) contributors | ||
* | ||
* PotatoWall is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PotatoWall is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with PotatoWall. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace PotatoWall.Converters; | ||
|
||
// <copyright file="IntArrayConverter.cs" company="POQDavid"> | ||
// Copyright (c) POQDavid. All rights reserved. | ||
// </copyright> | ||
// <author>POQDavid</author> | ||
// <summary>This is the IntArrayConverter class.</summary> | ||
|
||
public class IntArrayConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
return (targetType.FullName, value.GetType().FullName) switch | ||
{ | ||
("System.String", "System.Int32[]") => value.CastTo<int[]>().ToCSV(), | ||
("System.String", "System.UInt32[]") => value.CastTo<uint[]>().ToCSV(), | ||
_ => throw new NotImplementedException("Not implemented."), | ||
}; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
return (targetType.FullName, value.GetType().FullName) switch | ||
{ | ||
("System.Int32[]", "System.String") => value.CastTo<string>().CSVToArray(true).Select(x => int.Parse(x)).ToArray(), | ||
("System.UInt32[]", "System.String") => value.CastTo<string>().CSVToArray(true).Select(x => uint.Parse(x)).ToArray(), | ||
_ => throw new NotImplementedException("Not implemented."), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/). | ||
* Copyright (c) 2023 POQDavid | ||
* Copyright (c) contributors | ||
* | ||
* PotatoWall is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PotatoWall is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with PotatoWall. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace PotatoWall.Extensions; | ||
|
||
// <copyright file="ArrayExtensions.cs" company="POQDavid"> | ||
// Copyright (c) POQDavid. All rights reserved. | ||
// </copyright> | ||
// <author>POQDavid</author> | ||
// <summary>This is the ArrayExtensions class.</summary> | ||
|
||
public static class ArrayExtensions | ||
{ | ||
/// <summary> | ||
/// Returns a CSV string of the int array | ||
/// </summary> | ||
/// <param name="array"></param> | ||
/// <returns>CSV string</returns> | ||
public static string ToCSV(this int[] array) | ||
{ | ||
return String.Join(", ", array); | ||
} | ||
|
||
/// <summary> | ||
/// Returns a CSV string of the uint array | ||
/// </summary> | ||
/// <param name="array"></param> | ||
/// <returns>CSV string</returns> | ||
public static string ToCSV(this uint[] array) | ||
{ | ||
return String.Join(", ", array); | ||
} | ||
|
||
/// <summary> | ||
/// Returns a CSV string of the int array | ||
/// </summary> | ||
/// <param name="array"></param> | ||
/// <param name="withoutspace">CSV without whitespace</param> | ||
/// <returns>CSV string</returns> | ||
public static string ToCSV(this int[] array, bool withoutspace) | ||
{ | ||
return withoutspace switch | ||
{ | ||
true => String.Join(",", array).RemoveWhitespace(), | ||
false => String.Join(", ", array), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace PotatoWall.Extensions; | ||
|
||
public static class DictionaryExtensions | ||
{ | ||
public static TValue Pop<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key) | ||
{ | ||
if (dictionary.TryGetValue(key, out TValue temp)) | ||
{ | ||
dictionary.Remove(key); | ||
return temp; | ||
} | ||
else | ||
{ | ||
throw new KeyNotFoundException($"Key {key} not found in dictionary."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* This file is part of PotatoWall distribution (https://github.com/poqdavid/PotatoWall or http://poqdavid.github.io/PotatoWall/). | ||
* Copyright (c) 2023 POQDavid | ||
* Copyright (c) contributors | ||
* | ||
* PotatoWall is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PotatoWall is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with PotatoWall. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace PotatoWall.Extensions; | ||
|
||
// <copyright file="ObjectExtensions.cs" company="POQDavid"> | ||
// Copyright (c) POQDavid. All rights reserved. | ||
// </copyright> | ||
// <author>POQDavid</author> | ||
// <summary>This is the ObjectExtensions class.</summary> | ||
|
||
public static class ObjectExtensions | ||
{ | ||
/// <summary> | ||
/// Cast's a System.Object to T | ||
/// </summary> | ||
/// <typeparam name="T">Type to cast to</typeparam> | ||
/// <param name="value"></param> | ||
/// <returns></returns> | ||
/// <exception cref="ArgumentNullException"></exception> | ||
public static T CastTo<T>(this object value) | ||
{ | ||
if (value == null) throw new ArgumentNullException(nameof(value)); | ||
|
||
if (value is T t) return t; | ||
|
||
throw new Exception($"Casting from {value.GetType().FullName} to {typeof(T).FullName} wasn't successful."); | ||
} | ||
|
||
/// <summary> | ||
/// Cast's a System.Object to T | ||
/// </summary> | ||
/// <typeparam name="T">Type to cast to</typeparam> | ||
/// <param name="value"></param> | ||
/// <param name="success"></param> | ||
/// <returns></returns> | ||
public static T TryCastTo<T>(this object value, out bool success) | ||
{ | ||
success = true; | ||
|
||
if (value == null) | ||
{ | ||
success = false; | ||
return default; | ||
} | ||
|
||
if (value is T t) | ||
return t; | ||
|
||
success = false; | ||
return default; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.