コード例 #1
0
        public bool TryGetPropertyValue <T>(PropertyId property, out T value)
        {
            if (Equals(property, PropertyId.NotSupportedByFramework))
            {
                throw new NotSupportedByFrameworkException();
            }

            var isCacheActive = CacheRequest.IsCachingActive;

            try
            {
                var internalValue = this.InternalGetPropertyValue(property.Id, isCacheActive, useDefaultIfNotSupported: false);
                if (internalValue == this.Automation.NotSupportedValue)
                {
                    value = default(T);
                    return(false);
                }

                value = property.Convert <T>(this.Automation, internalValue);
                return(true);
            }
            catch (Exception ex)
            {
                if (isCacheActive)
                {
                    var cacheRequest = CacheRequest.Current;
                    if (!cacheRequest.Properties.Contains(property))
                    {
                        throw new PropertyNotCachedException(property, ex);
                    }
                }

                // Should actually never come here
                throw;
            }
        }
コード例 #2
0
 public void Add(PropertyId property)
 {
     this.Properties.Add(property);
 }
 public PropertyNotSupportedException(string message, PropertyId property, Exception innerException)
     : base(message, innerException)
 {
     this.Property = property;
 }
 public PropertyNotSupportedException(PropertyId property, Exception innerException)
     : base(string.Format(DefaultMessageWithData, property.Name), innerException)
 {
     this.Property = property;
 }
 public PropertyNotSupportedException(string message, PropertyId property)
     : base(message)
 {
     this.Property = property;
 }
コード例 #6
0
 public PropertyNotCachedException(PropertyId property)
     : base(string.Format(DefaultMessageWithData, property))
 {
     this.Property = property;
 }
コード例 #7
0
 public static PatternId GetOrCreate(int id, string name, PropertyId availabilityProperty)
 {
     return(Cache.GetOrAdd(id, x => new PatternId(x, name, availabilityProperty)));
 }
コード例 #8
0
 private PatternId(int id, string name, PropertyId availabilityProperty)
 {
     this.Id   = id;
     this.Name = name;
     this.AvailabilityProperty = availabilityProperty;
 }
 /// <inheritdoc/>
 public void HandlePropertyChangedEvent(AutomationElement sender, PropertyId propertyId, object newValue)
 {
     this.callAction(sender, propertyId, newValue);
 }
コード例 #10
0
 /// <summary>
 /// Gets the desired property value. Ends in an exception if the property is not supported or not cached.
 /// </summary>
 public object GetPropertyValue(PropertyId property)
 {
     return(this.GetPropertyValue <object>(property));
 }
コード例 #11
0
 /// <summary>
 /// Tries to get the property value.
 /// Returns false and sets a default value if the property is not supported.
 /// </summary>
 public bool TryGetPropertyValue(PropertyId property, out object value)
 {
     return(this.TryGetPropertyValue <object>(property, out value));
 }
コード例 #12
0
 protected AutomationProperty <T> GetOrCreate <T>(ref AutomationProperty <T> val, PropertyId propertyId)
 {
     return(val ?? (val = new AutomationProperty <T>(propertyId, this.BasicAutomationElement)));
 }
コード例 #13
0
 /// <summary>
 /// Method to check if the element supports the given property via UIA method.
 /// Does not work with cached elements and might be unreliable.
 /// </summary>
 public bool IsPropertySupportedDirect(PropertyId property)
 {
     return(this.GetSupportedPropertiesDirect().Contains(property));
 }
コード例 #14
0
 public PropertyCondition(PropertyId property, object value)
     : this(property, value, PropertyConditionFlags.None)
 {
 }
コード例 #15
0
 public PropertyCondition(PropertyId property, object value, PropertyConditionFlags propertyConditionFlags)
 {
     this.Property = property;
     this.Value    = value;
     this.PropertyConditionFlags = propertyConditionFlags;
 }
コード例 #16
0
 public static bool TryGet(int id, out PropertyId result)
 {
     return(Cache.TryGetValue(id, out result));
 }