using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using LightInject;
namespace Barotrauma.LuaCs.Services;
///
/// Provides instancing and management of IServices.
///
public interface IServicesProvider
{
#region Type_Registration
///
/// Registers a type as a service for a given interface.
///
///
///
///
///
void RegisterServiceType(ServiceLifetime lifetime, ILifetime lifetimeInstance = null) where TSvcInterface : class, IService where TService : class, IService, TSvcInterface;
///
/// Registers a type as a service for a given interface that can be requested by name.
///
///
///
///
///
///
void RegisterServiceType(string name, ServiceLifetime lifetime, ILifetime lifetimeInstance = null) where TSvcInterface : class, IService where TService : class, IService, TSvcInterface;
///
/// Called whenever a new service type for a given interface is implemented.
/// Args[0]: Interface type
/// Args[1]: Implementing type
///
event System.Action OnServiceRegistered;
///
/// Runs compilation of registered services.
///
public void Compile();
#endregion
#region Services_Instancing_Injection
///
/// Injects services into the properties of already instanced objects.
///
///
///
void InjectServices(T inst) where T : class;
///
/// Tries to get a service for the given interface, returns success/failure.
///
///
///
///
bool TryGetService(out TSvcInterface service) where TSvcInterface : class, IService;
///
/// Tries to get a service for the given interface, throws an exception upon failure.
///
///
///
TSvcInterface GetService() where TSvcInterface : class, IService;
///
/// Tries to get a service for the given name and interface, returns success/failure.
///
///
///
///
///
bool TryGetService(string name, out TSvcInterface service) where TSvcInterface : class, IService;
///
/// Called whenever a new service is created/instanced.
/// Args[0]: The interface type of the service.
/// Args[1]: The instance of the service.
///
event System.Action OnServiceInstanced;
#endregion
#region ActiveServices
///
/// Returns all services for the given interface.
///
///
///
ImmutableArray GetAllServices() where TSvc : class, IService;
#endregion
// Notes: Left public due to the common use of Publicizers
#region Internal_Use
///
/// Notes: Internal use only if hosted by LuaCsForBarotrauma. Disposes of all services and resets DI container. Warning: unable to dispose of services held by other objects.
///
void DisposeAndReset();
#endregion
}
public enum ServiceLifetime
{
Transient, Singleton, PerThread, Invalid, Custom
}