![](/img/trans.png)
[英]Hive adapters and boxes with Get_it how should i regester them into getit
我總是遇到 hive boxies 實例和未初始化盒子或適配器的錯誤,所以我決定在一個地方注冊它們並在所有地方使用它。但我不知道如何使用和注冊適配器和盒子我沒有嘗試過,因為我不知道如何實現 ...
[英]Hive adapters and boxes with Get_it how should i regester them into getit
我總是遇到 hive boxies 實例和未初始化盒子或適配器的錯誤,所以我決定在一個地方注冊它們並在所有地方使用它。但我不知道如何使用和注冊適配器和盒子我沒有嘗試過,因為我不知道如何實現 ...
[英]Symfony - How do I get services dynamically from the container?
對於一個 API 項目,如果輸入數據不正確,我想盡早失敗,在 controller 被調度之前。 我已經設法通過使用路由默認值和訂閱KernelEvents::REQUEST事件的事件訂閱者來完成驗證。 正如您在代碼中看到的,我正在嘗試從容器中獲取驗證器。 我在這里的假設是,因為自動連線已打開,所 ...
[英]My .NET 7 app is unable to resolve the service for a type. Already added scoped to DI
如果我已經在 DI 中注冊了服務,我還缺少什么? 錯誤: System.InvalidOperationException:在嘗試激活“Contoso.API.Controllers.AccountsController”時無法解析“Contoso.API.Services.AccountSer ...
[英]Combining dependency injection with service locator
在以下示例中,服務定位器用於注入對類的依賴項。 這比在 class 中解決依賴關系並保持初始化程序(或 class 接口)干凈更好的方法嗎? ...
[英]Unable to use Get It background callback
我有一個 flutter 應用程序,它有一個后台偵聽器,但我一直收到 Unhanded 異常。 這是我的主要() 這是我的 setupLocator(): 這是我的 backgroundCallback: 我在后台調用中嘗試檢索存儲庫時出現以下錯誤: E/flutter (11326): [ERR ...
[英]how can I route using GoRouter in Flutter without context?
我要解決的問題:我使用 GoRouter 的應用程序需要能夠從 main() 中路由到命名路由。 由於大多數路由都是 'context.go' 形式,所以我不能在 main 中這樣做。 背景我的應用程序使用 GoRouter。 GetX 讓我輕松地定義命名路由並從 main() 傳遞參數是完美的 ...
[英]How can we use service locator in custom flutter library or package?
我想將我的應用程序拆分為功能和包中的每個功能,那么我們如何在每個包中分別使用get_it應用依賴注入 “每個包代表一個包含該功能的所有業務邏輯和用戶界面的功能” ...
[英]how to solve getit shared preferences error?
我正在為我的項目嘗試 bloctesting 並收到以下錯誤: 以下是我的 sharedpreferences 注入文件 shared_preference_injection_configuration.dart import 'package:get_it/get_it.dar ...
[英]How get_it flutter package deals with Garbage Collector as it registers all the instance at start
我有一個天真的問題,我已經閱讀了有關 flutter 依賴注入 package get_it 的信息,它像服務定位器設計模式一樣在啟動時注冊所有實例,我的問題是它如何處理垃圾收集器以及何時釋放對象? 它是否在應用程序生命周期開始時將所有實例存儲在 memory 中? 老實說,我對服務定位器設計模式知 ...
[英]Use a specific instance of a class inside an isolate
賞金將在 5 天后到期。 此問題的答案有資格獲得+200聲望賞金。 Guillaume Roux想引起更多人對這個問題的關注: 尋找解決方案或替代方法將模擬 class 注入隔離區內並使其可測試。 我通過compute()方法使用隔離來從 API(大約 10k 個條目)中獲取、解析和排序數據。 ...
[英]Flutter/Dart get_It singleton locator method failure
我有一個簡單的飛鏢類,如下所示: (注意:以上是一個示例,實際類確實比臨時功能更多。) 我的pubspec.yml文件包含以下內容: 我有一個dependency locator文件: 最后,在main.dart我有以下內容: (當然還有比這更多的代碼)。 正如所顯示的那樣, ...
[英]Avoid Service locator in strategy design pattern
看看那個偽代碼 由於服務定位器被認為是反模式,在這種情況下如何避免它? A,B,C可以有各種依賴項,這就是為什么我想使用依賴項注入的所有好處來實例化它。 我也可以注入A,B,C作為StrategyResolver依賴項,但是如果我有 10 個策略呢? StrategyResolver依賴項列 ...
[英]How to use get_it for Provider.of<ExampleProvider>(context)?
我是 flutter 的新手,我正在嘗試將 get_it package 用於 DI。 我想了解如何使用 get_it 替換對 Inherited Widget 的依賴。 我的代碼如下所示: 我有一個定位器文件,用於初始化定位器實例及其設置。 定位器.dart 文件: example_provi ...
[英]Can't initialized GraphQl Client in flutter using Get_it
我想在我的 Flutter 應用程序中實現 GraphQL 客戶端。 對於依賴注入,我使用 GetIt 庫。 但是當我運行應用程序時,它說 '無效參數(HomeGraphQLService 類型的對象未在 GetIt 中注冊。您是否忘記傳遞實例名稱?(您是否不小心執行了 GetIt sl=Ge ...
[英]Is calling IServiceProvider.CreateScope from within a Hosted Service an anti-pattern?
最近我一直在看下面的 StackOverflow 問題。 那里有一個答案,建議閱讀 Microsoft 的文檔,尤其是在后台任務中使用范圍服務的段落。 在頁面中,我們有以下代碼的一部分: 這不是一種反模式嗎? 在方法中創建 scope 並從服務提供者解析服務? 這似乎有一種服務定位器(如果我錯了, ...
[英]C# ASP.NET Core alternative to an extension method to register services
我的 AspNet Core 應用程序有問題,我有一個擴展方法來在外部庫上注冊配置,如示例所示: 在啟動 class 中,在 ConfigureServices 中我這樣調用此方法: 現在不幸的是我不得不進行一些更改,所以我需要注入依賴項才能在 class 中執行其他操作,所以我不能再使用 stat ...
[英]How can I register the async object to get_it package without making the main() async?
我想在 get_it package 中注冊 SharedPrefrences object 以從應用程序周圍的所有地方訪問它,而不是使 main() 異步。 這是正確的方法嗎? 我該怎么做? 我就是這樣做的,但是它拋出了一個異常。 代碼: 例外: 未處理的異常:'package:get_it/g ...
[英]C++ general question on OOP Design, how to access member of object in the top of hierarchy from bottom
I have a Class A, in the class there is some important member (lets call it someVeryImportantNumber) and also objects of class B. In class B there ar ...
[英]ServiceLocator with Autofac in asp.net core 3.1
我正在開發一個 asp.net core 3.1 webapi 應用程序,我使用 Autofac 作為 DI 容器。 對於一種特殊情況,我不能使用 ConstructorInjection、propertyinjection 或 methodinjection。 我唯一的方法是在 Autofac 的 ...
[英]Flutter - Using GetIt with BuildContext
我根據 flutter 文檔在我的應用程序中使用本地化。 看這里: https://flutter.dev/docs/development/accessibility-and-localization/internationalization 我使用 get_it package(版本 4.0.4 ...