Bläddra i källkod

Merge pull request #2305 from AvaloniaUI/refactor/remove-isupportinitialize

Remove Avalonia.ISupportInitialize.
Steven Kirk 6 år sedan
förälder
incheckning
bd64e1bde2

+ 0 - 22
src/Avalonia.Base/ISupportInitialize.cs

@@ -1,22 +0,0 @@
-// Copyright (c) The Avalonia Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-namespace Avalonia
-{
-    /// <summary>
-    /// Specifies that this object supports a simple, transacted notification for batch 
-    /// initialization.
-    /// </summary>
-    public interface ISupportInitialize
-    {
-        /// <summary>
-        /// Signals the object that initialization is starting.
-        /// </summary>
-        void BeginInit();
-
-        /// <summary>
-        /// Signals the object that initialization is complete.
-        /// </summary>
-        void EndInit();
-    }
-}

+ 1 - 0
src/Avalonia.Controls/Control.cs

@@ -1,6 +1,7 @@
 // Copyright (c) The Avalonia Project. All rights reserved.
 // Licensed under the MIT license. See licence.md file in the project root for full license information.
 
+using System.ComponentModel;
 using Avalonia.Controls.Primitives;
 using Avalonia.Controls.Templates;
 using Avalonia.Input;

+ 1 - 0
src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs

@@ -1,4 +1,5 @@
 using System;
+using System.ComponentModel;
 using Avalonia.Controls.Platform;
 using Avalonia.Input;
 using Avalonia.Platform;

+ 1 - 0
src/Avalonia.Controls/Embedding/Offscreen/OffscreenTopLevel.cs

@@ -1,4 +1,5 @@
 using System;
+using System.ComponentModel;
 using Avalonia.Styling;
 
 namespace Avalonia.Controls.Embedding.Offscreen

+ 1 - 0
src/Avalonia.Controls/WindowBase.cs

@@ -1,4 +1,5 @@
 using System;
+using System.ComponentModel;
 using System.Linq;
 using System.Reactive.Disposables;
 using System.Reactive.Linq;

+ 1 - 0
src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs

@@ -8,6 +8,7 @@ using Avalonia.Platform;
 using Portable.Xaml;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.IO;
 using System.Reflection;
 using System.Runtime.Serialization;

+ 0 - 35
src/Markup/Avalonia.Markup.Xaml/PortableXaml/AvaloniaXamlObjectWriter.cs

@@ -77,40 +77,15 @@ namespace Avalonia.Markup.Xaml.PortableXaml
             _delayedValuesHelper.ApplyAll();
         }
 
-        protected internal override void OnAfterBeginInit(object value)
-        {
-            //not called for avalonia objects
-            //as it's called inly for
-            //Portable.Xaml.ComponentModel.ISupportInitialize
-            base.OnAfterBeginInit(value);
-        }
-
-        protected internal override void OnAfterEndInit(object value)
-        {
-            //not called for avalonia objects
-            //as it's called inly for
-            //Portable.Xaml.ComponentModel.ISupportInitialize
-            base.OnAfterEndInit(value);
-        }
-
         protected internal override void OnAfterProperties(object value)
         {
             _delayedValuesHelper.EndInit(value);
 
             base.OnAfterProperties(value);
-
-            //AfterEndInit is not called as it supports only
-            //Portable.Xaml.ComponentModel.ISupportInitialize
-            //and we have Avalonia.ISupportInitialize so we need some hacks
-            HandleEndEdit(value);
         }
 
         protected internal override void OnBeforeProperties(object value)
         {
-            //OnAfterBeginInit is not called as it supports only
-            //Portable.Xaml.ComponentModel.ISupportInitialize
-            //and we have Avalonia.ISupportInitialize so we need some hacks
-            HandleBeginInit(value);
             if (value != null)
                 _delayedValuesHelper.BeginInit(value);
 
@@ -127,16 +102,6 @@ namespace Avalonia.Markup.Xaml.PortableXaml
             return base.OnSetValue(target, member, value);
         }
 
-        private void HandleBeginInit(object value)
-        {
-            (value as Avalonia.ISupportInitialize)?.BeginInit();
-        }
-
-        private void HandleEndEdit(object value)
-        {
-            (value as Avalonia.ISupportInitialize)?.EndInit();
-        }
-
         public override void WriteStartMember(XamlMember property)
         {
             foreach(var d in DesignDirectives)

+ 1 - 0
tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

@@ -4,6 +4,7 @@
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Collections.Specialized;
+using System.ComponentModel;
 using System.Linq;
 using Avalonia.Collections;
 using Avalonia.Controls.Presenters;

+ 2 - 1
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/InitializationOrderTracker.cs

@@ -4,6 +4,7 @@
 using Avalonia.Controls;
 using Avalonia.LogicalTree;
 using System.Collections.Generic;
+using System.ComponentModel;
 
 namespace Avalonia.Markup.Xaml.UnitTests.Xaml
 {
@@ -39,4 +40,4 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml
             Order.Add($"EndInit {InitState}");
         }
     }
-}
+}

+ 1 - 0
tests/Avalonia.Styling.UnitTests/StyledElementTests.cs

@@ -10,6 +10,7 @@ using Avalonia.UnitTests;
 using Xunit;
 using Avalonia.LogicalTree;
 using Avalonia.Controls;
+using System.ComponentModel;
 
 namespace Avalonia.Styling.UnitTests
 {