.NET Core
-
.net core에서 IServiceScopeFactory를 써야할 때프로그래밍 2025. 2. 7. 22:34
IoC Container에 등록된 서비스의 라이프 사이클이 다를 때 사용한다. AService라는 클래스가 등록될 때 Singleton이고BService라는 클래스가 등록될 때 Scope라면 AService는 BService를 참조할 수 없다. 즉, Singleton인 클래스는 하위 lifecycle에 해당하는 클래스 참조가 불가능하다. 따라서 참조 우선 순위는 Transiant 대표적으로 WorkerService 작성시 Service를 Scope, Transiant 로 등록할 경우 Worker에서 주입 받을 때 IServiceScopeFactory를 사용해서 주입받게 된다. 생각해보면 Singleton이 Instance가 메모리에 유일 존재일 때 (즉, 프로그램이 종료하기 전까지 해제 할 수 없는 ..
-
python + .net core integration, use pythonnet프로그래밍 2024. 7. 26. 15:04
파이썬가 .net core에 대한 통합 방법은 여러가지가 있다. ironpython을 사용하는 방법.process stdio를 사용하는 방법. 오늘은 .net에서 python 인터프린터 구현인 pythonnet을 소개한다. 먼저 pythonnet은 python의 .net 인터프린터 구현인 만큼 process stdio를 사용하는 방법보다 효율적이고 성능면에서 보다 나은 방법인다. 아래의 기본적인 사용코드를 보자. PythonEngine.Initialize(); using (Py.GIL()) { dynamic np = Py.Import("numpy"); Console.WriteLine(np.cos(np.pi * 2)); dynamic sin = np...