A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

55 lines
2.0 KiB

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Input;
using Perspex.Layout;
using Perspex.Platform;
using Perspex.Styling;
using Perspex.Controls;
namespace Perspex.UnitTests
{
public class UnitTestApplication : Application
{
public UnitTestApplication(TestServices services)
{
Services = services ?? new TestServices();
RegisterServices();
var styles = Services.Theme?.Invoke();
if (styles != null)
{
Styles.AddRange(styles);
}
}
public static new UnitTestApplication Current => (UnitTestApplication)Application.Current;
public TestServices Services { get; }
public static IDisposable Start(TestServices services = null)
{
var scope = PerspexLocator.EnterScope();
var app = new UnitTestApplication(services);
return scope;
}
protected override void RegisterServices()
{
PerspexLocator.CurrentMutable
.Bind<IAssetLoader>().ToConstant(Services.AssetLoader)
.BindToSelf<IGlobalStyles>(this)
.Bind<IInputManager>().ToConstant(Services.InputManager)
.Bind<ILayoutManager>().ToConstant(Services.LayoutManager)
.Bind<IPclPlatformWrapper>().ToConstant(Services.PlatformWrapper)
.Bind<IPlatformRenderInterface>().ToConstant(Services.RenderInterface)
.Bind<IPlatformThreadingInterface>().ToConstant(Services.ThreadingInterface)
.Bind<IStandardCursorFactory>().ToConstant(Services.StandardCursorFactory)
.Bind<IStyler>().ToConstant(Services.Styler)
.Bind<IWindowingPlatform>().ToConstant(Services.WindowingPlatform)
.Bind<IApplicationLifecycle>().ToConstant(this);
}
}
}