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; } }
internal static AutomationIdentifier LookupById(UiaCoreIds.AutomationIdType type, int id) { AutomationIdentifier identifier; lock (_identifierDirectory) { identifier = (AutomationIdentifier)_identifierDirectory[id]; } if (identifier == null) { return null; } if (identifier._type != type) { return null; } return identifier; }
internal AutomationIdentifier(UiaCoreIds.AutomationIdType type, int id, Guid guid, string programmaticName) { this._id = id; this._type = type; this._guid = guid; this._programmaticName = programmaticName; }
internal static AutomationIdentifier Register(UiaCoreIds.AutomationIdType type, Guid guid, string programmaticName) { int id = UiaCoreIds.UiaLookupId(type, ref guid); if (id == 0) { return null; } var directory = GetIdentifierDictionaryForType(type); lock (directory) { AutomationIdentifier identifier; if (directory.TryGetValue(id, out identifier)) return identifier; 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"); } directory[id] = identifier; return identifier; } }
internal static AutomationIdentifier LookupById(UiaCoreIds.AutomationIdType type, int id) { AutomationIdentifier identifier; bool found; var directory = GetIdentifierDictionaryForType(type); lock (directory) { found = directory.TryGetValue(id, out identifier); } if (!found || identifier == null || identifier._type != type) { return null; } return identifier; }
private static Dictionary<int, AutomationIdentifier> GetIdentifierDictionaryForType(UiaCoreIds.AutomationIdType type) { switch (type) { case UiaCoreIds.AutomationIdType.Property: return _propertyIdentifierDirectory; case UiaCoreIds.AutomationIdType.Pattern: return _patternIdentifierDirectory; case UiaCoreIds.AutomationIdType.Event: return _eventIdentifierDirectory; case UiaCoreIds.AutomationIdType.ControlType: return _controlTypeIdentifierDirectory; case UiaCoreIds.AutomationIdType.TextAttribute: return _textAttributeIdentifierDirectory; default: throw new ArgumentOutOfRangeException("type"); } }