internal static ControlType Register(Guid guid, string programmaticName, STID stId, AutomationProperty[] requiredProperties, AutomationPattern[] neverSupportedPatterns, AutomationPattern[][] requiredPatternsSets) { ControlType controlType = (ControlType)AutomationIdentifier.Register(UiaCoreTypesApi.AutomationIdType.ControlType, guid, programmaticName); controlType._stId = stId; controlType._requiredPatternsSets = requiredPatternsSets; controlType._neverSupportedPatterns = neverSupportedPatterns; controlType._requiredProperties = requiredProperties; return(controlType); }
public override bool Equals(object obj) { AutomationIdentifier other = obj as AutomationIdentifier; if (other == null) { return(false); } return(id.Equals(other.Id)); }
public int CompareTo(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } AutomationIdentifier other = obj as AutomationIdentifier; if (other == null) { // As tested on Windows, when the object is not an AutomationIdentifier, // a strange large integer will be returned, so we just return the MaxValue. return(int.MaxValue); } return(id.CompareTo(other.Id)); }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods internal static AutomationIdentifier Register(UiaCoreTypesApi.AutomationIdType type, int id, string programmaticName) { // Keep past behavior, if the id is not supported by the current OS, return null if (!IsIdSupported(type, id)) { return(null); } lock (_idTable) { // See if instance already exists... AutomationIdentifier autoid = (AutomationIdentifier)_idTable[id]; if (autoid != null) { return(autoid); } // If not, create one... switch (type) { case UiaCoreTypesApi.AutomationIdType.Property: autoid = new AutomationProperty(id, programmaticName); break; case UiaCoreTypesApi.AutomationIdType.Event: autoid = new AutomationEvent(id, programmaticName); break; case UiaCoreTypesApi.AutomationIdType.TextAttribute: autoid = new AutomationTextAttribute(id, programmaticName); break; case UiaCoreTypesApi.AutomationIdType.Pattern: autoid = new AutomationPattern(id, programmaticName); break; case UiaCoreTypesApi.AutomationIdType.ControlType: autoid = new ControlType(id, programmaticName); break; default: Debug.Assert(false, "Invalid type specified for AutomationIdentifier"); throw new InvalidOperationException("Invalid type specified for AutomationIdentifier"); } _idTable[id] = autoid; return(autoid); } }
//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods // Lookup a cached AutomationPattern or AutomationProperty object LookupCachedValue(AutomationIdentifier id, bool throwIfNotRequested, bool wrap) { if (_cachedValues == null) { if (throwIfNotRequested) { throw new InvalidOperationException(SR.Get(SRID.CachedPropertyNotRequested)); } else { return null; } } AutomationProperty automationProperty = id as AutomationProperty; bool isProperty = automationProperty != null; AutomationIdentifier[] refTable = isProperty ? (AutomationIdentifier[])_request.Properties : (AutomationIdentifier[])_request.Patterns; bool found = false; object val = null; int dataOffset = isProperty ? 1 : 1 + _request.Properties.Length; for (int i = 0; i < refTable.Length; i++) { if (refTable[i] == id) { found = true; val = _cachedValues[_cachedValuesIndex, i + dataOffset]; break; } } if (!found) { if (throwIfNotRequested) { throw new InvalidOperationException(SR.Get(SRID.CachedPropertyNotRequested)); } else { return null; } } // Bail now if no wrapping required; also, even with wrapping, null remains null // for both properties and patterns.. if (!wrap || val == null) { return val; } AutomationPattern automationPattern = id as AutomationPattern; // Cached values are internally stored as unwrapped, direct-from-provider values, so // need to be wrapped as appropriate before handing back to client... if (automationPattern != null) { SafePatternHandle hpatternobj = (SafePatternHandle)val; val = Misc.WrapInterfaceOnClientSide(this, hpatternobj, automationPattern); } // No wrapping necessary here for properties - the objects in the array are fully wrapped/converted as soon as they are // received from the unmanaged API, so they're ready-to-use without any further processing. return val; }
internal static bool GetPropertyTypeInfo(AutomationIdentifier id, out PropertyTypeInfo info) { foreach (PropertyTypeInfo info2 in _propertyInfoTable) { if (info2.ID == id) { info = info2; return true; } } info = null; return false; }
internal PropertyTypeInfo(PropertyConverter converter, AutomationIdentifier id, Type type) { this._id = id; this._type = type; this._converter = converter; }
internal void TSC_VerifyPropertyNotEqual(object actual, object expected, AutomationIdentifier propName, CheckType checkType) { TSC_VerifyProperty(actual, expected, false, Helpers.GetProgrammaticName(propName), checkType); }
/// ------------------------------------------------------------------- /// <summary></summary> /// ------------------------------------------------------------------- internal void TSC_VerifyProperty(object actual, object expected, bool shouldBeEqual, AutomationIdentifier propName, CheckType checkType) { TSC_VerifyProperty(actual, expected, shouldBeEqual, Helpers.GetProgrammaticName(propName), checkType); }
/// <summary> /// </summary> internal static AutomationProperty Register(AutomationIdentifierConstants.Properties id, string programmaticName) { return((AutomationProperty)AutomationIdentifier.Register(UiaCoreTypesApi.AutomationIdType.Property, (int)id, programmaticName)); }
/// <summary> /// </summary> public static ControlType LookupById(int id) { return((ControlType)AutomationIdentifier.LookupById(UiaCoreTypesApi.AutomationIdType.ControlType, id)); }
/// <summary> /// </summary> public static AutomationPattern LookupById(int id) { return((AutomationPattern)AutomationIdentifier.LookupById(UiaCoreTypesApi.AutomationIdType.Pattern, id)); }
public static AutomationEvent LookupById(int id) { return((AutomationEvent)AutomationIdentifier.LookupById(UiaCoreTypesApi.AutomationIdType.Event, id)); }
internal static AutomationEvent Register(Guid guid, string programmaticName) { return((AutomationEvent)AutomationIdentifier.Register(UiaCoreTypesApi.AutomationIdType.Event, guid, programmaticName)); }
public static AutomationProperty LookupById(int id) { return((AutomationProperty)AutomationIdentifier.LookupById(UiaCoreTypesApi.AutomationIdType.Property, id)); }
internal static AutomationProperty Register(Guid guid, string programmaticName) { return((AutomationProperty)AutomationIdentifier.Register(UiaCoreTypesApi.AutomationIdType.Property, guid, programmaticName)); }
static void Register(AutomationIdentifier identifier) { identifiers.Add(key: identifier.Id, value: identifier); }
/// <summary> /// </summary> internal static AutomationPattern Register(AutomationIdentifierConstants.Patterns id, string programmaticName) { return((AutomationPattern)AutomationIdentifier.Register(UiaCoreTypesApi.AutomationIdType.Pattern, (int)id, programmaticName)); }
/// <summary> /// </summary> internal static AutomationTextAttribute Register(AutomationIdentifierConstants.TextAttributes id, string programmaticName) { return((AutomationTextAttribute)AutomationIdentifier.Register(UiaCoreTypesApi.AutomationIdType.TextAttribute, (int)id, programmaticName)); }
/// <summary> /// </summary> internal static ControlType Register(AutomationIdentifierConstants.ControlTypes id, string programmaticName) { return((ControlType)AutomationIdentifier.Register(UiaCoreTypesApi.AutomationIdType.ControlType, (int)id, programmaticName)); }
/// <summary> /// </summary> public static AutomationTextAttribute LookupById(int id) { return((AutomationTextAttribute)AutomationIdentifier.LookupById(UiaCoreTypesApi.AutomationIdType.TextAttribute, id)); }
private static string GetPropertyName(AutomationIdentifier property) { var pattern = new Regex(@".*\.(?<name>.*)Property"); return pattern.Match(property.ProgrammaticName).Groups["name"].Value; }
internal static AutomationIdentifier Register(UiaCoreTypesApi.AutomationIdType type, Guid guid, string programmaticName) { int num = UiaCoreTypesApi.UiaLookupId(type, ref guid); if (num == 0) { if ((!AutomationIdentifier.IsWin7OnlyPatternGuid(guid) && Environment.OSVersion.Version.Major <= 6) || Environment.OSVersion.Version.Major >= 7) { int num2 = 1; while (num == 0 && num2 < 1000) { Thread.Sleep(num2); num = UiaCoreTypesApi.UiaLookupId(type, ref guid); num2 *= 2; } } if (num == 0) { return(null); } } Hashtable idTable = AutomationIdentifier._idTable; AutomationIdentifier result; lock (idTable) { AutomationIdentifier automationIdentifier = (AutomationIdentifier)AutomationIdentifier._idTable[guid]; if (automationIdentifier != null) { result = automationIdentifier; } else { switch (type) { case UiaCoreTypesApi.AutomationIdType.Property: automationIdentifier = new AutomationProperty(num, guid, programmaticName); break; case UiaCoreTypesApi.AutomationIdType.Pattern: automationIdentifier = new AutomationPattern(num, guid, programmaticName); break; case UiaCoreTypesApi.AutomationIdType.Event: automationIdentifier = new AutomationEvent(num, guid, programmaticName); break; case UiaCoreTypesApi.AutomationIdType.ControlType: automationIdentifier = new ControlType(num, guid, programmaticName); break; case UiaCoreTypesApi.AutomationIdType.TextAttribute: automationIdentifier = new AutomationTextAttribute(num, guid, programmaticName); break; default: throw new InvalidOperationException("Invalid type specified for AutomationIdentifier"); } AutomationIdentifier._idTable[num] = automationIdentifier; result = automationIdentifier; } } return(result); }