diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Common/Extensions.cs | 30 | ||||
| -rw-r--r-- | src/slskd/Common/IStateMonitor.cs | 40 | ||||
| -rw-r--r-- | src/slskd/Common/IStateMutator.cs | 14 | ||||
| -rw-r--r-- | src/slskd/Common/IStateSnapshot.cs | 7 | ||||
| -rw-r--r-- | src/slskd/Common/ManagedState.cs | 5 | ||||
| -rw-r--r-- | src/slskd/Program.cs | 2 |
6 files changed, 4 insertions, 94 deletions
diff --git a/src/slskd/Common/Extensions.cs b/src/slskd/Common/Extensions.cs index 077f5b17..4f2cf29f 100644 --- a/src/slskd/Common/Extensions.cs +++ b/src/slskd/Common/Extensions.cs @@ -89,36 +89,6 @@ namespace slskd } /// <summary> - /// Computes a stable/consistent hash code for strings. - /// </summary> - /// <remarks> - /// https://stackoverflow.com/questions/5154970/how-do-i-create-a-hashcode-in-net-c-for-a-string-that-is-safe-to-store-in-a - /// </remarks> - /// <param name="str">The string for which the hash code is to be computed.</param> - /// <returns>The hash code.</returns> - public static int GetStableHashCode(this string str) - { - unchecked - { - int hash1 = 5381; - int hash2 = hash1; - - for (int i = 0; i < str.Length && str[i] != '\0'; i += 2) - { - hash1 = ((hash1 << 5) + hash1) ^ str[i]; - if (i == str.Length - 1 || str[i + 1] == '\0') - { - break; - } - - hash2 = ((hash2 << 5) + hash2) ^ str[i + 1]; - } - - return hash1 + (hash2 * 1566083941); - } - } - - /// <summary> /// Determines whether the string is a valid regular expression. /// </summary> /// <param name="pattern">The string to validate.</param> diff --git a/src/slskd/Common/IStateMonitor.cs b/src/slskd/Common/IStateMonitor.cs deleted file mode 100644 index 9600e37a..00000000 --- a/src/slskd/Common/IStateMonitor.cs +++ /dev/null @@ -1,40 +0,0 @@ -//// <copyright file="IStateMonitor.cs" company="slskd Team"> -//// Copyright (c) slskd Team. All rights reserved. -//// -//// This program is free software: you can redistribute it and/or modify -//// it under the terms of the GNU Affero General Public License as published -//// by the Free Software Foundation, either version 3 of the License, or -//// (at your option) any later version. -//// -//// This program 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 Affero General Public License for more details. -//// -//// You should have received a copy of the GNU Affero General Public License -//// along with this program. If not, see https://www.gnu.org/licenses/. -//// </copyright> - -//namespace slskd -//{ -// using System; - -// /// <summary> -// /// Provideds observable management of state objects. -// /// </summary> -// /// <typeparam name="T">The type of the tracked state object.</typeparam> -// public interface IStateMonitor<T> -// { -// /// <summary> -// /// Gets the current application state. -// /// </summary> -// T CurrentValue { get; } - -// /// <summary> -// /// Registers a listener to be called whenever the tracked state changes. -// /// </summary> -// /// <param name="listener">Registers a listener to be called whenver state changes.</param> -// /// <returns>An <see cref="IDisposable"/> which should be disposed to stop listening for changes.</returns> -// IDisposable OnChange(Action<(T Previous, T Current)> listener); -// } -//} diff --git a/src/slskd/Common/IStateMutator.cs b/src/slskd/Common/IStateMutator.cs deleted file mode 100644 index b4f35e78..00000000 --- a/src/slskd/Common/IStateMutator.cs +++ /dev/null @@ -1,14 +0,0 @@ -//using System; - -//namespace slskd -//{ -// public interface IStateMutator<T> -// { -// /// <summary> -// /// Replaces the current state with the value resolved by the <paramref name="setter"/>. -// /// </summary> -// /// <param name="setter">Given the current state, resolves a new state value.</param> -// /// <returns>The updated state.</returns> -// T SetValue(Func<T, T> setter); -// } -//} diff --git a/src/slskd/Common/IStateSnapshot.cs b/src/slskd/Common/IStateSnapshot.cs deleted file mode 100644 index 56113ca4..00000000 --- a/src/slskd/Common/IStateSnapshot.cs +++ /dev/null @@ -1,7 +0,0 @@ -//namespace slskd -//{ -// public interface IStateSnapshot<T> -// { -// T Value { get; } -// } -//} diff --git a/src/slskd/Common/ManagedState.cs b/src/slskd/Common/ManagedState.cs index 0453aa06..bfde3c80 100644 --- a/src/slskd/Common/ManagedState.cs +++ b/src/slskd/Common/ManagedState.cs @@ -18,6 +18,7 @@ namespace slskd { using System; + using System.Text.Json; using Microsoft.Extensions.DependencyInjection; /// <summary> @@ -57,7 +58,7 @@ namespace slskd /// Provides point-in-time read access for state objects. /// </summary> /// <typeparam name="T">The type of the tracked state object.</typeparam> - public interface IStateSnapshot<T> + public interface IStateSnapshot<out T> { /// <summary> /// Gets the snapshotted state. @@ -133,7 +134,7 @@ namespace slskd /// <param name="value">The current value of the state.</param> public StateSnapshot(T value) { - Value = value.ToJson().ToObject<T>(); + Value = JsonSerializer.Deserialize<T>(JsonSerializer.Serialize(value)); } /// <summary> diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index ec672f23..9590ed48 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -89,7 +89,7 @@ namespace slskd /// <remarks> /// Inaccurate when running locally. /// </remarks> - public static Version AssemblyVersion { get; } = Assembly.GetExecutingAssembly().GetName().Version.Equals(new Version(1,0,0,0)) ? new Version(0, 0, 0, 0) : Assembly.GetExecutingAssembly().GetName().Version; + public static Version AssemblyVersion { get; } = Assembly.GetExecutingAssembly().GetName().Version.Equals(new Version(1, 0, 0, 0)) ? new Version(0, 0, 0, 0) : Assembly.GetExecutingAssembly().GetName().Version; /// <summary> /// Gets the informational version of the application, including the git sha at the latest commit. |
