-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip useless handler mappings calls while connecting
- Loading branch information
1 parent
5ceff42
commit 5573017
Showing
11 changed files
with
244 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Maui | ||
{ | ||
internal static class InternalElementExtensions | ||
{ | ||
/// <summary> | ||
/// The handler is connecting for the first time to the element and mapping all properties. | ||
/// </summary> | ||
/// <param name="element"></param> | ||
/// <returns></returns> | ||
internal static bool IsMappingProperties(this IElement element) => | ||
(element.Handler as IElementHandlerStateExhibitor)?.State.HasFlag(ElementHandlerState.MappingProperties) ?? false; | ||
|
||
/// <summary> | ||
/// Indicates whether the handler is connecting for the first time to the element and mapping all properties. | ||
/// </summary> | ||
/// <param name="element"></param> | ||
/// <returns></returns> | ||
internal static bool IsConnectingHandler(this IElement element) => | ||
(element.Handler as IElementHandlerStateExhibitor)?.State.HasFlag(ElementHandlerState.Connecting) ?? false; | ||
|
||
/// <summary> | ||
/// Indicates whether the connected handler is now connecting to a new element and updating properties. | ||
/// </summary> | ||
/// <param name="element"></param> | ||
/// <returns></returns> | ||
internal static bool IsReconnectingHandler(this IElement element) => | ||
(element.Handler as IElementHandlerStateExhibitor)?.State.HasFlag(ElementHandlerState.Reconnecting) ?? false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
|
||
namespace Microsoft.Maui | ||
{ | ||
/// <summary> | ||
/// Exposes the state of an element handler. | ||
/// </summary> | ||
[Flags] | ||
internal enum ElementHandlerState : byte | ||
{ | ||
/// <summary> | ||
/// The handler is not connected to an element. | ||
/// </summary> | ||
Disconnected = 0x0, | ||
/// <summary> | ||
/// The handler is mapping all properties to the element. | ||
/// </summary> | ||
MappingProperties = 0x1, | ||
/// <summary> | ||
/// The handler is connecting for the first time to the element and mapping all properties. | ||
/// </summary> | ||
Connecting = MappingProperties | 0x2, | ||
/// <summary> | ||
/// The connected handler is now connecting to a new element and updating properties. | ||
/// </summary> | ||
Reconnecting = MappingProperties | 0x4, | ||
/// <summary> | ||
/// The handler is connected to an element. | ||
/// </summary> | ||
Connected = 0x8 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Microsoft.Maui | ||
{ | ||
/// <summary> | ||
/// Exposes the state of an element handler. | ||
/// </summary> | ||
/// <remarks> | ||
/// To be migrated to a public API. | ||
/// </remarks> | ||
internal interface IElementHandlerStateExhibitor | ||
{ | ||
/// <summary> | ||
/// Gets the state of the element handler. | ||
/// </summary> | ||
ElementHandlerState State { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Maui | ||
{ | ||
internal static class InternalElementHandlerExtensions | ||
{ | ||
/// <summary> | ||
/// The handler is connecting for the first time to the element and mapping all properties. | ||
/// </summary> | ||
/// <param name="handler"></param> | ||
/// <returns></returns> | ||
internal static bool IsMappingProperties(this IElementHandler handler) => | ||
(handler as IElementHandlerStateExhibitor)?.State.HasFlag(ElementHandlerState.MappingProperties) ?? false; | ||
|
||
/// <summary> | ||
/// Indicates whether the handler is connecting for the first time to the element and mapping all properties. | ||
/// </summary> | ||
/// <param name="handler"></param> | ||
/// <returns></returns> | ||
internal static bool IsConnectingHandler(this IElementHandler handler) => | ||
(handler as IElementHandlerStateExhibitor)?.State.HasFlag(ElementHandlerState.Connecting) ?? false; | ||
|
||
/// <summary> | ||
/// Indicates whether the connected handler is now connecting to a new element and updating properties. | ||
/// </summary> | ||
/// <param name="handler"></param> | ||
/// <returns></returns> | ||
internal static bool IsReconnectingHandler(this IElementHandler handler) => | ||
(handler as IElementHandlerStateExhibitor)?.State.HasFlag(ElementHandlerState.Reconnecting) ?? false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.