2026-11-25 14:09:16 +01:00
|
|
|
|
#nullable enable
|
2026-11-25 13:44:02 +01:00
|
|
|
|
using System;
|
2026-11-25 14:09:16 +01:00
|
|
|
|
using System.Linq;
|
2026-11-25 13:44:02 +01:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using ReminderOrganizer.Services;
|
|
|
|
|
|
using ReminderOrganizer.ViewModels;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ReminderOrganizer
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class ServiceLocator
|
|
|
|
|
|
{
|
|
|
|
|
|
private static IServiceProvider? _serviceProvider;
|
|
|
|
|
|
|
|
|
|
|
|
public static IServiceProvider Services => _serviceProvider
|
|
|
|
|
|
?? throw new InvalidOperationException("ServiceLocator not initialized");
|
|
|
|
|
|
|
|
|
|
|
|
public static void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
|
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
services.AddSingleton<IDataService>(_ =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var ds = new DataService();
|
2026-11-25 14:52:25 +01:00
|
|
|
|
if (Environment.GetEnvironmentVariable("REMINDER_ORGANIZER_DATA") is { Length: > 0 })
|
|
|
|
|
|
return ds; // isolated test/screenshot run: never pull in real data
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
// Older versions stored tasks.json next to the exe (or in the single-file extract dir).
|
|
|
|
|
|
ds.MigrateFrom(System.IO.Path.GetDirectoryName(Environment.ProcessPath));
|
|
|
|
|
|
ds.MigrateFrom(AppContext.BaseDirectory);
|
2026-11-25 14:09:16 +01:00
|
|
|
|
// v1.0 single-file builds extracted to %TEMP%\.net\ReminderOrganizer\<hash>\ and saved there.
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var extractRoot = System.IO.Path.Combine(System.IO.Path.GetTempPath(), ".net", "ReminderOrganizer");
|
|
|
|
|
|
if (System.IO.Directory.Exists(extractRoot))
|
|
|
|
|
|
{
|
|
|
|
|
|
var newest = new System.IO.DirectoryInfo(extractRoot)
|
|
|
|
|
|
.GetFiles("tasks.json", System.IO.SearchOption.AllDirectories)
|
|
|
|
|
|
.OrderByDescending(f => f.LastWriteTimeUtc).FirstOrDefault();
|
|
|
|
|
|
ds.MigrateFrom(newest?.DirectoryName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { }
|
Fix data loss risk, reminder bugs; theme, credits, tests
- Store tasks in %APPDATA% (single-file extract dir lost data on update),
atomic serialized saves, corrupt-file backup, migration of old tasks.json
- Reminders without description never showed (empty balloon text threw)
- Catch up missed reminders on start; monthly recurrence no longer drifts
- Task dialog: date pick kept 00:00, cancel leaked recurrence changes
- CSV import understands quoted fields written by export
- Confirm before deleting; name folders on create; tasks sorted by date
- Single instance, autostart starts hidden in tray, tray icon disposed
- Theme helper for all dialogs, MDL2/Path icons instead of emojis,
fixed folder selection/badge, localized counts and messages
- Credits (c) Michael Media + Discord link, exe Company/Copyright
- Locales embedded; xUnit tests (24); README, CLAUDE.md, sprite-generator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:08:53 +01:00
|
|
|
|
return ds;
|
|
|
|
|
|
});
|
2026-11-25 13:44:02 +01:00
|
|
|
|
services.AddSingleton<INotificationService, NotificationService>();
|
|
|
|
|
|
services.AddSingleton<IAutostartService, AutostartService>();
|
|
|
|
|
|
services.AddSingleton<ILocalizationService>(sp =>
|
|
|
|
|
|
new LocalizationService(sp.GetRequiredService<IDataService>()));
|
|
|
|
|
|
services.AddTransient<MainViewModel>();
|
|
|
|
|
|
|
|
|
|
|
|
_serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-11-25 14:09:16 +01:00
|
|
|
|
|