Поделиться через


ControlType.GetRequiredPatternSets Метод

Определение

Извлекает массив наборов требуемых шаблонов.

public:
 cli::array <cli::array <System::Windows::Automation::AutomationPattern ^> ^> ^ GetRequiredPatternSets();
public System.Windows.Automation.AutomationPattern[][] GetRequiredPatternSets ();
member this.GetRequiredPatternSets : unit -> System.Windows.Automation.AutomationPattern[][]
Public Function GetRequiredPatternSets () As AutomationPattern()()

Возвращаемое значение

Массив наборов требуемых шаблонов.

Примеры

В следующем примере вызывается GetRequiredPatternSets для всех типов, ControlType содержащихся в виде статического поля в ControlType классе .

/// <summary>
/// Obtains information about patterns supported by control types.
/// Control types are obtained by reflection.
/// </summary>
private void ListPatterns()
{
    // Any instance of a ControlType will do since we just want to get the type.
    ControlType controlTypeInstance = ControlType.Button;
    Type type = typeof(ControlType);
    System.Reflection.FieldInfo[] fields = type.GetFields();
    foreach (System.Reflection.FieldInfo field in fields)
    {
        if (field.IsStatic)
        {
            ControlType controlType = field.GetValue(controlTypeInstance) as ControlType;
            Console.WriteLine("\n******************** {0} never supports:",
                               controlType.ProgrammaticName);
            AutomationPattern[] neverSupportedPatterns =
                               controlType.GetNeverSupportedPatterns();
            if (neverSupportedPatterns.Length == 0)
            {
                Console.WriteLine("(None)");
            }
            else
            {
                foreach (AutomationPattern pattern in neverSupportedPatterns)
                {
                    Console.WriteLine(pattern.ProgrammaticName);
                }
            }

            Console.WriteLine("\n******************** {0} requires:",
                              controlType.ProgrammaticName);
            AutomationPattern[][] requiredPatternSets =
                              controlType.GetRequiredPatternSets();
            if (requiredPatternSets.Length == 0)
            {
                Console.WriteLine("(None)");
            }
            else
            {
                foreach (AutomationPattern[] patterns in requiredPatternSets)
                {
                    Console.WriteLine("Pattern set:");
                    foreach (AutomationPattern pattern in patterns)
                    {
                        Console.WriteLine(pattern.ProgrammaticName);
                    }
                    Console.WriteLine("--------------------");
                }
            }
        }
    }
}
''' <summary>
''' Obtains information about patterns supported by control types.
''' Control types are obtained by reflection.
''' </summary>
Private Sub ListPatterns()
    ' Any instance of a ControlType will do since we just want to get the type.
    Dim controlTypeInstance As ControlType = ControlType.Button
    Dim type As Type = GetType(ControlType)
    Dim fields() As System.Reflection.FieldInfo = type.GetFields()
    For Each field As System.Reflection.FieldInfo In fields
        If field.IsStatic Then
            Dim controlType As ControlType = TryCast(field.GetValue(controlTypeInstance), ControlType)
            Console.WriteLine(vbLf & "******************** {0} never supports:", controlType.ProgrammaticName)
            Dim neverSupportedPatterns() As AutomationPattern = controlType.GetNeverSupportedPatterns()
            If neverSupportedPatterns.Length = 0 Then
                Console.WriteLine("(None)")
            Else
                For Each pattern As AutomationPattern In neverSupportedPatterns
                    Console.WriteLine(pattern.ProgrammaticName)
                Next pattern
            End If

            Console.WriteLine(vbLf & "******************** {0} requires:", controlType.ProgrammaticName)
            Dim requiredPatternSets()() As AutomationPattern = controlType.GetRequiredPatternSets()
            If requiredPatternSets.Length = 0 Then
                Console.WriteLine("(None)")
            Else
                For Each patterns As AutomationPattern() In requiredPatternSets
                    Console.WriteLine("Pattern set:")
                    For Each pattern As AutomationPattern In patterns
                        Console.WriteLine(pattern.ProgrammaticName)
                    Next pattern
                    Console.WriteLine("--------------------")
                Next patterns
            End If
        End If
    Next field
End Sub

Комментарии

Каждый элемент массива содержит массив шаблонов, и каждый элемент, имеющий этот тип элемента управления, должен поддерживать по крайней мере один из этих массивов.

Этот метод полезен для модель автоматизации пользовательского интерфейса клиентов, которым требуется найти все возможные шаблоны, такие как тестовые платформы для реализации поставщика.

Применяется к