diff --git a/Perspex/Controls/TextBlock.cs b/Perspex/Controls/TextBlock.cs index 454bcb8a38..cbae827ec3 100644 --- a/Perspex/Controls/TextBlock.cs +++ b/Perspex/Controls/TextBlock.cs @@ -7,6 +7,7 @@ namespace Perspex.Controls { using Perspex.Media; + using Splat; public class TextBlock : Control { @@ -57,7 +58,7 @@ namespace Perspex.Controls protected override Size MeasureContent(Size availableSize) { - ITextService service = ServiceLocator.Get(); + ITextService service = Locator.Current.GetService(); return service.Measure(this.FormattedText); } } diff --git a/Perspex/Perspex.csproj b/Perspex/Perspex.csproj index 74353bce5c..ed7c7cdbc9 100644 --- a/Perspex/Perspex.csproj +++ b/Perspex/Perspex.csproj @@ -115,7 +115,6 @@ - diff --git a/Perspex/ServiceLocator.cs b/Perspex/ServiceLocator.cs deleted file mode 100644 index e83ddbf1ab..0000000000 --- a/Perspex/ServiceLocator.cs +++ /dev/null @@ -1,27 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright 2014 MIT Licence. See licence.md for more information. -// -// ----------------------------------------------------------------------- - -namespace Perspex -{ - using System; - using System.Collections.Generic; - - public static class ServiceLocator - { - private static Dictionary> services = - new Dictionary>(); - - public static T Get() - { - return (T)services[typeof(T)](); - } - - public static void Register(Func func) - { - services.Add(typeof(T), () => (object)func()); - } - } -} diff --git a/TestApplication/Program.cs b/TestApplication/Program.cs index a70f29ef34..87d7c11752 100644 --- a/TestApplication/Program.cs +++ b/TestApplication/Program.cs @@ -37,7 +37,8 @@ namespace TestApplication { static void Main(string[] args) { - ServiceLocator.Register(() => new TextService(new SharpDX.DirectWrite.Factory())); + Locator.CurrentMutable.Register(() => new TextService(new SharpDX.DirectWrite.Factory()), typeof(ITextService)); + Locator.CurrentMutable.Register(() => new Styler(), typeof(IStyler)); Locator.CurrentMutable.Register(() => new TestLogger(), typeof(ILogger)); Application application = new Application