How can I set up Unity 3 to work in a console application?

可紊 提交于 2019-12-11 08:30:00

问题


I would like to get some experience using Unity 3 so I set up a console application and downloaded Unity from nuGet.

However I didn't find any examples on how I can start Unity? Do I need to add some code to my main method to make a Unity container or is it normal to put that code into another file and call that?

Note that I did find the "Unity hands-on labs" but these look far too complicated for a starter tutorial. I would really like to find some starter example coded in C# if anyone has any links bookmared that would be a great help.


回答1:


http://msdn.microsoft.com/en-us/library/dn178463(v=pandp.30).aspx

Basically, yes, you have to initialize Unity first. Just put this in the beginning of your Main method:

var container = new UnityContainer();
container.RegisterType<IYourType, YourType>();


来源:https://stackoverflow.com/questions/22961463/how-can-i-set-up-unity-3-to-work-in-a-console-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!