Browse Source

Don't allow to call AppBuilder.Setup twice

Nikita Tsukanov 8 years ago
parent
commit
37c5414922
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/Avalonia.Controls/AppBuilderBase.cs

+ 5 - 0
src/Avalonia.Controls/AppBuilderBase.cs

@@ -14,6 +14,8 @@ namespace Avalonia.Controls
     /// <typeparam name="TAppBuilder">The type of the AppBuilder class itself.</typeparam>
     public abstract class AppBuilderBase<TAppBuilder> where TAppBuilder : AppBuilderBase<TAppBuilder>, new()
     {
+        private static bool s_setupWasAlreadyCalled;
+        
         /// <summary>
         /// Gets or sets the <see cref="IRuntimePlatform"/> instance.
         /// </summary>
@@ -252,6 +254,9 @@ namespace Avalonia.Controls
                 throw new InvalidOperationException("No rendering system configured.");
             }
 
+            if (s_setupWasAlreadyCalled)
+                throw new InvalidOperationException("Setup was already called on one of AppBuilder instances");
+
             Instance.RegisterServices();
             RuntimePlatformServicesInitializer();
             WindowingSubsystemInitializer();