我想通过 SimpleInjector 注入 Container 属性。我没有找到 SimpleInjector 的任何功能。
然后我想将self Container注册到自己,但是Container没有接口。
我想要这个功能,因为我不通过构造函数传输 Container 对象 - 因为如果我可以使用注册对象的自动注入。
我的使用思路:
var container = new Container();
container.Options.AutowirePropertiesWithAttribute<InjectableProperty>();
container.Register<ISomething, Something>(Lifestyle.Singleton);
Run Code Online (Sandbox Code Playgroud)
ISomething:
public interface ISomething
{
void SomeMethod();
}
Run Code Online (Sandbox Code Playgroud)
东西类:
public class Something : ISomething
{
public void SomeMethod()
{
var environment = _container.GetInstance<IEnvironment>();
environment.DoSomething();
}
[InjectableProperty] // - maybe it is not possible (I don't know it)
Container Container {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
你有什么想法来实现这一目标吗?
非常感谢。
我想在我的页面上使用 summernote 编辑器,但我需要为此添加特殊功能。我想在summernote 工具栏中添加一个按钮。这个按钮应该类似于下拉菜单,可以选择一些值,并且这个值应该插入到当前光标位置。
我想象中的用法:
网址:
<summernote some-values="values"></summernote>
Run Code Online (Sandbox Code Playgroud)
角度控制器:
module.controller("ControllerName", ["$scope", ($scope) => {
$scope.values = ["value-for-insert1", "value-for-insert2", "value-for-insert3"];
}]);
Run Code Online (Sandbox Code Playgroud)
当然,我可以编辑 summernote 源代码来实现这一点。但我不想用这种方式解决这个问题。我的问题有什么不同的解决方案吗?
谢谢