我试图说明如何在法典中解决某个地方的问题。
在申请启动时,我登记了一种类型。
static void Main()
{
var builder = new ContainerBuilder();
builder.RegisterType<Foo>().As<IFoo>();
}
现在,我如何能够在法典中找到一个例子?
结构计划 固定物体<代码>
我试图说明如何在法典中解决某个地方的问题。
在申请启动时,我登记了一种类型。
static void Main()
{
var builder = new ContainerBuilder();
builder.RegisterType<Foo>().As<IFoo>();
}
现在,我如何能够在法典中找到一个例子?
结构计划 固定物体<代码>
首先,你所期待的是<条码>。 采用<条码> 孔伯尔德条码>,如这种简单的温树图:
static void Main()
{
using (var container = builder.Build())
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var mainForm = container.Resolve<MainForm>();
Application.Run(mainForm)
}
}
总的想法是,你只得解决第一或最高级的问题。 集装箱将通过建筑参数处理基于依赖性注射的所有其他情况。
如果在您的整个申请中都遵循了DI模式,那么你就只能一开始便进入集装箱。
如何解决最突出的问题,主要取决于你正在建立什么样的应用。 如果有网站,ASP.Net Integration和MVC Integration将请你注意。 (除此以外,最引人注意的是伙伴关系。) 净额为<编码>不适用>。
另一方面,如果其“黄色”或“温Forms”与我前面的样本一样,用人工方式解决“Main
As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....
I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...
I ve got some code which sets up a datacontext. Often enough, the datacontext should be set to some underlying data collection, such as an ObservableCollection - but occasionally I d like to set it ...
I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...
NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...