Пример #1
0
 internal AutomationIdentifier(UiaCoreTypesApi.AutomationIdType type, int id, Guid guid, string programmaticName)
 {
     this._id               = id;
     this._type             = type;
     this._guid             = guid;
     this._programmaticName = programmaticName;
 }
 // Internal so only our own derived classes can actually
 // use this class. (3rd party classes can try deriving,
 // but the internal ctor will prevent instantiation.)
 internal AutomationIdentifier(UiaCoreTypesApi.AutomationIdType type, int id, Guid guid, string programmaticName)
 {
     Debug.Assert(id != 0);
     _id               = id;
     _type             = type;
     _guid             = guid;
     _programmaticName = programmaticName;
 }
        private static bool IsIdSupported(UiaCoreTypesApi.AutomationIdType type, int id)
        {
            switch (type)
            {
            case UiaCoreTypesApi.AutomationIdType.Property: return(IsPropertySupported(id));

            case UiaCoreTypesApi.AutomationIdType.Event: return(IsEventSupported(id));

            case UiaCoreTypesApi.AutomationIdType.TextAttribute: return(IsTextAttributeSupported(id));

            case UiaCoreTypesApi.AutomationIdType.Pattern: return(IsPatternSupported(id));

            case UiaCoreTypesApi.AutomationIdType.ControlType: return(IsControlTypeSupported(id));

            default: return(false);
            }
        }
Пример #4
0
        internal static AutomationIdentifier LookupById(UiaCoreTypesApi.AutomationIdType type, int id)
        {
            Hashtable            idTable = AutomationIdentifier._idTable;
            AutomationIdentifier automationIdentifier;

            lock (idTable)
            {
                automationIdentifier = (AutomationIdentifier)AutomationIdentifier._idTable[id];
            }
            if (automationIdentifier == null)
            {
                return(null);
            }
            if (automationIdentifier._type != type)
            {
                return(null);
            }
            return(automationIdentifier);
        }
        internal static AutomationIdentifier LookupById(UiaCoreTypesApi.AutomationIdType type, int id)
        {
            AutomationIdentifier autoid;

            lock (_idTable)
            {
                autoid = (AutomationIdentifier)_idTable[id];
            }

            if (autoid == null)
            {
                return(null);
            }

            if (autoid._type != type)
            {
                return(null);
            }

            return(autoid);
        }
        //------------------------------------------------------
        //
        //  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);
            }
        }
Пример #7
0
 internal static int UiaLookupId(UiaCoreTypesApi.AutomationIdType type, ref Guid guid)
 {
     return(UiaCoreTypesApi.RawUiaLookupId(type, ref guid));
 }
Пример #8
0
 private static extern int RawUiaLookupId(UiaCoreTypesApi.AutomationIdType type, ref Guid guid);
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        // All Guids will be empty now since we are not calling UiaLookupId, but we need to keep the Guid
        // constructor and field because VS reflects into it
        internal AutomationIdentifier(UiaCoreTypesApi.AutomationIdType type, int id, string programmaticName)
            : this(type, id, Guid.Empty, programmaticName)
        {
        }
Пример #10
0
        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);
        }