WindowsCommunityToolkit/CommunityToolkit.WinUI.UI/Extensions/Predicates/PredicateByName.cs

45 строки
1.6 KiB
C#
Исходник Постоянная ссылка Обычный вид История

2021-02-20 12:52:35 +03:00
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.CompilerServices;
Merge branch 'master' into winui # Conflicts: # Microsoft.Toolkit.Uwp.Connectivity/BluetoothLEHelper/BluetoothLEHelper.cs # Microsoft.Toolkit.Uwp.Connectivity/BluetoothLEHelper/ObservableBluetoothLEDevice.cs # Microsoft.Toolkit.Uwp.Connectivity/BluetoothLEHelper/ObservableGattCharacteristics.cs # Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/AdaptiveGridView/AdaptiveGridViewPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/BladeView/BladePage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/CameraPreview/CameraPreviewPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/CanvasPathGeometry/CanvasPathGeometryPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Carousel/CarouselPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/DataGrid/DataGridPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/DispatcherQueueHelper/DispatcherQueueHelperPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/DockPanel/DockPanelPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/EnumValuesExtension/EnumValuesExtensionPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Eyedropper/EyedropperPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/FadeHeader/FadeHeaderBehaviorPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/FrameworkElementExtensions/FrameworkElementExtensionsPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/GazeInteraction/GazeInteractionPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/GazeTracing/GazeTracingPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/HeaderedItemsControl/HeaderedItemsControlPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ImageCache/ImageCachePage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ImageCropper/ImageCropperPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ImageEx/ImageExPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Implicit Animations/ImplicitAnimationsPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/InAppNotification/InAppNotificationPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/InfiniteCanvas/InfiniteCanvasPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ItemsReorderAnimation/ItemsReorderAnimationPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Loading/LoadingPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MarkdownTextBlock/MarkdownTextBlockPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/OrbitView/OrbitViewPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/PrintHelper/PrintHelperPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RotatorTile/RotatorTilePage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ScrollHeader/ScrollHeaderPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ScrollViewerExtensions/ScrollViewerExtensionsPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/StaggeredLayout/StaggeredLayoutPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/StaggeredPanel/StaggeredPanelPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/StringExtensions/StringExtensionsPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/SurfaceDialTextbox/SurfaceDialTextboxPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextToolbar/TextToolbarPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TokenizingTextBox/TokenizingTextBoxPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Triggers/FullScreenModeStateTriggerPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Triggers/IsNullOrEmptyStateTriggerPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ViewExtensions/ViewExtensionsPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ViewportBehavior/ViewportBehaviorPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/WrapLayout/WrapLayoutPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/SamplePages/WrapPanel/WrapPanelPage.xaml.cs # Microsoft.Toolkit.Uwp.SampleApp/Shell.SamplePicker.cs # Microsoft.Toolkit.Uwp.SampleApp/Shell.Search.cs # Microsoft.Toolkit.Uwp.SampleApp/Shell.xaml.cs # Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/Connected.cs # Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Abstract/ImplicitAnimation{TValue,TKeyFrame}.cs # Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Default/AnchorPointAnimation.cs # Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Default/CenterPointAnimation.cs # Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Default/OffsetAnimation.cs # Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Default/OrientationAnimation.cs # Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Default/RotationAxisAnimation.cs # Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Default/ScaleAnimation.cs # Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Default/SizeAnimation.cs # Microsoft.Toolkit.Uwp.UI.Behaviors/Headers/FadeHeaderBehavior.cs # Microsoft.Toolkit.Uwp.UI.Behaviors/Headers/QuickReturnHeaderBehavior.cs # Microsoft.Toolkit.Uwp.UI.Behaviors/Headers/StickyHeaderBehavior.cs # Microsoft.Toolkit.Uwp.UI.Behaviors/Viewport/ViewportBehavior.cs # Microsoft.Toolkit.Uwp.UI.Controls.Core/ImageEx/ImageExBase.cs # Microsoft.Toolkit.Uwp.UI.Controls.Core/InAppNotification/InAppNotification.cs # Microsoft.Toolkit.Uwp.UI.Controls.Core/Menu/MenuItem.cs # Microsoft.Toolkit.Uwp.UI.Controls.Core/TextToolbar/ToolbarItems/Common/CommonButtons.Events.cs # Microsoft.Toolkit.Uwp.UI.Controls.Core/TextToolbar/ToolbarItems/Common/CommonButtons.cs # Microsoft.Toolkit.Uwp.UI.Controls.Core/TileControl/TileControl.cs # Microsoft.Toolkit.Uwp.UI.Controls.Input/RangeSelector/RangeSelector.cs # Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBox.Selection.cs # Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBoxItem.AutoSuggestBox.cs # Microsoft.Toolkit.Uwp.UI.Controls.Layout/BladeView/BladeItemAutomationPeer.cs # Microsoft.Toolkit.Uwp.UI.Controls.Layout/BladeView/BladeView.cs # Microsoft.Toolkit.Uwp.UI.Controls.Layout/Carousel/Carousel.cs # Microsoft.Toolkit.Uwp.UI.Controls.Layout/Carousel/CarouselPanel.cs # Microsoft.Toolkit.Uwp.UI.Controls.Layout/GridSplitter/GridSplitter.cs # Microsoft.Toolkit.Uwp.UI.Controls.Layout/LayoutTransformControl/LayoutTransformControl.cs # Microsoft.Toolkit.Uwp.UI.Controls.Layout/ListDetailsView/ListDetailsView.cs # Microsoft.Toolkit.Uwp.UI.Controls.Layout/OrbitView/OrbitViewPanel.cs # Microsoft.Toolkit.Uwp.UI.Controls.Markdown/Render/MarkdownRenderer.cs # Microsoft.Toolkit.Uwp.UI.Controls.Media/Eyedropper/Eyedropper.Logic.cs # Microsoft.Toolkit.Uwp.UI.Controls.Media/Eyedropper/EyedropperToolButton.cs # Microsoft.Toolkit.Uwp.UI.Controls.Media/ImageCropper/ImageCropper.Animations.cs # Microsoft.Toolkit.Uwp.UI.Controls.Media/ImageCropper/ImageCropper.Events.cs # Microsoft.Toolkit.Uwp.UI.Controls.Media/ImageCropper/ImageCropper.Helpers.cs # Microsoft.Toolkit.Uwp.UI.Controls.Media/ImageCropper/ImageCropper.Logic.cs # Microsoft.Toolkit.Uwp.UI.Controls.Media/ImageCropper/ImageCropper.cs # Microsoft.Toolkit.Uwp.UI.Controls.Primitives/DockPanel/DockPanel.cs # Microsoft.Toolkit.Uwp.UI.Media/Extensions/UIElementExtensions.cs # Microsoft.Toolkit.Uwp.UI.Media/Helpers/SurfaceLoader.cs # Microsoft.Toolkit.Uwp.UI.Media/Pipelines/PipelineBuilder.Effects.Internals.cs # Microsoft.Toolkit.Uwp.UI.Media/Pipelines/PipelineBuilder.Effects.cs # Microsoft.Toolkit.Uwp.UI.Media/Pipelines/PipelineBuilder.Initialization.cs # Microsoft.Toolkit.Uwp.UI.Media/Pipelines/PipelineBuilder.Merge.cs # Microsoft.Toolkit.Uwp.UI.Media/Pipelines/PipelineBuilder.cs # Microsoft.Toolkit.Uwp.UI/Cache/ImageCache.cs # Microsoft.Toolkit.Uwp.UI/Converters/TaskResultConverter.cs # Microsoft.Toolkit.Uwp.UI/Extensions/ApplicationViewExtensions.cs # Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement/FrameworkElementExtensions.ActualSize.cs # Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement/FrameworkElementExtensions.RelativeAncestor.cs # Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ListViewExtensions.cs # Microsoft.Toolkit.Uwp.UI/Extensions/Markup/NullableBoolExtension.cs # Microsoft.Toolkit.Uwp.UI/Extensions/Markup/OnDeviceExtension.cs # Microsoft.Toolkit.Uwp.UI/Extensions/Media/MatrixHelperEx.cs # Microsoft.Toolkit.Uwp.UI/Extensions/ScrollViewer/ScrollViewerExtensions.MiddleClickScrolling.cs # Microsoft.Toolkit.Uwp.UI/Extensions/SurfaceDialTextbox/SurfaceDialTextbox.cs # Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Regex.Internals.cs # Microsoft.Toolkit.Uwp.UI/Extensions/Tree/LogicalTree.cs # Microsoft.Toolkit.Uwp.UI/Extensions/Tree/VisualTree.cs # Microsoft.Toolkit.Uwp.UI/Helpers/ThemeListener.cs # Microsoft.Toolkit.Uwp.UI/Microsoft.Toolkit.Uwp.UI.csproj # Microsoft.Toolkit.Uwp/Helpers/PrintHelper/PrintHelper.cs # Microsoft.Toolkit.Uwp/Helpers/PrintHelper/PrintHelperStateBag.cs # Microsoft.Toolkit.Uwp/Helpers/RemoteDeviceHelper/RemoteDeviceHelper.cs # UnitTests/UnitTests.UWP/Extensions/Test_DispatcherQueueExtensions.cs # UnitTests/UnitTests.UWP/Extensions/Test_FontIconExtensionMarkupExtension.cs # UnitTests/UnitTests.UWP/Extensions/Test_FontIconSourceExtensionMarkupExtension.cs # UnitTests/UnitTests.XamlIslands.UWPApp/TestsPage.xaml.cs # UnitTests/UnitTests.XamlIslands.UWPApp/XamlIslandsTest_DropShadowPanel.cs # UnitTests/UnitTests.XamlIslands.UWPApp/XamlIslandsTest_Eyedropper.cs # UnitTests/UnitTests.XamlIslands.UWPApp/XamlIslandsTest_TextToolbar.cs # UnitTests/UnitTests.XamlIslands.UWPApp/XamlIslandsTest_ThemeListener_Threading.cs # UnitTests/UnitTests.XamlIslands.UWPApp/XamlIslandsTest_TokenizingTextBox.cs # UnitTests/UnitTests.XamlIslands.UWPApp/XamlIslandsTest_WrapPanel.cs # azure-pipelines.yml
2021-02-24 22:35:37 +03:00
using Microsoft.UI.Xaml;
2021-02-20 12:52:35 +03:00
namespace CommunityToolkit.WinUI.UI.Predicates
2021-02-20 12:52:35 +03:00
{
/// <summary>
/// An <see cref="IPredicate{T}"/> type matching <see cref="FrameworkElement"/> instances by name.
/// </summary>
internal readonly struct PredicateByName : IPredicate<FrameworkElement>
{
/// <summary>
/// The name of the element to look for.
/// </summary>
private readonly string name;
/// <summary>
/// The comparison type to use to match <see name="name"/>.
/// </summary>
private readonly StringComparison comparisonType;
/// <summary>
/// Initializes a new instance of the <see cref="PredicateByName"/> struct.
/// </summary>
/// <param name="name">The name of the element to look for.</param>
/// <param name="comparisonType">The comparison type to use to match <paramref name="name"/>.</param>
public PredicateByName(string name, StringComparison comparisonType)
{
this.name = name;
this.comparisonType = comparisonType;
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Match(FrameworkElement element)
{
return element.Name.Equals(this.name, this.comparisonType);
}
}
}