Skip to content

Commit

Permalink
chore: move all extensions to their own namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Dec 6, 2024
1 parent 0a7b8b5 commit eabdf49
Show file tree
Hide file tree
Showing 31 changed files with 33 additions and 40 deletions.
1 change: 1 addition & 0 deletions Shokofin/API/Info/EpisodeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Shokofin.API.Models.TMDB;
using Shokofin.Configuration;
using Shokofin.Events.Interfaces;
using Shokofin.Extensions;
using Shokofin.Utils;

namespace Shokofin.API.Info;
Expand Down
8 changes: 1 addition & 7 deletions Shokofin/API/Models/ApiException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Net;
using System.Net.Http;
using System.Text.Json;
using Shokofin.Extensions;

namespace Shokofin.API.Models;

Expand Down Expand Up @@ -81,10 +82,3 @@ public enum ApiExceptionType {
RemoteException = 2,
}
}

public static class IListExtension {
public static void Deconstruct<T>(this IList<T> list, out T? first, out IList<T> rest) {
first = list.Count > 0 ? list[0] : default; // or throw
rest = list.Skip(1).ToList();
}
}
1 change: 1 addition & 0 deletions Shokofin/API/Models/ComponentVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Linq;
using System.Text.Json.Serialization;
using Shokofin.Extensions;

namespace Shokofin.API.Models;

Expand Down
21 changes: 0 additions & 21 deletions Shokofin/API/Models/Relation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,3 @@ public enum RelationType {
/// </summary>
Summary = 42,
}

/// <summary>
/// Extensions related to relations
/// </summary>
public static class RelationExtensions {
/// <summary>
/// Reverse the relation.
/// </summary>
/// <param name="type">The relation to reverse.</param>
/// <returns>The reversed relation.</returns>
public static RelationType Reverse(this RelationType type)
=> type switch {
RelationType.Prequel => RelationType.Sequel,
RelationType.Sequel => RelationType.Prequel,
RelationType.MainStory => RelationType.SideStory,
RelationType.SideStory => RelationType.MainStory,
RelationType.FullStory => RelationType.Summary,
RelationType.Summary => RelationType.FullStory,
_ => type
};
}
1 change: 1 addition & 0 deletions Shokofin/API/ShokoAPIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Path = System.IO.Path;
using Regex = System.Text.RegularExpressions.Regex;
using RegexOptions = System.Text.RegularExpressions.RegexOptions;
using Shokofin.Extensions;

namespace Shokofin.API;

Expand Down
1 change: 1 addition & 0 deletions Shokofin/Collections/CollectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.Extensions.Logging;
using Shokofin.API;
using Shokofin.API.Info;
using Shokofin.Extensions;
using Shokofin.ExternalIds;
using Shokofin.Utils;

Expand Down
1 change: 1 addition & 0 deletions Shokofin/Configuration/MediaFolderConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.Extensions.Logging;
using Shokofin.API;
using Shokofin.Configuration.Models;
using Shokofin.Extensions;
using Shokofin.Utils;

namespace Shokofin.Configuration;
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions Shokofin/Events/EventDispatchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Shokofin.API.Models;
using Shokofin.Configuration;
using Shokofin.Events.Interfaces;
using Shokofin.Extensions;
using Shokofin.ExternalIds;
using Shokofin.Resolvers;
using Shokofin.Resolvers.Models;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Jellyfin.Data.Enums;
using MediaBrowser.Model.Entities;

namespace Shokofin;
namespace Shokofin.Extensions;

public static class CollectionTypeExtensions {
public static CollectionType? ConvertToCollectionType(this CollectionTypeOptions? collectionType)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;
using MediaBrowser.Controller.Entities;

namespace Shokofin;
namespace Shokofin.Extensions;

public static class FolderExtensions {
public static string GetVirtualRoot(this Folder libraryFolder)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace Shokofin;
namespace Shokofin.Extensions;

public static class ListExtensions {
public static bool TryRemoveAt<T>(this List<T> list, int index, [NotNullWhen(true)] out T? item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Controller.Entities;
using Shokofin.Configuration;

namespace Shokofin.Configuration;
namespace Shokofin.Extensions;

public static class MediaFolderConfigurationExtensions {
public static Folder GetFolderForPath(this string mediaFolderPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using MediaBrowser.Model.Entities;
using Shokofin.ExternalIds;

namespace Shokofin;
namespace Shokofin.Extensions;

public static partial class StringExtensions {
public static string Replace(this string input, Regex regex, string replacement, int count, int startAt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using MediaBrowser.Controller.Entities;
using Shokofin.API.Models;

namespace Shokofin.Sync;
namespace Shokofin.Extensions;

public static class SyncExtensions {
public static File.UserStats ToFileUserStats(this UserItemData userData) {
Expand Down
1 change: 1 addition & 0 deletions Shokofin/IdLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
using Shokofin.API;
using Shokofin.Extensions;
using Shokofin.ExternalIds;
using Shokofin.Providers;

Expand Down
1 change: 1 addition & 0 deletions Shokofin/MergeVersions/MergeVersionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using MediaBrowser.Model.Entities;
using Microsoft.Extensions.Logging;
using Shokofin.API;
using Shokofin.Extensions;
using Shokofin.ExternalIds;
using Shokofin.Utils;

Expand Down
1 change: 1 addition & 0 deletions Shokofin/Providers/BoxSetProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using MediaBrowser.Model.Providers;
using Microsoft.Extensions.Logging;
using Shokofin.API;
using Shokofin.Extensions;
using Shokofin.ExternalIds;
using Shokofin.Utils;

Expand Down
1 change: 1 addition & 0 deletions Shokofin/Providers/CustomBoxSetProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Shokofin.API;
using Shokofin.API.Info;
using Shokofin.Collections;
using Shokofin.Extensions;
using Shokofin.ExternalIds;
using Shokofin.Utils;

Expand Down
1 change: 1 addition & 0 deletions Shokofin/Providers/CustomSeasonProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using MediaBrowser.Model.Entities;
using Microsoft.Extensions.Logging;
using Shokofin.API;
using Shokofin.Extensions;
using Shokofin.ExternalIds;
using Shokofin.MergeVersions;

Expand Down
1 change: 1 addition & 0 deletions Shokofin/Providers/CustomSeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using MediaBrowser.Model.Entities;
using Microsoft.Extensions.Logging;
using Shokofin.API;
using Shokofin.Extensions;
using Shokofin.ExternalIds;
using Shokofin.MergeVersions;
using Shokofin.Utils;
Expand Down
1 change: 1 addition & 0 deletions Shokofin/Providers/SeasonProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using MediaBrowser.Model.Providers;
using Microsoft.Extensions.Logging;
using Shokofin.API;
using Shokofin.Extensions;
using Shokofin.ExternalIds;
using Shokofin.Utils;

Expand Down
1 change: 1 addition & 0 deletions Shokofin/Resolvers/ShokoResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.Extensions.Logging;
using Shokofin.API;
using Shokofin.API.Models;
using Shokofin.Extensions;
using Shokofin.ExternalIds;

using File = System.IO.File;
Expand Down
1 change: 1 addition & 0 deletions Shokofin/Resolvers/VirtualFileSystemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Shokofin.API;
using Shokofin.API.Models;
using Shokofin.Configuration;
using Shokofin.Extensions;
using Shokofin.ExternalIds;
using Shokofin.Resolvers.Models;
using Shokofin.Utils;
Expand Down
1 change: 1 addition & 0 deletions Shokofin/SignalR/SignalRConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Shokofin.Configuration;
using Shokofin.Events;
using Shokofin.Events.Interfaces;
using Shokofin.Extensions;
using Shokofin.SignalR.Models;
using Shokofin.Utils;

Expand Down
2 changes: 1 addition & 1 deletion Shokofin/Sync/UserDataSyncManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using Microsoft.Extensions.Logging;
using Shokofin.API;
using Shokofin.Configuration;

using Shokofin.Extensions;
using UserStats = Shokofin.API.Models.File.UserStats;

namespace Shokofin.Sync;
Expand Down
1 change: 1 addition & 0 deletions Shokofin/Tasks/CleanupVirtualRootTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
using Shokofin.Configuration;
using Shokofin.Extensions;
using Shokofin.Utils;

namespace Shokofin.Tasks;
Expand Down
2 changes: 1 addition & 1 deletion Shokofin/Utils/ContentRating.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Shokofin.API.Info;
using Shokofin.API.Models;
using Shokofin.Events.Interfaces;

using Shokofin.Extensions;
using TagWeight = Shokofin.Utils.TagFilter.TagWeight;

namespace Shokofin.Utils;
Expand Down
2 changes: 1 addition & 1 deletion Shokofin/Utils/Ordering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Shokofin.API.Info;
using Shokofin.API.Models;
using Shokofin.API.Models.AniDB;

using Shokofin.Extensions;
using ExtraType = MediaBrowser.Model.Entities.ExtraType;

namespace Shokofin.Utils;
Expand Down
7 changes: 4 additions & 3 deletions Shokofin/Utils/Text.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Shokofin.API;
using Shokofin.API.Info;
using Shokofin.API.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Shokofin.API;
using Shokofin.API.Info;
using Shokofin.API.Models;
using Shokofin.Extensions;

namespace Shokofin.Utils;

Expand Down
1 change: 1 addition & 0 deletions Shokofin/Web/Models/VfsLibraryPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using MediaBrowser.Model.Entities;
using Shokofin.Extensions;
using Shokofin.Resolvers.Models;

namespace Shokofin.Web.Models;
Expand Down

0 comments on commit eabdf49

Please sign in to comment.