本文整理汇总了C#中IServiceLocator.?.GetInstance方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceLocator.?.GetInstance方法的具体用法?C# IServiceLocator.?.GetInstance怎么用?C# IServiceLocator.?.GetInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceLocator
的用法示例。
在下文中一共展示了IServiceLocator.?.GetInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BasicGraphicsScreen
//--------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="BasicGraphicsScreen"/> class.
/// </summary>
/// <param name="services">The services.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="services"/> is <see langword="null"/>.
/// </exception>
public BasicGraphicsScreen(IServiceLocator services)
: base(services?.GetInstance<IGraphicsService>())
{
if (services == null)
throw new ArgumentNullException(nameof(services));
_meshRenderer = new MeshRenderer();
_billboardRenderer = new BillboardRenderer(GraphicsService, 2048);
var contentManager = services.GetInstance<ContentManager>();
var spriteFont = contentManager.Load<SpriteFont>("DigitalRune.Editor.Game/Fonts/DejaVuSans");
DebugRenderer = new DebugRenderer(GraphicsService, spriteFont);
Scene = new Scene();
}
示例2: DebugGraphicsScreen
//--------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="DebugGraphicsScreen" /> class.
/// </summary>
/// <param name="services">The services.</param>
public DebugGraphicsScreen(IServiceLocator services)
: base(services?.GetInstance<IGraphicsService>())
{
if (services == null)
throw new ArgumentNullException(nameof(services));
Coverage = GraphicsScreenCoverage.Partial;
_spriteBatch = GraphicsService.GetSpriteBatch();
_whiteTexture = GraphicsService.GetDefaultTexture2DWhite();
var contentManager = services.GetInstance<ContentManager>();
var spriteFont = contentManager.Load<SpriteFont>("DigitalRune.Editor.Game/Fonts/DejaVuSans");
DebugRenderer = new DebugRenderer(GraphicsService, spriteFont);
_internalDebugRenderer = new DebugRenderer(GraphicsService, spriteFont);
// To count the update frame rate, we handle the GameLogicUpdating event.
// (We cannot use GraphicsScreen.OnUpdate because it is only called at the same rate if
// the graphics screen is registered in the graphics service. If it is not registered,
// then OnUpdate and OnRender are always called together.)
var editor = services.GetInstance<IEditorService>();
_gameExtension = editor.Extensions.OfType<GameExtension>().FirstOrDefault();
if (_gameExtension != null)
_gameExtension.GameLogicUpdating += OnGameLogicUpdating;
}