Playvoi/Playvoi.Client/Assets/ShiroginSDK/Runtime/Services/Registry/ShiroginServiceRegistry.cs

72 lines
No EOL
3.6 KiB
C#

using ShiroginSDK.Runtime.Services.Base;
using ShiroginSDK.Runtime.Services.Implementations.Ads;
using ShiroginSDK.Runtime.Services.Implementations.Analytics;
using ShiroginSDK.Runtime.Services.Implementations.AppsFlyerServiceNS;
using ShiroginSDK.Runtime.Services.Implementations.Core;
using ShiroginSDK.Runtime.Services.Implementations.Data;
using ShiroginSDK.Runtime.Services.Implementations.Facebook;
using ShiroginSDK.Runtime.Services.Implementations.Firebase;
using ShiroginSDK.Runtime.Services.Implementations.IAP;
using ShiroginSDK.Runtime.Services.Implementations.RemoteConfig;
using ShiroginSDK.Runtime.Services.Implementations.UI;
using ShiroginSDK.Runtime.Services.Interfaces;
using UnityEngine;
namespace ShiroginSDK.Runtime.Services.Registry
{
/// <summary>
/// Central orchestrator for initializing all ShiroginSDK services in proper dependency order.
/// </summary>
public static class ShiroginServiceRegistry
{
public static void InitializeAll()
{
// ------------------------------------------------------------------
// 🧩 CORE LAYER
// ------------------------------------------------------------------
RegisterAndInit<IEventService>(new EventService()); // Events backbone
RegisterAndInit<IDataService>(new DataService()); // Save/Load system
RegisterAndInit<ICoroutineRunnerService>(new CoroutineRunnerService()); // Global coroutine executor
// ------------------------------------------------------------------
// 🔥 BACKEND LAYER
// ------------------------------------------------------------------
RegisterAndInit<IFirebaseService>(new FirebaseService()); // Firebase Analytics + Remote Config
RegisterAndInit<IRemoteConfigService>(new RemoteConfigService()); // Uses FirebaseService
RegisterAndInit<IAppsFlyerService>(new AppsFlyerService()); // AppsFlyer analytics SDK
RegisterAndInit<IFacebookService>(new FacebookService()); // Facebook SDK
RegisterAndInit<IAnalyticsService>(new AnalyticsService()); // Unified analytics forwarding
RegisterAndInit<IAnalyticsEventListenerService>(new AnalyticsEventListenerService()); // Track Analytics Events
// ------------------------------------------------------------------
// 💰 ECONOMY & ADS
// ------------------------------------------------------------------
RegisterAndInit<IIAPService>(new IAPService()); // In-app purchases
RegisterAndInit<IAdsService>(new AdsService()); // Rewarded & Interstitial ads
// ------------------------------------------------------------------
// 🎨 UI / PRESENTATION LAYER
// ------------------------------------------------------------------
RegisterAndInit<IThemeService>(new ThemeService()); // UI themes / skins
RegisterAndInit<IPopupService>(new PopupService()); // Global popup queue system
Debug.Log("[ShiroginSDK] ✅ All services initialized successfully.");
}
/// <summary>
/// Registers and initializes a service with its interface type.
/// </summary>
private static void RegisterAndInit<TInterface>(ServiceBase service) where TInterface : class
{
// Register by interface type
ServiceLocator.Register((TInterface)(object)service);
service.Initialize();
}
public static void DisposeAll()
{
ServiceLocator.Clear();
Debug.Log("[ShiroginSDK] 🧹 All services disposed.");
}
}
}