Service
- Service Class Diagram
IService 상속 구현
IService
인터페이스 구현을 통한 통합 인스턴스 관리IService
를 상속 받은 모든Class
를Service
에서 통합 관리
public interface IService {
protected internal bool IsServing() => false;
protected internal void Init() { }
protected internal void Start();
protected internal void Stop();
protected internal void Refresh() { }
protected internal void Remove() { }
}
- Implement Member
IsServing()
Service
생성 후 매Service.StartService()
에서 동작. 기본적으로 이미 시작한Service
도 중복으로 시작할 수 있기 때문에 중복을 막기 위해선 오버라이딩 필요Init()
Service
초기화 동작 구현 최초 생성 시 한 번 동작Start()
Service
시작시 동작 구현Service.StartService()
를 통해 동작Stop()
Service
정지시 동작 구현Service.StopService()
를 통해 동작Refresh()
Service
새로 고침 동작 구현Service.RefreshService()
를 통해 동작Remove()
Service
제거시 동작 구현Service.RemoveService()
를 통해 동작
Service 처리
IService
를 상속 받은 모든Class
를 관리 하며Interface
에 대한 개별 적인 접근을 차단 하고Service
를 통해서만 접근 하도록 제한.무분별한 인스턴스 확장을 막고
enum
정의를 통해 전체 혹은 일부분에 대한 통합 처리를 제공구현된
Class
는public
으로 개별 구현된Method
에 대해서 만 접근이 가능
[AttributeUsage(AttributeTargets.Class)]
public sealed class ServiceAttribute : Attribute {
public List<Enum> serviceTypeList = new();
public ServiceAttribute() => serviceTypeList.Add(DEFAULT_SERVICE_TYPE.NONE);
public ServiceAttribute(params object[] serviceTypes) {
foreach (var type in serviceTypes) {
if (type is Enum enumType) {
serviceTypeList.Add(enumType);
}
}
}
}
public static class Service {
public static bool StartService(Type type)
public static bool StartService<TService>() where TService : class, IService, new()
public static bool StartService(Enum serviceType)
}
public static class Service {
public static bool StopService(Type type)
public static bool StopService<TService>() where TService : class, IService, new()
public static bool StopService(Enum serviceType)
public static bool StopService(IService service)
}
public static class Service {
public static bool RestartService(Type type)
public static bool RestartService<TService>() where TService : class, IService, new()
public static bool RestartService(Enum serviceType)
public static bool RestartService(IService service)
}
public static class Service {
public static bool RefreshService(Type type)
public static bool RefreshService<TService>() where TService : class, IService, new()
public static bool RefreshService(Enum serviceType)
public static bool RefreshService(IService service)
}
public static class Service {
public static bool RemoveService<TService>() where TService : class, IService
public static bool RemoveService(Enum serviceType)
public static bool RemoveService(Type type)
}
Last modified: 01 2월 2025