diff --git a/src/CrossWikiEditor.Core/CrossWikiEditor.Core.csproj b/src/CrossWikiEditor.Core/CrossWikiEditor.Core.csproj
index 905f922..b0aa591 100644
--- a/src/CrossWikiEditor.Core/CrossWikiEditor.Core.csproj
+++ b/src/CrossWikiEditor.Core/CrossWikiEditor.Core.csproj
@@ -8,13 +8,13 @@
true
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/CrossWikiEditor.Core/GlobalUsings.cs b/src/CrossWikiEditor.Core/GlobalUsings.cs
index 9140024..270ac56 100644
--- a/src/CrossWikiEditor.Core/GlobalUsings.cs
+++ b/src/CrossWikiEditor.Core/GlobalUsings.cs
@@ -2,7 +2,6 @@
global using System.Collections.Immutable;
global using System.Collections.ObjectModel;
global using System.Collections.Specialized;
-
global using System.ComponentModel;
global using System.Globalization;
global using System.Security.Cryptography;
@@ -11,12 +10,10 @@
global using System.Web;
global using System.Xml;
global using System.Xml.Serialization;
-
global using CommunityToolkit.Mvvm.ComponentModel;
global using CommunityToolkit.Mvvm.Input;
global using CommunityToolkit.Mvvm.Messaging;
global using CommunityToolkit.Mvvm.Messaging.Messages;
-
global using CrossWikiEditor.Core.ListProviders;
global using CrossWikiEditor.Core.ListProviders.BaseListProviders;
global using CrossWikiEditor.Core.Messages;
@@ -33,10 +30,8 @@
global using CrossWikiEditor.Core.ViewModels.ReportViewModels;
global using CrossWikiEditor.Core.WikiClientLibraryUtils;
global using CrossWikiEditor.Core.WikiClientLibraryUtils.Generators;
-
global using HtmlAgilityPack;
global using Serilog;
-
global using WikiClientLibrary;
global using WikiClientLibrary.Client;
global using WikiClientLibrary.Generators;
diff --git a/src/CrossWikiEditor.Core/IDialog.cs b/src/CrossWikiEditor.Core/IDialog.cs
index 679ec8a..2ffa37f 100644
--- a/src/CrossWikiEditor.Core/IDialog.cs
+++ b/src/CrossWikiEditor.Core/IDialog.cs
@@ -2,8 +2,8 @@
public interface IDialog
{
- void Close(object? dialogResult);
object? DataContext { get; set; }
+ void Close(object? dialogResult);
}
public interface IOwner;
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/AllCategoriesListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/AllCategoriesListProvider.cs
index a6f2a01..b2ea040 100644
--- a/src/CrossWikiEditor.Core/ListProviders/AllCategoriesListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/AllCategoriesListProvider.cs
@@ -1,6 +1,7 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class AllCategoriesListProvider(ICategoryService categoryService,
+public sealed class AllCategoriesListProvider(
+ ICategoryService categoryService,
IDialogService dialogService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
@@ -8,6 +9,8 @@ public sealed class AllCategoriesListProvider(ICategoryService categoryService,
public override string ParamTitle => "Start from";
public override bool CanMake => true;
- public override async Task>> MakeList(int limit) =>
- await categoryService.GetAllCategories(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await categoryService.GetAllCategories(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/AllFilesListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/AllFilesListProvider.cs
index 079145e..061a497 100644
--- a/src/CrossWikiEditor.Core/ListProviders/AllFilesListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/AllFilesListProvider.cs
@@ -1,6 +1,7 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class AllFilesListProvider(IDialogService dialogService,
+public sealed class AllFilesListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
@@ -8,6 +9,8 @@ public sealed class AllFilesListProvider(IDialogService dialogService,
public override string ParamTitle => "Start from";
public override bool CanMake => true;
- public override async Task>> MakeList(int limit) =>
- await pageService.GetAllFiles(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetAllFiles(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/AllPagesListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/AllPagesListProvider.cs
index 057adc1..43b1f4a 100644
--- a/src/CrossWikiEditor.Core/ListProviders/AllPagesListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/AllPagesListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class AllPagesListProvider(IDialogService dialogService,
+public sealed class AllPagesListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService,
IViewModelFactory viewModelFactory) : AllPagesListProviderBase(dialogService, pageService, viewModelFactory, settingsService)
{
public override string Title => "All Pages";
- public override async Task>> MakeList(int limit) =>
- await MakeListBase(limit, PropertyFilterOption.Disable, PropertyFilterOption.Disable);
+ public override async Task>> MakeList(int limit)
+ {
+ return await MakeListBase(limit, PropertyFilterOption.Disable, PropertyFilterOption.Disable);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/AllPagesNoRedirectsListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/AllPagesNoRedirectsListProvider.cs
index 6d008dd..922323d 100644
--- a/src/CrossWikiEditor.Core/ListProviders/AllPagesNoRedirectsListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/AllPagesNoRedirectsListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class AllPagesNoRedirectsListProvider(IDialogService dialogService,
+public sealed class AllPagesNoRedirectsListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService,
IViewModelFactory viewModelFactory) : AllPagesListProviderBase(dialogService, pageService, viewModelFactory, settingsService)
{
public override string Title => "All Pages (no redirects)";
- public override async Task>> MakeList(int limit) =>
- await MakeListBase(limit, PropertyFilterOption.WithoutProperty, PropertyFilterOption.Disable);
+ public override async Task>> MakeList(int limit)
+ {
+ return await MakeListBase(limit, PropertyFilterOption.WithoutProperty, PropertyFilterOption.Disable);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/AllPagesWithPrefixListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/AllPagesWithPrefixListProvider.cs
index fd0c7ae..df7ec97 100644
--- a/src/CrossWikiEditor.Core/ListProviders/AllPagesWithPrefixListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/AllPagesWithPrefixListProvider.cs
@@ -1,6 +1,7 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class AllPagesWithPrefixListProvider(IDialogService dialogService,
+public sealed class AllPagesWithPrefixListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService,
IViewModelFactory viewModelFactory) : LimitedListProviderBase(dialogService), INeedNamespacesListProvider
@@ -8,10 +9,15 @@ public sealed class AllPagesWithPrefixListProvider(IDialogService dialogService,
private int[]? _namespaces;
public override string Title => "All Pages with prefix (Prefixindex)";
public override string ParamTitle => "Prefix";
- public override bool CanMake => _namespaces is { Length: 1 };
+ public override bool CanMake => _namespaces is {Length: 1};
- public async Task GetAdditionalParams() => _namespaces = await this.GetNamespaces(isMultiselect: false, DialogService, viewModelFactory);
+ public async Task GetAdditionalParams()
+ {
+ _namespaces = await this.GetNamespaces(false, DialogService, viewModelFactory);
+ }
- public override async Task>> MakeList(int limit) =>
- await pageService.GetAllPagesWithPrefix(settingsService.CurrentApiUrl, Param, _namespaces![0], limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetAllPagesWithPrefix(settingsService.CurrentApiUrl, Param, _namespaces![0], limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/AllRedirectsListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/AllRedirectsListProvider.cs
index feca780..97a2af7 100644
--- a/src/CrossWikiEditor.Core/ListProviders/AllRedirectsListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/AllRedirectsListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class AllRedirectsListProvider(IDialogService dialogService,
+public sealed class AllRedirectsListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService,
IViewModelFactory viewModelFactory) : AllPagesListProviderBase(dialogService, pageService, viewModelFactory, settingsService)
{
public override string Title => "All Redirects";
- public override async Task>> MakeList(int limit) =>
- await MakeListBase(limit, PropertyFilterOption.WithProperty, PropertyFilterOption.Disable);
+ public override async Task>> MakeList(int limit)
+ {
+ return await MakeListBase(limit, PropertyFilterOption.WithProperty, PropertyFilterOption.Disable);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/AllUsersListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/AllUsersListProvider.cs
index 3d4138a..9714ede 100644
--- a/src/CrossWikiEditor.Core/ListProviders/AllUsersListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/AllUsersListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class AllUsersListProvider(IDialogService dialogService,
+public sealed class AllUsersListProvider(
+ IDialogService dialogService,
ISettingsService settingsService,
IUserService userService) : LimitedListProviderBase(dialogService)
{
public override string Title => "All Users";
public override string ParamTitle => "Start from";
- public override async Task>> MakeList(int limit) =>
- await userService.GetAllUsers(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await userService.GetAllUsers(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/BaseListProviders/AllPagesListProviderBase.cs b/src/CrossWikiEditor.Core/ListProviders/BaseListProviders/AllPagesListProviderBase.cs
index 19736d7..617e891 100644
--- a/src/CrossWikiEditor.Core/ListProviders/BaseListProviders/AllPagesListProviderBase.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/BaseListProviders/AllPagesListProviderBase.cs
@@ -8,13 +8,17 @@ public abstract class AllPagesListProviderBase(
{
private int[]? _namespaces;
public override string ParamTitle => "Start from";
- public override bool CanMake => _namespaces is { Length: 1 };
- public async Task GetAdditionalParams() => _namespaces = await this.GetNamespaces(isMultiselect: false, DialogService, viewModelFactory);
+ public override bool CanMake => _namespaces is {Length: 1};
+
+ public async Task GetAdditionalParams()
+ {
+ _namespaces = await this.GetNamespaces(false, DialogService, viewModelFactory);
+ }
protected async Task>> MakeListBase(int limit, PropertyFilterOption redirectsFilter,
PropertyFilterOption langLinksFilter)
{
return await pageService.GetAllPages(settingsService.CurrentApiUrl, Param, _namespaces![0],
- redirectsFilter: redirectsFilter, langLinksFilter: langLinksFilter, limit);
+ redirectsFilter, langLinksFilter, limit);
}
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/BaseListProviders/LimitedListProviderBase.cs b/src/CrossWikiEditor.Core/ListProviders/BaseListProviders/LimitedListProviderBase.cs
index 27327bb..88f033f 100644
--- a/src/CrossWikiEditor.Core/ListProviders/BaseListProviders/LimitedListProviderBase.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/BaseListProviders/LimitedListProviderBase.cs
@@ -9,6 +9,7 @@ public interface ILimitedListProvider : IListProvider
public abstract class LimitedListProviderBase(IDialogService dialogService) : ListProviderBase, ILimitedListProvider
{
protected IDialogService DialogService => dialogService;
+
public async Task GetLimit()
{
return await dialogService.ShowDialog(new PromptViewModel("How many page", "Limit: ")
diff --git a/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageListProvider.cs
index 64ee59f..06ead61 100644
--- a/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageListProvider.cs
@@ -10,6 +10,8 @@ public class CategoriesOnPageListProvider(
public override string Title => "Categories on page";
public override string ParamTitle => "Page";
- public override async Task>> MakeList(int limit) =>
- await categoryService.GetCategoriesOf(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await categoryService.GetCategoriesOf(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageNoHiddenCategoriesListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageNoHiddenCategoriesListProvider.cs
index ab58504..bbbeebf 100644
--- a/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageNoHiddenCategoriesListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageNoHiddenCategoriesListProvider.cs
@@ -7,6 +7,8 @@ public sealed class CategoriesOnPageNoHiddenCategoriesListProvider(
{
public override string Title => "Categories on page (no hidden categories)";
- public override async Task>> MakeList(int limit) =>
- await CategoryService.GetCategoriesOf(SettingsService.CurrentApiUrl, Param, limit, includeHidden: false);
+ public override async Task>> MakeList(int limit)
+ {
+ return await CategoryService.GetCategoriesOf(SettingsService.CurrentApiUrl, Param, limit, false);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageOnlyHiddenCategoriesListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageOnlyHiddenCategoriesListProvider.cs
index ad532bc..0a57e92 100644
--- a/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageOnlyHiddenCategoriesListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/CategoriesOnPageOnlyHiddenCategoriesListProvider.cs
@@ -7,6 +7,8 @@ public sealed class CategoriesOnPageOnlyHiddenCategoriesListProvider(
{
public override string Title => "Categories on page (only hidden categories)";
- public override async Task>> MakeList(int limit) =>
- await CategoryService.GetCategoriesOf(SettingsService.CurrentApiUrl, Param, limit, onlyHidden: true);
+ public override async Task>> MakeList(int limit)
+ {
+ return await CategoryService.GetCategoriesOf(SettingsService.CurrentApiUrl, Param, limit, onlyHidden: true);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/CategoryListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/CategoryListProvider.cs
index ae3a3f4..e2982e0 100644
--- a/src/CrossWikiEditor.Core/ListProviders/CategoryListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/CategoryListProvider.cs
@@ -1,11 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class CategoryListProvider(ICategoryService categoryService,
- IDialogService dialogService, ISettingsService settingsService) : LimitedListProviderBase(dialogService)
+public sealed class CategoryListProvider(
+ ICategoryService categoryService,
+ IDialogService dialogService,
+ ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Category";
public override string ParamTitle => "Category";
- public override async Task>> MakeList(int limit) =>
- await categoryService.GetPagesOfCategory(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await categoryService.GetPagesOfCategory(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/CategoryRecursive1LevelListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/CategoryRecursive1LevelListProvider.cs
index 3fe2722..d1f38af 100644
--- a/src/CrossWikiEditor.Core/ListProviders/CategoryRecursive1LevelListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/CategoryRecursive1LevelListProvider.cs
@@ -1,11 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class CategoryRecursive1LevelListProvider(ICategoryService categoryService,
- IDialogService dialogService, ISettingsService settingsService) : LimitedListProviderBase(dialogService)
+public sealed class CategoryRecursive1LevelListProvider(
+ ICategoryService categoryService,
+ IDialogService dialogService,
+ ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Category (recursive 1 level)";
public override string ParamTitle => "Category";
- public override async Task>> MakeList(int limit) =>
- await categoryService.GetPagesOfCategory(settingsService.CurrentApiUrl, Param, limit, 1);
+ public override async Task>> MakeList(int limit)
+ {
+ return await categoryService.GetPagesOfCategory(settingsService.CurrentApiUrl, Param, limit, 1);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/CategoryRecursiveListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/CategoryRecursiveListProvider.cs
index ac5b74b..64c5965 100644
--- a/src/CrossWikiEditor.Core/ListProviders/CategoryRecursiveListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/CategoryRecursiveListProvider.cs
@@ -1,11 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class CategoryRecursiveListProvider(ICategoryService categoryService,
- IDialogService dialogService, ISettingsService settingsService) : LimitedListProviderBase(dialogService)
+public sealed class CategoryRecursiveListProvider(
+ ICategoryService categoryService,
+ IDialogService dialogService,
+ ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Category (recursive)";
public override string ParamTitle => "Category";
- public override async Task>> MakeList(int limit) =>
- await categoryService.GetPagesOfCategory(settingsService.CurrentApiUrl, Param, limit, Int32.MaxValue);
+ public override async Task>> MakeList(int limit)
+ {
+ return await categoryService.GetPagesOfCategory(settingsService.CurrentApiUrl, Param, limit, int.MaxValue);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/CategoryRecursiveUserDefinedLevelListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/CategoryRecursiveUserDefinedLevelListProvider.cs
index 4483d8b..dcba188 100644
--- a/src/CrossWikiEditor.Core/ListProviders/CategoryRecursiveUserDefinedLevelListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/CategoryRecursiveUserDefinedLevelListProvider.cs
@@ -1,8 +1,9 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class CategoryRecursiveUserDefinedLevelListProvider(ICategoryService categoryService,
- IDialogService dialogService,
- ISettingsService settingsService)
+public sealed class CategoryRecursiveUserDefinedLevelListProvider(
+ ICategoryService categoryService,
+ IDialogService dialogService,
+ ISettingsService settingsService)
: LimitedListProviderBase(dialogService), INeedAdditionalParamsListProvider
{
private int? _recursionLevel;
@@ -11,19 +12,6 @@ public sealed class CategoryRecursiveUserDefinedLevelListProvider(ICategoryServi
public override string ParamTitle => "Category";
public override bool CanMake => _recursionLevel is not null && !string.IsNullOrWhiteSpace(Param);
- public override async Task>> MakeList(int limit)
- {
- if (_recursionLevel is null)
- {
- return new Exception("Please select recursive level.");
- }
-
- UserSettings userSettings = settingsService.GetCurrentSettings();
- Result> result = await categoryService.GetPagesOfCategory(userSettings.GetApiUrl(), Param, limit, (int) _recursionLevel);
- _recursionLevel = null;
- return result;
- }
-
public async Task GetAdditionalParams()
{
int? result = await DialogService.ShowDialog(new PromptViewModel("Number", "Recursion depth: ")
@@ -36,4 +24,17 @@ public async Task GetAdditionalParams()
_recursionLevel = result;
}
}
+
+ public override async Task>> MakeList(int limit)
+ {
+ if (_recursionLevel is null)
+ {
+ return new Exception("Please select recursive level.");
+ }
+
+ UserSettings userSettings = settingsService.GetCurrentSettings();
+ Result> result = await categoryService.GetPagesOfCategory(userSettings.GetApiUrl(), Param, limit, (int) _recursionLevel);
+ _recursionLevel = null;
+ return result;
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/DisambiguationPagesListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/DisambiguationPagesListProvider.cs
index fdc7ae9..1a643d3 100644
--- a/src/CrossWikiEditor.Core/ListProviders/DisambiguationPagesListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/DisambiguationPagesListProvider.cs
@@ -1,6 +1,7 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class DisambiguationPagesListProvider(IDialogService dialogService,
+public sealed class DisambiguationPagesListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
@@ -8,6 +9,8 @@ public sealed class DisambiguationPagesListProvider(IDialogService dialogService
public override string ParamTitle => "";
public override bool CanMake => true;
- public override async Task>> MakeList(int limit) =>
- await pageService.GetPagesWithProp(settingsService.CurrentApiUrl, "disambiguation", limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetPagesWithProp(settingsService.CurrentApiUrl, "disambiguation", limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/FilesOnPageListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/FilesOnPageListProvider.cs
index eda1f75..105e325 100644
--- a/src/CrossWikiEditor.Core/ListProviders/FilesOnPageListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/FilesOnPageListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class FilesOnPageListProvider(IDialogService dialogService,
+public sealed class FilesOnPageListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Files on page";
public override string ParamTitle => "Files on";
- public override async Task>> MakeList(int limit) =>
- await pageService.FilesOnPage(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.FilesOnPage(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/HTMLScraperListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/HTMLScraperListProvider.cs
index dfd54f5..0e3f716 100644
--- a/src/CrossWikiEditor.Core/ListProviders/HTMLScraperListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/HTMLScraperListProvider.cs
@@ -1,6 +1,9 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class HtmlScraperListProvider(HtmlAgilityPackParser htmlAgilityPackParser, IHttpClientFactory httpClientFactory, ILogger logger,
+public sealed class HtmlScraperListProvider(
+ HtmlAgilityPackParser htmlAgilityPackParser,
+ IHttpClientFactory httpClientFactory,
+ ILogger logger,
SimpleHtmlParser simpleHtmlParser) : UnlimitedListProviderBase
{
public override string Title => "HTML Scraper";
diff --git a/src/CrossWikiEditor.Core/ListProviders/ImageFileLinksListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/ImageFileLinksListProvider.cs
index dd01a5a..8af4b7a 100644
--- a/src/CrossWikiEditor.Core/ListProviders/ImageFileLinksListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/ImageFileLinksListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class ImageFileLinksListProvider(IDialogService dialogService,
+public sealed class ImageFileLinksListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Image file links";
public override string ParamTitle => "File";
- public override async Task>> MakeList(int limit) =>
- await pageService.GetPagesByFileUsage(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetPagesByFileUsage(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/LinkSearchListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/LinkSearchListProvider.cs
index 5318647..ce9e891 100644
--- a/src/CrossWikiEditor.Core/ListProviders/LinkSearchListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/LinkSearchListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class LinkSearchListProvider(IDialogService dialogService,
+public sealed class LinkSearchListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Link search";
public override string ParamTitle => "URL";
- public override async Task>> MakeList(int limit) =>
- await pageService.LinkSearch(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.LinkSearch(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/LinksOnPageBlueListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/LinksOnPageBlueListProvider.cs
index 6f1a5b8..bcc4ce4 100644
--- a/src/CrossWikiEditor.Core/ListProviders/LinksOnPageBlueListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/LinksOnPageBlueListProvider.cs
@@ -1,8 +1,9 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class LinksOnPageBlueListProvider(IDialogService dialogService,
- IPageService pageService,
- ISettingsService settingsService)
+public sealed class LinksOnPageBlueListProvider(
+ IDialogService dialogService,
+ IPageService pageService,
+ ISettingsService settingsService)
: LinksOnPageListProvider(dialogService, pageService, settingsService)
{
public override string Title => "Links on page (only bluelinks)";
@@ -10,7 +11,7 @@ public sealed class LinksOnPageBlueListProvider(IDialogService dialogService,
public override async Task>> MakeList(int limit)
{
Result> result = await base.MakeList(limit);
- if (result is not { IsSuccessful: true, Value: not null })
+ if (result is not {IsSuccessful: true, Value: not null})
{
return result;
}
diff --git a/src/CrossWikiEditor.Core/ListProviders/LinksOnPageListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/LinksOnPageListProvider.cs
index eb7932b..d44a496 100644
--- a/src/CrossWikiEditor.Core/ListProviders/LinksOnPageListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/LinksOnPageListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public class LinksOnPageListProvider(IDialogService dialogService,
+public class LinksOnPageListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Links on page";
public override string ParamTitle => "Links on";
- public override async Task>> MakeList(int limit) =>
- await pageService.LinksOnPage(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.LinksOnPage(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/LinksOnPageRedListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/LinksOnPageRedListProvider.cs
index 47923dd..1c365c1 100644
--- a/src/CrossWikiEditor.Core/ListProviders/LinksOnPageRedListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/LinksOnPageRedListProvider.cs
@@ -1,8 +1,9 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class LinksOnPageRedListProvider(IDialogService dialogService,
- IPageService pageService,
- ISettingsService settingsService)
+public sealed class LinksOnPageRedListProvider(
+ IDialogService dialogService,
+ IPageService pageService,
+ ISettingsService settingsService)
: LinksOnPageListProvider(dialogService, pageService, settingsService)
{
public override string Title => "Links on page (only redlinks)";
@@ -10,7 +11,7 @@ public sealed class LinksOnPageRedListProvider(IDialogService dialogService,
public override async Task>> MakeList(int limit)
{
Result> result = await base.MakeList(limit);
- if (result is not { IsSuccessful: true, Value: not null })
+ if (result is not {IsSuccessful: true, Value: not null})
{
return result;
}
diff --git a/src/CrossWikiEditor.Core/ListProviders/MyWatchlistListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/MyWatchlistListProvider.cs
index cebda2f..cc6b22c 100644
--- a/src/CrossWikiEditor.Core/ListProviders/MyWatchlistListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/MyWatchlistListProvider.cs
@@ -6,5 +6,8 @@ public sealed class MyWatchlistListProvider(IDialogService dialogService, IUserS
public override string ParamTitle => string.Empty;
public override bool CanMake => true;
- public override async Task>> MakeList(int limit) => await userService.GetWatchlistPages(limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await userService.GetWatchlistPages(limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/NewPagesListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/NewPagesListProvider.cs
index 6dd3eae..1bd566f 100644
--- a/src/CrossWikiEditor.Core/ListProviders/NewPagesListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/NewPagesListProvider.cs
@@ -1,6 +1,7 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class NewPagesListProvider(IDialogService dialogService,
+public sealed class NewPagesListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService,
IViewModelFactory viewModelFactory) : LimitedListProviderBase(dialogService), INeedNamespacesListProvider
@@ -8,10 +9,15 @@ public sealed class NewPagesListProvider(IDialogService dialogService,
private int[]? _namespaces;
public override string Title => "New pages";
public override string ParamTitle => string.Empty;
- public override bool CanMake => _namespaces is { Length: > 0 };
+ public override bool CanMake => _namespaces is {Length: > 0};
- public async Task GetAdditionalParams() => _namespaces = await this.GetNamespaces(true, DialogService, viewModelFactory);
+ public async Task GetAdditionalParams()
+ {
+ _namespaces = await this.GetNamespaces(true, DialogService, viewModelFactory);
+ }
- public override async Task>> MakeList(int limit) =>
- await pageService.GetNewPages(settingsService.CurrentApiUrl, _namespaces!, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetNewPages(settingsService.CurrentApiUrl, _namespaces!, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/PagesWithPropListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/PagesWithPropListProvider.cs
index 55f6e48..a64493d 100644
--- a/src/CrossWikiEditor.Core/ListProviders/PagesWithPropListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/PagesWithPropListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class PagesWithPropListProvider(IDialogService dialogService,
+public sealed class PagesWithPropListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Pages with a page property";
public override string ParamTitle => "Property name";
- public override async Task>> MakeList(int limit) =>
- await pageService.GetPagesWithProp(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetPagesWithProp(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/PagesWithoutLanguageLinksListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/PagesWithoutLanguageLinksListProvider.cs
index 6b7c8fc..3edf768 100644
--- a/src/CrossWikiEditor.Core/ListProviders/PagesWithoutLanguageLinksListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/PagesWithoutLanguageLinksListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class PagesWithoutLanguageLinksListProvider(IDialogService dialogService,
+public sealed class PagesWithoutLanguageLinksListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService,
IViewModelFactory viewModelFactory) : AllPagesListProviderBase(dialogService, pageService, viewModelFactory, settingsService)
{
public override string Title => "Pages without language links";
- public override async Task>> MakeList(int limit) =>
- await MakeListBase(limit, PropertyFilterOption.Disable, PropertyFilterOption.WithoutProperty);
+ public override async Task>> MakeList(int limit)
+ {
+ return await MakeListBase(limit, PropertyFilterOption.Disable, PropertyFilterOption.WithoutProperty);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/PagesWithoutLanguageLinksNoRedirectsListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/PagesWithoutLanguageLinksNoRedirectsListProvider.cs
index 3b5abd4..c3c6484 100644
--- a/src/CrossWikiEditor.Core/ListProviders/PagesWithoutLanguageLinksNoRedirectsListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/PagesWithoutLanguageLinksNoRedirectsListProvider.cs
@@ -1,11 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class PagesWithoutLanguageLinksNoRedirectsListProvider(IDialogService dialogService,
+public sealed class PagesWithoutLanguageLinksNoRedirectsListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService,
IViewModelFactory viewModelFactory) : AllPagesListProviderBase(dialogService, pageService, viewModelFactory, settingsService)
{
public override string Title => "Pages without language links (no redirects)";
- public override async Task>> MakeList(int limit) =>
- await MakeListBase(limit, PropertyFilterOption.WithoutProperty, PropertyFilterOption.WithoutProperty);
+
+ public override async Task>> MakeList(int limit)
+ {
+ return await MakeListBase(limit, PropertyFilterOption.WithoutProperty, PropertyFilterOption.WithoutProperty);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/PetscanListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/PetscanListProvider.cs
index c1fee69..99daf9f 100644
--- a/src/CrossWikiEditor.Core/ListProviders/PetscanListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/PetscanListProvider.cs
@@ -1,9 +1,11 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class PetscanListProvider(IHttpClientFactory httpClientFactory, ISettingsService settingsService, IWikiClientCache wikiClientCache) : UnlimitedListProviderBase
+public sealed class PetscanListProvider(IHttpClientFactory httpClientFactory, ISettingsService settingsService, IWikiClientCache wikiClientCache)
+ : UnlimitedListProviderBase
{
public override string Title => "Petscan";
public override string ParamTitle => "PSID";
+
public override async Task>> MakeList()
{
try
diff --git a/src/CrossWikiEditor.Core/ListProviders/ProtectedPagesListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/ProtectedPagesListProvider.cs
index 8d6bfbf..016f005 100644
--- a/src/CrossWikiEditor.Core/ListProviders/ProtectedPagesListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/ProtectedPagesListProvider.cs
@@ -1,20 +1,25 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class ProtectedPagesListProvider(IDialogService dialogService,
- IPageService pageService, ISettingsService settingsService,
+public sealed class ProtectedPagesListProvider(
+ IDialogService dialogService,
+ IPageService pageService,
+ ISettingsService settingsService,
IViewModelFactory viewModelFactory) : LimitedListProviderBase(dialogService), INeedAdditionalParamsListProvider
{
- private string _protectionType = string.Empty;
private string _protectionLevel = string.Empty;
+ private string _protectionType = string.Empty;
public override string Title => "Protected pages";
public override string ParamTitle => "";
public override bool CanMake => !string.IsNullOrWhiteSpace(_protectionType) && !string.IsNullOrWhiteSpace(_protectionLevel);
public async Task GetAdditionalParams()
{
- (_protectionType, _protectionLevel) = await DialogService.ShowDialog<(string, string)>(viewModelFactory.GetSelectProtectionSelectionPageViewModel());
+ (_protectionType, _protectionLevel) =
+ await DialogService.ShowDialog<(string, string)>(viewModelFactory.GetSelectProtectionSelectionPageViewModel());
}
- public override async Task>> MakeList(int limit) =>
- await pageService.GetProtectedPages(settingsService.CurrentApiUrl, _protectionType, _protectionLevel, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetProtectedPages(settingsService.CurrentApiUrl, _protectionType, _protectionLevel, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/RandomListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/RandomListProvider.cs
index b597f94..58d32c6 100644
--- a/src/CrossWikiEditor.Core/ListProviders/RandomListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/RandomListProvider.cs
@@ -1,9 +1,10 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class RandomListProvider(IDialogService dialogService,
- IPageService pageService,
- ISettingsService settingsService,
- IViewModelFactory viewModelFactory)
+public sealed class RandomListProvider(
+ IDialogService dialogService,
+ IPageService pageService,
+ ISettingsService settingsService,
+ IViewModelFactory viewModelFactory)
: LimitedListProviderBase(dialogService), INeedAdditionalParamsListProvider
{
private NamespacesAndRedirectFilterOptions? _options;
@@ -15,24 +16,25 @@ public async Task GetAdditionalParams()
{
NamespacesAndRedirectFilterOptions? result =
await DialogService.ShowDialog(
- await viewModelFactory.GetSelectNamespacesAndRedirectFilterViewModel(isIncludeRedirectsVisible: false));
+ await viewModelFactory.GetSelectNamespacesAndRedirectFilterViewModel(false));
if (result is not null)
{
_options = result;
}
}
+
public override async Task>> MakeList(int limit)
{
return await pageService.GetRandomPages(
settingsService.CurrentApiUrl,
_options!.Namespaces,
- filterRedirects: _options.RedirectFilter switch
+ _options.RedirectFilter switch
{
RedirectFilter.All => null,
RedirectFilter.Redirects => true,
RedirectFilter.NoRedirects => false,
_ => null
},
- limit: limit);
+ limit);
}
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/RecentChangesListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/RecentChangesListProvider.cs
index 0c43516..ee7d5ab 100644
--- a/src/CrossWikiEditor.Core/ListProviders/RecentChangesListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/RecentChangesListProvider.cs
@@ -1,6 +1,7 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class RecentChangesListProvider(IDialogService dialogService,
+public sealed class RecentChangesListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService,
IViewModelFactory viewModelFactory) : LimitedListProviderBase(dialogService), INeedNamespacesListProvider
@@ -8,13 +9,15 @@ public sealed class RecentChangesListProvider(IDialogService dialogService,
private int[]? _namespaces;
public override string Title => "Recent Changes";
public override string ParamTitle => "";
- public override bool CanMake => _namespaces is { Length: > 0 };
+ public override bool CanMake => _namespaces is {Length: > 0};
public async Task GetAdditionalParams()
{
_namespaces = await this.GetNamespaces(true, DialogService, viewModelFactory);
}
- public override async Task>> MakeList(int limit) =>
- await pageService.GetRecentlyChangedPages(settingsService.CurrentApiUrl, _namespaces, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetRecentlyChangedPages(settingsService.CurrentApiUrl, _namespaces, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/TextFileListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/TextFileListProvider.cs
index f83ee2f..be72ebf 100644
--- a/src/CrossWikiEditor.Core/ListProviders/TextFileListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/TextFileListProvider.cs
@@ -1,9 +1,10 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class TextFileListProvider(IFileDialogService fileDialogService,
- ISystemService systemService,
- ISettingsService settingsService,
- IWikiClientCache wikiClientCache)
+public sealed class TextFileListProvider(
+ IFileDialogService fileDialogService,
+ ISystemService systemService,
+ ISettingsService settingsService,
+ IWikiClientCache wikiClientCache)
: UnlimitedListProviderBase, INeedAdditionalParamsListProvider
{
private readonly List _textFiles = [];
@@ -12,6 +13,15 @@ public sealed class TextFileListProvider(IFileDialogService fileDialogService,
public override string ParamTitle => string.Empty;
public override bool CanMake => _textFiles.Count != 0;
+ public async Task GetAdditionalParams()
+ {
+ string[]? result = await fileDialogService.OpenFilePickerAsync("Select text files to extract pages", true);
+ if (result is not null)
+ {
+ _textFiles.AddRange(result);
+ }
+ }
+
public override async Task>> MakeList()
{
var titles = new List();
@@ -28,7 +38,7 @@ public override async Task>> MakeList()
}
else
{
- titles.AddRange(pageText.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries)
+ titles.AddRange(pageText.Split(new[] {"\r\n", "\n"}, StringSplitOptions.RemoveEmptyEntries)
.Where(s => s.Trim().Length != 0)
.Select(Tools.RemoveSyntax));
}
@@ -39,13 +49,4 @@ public override async Task>> MakeList()
_textFiles.Clear();
return result;
}
-
- public async Task GetAdditionalParams()
- {
- string[]? result = await fileDialogService.OpenFilePickerAsync("Select text files to extract pages", true);
- if (result is not null)
- {
- _textFiles.AddRange(result);
- }
- }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/TransclusionsOnPageListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/TransclusionsOnPageListProvider.cs
index a0e84cd..9c9274a 100644
--- a/src/CrossWikiEditor.Core/ListProviders/TransclusionsOnPageListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/TransclusionsOnPageListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class TransclusionsOnPageListProvider(IDialogService dialogService,
+public sealed class TransclusionsOnPageListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Transclusions on page";
public override string ParamTitle => "Transclusions on";
- public override async Task>> MakeList(int limit) =>
- await pageService.GetTransclusionsOn(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetTransclusionsOn(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/UserContributionsListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/UserContributionsListProvider.cs
index 3470c9a..1252db6 100644
--- a/src/CrossWikiEditor.Core/ListProviders/UserContributionsListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/UserContributionsListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class UserContributionsListProvider(IDialogService dialogService,
+public sealed class UserContributionsListProvider(
+ IDialogService dialogService,
ISettingsService settingsService,
IUserService userService) : LimitedListProviderBase(dialogService)
{
public override string Title => "User contribs";
public override string ParamTitle => "User";
- public override async Task>> MakeList(int limit) =>
- await userService.GetUserContributionsPages(settingsService.CurrentApiUrl, Param, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await userService.GetUserContributionsPages(settingsService.CurrentApiUrl, Param, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/WhatLinksHereListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/WhatLinksHereListProvider.cs
index a33a97e..1118ee4 100644
--- a/src/CrossWikiEditor.Core/ListProviders/WhatLinksHereListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/WhatLinksHereListProvider.cs
@@ -1,7 +1,9 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class WhatLinksHereListProvider(IDialogService dialogService,
- IPageService pageService, ISettingsService settingsService,
+public sealed class WhatLinksHereListProvider(
+ IDialogService dialogService,
+ IPageService pageService,
+ ISettingsService settingsService,
IViewModelFactory viewModelFactory) : LimitedListProviderBase(dialogService), INeedAdditionalParamsListProvider
{
private NamespacesAndRedirectFilterOptions? _options;
@@ -9,6 +11,17 @@ public sealed class WhatLinksHereListProvider(IDialogService dialogService,
public override string ParamTitle => "What links to";
public override bool CanMake => !string.IsNullOrWhiteSpace(Param) && _options is not null;
+ public async Task GetAdditionalParams()
+ {
+ NamespacesAndRedirectFilterOptions? result =
+ await DialogService.ShowDialog(await viewModelFactory
+ .GetSelectNamespacesAndRedirectFilterViewModel());
+ if (result is not null)
+ {
+ _options = result;
+ }
+ }
+
public override async Task>> MakeList(int limit)
{
return await pageService.GetPagesLinkedTo(
@@ -25,14 +38,4 @@ public override async Task>> MakeList(int limit)
allowRedirectLinks: _options.IncludeRedirects,
limit: limit);
}
-
- public async Task GetAdditionalParams()
- {
- NamespacesAndRedirectFilterOptions? result =
- await DialogService.ShowDialog(await viewModelFactory.GetSelectNamespacesAndRedirectFilterViewModel());
- if (result is not null)
- {
- _options = result;
- }
- }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/WhatTranscludesHereAllNsListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/WhatTranscludesHereAllNsListProvider.cs
index 7285fe6..f945496 100644
--- a/src/CrossWikiEditor.Core/ListProviders/WhatTranscludesHereAllNsListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/WhatTranscludesHereAllNsListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class WhatTranscludesHereAllNsListProvider(IDialogService dialogService,
+public sealed class WhatTranscludesHereAllNsListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "What transcludes page (all NS)";
public override string ParamTitle => "What embeds";
- public override async Task>> MakeList(int limit) =>
- await pageService.GetTransclusionsOf(settingsService.CurrentApiUrl, Param, null, limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetTransclusionsOf(settingsService.CurrentApiUrl, Param, null, limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/WhatTranscludesHereListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/WhatTranscludesHereListProvider.cs
index e4563d4..39d6a0e 100644
--- a/src/CrossWikiEditor.Core/ListProviders/WhatTranscludesHereListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/WhatTranscludesHereListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class WhatTranscludesHereListProvider(IDialogService dialogService,
+public sealed class WhatTranscludesHereListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "What transcludes page";
public override string ParamTitle => "What embeds";
- public override async Task>> MakeList(int limit) =>
- await pageService.GetTransclusionsOf(settingsService.CurrentApiUrl, Param, [0], limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.GetTransclusionsOf(settingsService.CurrentApiUrl, Param, [0], limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTextAllNsListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTextAllNsListProvider.cs
index e3d418e..10d6438 100644
--- a/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTextAllNsListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTextAllNsListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class WikiSearchInTextAllNsListProvider(IDialogService dialogService,
+public sealed class WikiSearchInTextAllNsListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Wiki search (text) (all NS)";
public override string ParamTitle => "Wiki search";
- public override async Task>> MakeList(int limit) =>
- await pageService.WikiSearch(settingsService.CurrentApiUrl, Param, [], limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.WikiSearch(settingsService.CurrentApiUrl, Param, [], limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTextListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTextListProvider.cs
index 10eec49..68d9c5f 100644
--- a/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTextListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTextListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class WikiSearchInTextListProvider(IDialogService dialogService,
+public sealed class WikiSearchInTextListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Wiki search (text)";
public override string ParamTitle => "Wiki search";
- public override async Task>> MakeList(int limit) =>
- await pageService.WikiSearch(settingsService.CurrentApiUrl, Param, [0], limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.WikiSearch(settingsService.CurrentApiUrl, Param, [0], limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTitleAllNsListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTitleAllNsListProvider.cs
index f9d08ae..08bd565 100644
--- a/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTitleAllNsListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTitleAllNsListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class WikiSearchInTitleAllNsListProvider(IDialogService dialogService,
+public sealed class WikiSearchInTitleAllNsListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Wiki search (title) (all NS)";
public override string ParamTitle => "Wiki search";
- public override async Task>> MakeList(int limit) =>
- await pageService.WikiSearch(settingsService.CurrentApiUrl, $"intitle:{Param}", [], limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.WikiSearch(settingsService.CurrentApiUrl, $"intitle:{Param}", [], limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTitleListProvider.cs b/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTitleListProvider.cs
index eb51221..aa97885 100644
--- a/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTitleListProvider.cs
+++ b/src/CrossWikiEditor.Core/ListProviders/WikiSearchInTitleListProvider.cs
@@ -1,12 +1,15 @@
namespace CrossWikiEditor.Core.ListProviders;
-public sealed class WikiSearchInTitleListProvider(IDialogService dialogService,
+public sealed class WikiSearchInTitleListProvider(
+ IDialogService dialogService,
IPageService pageService,
ISettingsService settingsService) : LimitedListProviderBase(dialogService)
{
public override string Title => "Wiki search (title)";
public override string ParamTitle => "Wiki search";
- public override async Task>> MakeList(int limit) =>
- await pageService.WikiSearch(settingsService.CurrentApiUrl, $"intitle:{Param}", [0], limit);
+ public override async Task>> MakeList(int limit)
+ {
+ return await pageService.WikiSearch(settingsService.CurrentApiUrl, $"intitle:{Param}", [0], limit);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Messages/CurrentSettingsUpdatedMessage.cs b/src/CrossWikiEditor.Core/Messages/CurrentSettingsUpdatedMessage.cs
index 81c0f03..85088d8 100644
--- a/src/CrossWikiEditor.Core/Messages/CurrentSettingsUpdatedMessage.cs
+++ b/src/CrossWikiEditor.Core/Messages/CurrentSettingsUpdatedMessage.cs
@@ -1,4 +1,5 @@
namespace CrossWikiEditor.Core.Messages;
+
public sealed class CurrentSettingsUpdatedMessage(UserSettings newSettings) : ValueChangedMessage(newSettings)
{
-}
+}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageProcessedMessage.cs b/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageProcessedMessage.cs
index f7b314e..207586e 100644
--- a/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageProcessedMessage.cs
+++ b/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageProcessedMessage.cs
@@ -1,7 +1,7 @@
namespace CrossWikiEditor.Core;
///
-/// Message is fired when the local processing is finished and the page is ready to be saved.
+/// Message is fired when the local processing is finished and the page is ready to be saved.
///
///
public sealed class PageProcessedMessage(WikiPageModel wikiPageModel, bool isSuccessful)
diff --git a/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageProcessingMessage.cs b/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageProcessingMessage.cs
index 00c82c6..a584740 100644
--- a/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageProcessingMessage.cs
+++ b/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageProcessingMessage.cs
@@ -1,9 +1,9 @@
namespace CrossWikiEditor.Core;
///
-/// This message is fired the program starts processing the page (local changes, before saving).
+/// This message is fired the program starts processing the page (local changes, before saving).
///
public sealed class PageProcessingMessage(WikiPageModel wikiPageModel)
{
public WikiPageModel Page { get; } = wikiPageModel;
-}
+}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageSavedMessage.cs b/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageSavedMessage.cs
index 1f78d76..40ba02e 100644
--- a/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageSavedMessage.cs
+++ b/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageSavedMessage.cs
@@ -1,7 +1,7 @@
namespace CrossWikiEditor.Core;
///
-/// Message is fired when the page has been saved.
+/// Message is fired when the page has been saved.
///
///
public sealed class PageSavedMessage(WikiPageModel wikiPageModel, bool isSuccessful, Exception? exception = null)
diff --git a/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageSavingMessage.cs b/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageSavingMessage.cs
index 66d32c8..c714856 100644
--- a/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageSavingMessage.cs
+++ b/src/CrossWikiEditor.Core/Messages/PageProcessingMessages/PageSavingMessage.cs
@@ -1,9 +1,9 @@
namespace CrossWikiEditor.Core;
///
-/// This message is fired the program starts saving the page.
+/// This message is fired the program starts saving the page.
///
public sealed class PageSavingMessage(WikiPageModel wikiPageModel)
{
public WikiPageModel Page { get; } = wikiPageModel;
-}
+}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Models/FilterOptions.cs b/src/CrossWikiEditor.Core/Models/FilterOptions.cs
index f7ee6fa..bc139df 100644
--- a/src/CrossWikiEditor.Core/Models/FilterOptions.cs
+++ b/src/CrossWikiEditor.Core/Models/FilterOptions.cs
@@ -6,7 +6,8 @@ public enum SetOperations
Intersection
}
-public class FilterOptions(IReadOnlyCollection namespacesToKeep,
+public class FilterOptions(
+ IReadOnlyCollection namespacesToKeep,
string removeTitlesContaining,
string keepTitlesContaining,
bool useRegex,
@@ -36,7 +37,9 @@ public List PerNamespacesToKeep(IEnumerable pages)
public List PerRemoveTitlesContaining(IEnumerable pages)
{
- return RemoveTitlesContaining != string.Empty ? pages.Where(p => !p.Title.Contains(RemoveTitlesContaining, UseRegex)).ToList() : pages.ToList();
+ return RemoveTitlesContaining != string.Empty
+ ? pages.Where(p => !p.Title.Contains(RemoveTitlesContaining, UseRegex)).ToList()
+ : pages.ToList();
}
public List PerKeepTitlesContaining(IEnumerable pages)
@@ -50,15 +53,18 @@ public List PerSetOperation(List pages)
{
return pages;
}
+
var list = new HashSet(pages);
if (SetOperation == SetOperations.SymmetricDifference)
{
list.ExceptWith(FilterPages);
}
+
if (SetOperation == SetOperations.Intersection)
{
list.IntersectWith(FilterPages);
}
+
return new List(list);
}
diff --git a/src/CrossWikiEditor.Core/Models/WikiPageModel.cs b/src/CrossWikiEditor.Core/Models/WikiPageModel.cs
index d2a62c9..71036bb 100644
--- a/src/CrossWikiEditor.Core/Models/WikiPageModel.cs
+++ b/src/CrossWikiEditor.Core/Models/WikiPageModel.cs
@@ -4,6 +4,8 @@ public sealed class WikiPageModel : IEquatable, IComparable _initAsync ??= InitializeAsync(Title, _apiRoot, _wikiClientCache!);
+
+ public int CompareTo(WikiPageModel? other)
+ {
+ if (ReferenceEquals(this, other))
+ {
+ return 0;
+ }
+
+ return ReferenceEquals(null, other) ? 1 : string.CompareOrdinal(Title, other.Title);
+ }
+
+ public bool Equals(WikiPageModel? other)
+ {
+ return this == other;
+ }
+
private async Task InitializeAsync(string title, string apiRoot, IWikiClientCache wikiClientCache)
{
WikiSite site = await wikiClientCache.GetWikiSite(apiRoot);
@@ -31,14 +54,6 @@ private async Task InitializeAsync(string title, string apiRoot, IWikiClientCach
NamespaceId = _wikiPage.NamespaceId;
}
- private Task? _initAsync = null;
-
- public Task InitAsync => _initAsync ??= InitializeAsync(Title, _apiRoot, _wikiClientCache!);
-
- public string Title { get; }
-
- public int NamespaceId { get; set; } = 0;
-
public async Task GetContent()
{
await InitAsync;
@@ -52,7 +67,8 @@ public async Task EditAsync(string content, string summary = "", bool isBo
{
return false;
}
- return await _wikiPage.EditAsync(new WikiPageEditOptions()
+
+ return await _wikiPage.EditAsync(new WikiPageEditOptions
{
Content = content,
Summary = summary,
@@ -88,11 +104,6 @@ public void Deconstruct(out string title, out int namespaceId)
namespaceId = NamespaceId;
}
- public bool Equals(WikiPageModel? other)
- {
- return this == other;
- }
-
public override bool Equals(object? obj)
{
if (obj is WikiPageModel wikiPageModel)
@@ -132,14 +143,4 @@ public override string ToString()
{
return !(left == right);
}
-
- public int CompareTo(WikiPageModel? other)
- {
- if (ReferenceEquals(this, other))
- {
- return 0;
- }
-
- return ReferenceEquals(null, other) ? 1 : string.CompareOrdinal(Title, other.Title);
- }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/PageListProcessor.cs b/src/CrossWikiEditor.Core/PageListProcessor.cs
index 3a4747e..ba14002 100644
--- a/src/CrossWikiEditor.Core/PageListProcessor.cs
+++ b/src/CrossWikiEditor.Core/PageListProcessor.cs
@@ -3,9 +3,9 @@
public sealed class PageListProcessor
{
private readonly IMessengerWrapper _messenger;
+ private readonly List _pages;
private readonly ISettingsService _settingsService;
private readonly UserSettings _userSettings;
- private readonly List _pages;
private bool _isAlive = true;
private TaskCompletionSource? _shouldSaveTaskCompletionSource;
@@ -40,7 +40,7 @@ public async Task Start()
private async Task TreatPage(WikiPageModel page)
{
- var (initialContent, newContent, replacements) = await ProcessPage(page);
+ (string? initialContent, string? newContent, List>? replacements) = await ProcessPage(page);
if (initialContent is null || newContent is null || replacements is null)
{
_messenger.Send(new PageSkippedMessage(page, SkipReason.ErrorProcessing));
@@ -91,12 +91,14 @@ private async Task TreatPage(WikiPageModel page)
newContent = regex.Replace(newContent, match =>
{
string replacedValue = normalFindAndReplaceRule.ReplaceWith;
- replacedValue = Regex.Replace(replacedValue, @"\$([1-9])", groupReference => match.Groups[int.Parse(groupReference.Groups[1].Value)].Value);
+ replacedValue = Regex.Replace(replacedValue, @"\$([1-9])",
+ groupReference => match.Groups[int.Parse(groupReference.Groups[1].Value)].Value);
replacements.Add(Tuple.Create(match.Value, replacedValue));
return replacedValue;
});
}
}
+
_messenger.Send(new PageProcessedMessage(page, true));
return (initialContent, newContent, replacements);
}
@@ -127,10 +129,8 @@ private string GetSummary(List> replacements)
{
return string.Join(", ", replacements.Select(tp => $"{tp.Item1} \u2192 {tp.Item2}")) + ", օգտվելով CWE";
}
- else
- {
- return "օգտվելով CWE";
- }
+
+ return "օգտվելով CWE";
}
public void Stop()
diff --git a/src/CrossWikiEditor.Core/Repositories/SimpleJsonProfileRepository.cs b/src/CrossWikiEditor.Core/Repositories/SimpleJsonProfileRepository.cs
index 4f173db..b9408a4 100644
--- a/src/CrossWikiEditor.Core/Repositories/SimpleJsonProfileRepository.cs
+++ b/src/CrossWikiEditor.Core/Repositories/SimpleJsonProfileRepository.cs
@@ -42,8 +42,9 @@ public static Profile JsonProfileToProfile(JsonProfile realmProfile, IStringEncr
}
///
-/// Realm is great but we use a tiny fraction of its capabilities and it is responsible for 30% of the final filesize of the app.
-/// Write the content on a file instead for now.
+/// Realm is great but we use a tiny fraction of its capabilities and it is responsible for 30% of the final filesize
+/// of the app.
+/// Write the content on a file instead for now.
///
public sealed class SimpleJsonProfileRepository(IStringEncryptionService stringEncryptionService) : IProfileRepository
{
@@ -74,6 +75,7 @@ public void Update(Profile profile)
profiles.Remove(p);
profiles.Add(profile);
}
+
SaveAll(profiles);
}
@@ -85,33 +87,35 @@ public List GetAll()
{
SaveAll([]);
}
+
string json = File.ReadAllText(JsonName);
List? jsonProfiles = JsonSerializer.Deserialize>(json);
return jsonProfiles is null ? [] : jsonProfiles.ConvertAll(p => Mapper.JsonProfileToProfile(p, stringEncryptionService));
}
}
+ public void Delete(int id)
+ {
+ List profiles = GetAll();
+ Profile? p = profiles.Find(p => p.Id == id);
+ if (p is not null)
+ {
+ profiles.Remove(p);
+ }
+
+ SaveAll(profiles);
+ }
+
private void SaveAll(List profiles)
{
lock (_profileJsonLock)
{
List jsonProfiles = profiles.ConvertAll(p => Mapper.ProfileToJsonProfile(p, stringEncryptionService));
- string json = JsonSerializer.Serialize(jsonProfiles, new JsonSerializerOptions()
+ string json = JsonSerializer.Serialize(jsonProfiles, new JsonSerializerOptions
{
WriteIndented = true
});
File.WriteAllText(JsonName, json);
}
}
-
- public void Delete(int id)
- {
- List profiles = GetAll();
- Profile? p = profiles.Find(p => p.Id == id);
- if (p is not null)
- {
- profiles.Remove(p);
- }
- SaveAll(profiles);
- }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Services/HtmlParsers/SimpleHtmlParser.cs b/src/CrossWikiEditor.Core/Services/HtmlParsers/SimpleHtmlParser.cs
index 37d5e0f..70636a0 100644
--- a/src/CrossWikiEditor.Core/Services/HtmlParsers/SimpleHtmlParser.cs
+++ b/src/CrossWikiEditor.Core/Services/HtmlParsers/SimpleHtmlParser.cs
@@ -1,9 +1,11 @@
namespace CrossWikiEditor.Core.Services.HtmlParsers;
-public sealed class SimpleHtmlParser(ILogger logger, ISettingsService settingsService,
+public sealed class SimpleHtmlParser(
+ ILogger logger,
+ ISettingsService settingsService,
IWikiClientCache wikiClientCache)
{
- readonly char[] _terminationChars = [' ', '\t', '\n', '"', '<', '>', '{', '}', '&'];
+ private readonly char[] _terminationChars = [' ', '\t', '\n', '"', '<', '>', '{', '}', '&'];
public async Task> GetPages(string html)
{
@@ -47,8 +49,10 @@ private async Task TryGetWikiPageModel(string urlStart)
{
return page;
}
+
return new WikiPageModel(Tools.GetPageTitleFromUrl(baseUrl + url), apiUrl, wikiClientCache);
}
+
return new WikiPageModel(Tools.GetPageTitleFromUrl(baseUrl + url), apiUrl, wikiClientCache);
}
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Services/IDialogService.cs b/src/CrossWikiEditor.Core/Services/IDialogService.cs
index b81baa6..4ac4adb 100644
--- a/src/CrossWikiEditor.Core/Services/IDialogService.cs
+++ b/src/CrossWikiEditor.Core/Services/IDialogService.cs
@@ -4,4 +4,4 @@ public interface IDialogService
{
Task ShowDialog(ViewModelBase viewModel);
Task Alert(string title, string content);
-}
+}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Services/SettingsService.cs b/src/CrossWikiEditor.Core/Services/SettingsService.cs
index 64f33e9..62a4538 100644
--- a/src/CrossWikiEditor.Core/Services/SettingsService.cs
+++ b/src/CrossWikiEditor.Core/Services/SettingsService.cs
@@ -1,23 +1,22 @@
using System.Text.Json;
-using CommunityToolkit.Mvvm.Messaging;
namespace CrossWikiEditor.Core.Services;
public interface ISettingsService
{
+ string CurrentApiUrl { get; }
UserSettings GetDefaultSettings();
UserSettings? GetSettingsByPath(string path);
UserSettings GetCurrentSettings();
void SaveCurrentSettings();
void SetCurrentSettings(UserSettings userSettings);
- string CurrentApiUrl { get; }
}
public sealed class SettingsService : ISettingsService
{
+ private readonly string _currentSettingsPath;
private readonly JsonSerializerOptions _jsonSerializerOptions;
private readonly IMessengerWrapper _messenger;
- private string _currentSettingsPath;
private UserSettings _currentSettings;
public SettingsService(IMessengerWrapper messenger)
@@ -32,6 +31,7 @@ public SettingsService(IMessengerWrapper messenger)
_currentSettings = temp;
}
}
+
_currentSettings ??= GetDefaultSettings();
_jsonSerializerOptions = new JsonSerializerOptions
{
@@ -41,7 +41,10 @@ public SettingsService(IMessengerWrapper messenger)
messenger.Register(this, (r, m) => _currentSettings.UserWiki!.Project = m.Value);
}
- public UserSettings GetDefaultSettings() => UserSettings.GetDefaultUserSettings();
+ public UserSettings GetDefaultSettings()
+ {
+ return UserSettings.GetDefaultUserSettings();
+ }
public UserSettings? GetSettingsByPath(string path)
{
@@ -49,6 +52,7 @@ public SettingsService(IMessengerWrapper messenger)
{
return null;
}
+
string json = File.ReadAllText(path, Encoding.UTF8);
return JsonSerializer.Deserialize(json);
}
@@ -61,10 +65,12 @@ public void SaveCurrentSettings()
{
Directory.CreateDirectory("./oldSettings");
}
+
// Just in case. This is just a json file, so no big deal, they can delete it themself.
File.Move(_currentSettingsPath, $"./oldSettings/{DateTime.Now:yyyyMMdd_HHmmss}_settings.json");
}
- var json = JsonSerializer.Serialize(_currentSettings, options: _jsonSerializerOptions);
+
+ string? json = JsonSerializer.Serialize(_currentSettings, _jsonSerializerOptions);
File.WriteAllText(_currentSettingsPath, json);
}
diff --git a/src/CrossWikiEditor.Core/Services/ViewModelFactory.cs b/src/CrossWikiEditor.Core/Services/ViewModelFactory.cs
index 44ae86f..763a360 100644
--- a/src/CrossWikiEditor.Core/Services/ViewModelFactory.cs
+++ b/src/CrossWikiEditor.Core/Services/ViewModelFactory.cs
@@ -11,14 +11,15 @@ public interface IViewModelFactory
DatabaseScannerViewModel GetDatabaseScannerViewModel();
}
-public sealed class ViewModelFactory(IFileDialogService fileDialogService,
- IDialogService dialogService,
- IProfileRepository profileRepository,
- IWikiClientCache wikiClientCache,
- IUserService userService,
- ISettingsService settingsService,
- IMessengerWrapper messenger,
- TextFileListProvider textFileListProvider)
+public sealed class ViewModelFactory(
+ IFileDialogService fileDialogService,
+ IDialogService dialogService,
+ IProfileRepository profileRepository,
+ IWikiClientCache wikiClientCache,
+ IUserService userService,
+ ISettingsService settingsService,
+ IMessengerWrapper messenger,
+ TextFileListProvider textFileListProvider)
: IViewModelFactory
{
public ProfilesViewModel GetProfilesViewModel()
diff --git a/src/CrossWikiEditor.Core/Services/WikiServices/CategoryService.cs b/src/CrossWikiEditor.Core/Services/WikiServices/CategoryService.cs
index 600925c..e2bd3ad 100644
--- a/src/CrossWikiEditor.Core/Services/WikiServices/CategoryService.cs
+++ b/src/CrossWikiEditor.Core/Services/WikiServices/CategoryService.cs
@@ -32,7 +32,8 @@ public async Task>> GetCategoriesOf(string apiRoot, s
}
catch (Exception e)
{
- logger.Fatal(e, "Failed to get pages. Site: {Site}, page: {Page}, includeHidden: {IncludeHidden}, onlyHidden: {OnlyHidden}, limit: {Limit}",
+ logger.Fatal(e,
+ "Failed to get pages. Site: {Site}, page: {Page}, includeHidden: {IncludeHidden}, onlyHidden: {OnlyHidden}, limit: {Limit}",
apiRoot, pageName, includeHidden, onlyHidden, limit);
return e;
}
@@ -62,6 +63,7 @@ public async Task>> GetPagesOfCategory(string apiRoot
{
continue;
}
+
catGen = new CategoryMembersGenerator(new WikiPage(site, subCat.Title));
temp.AddRange(await catGen.EnumPagesAsync().Take(limit).Take(limit).ToListAsync());
}
diff --git a/src/CrossWikiEditor.Core/Services/WikiServices/IPageService.cs b/src/CrossWikiEditor.Core/Services/WikiServices/IPageService.cs
index 2d9acb2..efae7f0 100644
--- a/src/CrossWikiEditor.Core/Services/WikiServices/IPageService.cs
+++ b/src/CrossWikiEditor.Core/Services/WikiServices/IPageService.cs
@@ -9,10 +9,16 @@ public interface IPageService
Task>> GetNewPages(string apiRoot, int[] namespaces, int limit);
Task>> GetTransclusionsOn(string apiRoot, string pageName, int limit);
Task>> GetTransclusionsOf(string apiRoot, string pageName, int[]? namespaces, int limit);
- Task>> GetPagesLinkedTo(string apiRoot, string title, int[]? namespaces, bool allowRedirectLinks, bool? filterRedirects, int limit);
+
+ Task>> GetPagesLinkedTo(string apiRoot, string title, int[]? namespaces, bool allowRedirectLinks,
+ bool? filterRedirects, int limit);
+
Task>> GetPagesWithProp(string apiRoot, string param, int limit);
Task>> GetAllFiles(string apiRoot, string startTitle, int limit);
- Task>> GetAllPages(string apiRoot, string startTitle, int namespaceId, PropertyFilterOption redirectsFilter, PropertyFilterOption langLinksFilter, int limit);
+
+ Task>> GetAllPages(string apiRoot, string startTitle, int namespaceId, PropertyFilterOption redirectsFilter,
+ PropertyFilterOption langLinksFilter, int limit);
+
Task>> GetAllPagesWithPrefix(string apiRoot, string prefix, int namespaceId, int limit);
Task>> GetProtectedPages(string apiRoot, string protectType, string protectLevel, int limit);
Task>> WikiSearch(string apiRoot, string keyword, int[] namespaces, int limit);
diff --git a/src/CrossWikiEditor.Core/Services/WikiServices/PageService.cs b/src/CrossWikiEditor.Core/Services/WikiServices/PageService.cs
index 8effbac..2229fc7 100644
--- a/src/CrossWikiEditor.Core/Services/WikiServices/PageService.cs
+++ b/src/CrossWikiEditor.Core/Services/WikiServices/PageService.cs
@@ -137,7 +137,8 @@ public async Task>> GetTransclusionsOf(string apiRoot
}
catch (Exception e)
{
- logger.Fatal(e, "Failed to get pages. Site {Site}, page: {Page}, namespaces: {Namespaces}, limit: {Limit}", apiRoot, pageName, namespaces, limit);
+ logger.Fatal(e, "Failed to get pages. Site {Site}, page: {Page}, namespaces: {Namespaces}, limit: {Limit}", apiRoot, pageName, namespaces,
+ limit);
return e;
}
}
@@ -192,16 +193,19 @@ public async Task>> GetPagesWithProp(string apiRoot,
}
}
- public async Task>> GetAllFiles(string apiRoot, string startTitle, int limit) =>
- await GetAllPages(
- apiRoot: apiRoot,
- startTitle: startTitle,
- namespaceId: 6,
- redirectsFilter: PropertyFilterOption.Disable,
- langLinksFilter: PropertyFilterOption.Disable,
- limit: limit);
+ public async Task>> GetAllFiles(string apiRoot, string startTitle, int limit)
+ {
+ return await GetAllPages(
+ apiRoot,
+ startTitle,
+ 6,
+ PropertyFilterOption.Disable,
+ PropertyFilterOption.Disable,
+ limit);
+ }
- public async Task>> GetAllPages(string apiRoot, string startTitle, int namespaceId, PropertyFilterOption redirectsFilter, PropertyFilterOption langLinksFilter, int limit)
+ public async Task>> GetAllPages(string apiRoot, string startTitle, int namespaceId,
+ PropertyFilterOption redirectsFilter, PropertyFilterOption langLinksFilter, int limit)
{
return await GetAllPages(apiRoot, namespaceId, redirectsFilter, langLinksFilter, limit, startTitle);
}
@@ -248,7 +252,8 @@ public async Task>> WikiSearch(string apiRoot, string
}
catch (Exception e)
{
- logger.Fatal(e, "Failed to get pages. Site {Site}, keyword: {Keyword}, namespaces: {Namespaces}, limit: {Limit}", apiRoot, keyword, namespaces, limit);
+ logger.Fatal(e, "Failed to get pages. Site {Site}, keyword: {Keyword}, namespaces: {Namespaces}, limit: {Limit}", apiRoot, keyword,
+ namespaces, limit);
return e;
}
}
@@ -279,7 +284,7 @@ public async Task>> LinkSearch(string apiRoot, string
WikiSite wikiSite = await wikiClientCache.GetWikiSite(apiRoot);
var gen = new ExternalUrlUsageGenerator(wikiSite)
{
- Url = url,
+ Url = url
};
List result = await gen.EnumItemsAsync().Take(limit).ToListAsync();
@@ -292,6 +297,28 @@ public async Task>> LinkSearch(string apiRoot, string
}
}
+ public Result> ConvertToSubject(List pages)
+ {
+ List result = (from wikiPageModel in pages
+ select ConvertToSubject(wikiPageModel)
+ into subjectPageResult
+ where subjectPageResult is {IsSuccessful: true, Value: not null}
+ select subjectPageResult.Value).ToList();
+
+ return result;
+ }
+
+ public Result> ConvertToTalk(List pages)
+ {
+ var result = (from wikiPageModel in pages
+ select ConvertToTalk(wikiPageModel)
+ into talkPageResult
+ where talkPageResult is {IsSuccessful: true, Value: not null}
+ select talkPageResult.Value).ToList();
+
+ return result;
+ }
+
private async Task>> GetAllPages(
string apiRoot,
int namespaceId,
@@ -320,39 +347,20 @@ private async Task>> GetAllPages(
{
gen.Prefix = prefix;
}
+
List result = await gen.EnumPagesAsync().Take(limit).ToListAsync();
return result.ConvertAll(x => new WikiPageModel(x));
}
catch (Exception e)
{
- logger.Fatal(e, "Failed to get pages. Site {Site}, start title: {StartTitle}, prefix: {Prefix}, namespace: {NamespaceId}, redirectsFilter {RedirectsFilter}, limit: {Limit}", apiRoot,
+ logger.Fatal(e,
+ "Failed to get pages. Site {Site}, start title: {StartTitle}, prefix: {Prefix}, namespace: {NamespaceId}, redirectsFilter {RedirectsFilter}, limit: {Limit}",
+ apiRoot,
startTitle, prefix, namespaceId, redirectsFilter, limit);
return e;
}
}
- public Result> ConvertToSubject(List pages)
- {
- List result = (from wikiPageModel in pages
- select ConvertToSubject(wikiPageModel)
- into subjectPageResult
- where subjectPageResult is { IsSuccessful: true, Value: not null }
- select subjectPageResult.Value).ToList();
-
- return result;
- }
-
- public Result> ConvertToTalk(List pages)
- {
- var result = (from wikiPageModel in pages
- select ConvertToTalk(wikiPageModel)
- into talkPageResult
- where talkPageResult is { IsSuccessful: true, Value: not null }
- select talkPageResult.Value).ToList();
-
- return result;
- }
-
private Result ConvertToSubject(WikiPageModel page)
{
try
diff --git a/src/CrossWikiEditor.Core/Services/WikiServices/UserService.cs b/src/CrossWikiEditor.Core/Services/WikiServices/UserService.cs
index 9241344..dfe76af 100644
--- a/src/CrossWikiEditor.Core/Services/WikiServices/UserService.cs
+++ b/src/CrossWikiEditor.Core/Services/WikiServices/UserService.cs
@@ -65,7 +65,7 @@ public async Task>> GetUserContributionsPages(string
try
{
WikiSite site = await wikiClientCache.GetWikiSite(apiRoot);
- var gen = new UserContributionsGenerator(site, new List { username })
+ var gen = new UserContributionsGenerator(site, new List {username})
{
IncludeTitle = true,
IncludeIds = true
diff --git a/src/CrossWikiEditor.Core/Services/WikiServices/WikiClientCache.cs b/src/CrossWikiEditor.Core/Services/WikiServices/WikiClientCache.cs
index e9a351e..ba98a49 100644
--- a/src/CrossWikiEditor.Core/Services/WikiServices/WikiClientCache.cs
+++ b/src/CrossWikiEditor.Core/Services/WikiServices/WikiClientCache.cs
@@ -19,6 +19,7 @@ public WikiClient GetWikiClient(string apiRoot, bool forceNew = false)
client = new WikiClient();
_wikiClients[apiRoot] = client;
}
+
return client;
}
diff --git a/src/CrossWikiEditor.Core/Settings/GeneralOptions.cs b/src/CrossWikiEditor.Core/Settings/GeneralOptions.cs
index 406ef51..a69c08d 100644
--- a/src/CrossWikiEditor.Core/Settings/GeneralOptions.cs
+++ b/src/CrossWikiEditor.Core/Settings/GeneralOptions.cs
@@ -1,7 +1,7 @@
namespace CrossWikiEditor.Core.Settings;
///
-/// Corresponds to the
+/// Corresponds to the
///
public sealed class GeneralOptions
{
@@ -14,4 +14,4 @@ public sealed class GeneralOptions
public bool RegexTypoFixing { get; set; }
public bool SkipIfNoTypoFixed { get; set; }
public NormalFindAndReplaceRules NormalFindAndReplaceRules { get; set; } = [];
-}
+}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Settings/MoreOptions.cs b/src/CrossWikiEditor.Core/Settings/MoreOptions.cs
index 6eac8eb..7c1a70e 100644
--- a/src/CrossWikiEditor.Core/Settings/MoreOptions.cs
+++ b/src/CrossWikiEditor.Core/Settings/MoreOptions.cs
@@ -1,7 +1,7 @@
namespace CrossWikiEditor.Core.Settings;
///
-/// Corresponds to the
+/// Corresponds to the
///
public sealed class MoreOptions
{
@@ -45,4 +45,4 @@ public sealed class CategoryTask(CategoryTaskType type)
public string ReplaceCategory { get; set; } = string.Empty;
public bool SkipIfNoChanged { get; set; }
public bool RemoveSortkey { get; set; }
-}
+}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Settings/NormalFindAndReplaceRule.cs b/src/CrossWikiEditor.Core/Settings/NormalFindAndReplaceRule.cs
index 3ac85c1..01ca953 100644
--- a/src/CrossWikiEditor.Core/Settings/NormalFindAndReplaceRule.cs
+++ b/src/CrossWikiEditor.Core/Settings/NormalFindAndReplaceRule.cs
@@ -1,6 +1,7 @@
namespace CrossWikiEditor.Core.Settings;
-public partial class NormalFindAndReplaceRule(string find,
+public partial class NormalFindAndReplaceRule(
+ string find,
string replaceWith,
bool caseSensitive,
bool regex,
@@ -15,15 +16,25 @@ public NormalFindAndReplaceRule() : this("", "", false, false, false, false, fal
{
}
- [ObservableProperty] private string _find = find;
- [ObservableProperty] private string _replaceWith = replaceWith;
- [ObservableProperty] private bool _caseSensitive = caseSensitive;
- [ObservableProperty] private bool _regex = regex;
- [ObservableProperty] private bool _multiLine = multiLine;
- [ObservableProperty] private bool _singleLine = singleLine;
- [ObservableProperty] private bool _minor = minor;
- [ObservableProperty] private bool _afterFixes = afterFixes;
- [ObservableProperty] private bool _enabled = enabled;
- [ObservableProperty] private string _comment = comment;
+ [ObservableProperty] public partial string Find { get; set; } = find;
+
+ [ObservableProperty] public partial string ReplaceWith { get; set; } = replaceWith;
+
+ [ObservableProperty] public partial bool CaseSensitive { get; set; } = caseSensitive;
+
+ [ObservableProperty] public partial bool Regex { get; set; } = regex;
+
+ [ObservableProperty] public partial bool MultiLine { get; set; } = multiLine;
+
+ [ObservableProperty] public partial bool SingleLine { get; set; } = singleLine;
+
+ [ObservableProperty] public partial bool Minor { get; set; } = minor;
+
+ [ObservableProperty] public partial bool AfterFixes { get; set; } = afterFixes;
+
+ [ObservableProperty] public partial bool Enabled { get; set; } = enabled;
+
+ [ObservableProperty] public partial string Comment { get; set; } = comment;
+
public bool IsEmpty => string.IsNullOrEmpty(Find);
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Settings/NormalFindAndReplaceRules.cs b/src/CrossWikiEditor.Core/Settings/NormalFindAndReplaceRules.cs
index c5ab04a..3e3f996 100644
--- a/src/CrossWikiEditor.Core/Settings/NormalFindAndReplaceRules.cs
+++ b/src/CrossWikiEditor.Core/Settings/NormalFindAndReplaceRules.cs
@@ -2,9 +2,13 @@
public sealed class NormalFindAndReplaceRules : List
{
- public NormalFindAndReplaceRules() : base() { }
+ public NormalFindAndReplaceRules()
+ {
+ }
- public NormalFindAndReplaceRules(IEnumerable collection) : base(collection) { }
+ public NormalFindAndReplaceRules(IEnumerable collection) : base(collection)
+ {
+ }
public bool IgnoreLinks { get; set; }
diff --git a/src/CrossWikiEditor.Core/Settings/UserSettings.cs b/src/CrossWikiEditor.Core/Settings/UserSettings.cs
index b9310b2..d961aa0 100644
--- a/src/CrossWikiEditor.Core/Settings/UserSettings.cs
+++ b/src/CrossWikiEditor.Core/Settings/UserSettings.cs
@@ -2,15 +2,36 @@ namespace CrossWikiEditor.Core.Settings;
public sealed class UserSettings
{
- public UserWiki UserWiki { get; set; } = new UserWiki("hy", ProjectEnum.Wikipedia);
+ public UserWiki UserWiki { get; set; } = new("hy", ProjectEnum.Wikipedia);
public SkipOptions SkipOptions { get; set; } = new();
public GeneralOptions GeneralOptions { get; set; } = new();
public MoreOptions MoreOptions { get; set; } = new();
public bool IsBotMode { get; set; }
public string DefaultSummary { get; set; } = string.Empty;
- public string GetApiUrl() => UserWiki.GetApiUrl();
- public string GetBaseUrl() => UserWiki.GetBaseUrl();
- public string GetLongBaseUrl() => UserWiki.GetLongBaseUrl();
- public string GetIndexUrl() => UserWiki.GetIndexUrl();
- public static UserSettings GetDefaultUserSettings() => new(); // TODO: For now
+
+ public string GetApiUrl()
+ {
+ return UserWiki.GetApiUrl();
+ }
+
+ public string GetBaseUrl()
+ {
+ return UserWiki.GetBaseUrl();
+ }
+
+ public string GetLongBaseUrl()
+ {
+ return UserWiki.GetLongBaseUrl();
+ }
+
+ public string GetIndexUrl()
+ {
+ return UserWiki.GetIndexUrl();
+ }
+
+ public static UserSettings GetDefaultUserSettings()
+ {
+ return new UserSettings();
+ // TODO: For now
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Utils/LanguageSpecificRegexes.cs b/src/CrossWikiEditor.Core/Utils/LanguageSpecificRegexes.cs
index a460f31..92bcba9 100644
--- a/src/CrossWikiEditor.Core/Utils/LanguageSpecificRegexes.cs
+++ b/src/CrossWikiEditor.Core/Utils/LanguageSpecificRegexes.cs
@@ -18,6 +18,9 @@ public LanguageSpecificRegexes(
messenger.Register(this, (_, _) => InitAsync = InitializeAsync());
}
+ public Regex? ExtractTitle { get; private set; }
+ public Task InitAsync { get; private set; }
+
private async Task InitializeAsync()
{
string apiRoot = _settingsService.CurrentApiUrl;
@@ -36,7 +39,4 @@ private void MakeRegexes()
+ Regex.Escape(url[pos..]) + "/wiki/)";
ExtractTitle = new Regex("^" + s + "([^?&]*)$");
}
-
- public Regex? ExtractTitle { get; private set; }
- public Task InitAsync { get; private set; }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Utils/Result.cs b/src/CrossWikiEditor.Core/Utils/Result.cs
index 044bea2..70903b4 100644
--- a/src/CrossWikiEditor.Core/Utils/Result.cs
+++ b/src/CrossWikiEditor.Core/Utils/Result.cs
@@ -20,10 +20,10 @@ public Result(Exception exception)
ErrorMessage = Exception.Message;
}
- [MemberNotNullWhen(returnValue: true, nameof(Value))]
+ [MemberNotNullWhen(true, nameof(Value))]
public bool IsSuccessful { get; }
- [MemberNotNullWhen(returnValue: true, nameof(ErrorMessage))]
+ [MemberNotNullWhen(true, nameof(ErrorMessage))]
public bool IsError => !IsSuccessful;
public TResult? Value { get; }
@@ -31,12 +31,38 @@ public Result(Exception exception)
public Exception? Exception { get; }
public string ErrorMessage { get; }
- public bool Equals(Result other) => IsSuccessful && other.IsSuccessful && Equals(Value, other.Value);
- public override bool Equals(object? obj) => obj is Result result && Equals(result);
- public static bool operator ==(Result left, Result right) => left.Equals(right);
- public static bool operator !=(Result left, Result right) => !(left == right);
- public override int GetHashCode() => HashCode.Combine(IsSuccessful, Value, Exception, ErrorMessage);
+ public bool Equals(Result other)
+ {
+ return IsSuccessful && other.IsSuccessful && Equals(Value, other.Value);
+ }
+
+ public override bool Equals(object? obj)
+ {
+ return obj is Result result && Equals(result);
+ }
- public static implicit operator Result(TResult value) => new(value);
- public static implicit operator Result(Exception value) => new(value);
+ public static bool operator ==(Result left, Result right)
+ {
+ return left.Equals(right);
+ }
+
+ public static bool operator !=(Result left, Result right)
+ {
+ return !(left == right);
+ }
+
+ public override int GetHashCode()
+ {
+ return HashCode.Combine(IsSuccessful, Value, Exception, ErrorMessage);
+ }
+
+ public static implicit operator Result(TResult value)
+ {
+ return new Result(value);
+ }
+
+ public static implicit operator Result(Exception value)
+ {
+ return new Result(value);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Utils/StringExtensions.cs b/src/CrossWikiEditor.Core/Utils/StringExtensions.cs
index 3494eb1..35f7120 100644
--- a/src/CrossWikiEditor.Core/Utils/StringExtensions.cs
+++ b/src/CrossWikiEditor.Core/Utils/StringExtensions.cs
@@ -40,6 +40,7 @@ public static bool Contains(
{
return isCaseSensitive ? str.Contains(value) : str.Contains(value, StringComparison.OrdinalIgnoreCase);
}
+
Regex r = isCaseSensitive ? new Regex(value) : new Regex(value, RegexOptions.IgnoreCase);
return r.IsMatch(str);
}
diff --git a/src/CrossWikiEditor.Core/Utils/Tools.cs b/src/CrossWikiEditor.Core/Utils/Tools.cs
index 88591ff..3582776 100644
--- a/src/CrossWikiEditor.Core/Utils/Tools.cs
+++ b/src/CrossWikiEditor.Core/Utils/Tools.cs
@@ -3,7 +3,7 @@
public static partial class Tools
{
///
- /// Removes underscores and wiki syntax from links
+ /// Removes underscores and wiki syntax from links
///
public static string RemoveSyntax(string text)
{
@@ -34,7 +34,7 @@ public static string RemoveSyntax(string text)
}
///
- /// Returns index of first character different between strings
+ /// Returns index of first character different between strings
///
/// First string
/// Second string
@@ -69,7 +69,7 @@ public static string GetPageTitleFromUrl(string url)
// If the URL structure is not as expected, attempt to extract from the path
string path = UnescapeDataStringRec(uri.AbsolutePath);
- var extractedTitle = path[(path.LastIndexOf('/') + 1)..];
+ string? extractedTitle = path[(path.LastIndexOf('/') + 1)..];
return extractedTitle.Replace("_", " ");
}
diff --git a/src/CrossWikiEditor.Core/Utils/Unit.cs b/src/CrossWikiEditor.Core/Utils/Unit.cs
index 89dc77c..38c267e 100644
--- a/src/CrossWikiEditor.Core/Utils/Unit.cs
+++ b/src/CrossWikiEditor.Core/Utils/Unit.cs
@@ -2,15 +2,55 @@
public readonly struct Unit : IEquatable, IComparable
{
- public static readonly Unit Default = new Unit();
- public override int GetHashCode() => 0;
- public bool Equals(Unit other) => true;
- public override bool Equals(object? obj) => true;
- public static bool operator ==(Unit lhs, Unit rhs) => true;
- public static bool operator !=(Unit lhs, Unit rhs) => false;
- public static bool operator >(Unit lhs, Unit rhs) => false;
- public static bool operator >=(Unit lhs, Unit rhs) => true;
- public static bool operator <(Unit lhs, Unit rhs) => false;
- public static bool operator <=(Unit lhs, Unit rhs) => true;
- public int CompareTo(Unit other) => 0;
+ public static readonly Unit Default = new();
+
+ public override int GetHashCode()
+ {
+ return 0;
+ }
+
+ public bool Equals(Unit other)
+ {
+ return true;
+ }
+
+ public override bool Equals(object? obj)
+ {
+ return true;
+ }
+
+ public static bool operator ==(Unit lhs, Unit rhs)
+ {
+ return true;
+ }
+
+ public static bool operator !=(Unit lhs, Unit rhs)
+ {
+ return false;
+ }
+
+ public static bool operator >(Unit lhs, Unit rhs)
+ {
+ return false;
+ }
+
+ public static bool operator >=(Unit lhs, Unit rhs)
+ {
+ return true;
+ }
+
+ public static bool operator <(Unit lhs, Unit rhs)
+ {
+ return false;
+ }
+
+ public static bool operator <=(Unit lhs, Unit rhs)
+ {
+ return true;
+ }
+
+ public int CompareTo(Unit other)
+ {
+ return 0;
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Utils/WikiPageExtensions.cs b/src/CrossWikiEditor.Core/Utils/WikiPageExtensions.cs
index 27a3681..7fcc629 100644
--- a/src/CrossWikiEditor.Core/Utils/WikiPageExtensions.cs
+++ b/src/CrossWikiEditor.Core/Utils/WikiPageExtensions.cs
@@ -36,6 +36,7 @@ private static string TitleWithoutNamespace(this WikiPage wikiPage)
{
throw new Exception("Title is null");
}
+
return wikiPage.Title.Contains(':') ? wikiPage.Title.Split(':')[1] : wikiPage.Title;
}
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/Utils/WikiPageModelExtensions.cs b/src/CrossWikiEditor.Core/Utils/WikiPageModelExtensions.cs
index 0a2c852..6337698 100644
--- a/src/CrossWikiEditor.Core/Utils/WikiPageModelExtensions.cs
+++ b/src/CrossWikiEditor.Core/Utils/WikiPageModelExtensions.cs
@@ -15,8 +15,10 @@ public static string ToWikiList(this IEnumerable wikiPageModels,
{
sb.Append($"{seperator} [[{page.Title}]]{Environment.NewLine}");
}
+
i++;
}
+
return sb.ToString();
}
@@ -24,7 +26,8 @@ public static string ToWikiListAlphabetically(this IEnumerable wi
{
string seperator = isNumericList ? "#" : "*";
var sb = new StringBuilder();
- IEnumerable> pages = wikiPageModels.GroupBy(p => char.ToLower(p.Title[0])).OrderBy(p => p.First().Title).Select(l => l.OrderBy(p => p.Title));
+ IEnumerable> pages = wikiPageModels.GroupBy(p => char.ToLower(p.Title[0])).OrderBy(p => p.First().Title)
+ .Select(l => l.OrderBy(p => p.Title));
foreach (IEnumerable section in pages)
{
sb.Append($"== {char.ToUpper(section.First().Title[0])} =={Environment.NewLine}");
@@ -33,6 +36,7 @@ public static string ToWikiListAlphabetically(this IEnumerable wi
sb.Append($"{seperator} [[{page.Title}]]{Environment.NewLine}");
}
}
+
return sb.ToString();
}
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ViewModels/AddOrEditProfileViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/AddOrEditProfileViewModel.cs
index 0296d68..d2263d5 100644
--- a/src/CrossWikiEditor.Core/ViewModels/AddOrEditProfileViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/AddOrEditProfileViewModel.cs
@@ -3,8 +3,8 @@
public sealed partial class AddOrEditProfileViewModel : ViewModelBase
{
private readonly IFileDialogService _fileDialogService;
- private readonly IProfileRepository _profileRepository;
private readonly int _id;
+ private readonly IProfileRepository _profileRepository;
public AddOrEditProfileViewModel(
IFileDialogService fileDialogService,
@@ -60,7 +60,7 @@ private void Save(IDialog dialog)
return;
}
- var profile = new Profile()
+ var profile = new Profile
{
Username = Username,
DefaultSettingsPath = ShouldSelectDefaultSettings ? DefaultSettingsPath : string.Empty,
@@ -83,5 +83,8 @@ private void Save(IDialog dialog)
}
[RelayCommand]
- private void Cancel(IDialog dialog) => dialog.Close(false);
+ private void Cancel(IDialog dialog)
+ {
+ dialog.Close(false);
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/FindAndReplaceViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/FindAndReplaceViewModel.cs
index df31d42..6e1d4a7 100644
--- a/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/FindAndReplaceViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/FindAndReplaceViewModel.cs
@@ -9,12 +9,21 @@ public FindAndReplaceViewModel(NormalFindAndReplaceRules normalFindAndReplaceRul
{
model.PropertyChanged += OnModelPropertyChanged;
}
+
AddNewRow();
IgnoreLinks = normalFindAndReplaceRules.IgnoreLinks;
IgnoreMore = normalFindAndReplaceRules.IgnoreMore;
AddToSummary = normalFindAndReplaceRules.AddToSummary;
}
+ [ObservableProperty] public partial ObservableCollection NormalFindAndReplaceRules { get; set; }
+
+ [ObservableProperty] public partial bool IgnoreLinks { get; set; }
+
+ [ObservableProperty] public partial bool IgnoreMore { get; set; }
+
+ [ObservableProperty] public partial bool AddToSummary { get; set; }
+
[RelayCommand]
private void Clean()
{
@@ -40,17 +49,13 @@ private void Save(IDialog dialog)
dialog.Close(rules);
}
- [ObservableProperty] private ObservableCollection _normalFindAndReplaceRules;
- [ObservableProperty] private bool _ignoreLinks;
- [ObservableProperty] private bool _ignoreMore;
- [ObservableProperty] private bool _addToSummary;
-
private void OnModelPropertyChanged(object? sender, PropertyChangedEventArgs args)
{
- if (NormalFindAndReplaceRules.LastOrDefault() is not { IsEmpty: false })
+ if (NormalFindAndReplaceRules.LastOrDefault() is not {IsEmpty: false})
{
return;
}
+
AddNewRow();
}
diff --git a/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/MoreViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/MoreViewModel.cs
index ec6529d..2e9496d 100644
--- a/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/MoreViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/MoreViewModel.cs
@@ -2,9 +2,9 @@
public sealed partial class MoreViewModel : ViewModelBase
{
- private MoreOptions _moreOptions;
private readonly IDialogService _dialogService;
private readonly ISettingsService _settingsService;
+ private MoreOptions _moreOptions;
public MoreViewModel(
ISettingsService settingsService,
@@ -49,20 +49,75 @@ public MoreViewModel(
[ObservableProperty] public partial bool SkipIfNoCategoryChanged { get; set; }
[ObservableProperty] public partial bool RemoveSortkey { get; set; }
- partial void OnIsAppendOrPrependEnabledChanged(bool value) => _moreOptions.IsAppendPrependEnabled = value;
- partial void OnIsAppendChanged(bool value) => _moreOptions.IsAppend = value;
- partial void OnAppendOrPrependContentChanged(string value) => _moreOptions.AppendOrPrependContent = value;
- partial void OnAppendOrPrependNewLinesChanged(int value) => _moreOptions.AppendOrPrependNewLines = value;
- partial void OnShouldSortMetadataAfterAppendOrPrependChanged(bool value) => _moreOptions.ShouldSortMetaDataAfterAppendOrPrepend = value;
- partial void OnFileTypeChanged(FileTaskType value) => _moreOptions.FileActions[0].Type = value;
- partial void OnSourceFileChanged(string value) => _moreOptions.FileActions[0].SourceFile = value;
- partial void OnReplaceFileOrCommentChanged(string value) => _moreOptions.FileActions[0].ReplaceFileOrComment = value;
- partial void OnSkipIfNoFileChangedChanged(bool value) => _moreOptions.FileActions[0].SkipIfNoChanged = value;
- partial void OnCategoryTypeChanged(CategoryTaskType value) => _moreOptions.CategoryActions[0].Type = value;
- partial void OnSourceCategoryChanged(string value) => _moreOptions.CategoryActions[0].SourceCategory = value;
- partial void OnReplaceCategoryChanged(string value) => _moreOptions.CategoryActions[0].ReplaceCategory = value;
- partial void OnSkipIfNoCategoryChangedChanged(bool value) => _moreOptions.CategoryActions[0].SkipIfNoChanged = value;
- partial void OnRemoveSortkeyChanged(bool value) => _moreOptions.CategoryActions[0].RemoveSortkey = value;
+ partial void OnIsAppendOrPrependEnabledChanged(bool value)
+ {
+ _moreOptions.IsAppendPrependEnabled = value;
+ }
+
+ partial void OnIsAppendChanged(bool value)
+ {
+ _moreOptions.IsAppend = value;
+ }
+
+ partial void OnAppendOrPrependContentChanged(string value)
+ {
+ _moreOptions.AppendOrPrependContent = value;
+ }
+
+ partial void OnAppendOrPrependNewLinesChanged(int value)
+ {
+ _moreOptions.AppendOrPrependNewLines = value;
+ }
+
+ partial void OnShouldSortMetadataAfterAppendOrPrependChanged(bool value)
+ {
+ _moreOptions.ShouldSortMetaDataAfterAppendOrPrepend = value;
+ }
+
+ partial void OnFileTypeChanged(FileTaskType value)
+ {
+ _moreOptions.FileActions[0].Type = value;
+ }
+
+ partial void OnSourceFileChanged(string value)
+ {
+ _moreOptions.FileActions[0].SourceFile = value;
+ }
+
+ partial void OnReplaceFileOrCommentChanged(string value)
+ {
+ _moreOptions.FileActions[0].ReplaceFileOrComment = value;
+ }
+
+ partial void OnSkipIfNoFileChangedChanged(bool value)
+ {
+ _moreOptions.FileActions[0].SkipIfNoChanged = value;
+ }
+
+ partial void OnCategoryTypeChanged(CategoryTaskType value)
+ {
+ _moreOptions.CategoryActions[0].Type = value;
+ }
+
+ partial void OnSourceCategoryChanged(string value)
+ {
+ _moreOptions.CategoryActions[0].SourceCategory = value;
+ }
+
+ partial void OnReplaceCategoryChanged(string value)
+ {
+ _moreOptions.CategoryActions[0].ReplaceCategory = value;
+ }
+
+ partial void OnSkipIfNoCategoryChangedChanged(bool value)
+ {
+ _moreOptions.CategoryActions[0].SkipIfNoChanged = value;
+ }
+
+ partial void OnRemoveSortkeyChanged(bool value)
+ {
+ _moreOptions.CategoryActions[0].RemoveSortkey = value;
+ }
private void PopulateProperties()
{
diff --git a/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/OptionsViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/OptionsViewModel.cs
index dfdbb1c..4a9121d 100644
--- a/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/OptionsViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/OptionsViewModel.cs
@@ -4,9 +4,9 @@ namespace CrossWikiEditor.Core.ViewModels.ControlViewModels;
public sealed partial class OptionsViewModel : ViewModelBase
{
- private GeneralOptions _generalOptions;
private readonly IDialogService _dialogService;
private readonly ISettingsService _settingsService;
+ private GeneralOptions _generalOptions;
public OptionsViewModel(
ISettingsService settingsService,
@@ -26,7 +26,7 @@ public OptionsViewModel(
PropertyChanged += OptionsViewModel_PropertyChanged;
}
- [ObservableProperty] public partial bool AutoTag { get;set; }
+ [ObservableProperty] public partial bool AutoTag { get; set; }
[ObservableProperty] public partial bool ApplyGeneralFixes { get; set; }
[ObservableProperty] public partial bool UnicodifyWholePage { get; set; }
[ObservableProperty] public partial bool FindAndReplace { get; set; }
@@ -53,6 +53,7 @@ private void OptionsViewModel_PropertyChanged(object? sender, PropertyChangedEve
{
return;
}
+
PropertyInfo property = typeof(OptionsViewModel).GetProperty(e.PropertyName!)!;
PropertyInfo targetProperty = typeof(GeneralOptions).GetProperty(e.PropertyName)!;
targetProperty.SetValue(_generalOptions, property.GetValue(this));
diff --git a/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/StartViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/StartViewModel.cs
index 977c1bb..3393dfd 100644
--- a/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/StartViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/ControlViewModels/StartViewModel.cs
@@ -3,8 +3,9 @@
public sealed partial class StartViewModel : ViewModelBase
{
private readonly IMessengerWrapper _messenger;
- private bool _isProcessing = false;
- private bool _isSaving = false;
+ private bool _isProcessing;
+ private bool _isSaving;
+
public StartViewModel(IMessengerWrapper messenger)
{
_messenger = messenger;
@@ -40,7 +41,7 @@ private void Save()
{
if (!IsBusy)
{
- _messenger.Send(new SaveOrSkipPageMessage(shouldSavePage: true));
+ _messenger.Send(new SaveOrSkipPageMessage(true));
}
}
@@ -49,7 +50,7 @@ private void Skip()
{
if (!IsBusy)
{
- _messenger.Send(new SaveOrSkipPageMessage(shouldSavePage: false));
+ _messenger.Send(new SaveOrSkipPageMessage(false));
}
}
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ViewModels/DatabaseScannerViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/DatabaseScannerViewModel.cs
index a18848d..28d53b0 100644
--- a/src/CrossWikiEditor.Core/ViewModels/DatabaseScannerViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/DatabaseScannerViewModel.cs
@@ -4,14 +4,14 @@ namespace CrossWikiEditor.Core.ViewModels;
public sealed partial class DatabaseScannerViewModel : ViewModelBase
{
- private Task? _scannerTask;
- private Task? _updateUiTask;
- private CancellationTokenSource _scannerCancellationTokenSource = new();
- private readonly ConcurrentQueue _titlesQueue = new();
+ private readonly IFileDialogService _fileDialogService;
private readonly ISettingsService _settingsService;
+ private readonly ConcurrentQueue _titlesQueue = new();
private readonly IWikiClientCache _wikiClientCache;
- private readonly IFileDialogService _fileDialogService;
public EventHandler? _convertedTextChanged;
+ private CancellationTokenSource _scannerCancellationTokenSource = new();
+ private Task? _scannerTask;
+ private Task? _updateUiTask;
public DatabaseScannerViewModel(
ISettingsService settingsService,
@@ -31,8 +31,8 @@ public DatabaseScannerViewModel(
Base = string.Empty;
Generator = string.Empty;
Case = string.Empty;
- MinStartYear = new(new DateTime(2000, 1, 1));
- MinEndYear = new(new DateTime(2000, 1, 1));
+ MinStartYear = new DateTimeOffset(new DateTime(2000, 1, 1));
+ MinEndYear = new DateTimeOffset(new DateTime(2000, 1, 1));
ConvertedText = string.Empty;
NumberOfPagesOnEachSection = 25;
}
@@ -41,11 +41,11 @@ public DatabaseScannerViewModel(
[ObservableProperty] public partial ObservableCollection TalkNamespaces { get; set; }
[ObservableProperty] public partial ObservableCollection Pages { get; set; }
- [ObservableProperty] public partial bool IsTitleContainsEnabled { get; set;}
+ [ObservableProperty] public partial bool IsTitleContainsEnabled { get; set; }
[ObservableProperty] public partial bool IsTitleNotContainsEnabled { get; set; }
- [ObservableProperty] public partial string TitleContains {get;set;}
+ [ObservableProperty] public partial string TitleContains { get; set; }
[ObservableProperty] public partial string TitleNotContains { get; set; }
- [ObservableProperty] public partial bool IsTitleContainsRegex {get;set;}
+ [ObservableProperty] public partial bool IsTitleContainsRegex { get; set; }
[ObservableProperty] public partial bool IsTitleContainsCaseSensitive { get; set; }
[ObservableProperty] public partial bool IsAllTalkChecked { get; set; }
@@ -85,7 +85,7 @@ partial void OnIsAllSubjectCheckedChanged(bool value)
public async Task BrowseCommand()
{
string[]? result = await _fileDialogService.OpenFilePickerAsync("Open Database dump", false);
- if (result is not { Length: 1 })
+ if (result is not {Length: 1})
{
return;
}
@@ -101,6 +101,7 @@ private void Start()
{
return;
}
+
_scannerTask = Task.Run(Scan, _scannerCancellationTokenSource.Token);
_updateUiTask = Task.Run(async () =>
@@ -157,16 +158,19 @@ private void Scan()
{
break;
}
+
if (reader.NodeType != XmlNodeType.Element || reader.Name != "page")
{
continue;
}
+
DbPage page = ParsePageElement(reader);
if (ShouldIncludePage(page))
{
_titlesQueue.Enqueue(page.Title!);
}
}
+
_scannerTask = null;
}
@@ -213,15 +217,18 @@ private bool ViolatesTitleContains(DbPage page)
{
return false;
}
+
if (page.Revision.Count == 0)
{
return true;
}
+
string? currentText = page.Revision[^1].Text;
if (currentText == null)
{
return true;
}
+
return !currentText.Contains(TitleContains, IsTitleContainsRegex, IsTitleContainsCaseSensitive);
}
@@ -236,8 +243,10 @@ private bool ViolatesTitleNotContains(DbPage page)
return currentText?.Contains(TitleNotContains, IsTitleContainsRegex, IsTitleContainsCaseSensitive) == true;
}
- private bool ViolatesRevisionDateRange(DbPage page) =>
- IsSearchDateChecked && page.Revision.All(rev => rev.Timestamp <= SelectedStartDate || rev.Timestamp >= SelectedEndDate);
+ private bool ViolatesRevisionDateRange(DbPage page)
+ {
+ return IsSearchDateChecked && page.Revision.All(rev => rev.Timestamp <= SelectedStartDate || rev.Timestamp >= SelectedEndDate);
+ }
private DbPage ParsePageElement(XmlReader reader)
{
@@ -266,9 +275,9 @@ private DbPage ParsePageElement(XmlReader reader)
}
}
- if (reader is { NodeType: XmlNodeType.EndElement, Name: "page" })
+ if (reader is {NodeType: XmlNodeType.EndElement, Name: "page"})
{
- return new DbPage()
+ return new DbPage
{
Id = id,
Ns = ns,
@@ -277,6 +286,7 @@ private DbPage ParsePageElement(XmlReader reader)
};
}
}
+
throw new UnreachableException();
}
@@ -328,9 +338,10 @@ private DbRevision ParseRevisionElement(XmlReader reader)
break;
}
}
- if (reader is { NodeType: XmlNodeType.EndElement, Name: "revision" })
+
+ if (reader is {NodeType: XmlNodeType.EndElement, Name: "revision"})
{
- return new DbRevision()
+ return new DbRevision
{
Id = id,
Parentid = parentId,
@@ -345,6 +356,7 @@ private DbRevision ParseRevisionElement(XmlReader reader)
};
}
}
+
throw new UnreachableException();
}
@@ -363,15 +375,17 @@ private DbContributor ParseContributorElement(XmlReader reader)
username = reader.ReadElementContentAsString();
break;
}
- if (reader is { NodeType: XmlNodeType.EndElement, Name: "contributor" })
+
+ if (reader is {NodeType: XmlNodeType.EndElement, Name: "contributor"})
{
- return new DbContributor()
+ return new DbContributor
{
Id = id,
Username = username
};
}
}
+
throw new UnreachableException();
}
@@ -394,13 +408,13 @@ private void ParseSiteInfo(XmlReader reader)
Case = reader.ReadString();
break;
case "namespaces":
- {
- ParseNamespaces(reader);
- break;
- }
+ {
+ ParseNamespaces(reader);
+ break;
+ }
}
- if (reader is { NodeType: XmlNodeType.EndElement, Name: "siteinfo" })
+ if (reader is {NodeType: XmlNodeType.EndElement, Name: "siteinfo"})
{
break;
}
@@ -418,6 +432,7 @@ private void ParseNamespaces(XmlReader reader)
{
continue;
}
+
if (ns.Id.IsEven())
{
SubjectNamespaces.Add(ns);
@@ -427,7 +442,8 @@ private void ParseNamespaces(XmlReader reader)
TalkNamespaces.Add(ns);
}
}
- if (reader is { NodeType: XmlNodeType.EndElement, Name: "namespaces" })
+
+ if (reader is {NodeType: XmlNodeType.EndElement, Name: "namespaces"})
{
break;
}
@@ -446,13 +462,22 @@ private void SetUpFromDb(string dbPath)
}
}
}
- private void MakeAlphabetisedList() => _convertedTextChanged?.Invoke(this, Pages.ToWikiListAlphabetically(IsNumericList));
- private void MakeNumericList() => _convertedTextChanged?.Invoke(this, Pages.ToWikiList(IsNumericList, NumberOfPagesOnEachSection));
+
+ private void MakeAlphabetisedList()
+ {
+ _convertedTextChanged?.Invoke(this, Pages.ToWikiListAlphabetically(IsNumericList));
+ }
+
+ private void MakeNumericList()
+ {
+ _convertedTextChanged?.Invoke(this, Pages.ToWikiList(IsNumericList, NumberOfPagesOnEachSection));
+ }
+
private void UpdateUi(WikiSite wikiSite)
{
while (!_titlesQueue.IsEmpty)
{
- if (_titlesQueue.TryDequeue(out var title))
+ if (_titlesQueue.TryDequeue(out string? title))
{
Pages.Add(new WikiPageModel(new WikiPage(wikiSite, title)));
}
diff --git a/src/CrossWikiEditor.Core/ViewModels/FilterViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/FilterViewModel.cs
index a21b152..724a010 100644
--- a/src/CrossWikiEditor.Core/ViewModels/FilterViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/FilterViewModel.cs
@@ -5,7 +5,7 @@ public partial class FilterViewModel : ViewModelBase
private readonly TextFileListProvider _textFileListProvider;
public FilterViewModel(
- List subjectNamespaces,
+ List subjectNamespaces,
List talkNamespaces,
TextFileListProvider textFileListProvider)
{
@@ -13,12 +13,25 @@ public FilterViewModel(
SubjectNamespaces = subjectNamespaces.ToObservableCollection();
TalkNamespaces = talkNamespaces.ToObservableCollection();
Pages = [];
- SetOperations = new[] { Models.SetOperations.SymmetricDifference, Models.SetOperations.Intersection }.ToObservableCollection();
+ SetOperations = new[] {Models.SetOperations.SymmetricDifference, Models.SetOperations.Intersection}.ToObservableCollection();
RemoveTitlesContaining = string.Empty;
KeepTitlesContaining = string.Empty;
SelectedSetOperations = Models.SetOperations.SymmetricDifference;
}
+ [ObservableProperty] public partial ObservableCollection SubjectNamespaces { get; set; }
+ [ObservableProperty] public partial ObservableCollection TalkNamespaces { get; set; }
+ [ObservableProperty] public partial ObservableCollection Pages { get; set; }
+ [ObservableProperty] public partial ObservableCollection SetOperations { get; set; }
+ [ObservableProperty] public partial bool IsAllTalkChecked { get; set; }
+ [ObservableProperty] public partial bool IsAllSubjectChecked { get; set; }
+ [ObservableProperty] public partial bool UseRegex { get; set; }
+ [ObservableProperty] public partial bool SortAlphabetically { get; set; }
+ [ObservableProperty] public partial bool RemoveDuplicates { get; set; }
+ [ObservableProperty] public partial string RemoveTitlesContaining { get; set; }
+ [ObservableProperty] public partial string KeepTitlesContaining { get; set; }
+ [ObservableProperty] public partial SetOperations SelectedSetOperations { get; set; }
+
[RelayCommand]
private void Save(IDialog dialog)
{
@@ -49,7 +62,7 @@ private async Task OpenFile()
if (_textFileListProvider.CanMake)
{
Result> result = await _textFileListProvider.MakeList();
- if (result is { IsSuccessful: true, Value: not null })
+ if (result is {IsSuccessful: true, Value: not null})
{
Pages = result.Value.ToObservableCollection();
}
@@ -75,17 +88,4 @@ partial void OnIsAllSubjectCheckedChanged(bool value)
.Select(x => new WikiNamespace(x.Id, x.Name, value))
.ToObservableCollection();
}
-
- [ObservableProperty] public partial ObservableCollection SubjectNamespaces { get; set; }
- [ObservableProperty] public partial ObservableCollection TalkNamespaces { get; set; }
- [ObservableProperty] public partial ObservableCollection Pages { get; set; }
- [ObservableProperty] public partial ObservableCollection SetOperations { get; set; }
- [ObservableProperty] public partial bool IsAllTalkChecked { get; set; }
- [ObservableProperty] public partial bool IsAllSubjectChecked { get; set; }
- [ObservableProperty] public partial bool UseRegex { get; set; }
- [ObservableProperty] public partial bool SortAlphabetically { get; set; }
- [ObservableProperty] public partial bool RemoveDuplicates { get; set; }
- [ObservableProperty] public partial string RemoveTitlesContaining { get; set; }
- [ObservableProperty] public partial string KeepTitlesContaining { get; set; }
- [ObservableProperty] public partial SetOperations SelectedSetOperations { get; set; }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ViewModels/MainWindowViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/MainWindowViewModel.cs
index c51accd..241a4c2 100644
--- a/src/CrossWikiEditor.Core/ViewModels/MainWindowViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/MainWindowViewModel.cs
@@ -5,8 +5,6 @@ public sealed class MainWindowViewModel : ViewModelBase
private PageListProcessor? _listProcessor;
private Task? _myBot;
- public static MainWindowViewModel? Instance { get; private set; }
-
public MainWindowViewModel(StatusBarViewModel statusBarViewModel,
MakeListViewModel makeListViewModel,
OptionsViewModel optionsViewModel,
@@ -42,13 +40,16 @@ public MainWindowViewModel(StatusBarViewModel statusBarViewModel,
_myBot = Task.Run(async () =>
{
_listProcessor?.Stop();
- _listProcessor = new PageListProcessor(messenger, settingsService, [..MakeListViewModel.Pages], OptionsViewModel.NormalFindAndReplaceRules);
+ _listProcessor = new PageListProcessor(messenger, settingsService, [..MakeListViewModel.Pages],
+ OptionsViewModel.NormalFindAndReplaceRules);
await _listProcessor.Start();
});
});
messenger.Register(this, (recipient, message) => _listProcessor?.Stop());
}
+ public static MainWindowViewModel? Instance { get; private set; }
+
public StatusBarViewModel StatusBarViewModel { get; }
public MakeListViewModel MakeListViewModel { get; }
public OptionsViewModel OptionsViewModel { get; }
diff --git a/src/CrossWikiEditor.Core/ViewModels/MakeListViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/MakeListViewModel.cs
index 84e4344..9996e50 100644
--- a/src/CrossWikiEditor.Core/ViewModels/MakeListViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/MakeListViewModel.cs
@@ -4,14 +4,14 @@ namespace CrossWikiEditor.Core.ViewModels;
public sealed partial class MakeListViewModel : ViewModelBase
{
- private readonly ILogger _logger;
- private readonly IDialogService _dialogService;
private readonly IWikiClientCache _clientCache;
+ private readonly IDialogService _dialogService;
+ private readonly IFileDialogService _fileDialogService;
+ private readonly ILogger _logger;
private readonly IPageService _pageService;
+ private readonly ISettingsService _settingsService;
private readonly ISystemService _systemService;
private readonly IViewModelFactory _viewModelFactory;
- private readonly IFileDialogService _fileDialogService;
- private readonly ISettingsService _settingsService;
public MakeListViewModel(
IMessengerWrapper messenger,
@@ -41,13 +41,23 @@ public MakeListViewModel(
messenger.Register(this, (recipient, message) => Pages.Remove(Pages.First(p => p.Title == message.Page.Title)));
}
+ [ObservableProperty] public partial ObservableCollection ListProviders { get; set; }
+
+ [ObservableProperty] public partial IListProvider SelectedListProvider { get; set; }
+
+ [ObservableProperty] public partial ObservableCollection Pages { get; set; } = [];
+
+ [ObservableProperty] public partial ObservableCollection SelectedPages { get; set; } = [];
+
+ [ObservableProperty] public partial string NewPageTitle { get; set; } = string.Empty;
+
[RelayCommand]
private async Task AddNewPage()
{
if (!string.IsNullOrWhiteSpace(NewPageTitle))
{
Result result = await _clientCache.GetWikiPageModel(_settingsService.CurrentApiUrl, NewPageTitle);
- if (result is { IsSuccessful: true, Value: not null })
+ if (result is {IsSuccessful: true, Value: not null})
{
Pages.Add(result.Value);
}
@@ -87,7 +97,7 @@ private async Task MakeList(CancellationToken arg)
_ => throw new UnreachableException("Wait what? A list is either limited or unlimited.")
};
- if (result is { IsSuccessful: true, Value: not null })
+ if (result is {IsSuccessful: true, Value: not null})
{
Pages.AddRange(result.Value);
}
@@ -103,7 +113,8 @@ private void OpenInBrowser()
{
foreach (WikiPageModel selectedPage in SelectedPages)
{
- _systemService.OpenLinkInBrowser($"{_settingsService.GetCurrentSettings().GetIndexUrl()}title={HttpUtility.UrlEncode(selectedPage.Title)}");
+ _systemService.OpenLinkInBrowser(
+ $"{_settingsService.GetCurrentSettings().GetIndexUrl()}title={HttpUtility.UrlEncode(selectedPage.Title)}");
}
}
@@ -153,13 +164,14 @@ private async Task Paste()
{
return;
}
+
string[] titles = clipboardText.Split([Environment.NewLine],
StringSplitOptions.None);
string urlApi = _settingsService.CurrentApiUrl;
foreach (string title in titles)
{
Result result = await _clientCache.GetWikiPageModel(urlApi, title);
- if (result is { IsSuccessful: true, Value: not null })
+ if (result is {IsSuccessful: true, Value: not null})
{
Pages.Add(result.Value);
}
@@ -286,13 +298,16 @@ private async Task SaveList()
{
return;
}
+
string suggestedTitle = SelectedListProvider.Title;
if (!string.IsNullOrWhiteSpace(SelectedListProvider.Param))
{
suggestedTitle += $"_{SelectedListProvider.Param}";
}
+
suggestedTitle += $"_{DateTime.Now.ToString("yyyy-MM-dd-HH-mm", CultureInfo.InvariantCulture)}.txt";
- (_, Func>? openWriteStream) = await _fileDialogService.SaveFilePickerAsync("Save pages", suggestedFileName: suggestedTitle.ToFilenameSafe());
+ (_, Func>? openWriteStream) =
+ await _fileDialogService.SaveFilePickerAsync("Save pages", suggestedFileName: suggestedTitle.ToFilenameSafe());
if (openWriteStream is not null)
{
Stream stream = await openWriteStream();
@@ -316,10 +331,4 @@ private void SortReverseAlphabetically()
{
Pages = Pages.OrderByDescending(x => x.Title).ToObservableCollection();
}
-
- [ObservableProperty] private ObservableCollection _listProviders;
- [ObservableProperty] private IListProvider _selectedListProvider;
- [ObservableProperty] private ObservableCollection _pages = [];
- [ObservableProperty] private ObservableCollection _selectedPages = [];
- [ObservableProperty] private string _newPageTitle = string.Empty;
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ViewModels/MenuViewModels/FileMenuViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/MenuViewModels/FileMenuViewModel.cs
index aac966d..0351c3e 100644
--- a/src/CrossWikiEditor.Core/ViewModels/MenuViewModels/FileMenuViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/MenuViewModels/FileMenuViewModel.cs
@@ -7,18 +7,23 @@ public sealed partial class FileMenuViewModel(
IDialogService dialogService,
IMessengerWrapper messenger)
{
- [RelayCommand] private void ResetToDefaultSettings() => settingsService.SetCurrentSettings(settingsService.GetDefaultSettings());
+ [RelayCommand]
+ private void ResetToDefaultSettings()
+ {
+ settingsService.SetCurrentSettings(settingsService.GetDefaultSettings());
+ }
[RelayCommand]
private async Task OpenSettings()
{
string[]? result = await fileDialogService.OpenFilePickerAsync("Select settings", false, ["*.json"]);
- if (result is { Length: 1 })
+ if (result is {Length: 1})
{
string newSettingsPath = result[0];
try
{
- UserSettings? newUserSettings = settingsService.GetSettingsByPath(newSettingsPath) ?? throw new InvalidOperationException("Failed to load the settings");
+ UserSettings? newUserSettings = settingsService.GetSettingsByPath(newSettingsPath) ??
+ throw new InvalidOperationException("Failed to load the settings");
settingsService.SetCurrentSettings(newUserSettings);
}
catch (InvalidOperationException)
@@ -28,11 +33,45 @@ private async Task OpenSettings()
}
}
- [RelayCommand] private void SaveSettings() => settingsService.SaveCurrentSettings();
- [RelayCommand] private void SaveSettingsAs() => throw new NotImplementedException();
- [RelayCommand] private void SaveSettingsAsDefault() => throw new NotImplementedException();
- [RelayCommand] private async Task LoginProfiles() => await dialogService.ShowDialog(viewModelFactory.GetProfilesViewModel());
- [RelayCommand] private void Logout() => throw new NotImplementedException();
- [RelayCommand] private void RefreshStatusAndTypos() => throw new NotImplementedException();
- [RelayCommand] private void Exit() => messenger.Send(new ExitApplicationMessage());
+ [RelayCommand]
+ private void SaveSettings()
+ {
+ settingsService.SaveCurrentSettings();
+ }
+
+ [RelayCommand]
+ private void SaveSettingsAs()
+ {
+ throw new NotImplementedException();
+ }
+
+ [RelayCommand]
+ private void SaveSettingsAsDefault()
+ {
+ throw new NotImplementedException();
+ }
+
+ [RelayCommand]
+ private async Task LoginProfiles()
+ {
+ await dialogService.ShowDialog(viewModelFactory.GetProfilesViewModel());
+ }
+
+ [RelayCommand]
+ private void Logout()
+ {
+ throw new NotImplementedException();
+ }
+
+ [RelayCommand]
+ private void RefreshStatusAndTypos()
+ {
+ throw new NotImplementedException();
+ }
+
+ [RelayCommand]
+ private void Exit()
+ {
+ messenger.Send(new ExitApplicationMessage());
+ }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ViewModels/PreferencesViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/PreferencesViewModel.cs
index 599a437..4ebcecc 100644
--- a/src/CrossWikiEditor.Core/ViewModels/PreferencesViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/PreferencesViewModel.cs
@@ -2,8 +2,17 @@
public sealed partial class PreferencesViewModel : ViewModelBase
{
- private readonly ISettingsService _settingsService;
private readonly IMessengerWrapper _messenger;
+ private readonly ISettingsService _settingsService;
+
+ [ObservableProperty] private ObservableCollection _languages = new(
+ [
+ "en",
+ "hy",
+ "hyw",
+ "es",
+ "ru"
+ ]);
public PreferencesViewModel(ISettingsService settingsService, IMessengerWrapper messenger)
{
@@ -22,30 +31,31 @@ public PreferencesViewModel(ISettingsService settingsService, IMessengerWrapper
SelectedProject = settingsService.GetCurrentSettings().UserWiki.Project;
}
- [ObservableProperty] private bool _minimizeToSystray;
- [ObservableProperty] private bool _warnOnExit;
- [ObservableProperty] private bool _savePageListWithSettings;
- [ObservableProperty] private bool _lowThreadPriority;
- [ObservableProperty] private bool _previewDiffInBotMode;
- [ObservableProperty] private bool _enableLogging;
- [ObservableProperty] private ProjectEnum _selectedProject = ProjectEnum.Wikipedia;
- [ObservableProperty] private ObservableCollection _projects = new(Enum.GetValues());
- [ObservableProperty] private string _selectedLanguage = "en";
-
- [ObservableProperty]
- private ObservableCollection _languages = new(
- [
- "en",
- "hy",
- "hyw",
- "es",
- "ru"
- ]);
+ [ObservableProperty] public partial bool MinimizeToSystray { get; set; }
+
+ [ObservableProperty] public partial bool WarnOnExit { get; set; }
+
+ [ObservableProperty] public partial bool SavePageListWithSettings { get; set; }
+
+ [ObservableProperty] public partial bool LowThreadPriority { get; set; }
+
+ [ObservableProperty] public partial bool PreviewDiffInBotMode { get; set; }
+
+ [ObservableProperty] public partial bool EnableLogging { get; set; }
+
+ [ObservableProperty] public partial ProjectEnum SelectedProject { get; set; } = ProjectEnum.Wikipedia;
+
+ [ObservableProperty] public partial ObservableCollection Projects { get; set; } = new(Enum.GetValues());
+
+ [ObservableProperty] public partial string SelectedLanguage { get; set; } = "en";
- [ObservableProperty] private bool _suppressUsingAwb;
- [ObservableProperty] private bool _ignoreNoBots;
- [ObservableProperty] private bool _emptyPageListOnProjectChange;
- [ObservableProperty] private Alerts _alerts;
+ [ObservableProperty] public partial bool SuppressUsingAwb { get; set; }
+
+ [ObservableProperty] public partial bool IgnoreNoBots { get; set; }
+
+ [ObservableProperty] public partial bool EmptyPageListOnProjectChange { get; set; }
+
+ [ObservableProperty] public partial Alerts Alerts { get; set; }
[RelayCommand]
private void Save(IDialog dialog)
@@ -64,26 +74,47 @@ private void Cancel(IDialog dialog)
public partial class Alerts : ObservableObject
{
- [ObservableProperty] private bool _ambiguousCitationDates;
- [ObservableProperty] private bool _containsSicTag;
- [ObservableProperty] private bool _dabPageWithRef;
- [ObservableProperty] private bool _deadLinks;
- [ObservableProperty] private bool _duplicateParametersInWpBannerShell;
- [ObservableProperty] private bool _hasRefAfterReferences;
- [ObservableProperty] private bool _hasFootnotesTemplate;
- [ObservableProperty] private bool _headersWithWikilinks;
- [ObservableProperty] private bool _invalidCitationParameters;
- [ObservableProperty] private bool _linksWithDoublePipes;
- [ObservableProperty] private bool _linksWithNoTarget;
- [ObservableProperty] private bool _longArticleWithStubTag;
- [ObservableProperty] private bool _multipleDefaultSort;
- [ObservableProperty] private bool _noCategory;
- [ObservableProperty] private bool _seeAlsoOutOfPlace;
- [ObservableProperty] private bool _startsWithHeading;
- [ObservableProperty] private bool _unbalancedBrackets;
- [ObservableProperty] private bool _unclosedTags;
- [ObservableProperty] private bool _unformattedReferences;
- [ObservableProperty] private bool _unknownParametersInMultipleIssues;
- [ObservableProperty] private bool _unknownParametersInWpBannerShell;
- [ObservableProperty] private bool _editorsSignatureOrLink;
+ [ObservableProperty] public partial bool AmbiguousCitationDates { get; set; }
+
+ [ObservableProperty] public partial bool ContainsSicTag { get; set; }
+
+ [ObservableProperty] public partial bool DabPageWithRef { get; set; }
+
+ [ObservableProperty] public partial bool DeadLinks { get; set; }
+
+ [ObservableProperty] public partial bool DuplicateParametersInWpBannerShell { get; set; }
+
+ [ObservableProperty] public partial bool HasRefAfterReferences { get; set; }
+
+ [ObservableProperty] public partial bool HasFootnotesTemplate { get; set; }
+
+ [ObservableProperty] public partial bool HeadersWithWikilinks { get; set; }
+
+ [ObservableProperty] public partial bool InvalidCitationParameters { get; set; }
+
+ [ObservableProperty] public partial bool LinksWithDoublePipes { get; set; }
+
+ [ObservableProperty] public partial bool LinksWithNoTarget { get; set; }
+
+ [ObservableProperty] public partial bool LongArticleWithStubTag { get; set; }
+
+ [ObservableProperty] public partial bool MultipleDefaultSort { get; set; }
+
+ [ObservableProperty] public partial bool NoCategory { get; set; }
+
+ [ObservableProperty] public partial bool SeeAlsoOutOfPlace { get; set; }
+
+ [ObservableProperty] public partial bool StartsWithHeading { get; set; }
+
+ [ObservableProperty] public partial bool UnbalancedBrackets { get; set; }
+
+ [ObservableProperty] public partial bool UnclosedTags { get; set; }
+
+ [ObservableProperty] public partial bool UnformattedReferences { get; set; }
+
+ [ObservableProperty] public partial bool UnknownParametersInMultipleIssues { get; set; }
+
+ [ObservableProperty] public partial bool UnknownParametersInWpBannerShell { get; set; }
+
+ [ObservableProperty] public partial bool EditorsSignatureOrLink { get; set; }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ViewModels/ProfilesViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/ProfilesViewModel.cs
index d0dff37..2c6031d 100644
--- a/src/CrossWikiEditor.Core/ViewModels/ProfilesViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/ProfilesViewModel.cs
@@ -1,15 +1,17 @@
namespace CrossWikiEditor.Core.ViewModels;
-public sealed partial class ProfilesViewModel(IFileDialogService fileDialogService,
- IDialogService dialogService,
- IProfileRepository profileRepository,
- IUserService userService,
- ISettingsService settingsService,
- IMessengerWrapper messenger)
+public sealed partial class ProfilesViewModel(
+ IFileDialogService fileDialogService,
+ IDialogService dialogService,
+ IProfileRepository profileRepository,
+ IUserService userService,
+ ISettingsService settingsService,
+ IMessengerWrapper messenger)
: ViewModelBase
{
- [ObservableProperty] private Profile? _selectedProfile;
- [ObservableProperty] private ObservableCollection _profiles = new(profileRepository.GetAll() ?? []);
+ [ObservableProperty] public partial Profile? SelectedProfile { get; set; }
+
+ [ObservableProperty] public partial ObservableCollection Profiles { get; set; } = new(profileRepository.GetAll() ?? []);
public string Username { get; set; } = "";
public string Password { get; set; } = "";
@@ -78,7 +80,7 @@ private async Task QuickLogin(IDialog dialog)
return;
}
- var profile = new Profile()
+ var profile = new Profile
{
Username = Username,
Password = Password
@@ -92,7 +94,7 @@ private async Task Login(Profile profile, IDialog dialog)
currentUserSettings ??= settingsService.GetCurrentSettings();
Result loginResult = await userService.Login(profile, currentUserSettings.GetApiUrl());
- if (loginResult is { IsSuccessful: true })
+ if (loginResult is {IsSuccessful: true})
{
messenger.Send(new NewAccountLoggedInMessage(profile));
if (!string.IsNullOrEmpty(profile.DefaultSettingsPath))
diff --git a/src/CrossWikiEditor.Core/ViewModels/ReportViewModels/EditBoxViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/ReportViewModels/EditBoxViewModel.cs
index 4027371..57c69e4 100644
--- a/src/CrossWikiEditor.Core/ViewModels/ReportViewModels/EditBoxViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/ReportViewModels/EditBoxViewModel.cs
@@ -8,5 +8,5 @@ public EditBoxViewModel(IMessengerWrapper messenger)
messenger.Register(this, (recipient, message) => Content = message.NewContent);
}
- [ObservableProperty] public partial string Content { get; set; }
+ [ObservableProperty] public partial string Content { get; set; }
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ViewModels/SelectNamespacesAndRedirectFilterViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/SelectNamespacesAndRedirectFilterViewModel.cs
index 2af3180..093f83b 100644
--- a/src/CrossWikiEditor.Core/ViewModels/SelectNamespacesAndRedirectFilterViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/SelectNamespacesAndRedirectFilterViewModel.cs
@@ -2,11 +2,15 @@
public sealed partial class SelectNamespacesAndRedirectFilterViewModel(List namespaces) : ViewModelBase
{
- [ObservableProperty] private ObservableCollection _namespaces = namespaces.ToObservableCollection();
- [ObservableProperty] private bool _isAllNamespacesChecked;
- [ObservableProperty] private int _selectedRedirectFilter = 0;
- [ObservableProperty] private bool _includeRedirects;
- [ObservableProperty] private bool _isIncludeRedirectsVisible;
+ [ObservableProperty] public partial ObservableCollection Namespaces { get; set; } = namespaces.ToObservableCollection();
+
+ [ObservableProperty] public partial bool IsAllNamespacesChecked { get; set; }
+
+ [ObservableProperty] public partial int SelectedRedirectFilter { get; set; } = 0;
+
+ [ObservableProperty] public partial bool IncludeRedirects { get; set; }
+
+ [ObservableProperty] public partial bool IsIncludeRedirectsVisible { get; set; }
partial void OnIsAllNamespacesCheckedChanged(bool value)
{
diff --git a/src/CrossWikiEditor.Core/ViewModels/SelectNamespacesViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/SelectNamespacesViewModel.cs
index f068376..36a0b67 100644
--- a/src/CrossWikiEditor.Core/ViewModels/SelectNamespacesViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/SelectNamespacesViewModel.cs
@@ -2,6 +2,13 @@
public sealed partial class SelectNamespacesViewModel(List namespaces, bool isMultiselect = true) : ViewModelBase
{
+ [ObservableProperty]
+ public partial ObservableCollection Namespaces { get; set; } = namespaces.Where(x => x.Id >= 0).ToObservableCollection();
+
+ [ObservableProperty] public partial bool IsAllSelected { get; set; }
+
+ [ObservableProperty] public partial bool IsMultiselect { get; set; } = isMultiselect;
+
[RelayCommand]
private void Select(IDialog dialog)
{
@@ -15,8 +22,4 @@ partial void OnIsAllSelectedChanged(bool value)
.Select(x => new WikiNamespace(x.Id, x.Name, value))
.ToObservableCollection();
}
-
- [ObservableProperty] private ObservableCollection _namespaces = namespaces.Where(x => x.Id >= 0).ToObservableCollection();
- [ObservableProperty] private bool _isAllSelected;
- [ObservableProperty] private bool _isMultiselect = isMultiselect;
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/ViewModels/SelectProtectionSelectionPageViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/SelectProtectionSelectionPageViewModel.cs
index f8ced05..97d23a2 100644
--- a/src/CrossWikiEditor.Core/ViewModels/SelectProtectionSelectionPageViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/SelectProtectionSelectionPageViewModel.cs
@@ -2,8 +2,9 @@
public sealed partial class SelectProtectionSelectionPageViewModel : ViewModelBase
{
- [ObservableProperty] private int _protectionType;
- [ObservableProperty] private int _protectionLevel;
+ [ObservableProperty] public partial int ProtectionType { get; set; }
+
+ [ObservableProperty] public partial int ProtectionLevel { get; set; }
[RelayCommand]
private void Ok(IDialog dialog)
diff --git a/src/CrossWikiEditor.Core/ViewModels/StatusBarViewModel.cs b/src/CrossWikiEditor.Core/ViewModels/StatusBarViewModel.cs
index d4f3d44..be5bd76 100644
--- a/src/CrossWikiEditor.Core/ViewModels/StatusBarViewModel.cs
+++ b/src/CrossWikiEditor.Core/ViewModels/StatusBarViewModel.cs
@@ -2,8 +2,8 @@ namespace CrossWikiEditor.Core.ViewModels;
public sealed partial class StatusBarViewModel : ViewModelBase
{
- private readonly IViewModelFactory _viewModelFactory;
private readonly IDialogService _dialogService;
+ private readonly IViewModelFactory _viewModelFactory;
public StatusBarViewModel(IViewModelFactory viewModelFactory,
IDialogService dialogService,
@@ -24,13 +24,13 @@ public StatusBarViewModel(IViewModelFactory viewModelFactory,
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(CurrentWiki))]
- private string _username = "User: ";
+ public partial string Username { get; set; } = "User: ";
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(CurrentWiki))]
- private string _languageCode;
+ public partial string LanguageCode { get; set; }
- [ObservableProperty] private string _project;
+ [ObservableProperty] public partial string Project { get; set; }
[RelayCommand]
private async Task UsernameClicked()
diff --git a/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/AllPagesGeneratorEx.cs b/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/AllPagesGeneratorEx.cs
index f7361bf..06e91b7 100644
--- a/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/AllPagesGeneratorEx.cs
+++ b/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/AllPagesGeneratorEx.cs
@@ -19,7 +19,7 @@ public sealed class AllPagesGeneratorEx(WikiSite site) : AllPagesGenerator(site)
{"apminsize", MinPageContentLength},
{"apmaxsize", MaxPageContentLength},
{"apprtype", ProtectionType},
- {"apprlevel", ProtectionLevel},
+ {"apprlevel", ProtectionLevel}
};
}
}
\ No newline at end of file
diff --git a/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/AllUsersPageGenerator.cs b/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/AllUsersPageGenerator.cs
index dd61fb0..e48f591 100644
--- a/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/AllUsersPageGenerator.cs
+++ b/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/AllUsersPageGenerator.cs
@@ -9,7 +9,7 @@ public sealed class AllUsersPageGenerator(WikiSite site) : WikiList(si
public override IEnumerable> EnumListParameters()
{
- return new Dictionary()
+ return new Dictionary
{
{"aulimit", "max"},
{"aufrom", StartFrom}
@@ -18,7 +18,7 @@ public sealed class AllUsersPageGenerator(WikiSite site) : WikiList(si
protected override WikiPage ItemFromJson(JToken json)
{
- var name = json["name"]!.Value();
+ string? name = json["name"]!.Value();
var wikiPage = new WikiPage(Site, $"User:{name}", 2);
wikiPage.RefreshAsync();
return wikiPage;
diff --git a/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/ExternalUrlUsageGenerator.cs b/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/ExternalUrlUsageGenerator.cs
index 1f60f2a..649f027 100644
--- a/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/ExternalUrlUsageGenerator.cs
+++ b/src/CrossWikiEditor.Core/WikiClientLibraryUtils/Generators/ExternalUrlUsageGenerator.cs
@@ -11,7 +11,7 @@ public sealed class ExternalUrlUsageGenerator(WikiSite site) : WikiList> EnumListParameters()
{
- return new Dictionary