如何设置 Unity 3 以在控制台应用程序中工作? [英] How can I set up Unity 3 to work in a console application?

查看:25
本文介绍了如何设置 Unity 3 以在控制台应用程序中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一些使用 Unity 3 的经验,所以我设置了一个控制台应用程序并从 nuGet 下载了 Unity.

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

但是我没有找到任何关于如何启动 Unity 的示例?我是否需要在我的 main 方法中添加一些代码来制作 Unity 容器,还是将该代码放入另一个文件并调用它是否正常?

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?

请注意,我确实找到了Unity 动手实验",但对于入门教程来说,这些看起来太复杂了.我真的很想找到一些用 C# 编码的入门示例,如果有人收藏了任何链接,这将是一个很大的帮助.

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.

推荐答案

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

基本上,是的,您必须先初始化 Unity.只需将其放在 Main 方法的开头即可:

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>();

这篇关于如何设置 Unity 3 以在控制台应用程序中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆