在Emacs中使用viper + vimpulse时,Vim宏不起作用(Vim macros don't work when using viper + vimpulse in Emacs)
任何其他的调整,使emacs尽可能像vim一样,也将不胜感激。
附录:我不只是使用vim的主要原因是我喜欢emacs如何让你在两个不同的框架中打开一个文件[添加:对不起,这是令人困惑的:我的意思是单独的窗口 ,emacs称之为“帧”]。 这就像做垂直分割,但我不必有一个巨大的窗口。
Any other tweaks for making emacs as vim-like as possible would be appreciated as well.
Addendum: The main reason I don't just use vim is that I love how emacs lets you open a file in two different frames [ADDED: sorry, this was confusing: I mean separate windows, which emacs calls "frames"]. It's like making a vertical split but I don't have to have one enormous window.
原文:https://stackoverflow.com/questions/98225
最满意答案
使用Windsor 2.0:
[TestFixture] public class WindsorTests { public interface IDataService {} public class DataService: IDataService {} public interface IDataFactory { IDataService Service { get; } } public class DataFactory: IDataFactory { public IDataService Service { get { return new DataService(); } } } [Test] public void FactoryTest() { var container = new WindsorContainer(); container.AddFacility<FactorySupportFacility>(); container.AddComponent<IDataFactory, DataFactory>(); container.Register(Component.For<IDataService>().UsingFactory((IDataFactory f) => f.Service)); var service = container.Resolve<IDataService>(); Assert.IsInstanceOfType(typeof(DataService), service); } }
查看流畅的API维基页面以获取更多信息。
Using Windsor 2.0:
[TestFixture] public class WindsorTests { public interface IDataService {} public class DataService: IDataService {} public interface IDataFactory { IDataService Service { get; } } public class DataFactory: IDataFactory { public IDataService Service { get { return new DataService(); } } } [Test] public void FactoryTest() { var container = new WindsorContainer(); container.AddFacility<FactorySupportFacility>(); container.AddComponent<IDataFactory, DataFactory>(); container.Register(Component.For<IDataService>().UsingFactory((IDataFactory f) => f.Service)); var service = container.Resolve<IDataService>(); Assert.IsInstanceOfType(typeof(DataService), service); } }
See the fluent API wiki page for more information.
相关问答
更多-
事实证明,第二个请求是MVC框架试图找到我包含在Site.Master中的脚本。 路径不存在,所以我想它试图解决一个控制器(匹配/Scripts/sitescripts.js)。 我改变了这个方法: protected override IController GetControllerInstance(Type controllerType) { if (controllerType != null) { return (IController)_container.Reso ...
-
我的MVC控制器被设置为接受构造函数中的HttpContextBase参数 你必须在这里做一些非常错误的事情,所以在太迟之前停止并造成损害(物质,道德和人类伤亡:-))。 控制器中已经有了HttpContext。 不要在您的DI框架中注册任何HttpContext。 HttpContext处理是ASP.NET的工作。 My MVC Controllers are set up to accept an HttpContextBase argument in the constructor You gotta ...
-
.If(t => t.Name.EndsWith("Adapter")) 但是,将结果放在一边,为了架构清晰,将类型分隔到自己的命名空间可能是个好主意。 副作用是,你不需要额外的过滤谓词。 .If(t => t.Name.EndsWith("Adapter")) However, putting the how aside, it might be a good idea to separate the types into their own namespace, for architectural cl ...
-
Moq在内部使用Castle的动态代理,而模拟类实际上是由Castle生成的代理,这是Castle开发人员不希望支持的内部原因。 你可以在这里阅读更多内容: https://github.com/castleproject/Windsor/issues/224 https://github.com/castleproject/castle-youtrack-export/blob/master/IOC/IOC-332.xml 正如Nkosi已经评论的那样,您应该考虑一下您真正需要实现的内容并重新考虑您的设计 ...
-
使用Windsor 2.0: [TestFixture] public class WindsorTests { public interface IDataService {} public class DataService: IDataService {} public interface IDataFactory { IDataService Service { get; } } public class DataFactory: IDa ...
-
Castle Windsor - 使用工厂方法注册所有接口(Castle Windsor - Register all interfaces with factory method)[2023-08-01]
在Windsor <3.0中没有更好的内置方式 从Windsor 3开始,您可以使用Types而不是AllTypes来AllTypes 。 AllTypes实际上意味着所有非抽象类 Types确实意味着所有类型。 是的,虽然这确实有点AllTypes并且是违反直觉的,但由于AllTypes排在第一位,我们无法改变其现有行为以保持向后兼容性。 另外为了保持理智,建议使用Classes而不是AllTypes ,因此您最终会在类问题中为类似案例注册Classses和Types 。 There's no bette ... -
因为泛型方法调用通常由编译器设置,所以在运行时不能完全不使用反射调用,但是使用object GetService(Type t)签名而不是泛型参数,您可以这样做: container.Register(Types.FromThisAssembly() .BasedOn
() .Configure(c => c.UsingFactoryMethod((k, ctx) => GetService(ctx.RequestedType)) ) ); 这是使 ... -
我再次回答我自己的问题(发布后的第二天,亲爱的):P 这个错误信息正在这里抛出(感谢上帝的开源!): https://github.com/castleproject/Windsor/blob/016730de012f15985410fb33e2eb907690fe5a28/src/Castle.Windsor/MicroKernel/Lifestyle/PerWebRequestLifestyleModule.cs tldr - 见下文: public class PerWebRequestLifesty ...
-
也许使用真正的工厂,而不是键入的工厂: public ConnectionAFactory : IConnectionFactory { public ConnectionAFactory() { this.connectionString = "foo"; } } 并使用正确的存储库在windsor中注册它: Component.For
() .DependsOn( ServiceOverrid ... -
当您需要在运行时解析类型时,常规解决方案是注入一个工厂,可以在适当的时间做出决定: public class ReportFactory: IReportFactory { IReport CreateReport(bool useDefault) { if (useDefault) { return new DefaultReport(); } else { return new UnusualReport(); ...