internal static AutomationIdentifier Register(UiaCoreIds.AutomationIdType type, Guid guid, string programmaticName)
{
int id = UiaCoreIds.UiaLookupId(type, ref guid);
if (id == 0)
{
return null;
}
lock (_identifierDirectory)
{
AutomationIdentifier identifier = (AutomationIdentifier)_identifierDirectory[guid];
if (identifier == null)
{
switch (type)
{
case UiaCoreIds.AutomationIdType.Property:
identifier = new AutomationProperty(id, guid, programmaticName);
break;
case UiaCoreIds.AutomationIdType.Pattern:
identifier = new AutomationPattern(id, guid, programmaticName);
break;
case UiaCoreIds.AutomationIdType.Event:
identifier = new AutomationEvent(id, guid, programmaticName);
break;
case UiaCoreIds.AutomationIdType.ControlType:
identifier = new ControlType(id, guid, programmaticName);
break;
case UiaCoreIds.AutomationIdType.TextAttribute:
identifier = new AutomationTextAttribute(id, guid, programmaticName);
break;
default:
throw new InvalidOperationException("Invalid type specified for AutomationIdentifier");
}
_identifierDirectory[id] = identifier;
}
return identifier;
}
}