コード例 #1
0
        public void AddParameter(UiaParameterDescription param)
        {
            if (PatternMethodParamDescriptions.Count > 0 && UiaTypesHelper.IsOutType(PatternMethodParamDescriptions.Last().UiaType) && UiaTypesHelper.IsInType(param.UiaType))
            {
                throw new ArgumentException("In param can't go after an out one. Please, ensure the correct order");
            }
            if (ProviderMethodInfo != null &&
                param.Name != UiaTypesHelper.RetParamUnspeakableName &&
                !_providerMethodInfoIndicies.ContainsKey(param.Name))
            {
                throw new ArgumentException("Provided provider's method info does not have argument with this name");
            }

            UIAutomationType type = param.UiaType;
            var marshalledName    = Marshal.StringToCoTaskMemUni(param.Name);

            if (UiaTypesHelper.IsInType(type))
            {
                _inParamNames.Add(marshalledName);
                _inParamTypes.Add(type);
            }
            else
            {
                _outParamNames.Add(marshalledName);
                _outParamTypes.Add(type);
            }
            PatternMethodParamDescriptions.Add(param);
        }
コード例 #2
0
 /// <summary>
 /// Usable for general-purpose implementation that uses ISchemaMember.DispatchCallToProvider()
 /// </summary>
 /// <param name="getterFromProvider">Lambda for getting property value from pattern provider interface. It should be akin to
 /// <code>(object p) => ((ISomePatternProvider)p).MyProperty</code>. Or, same thing,
 /// <code>TypeMember&lt;ISomePatternProvider&gt;.GetPropertyGetter(p => p.MyProperty)</code>. For standalone properties
 /// it can be null (it is used for pattern handler implementation only, which doesn't take part in getting standalone properties).</param>
 public UiaPropertyInfoHelper(Guid propertyGuid, string programmaticName, UIAutomationType propertyType, Func <object, object> getterFromProvider)
 {
     _programmaticName   = programmaticName;
     _propertyGuid       = propertyGuid;
     _propertyType       = propertyType;
     _getterFromProvider = getterFromProvider;
 }
コード例 #3
0
 /// <summary>
 /// Usable for general-purpose implementation that uses ISchemaMember.DispatchCallToProvider()
 /// </summary>
 /// <param name="getterFromProvider">Lambda for getting property value from pattern provider interface. It should be akin to
 /// <code>(object p) => ((ISomePatternProvider)p).MyProperty</code>. Or, same thing, 
 /// <code>TypeMember&lt;ISomePatternProvider&gt;.GetPropertyGetter(p => p.MyProperty)</code>. For standalone properties
 /// it can be null (it is used for pattern handler implementation only, which doesn't take part in getting standalone properties).</param>
 public UiaPropertyInfoHelper(Guid propertyGuid, string programmaticName, UIAutomationType propertyType, Func<object, object> getterFromProvider)
 {
     _programmaticName = programmaticName;
     _propertyGuid = propertyGuid;
     _propertyType = propertyType;
     _getterFromProvider = getterFromProvider;
 }
コード例 #4
0
        // Compute a CLR type from its UIA type
        private Type ClrTypeFromUiaType(UIAutomationType uiaType)
        {
            // Mask off the out flag, which we don't care about.
            uiaType = (UIAutomationType)((int)uiaType & (int)~UIAutomationType.UIAutomationType_Out);

            switch (uiaType)
            {
            case UIAutomationType.UIAutomationType_Int:
                return(typeof(int));

            case UIAutomationType.UIAutomationType_Bool:
                return(typeof(int));     // These are BOOL, not bool

            case UIAutomationType.UIAutomationType_String:
                return(typeof(string));

            case UIAutomationType.UIAutomationType_Double:
                return(typeof(double));

            case UIAutomationType.UIAutomationType_Element:
                return((_onClientSide) ? typeof(IUIAutomationElement) : typeof(IRawElementProviderSimple));

            default:
                throw new ArgumentException("Type not supported by UIAutomationType");
            }
        }
        private void AssertPropertyInfo(string programmaticName, UIAutomationType uiaType, string guid, UiaPropertyInfoHelper propInfo)
        {
            var data = propInfo.Data;

            Assert.AreEqual(programmaticName, data.pProgrammaticName);
            Assert.AreEqual(uiaType, data.type);
            Assert.AreEqual(new Guid(guid), data.guid);
        }
コード例 #6
0
        public UiaParameterHelper(UIAutomationType type)
        {
            _uiaType = type;
            _clrType = ClrTypeFromUiaType(type);
            _marshalledData = Marshal.AllocCoTaskMem(GetSizeOfMarshalledData());
            _ownsData = true;

            // It is a safe assumption that if we are initialized without incoming data,
            // we are on the client side.  If this changes, we can make this an explicit parameter.
            _onClientSide = true;
        }
コード例 #7
0
        public UiaParameterHelper(UIAutomationType type)
        {
            _uiaType        = type;
            _clrType        = ClrTypeFromUiaType(type);
            _marshalledData = Marshal.AllocCoTaskMem(GetSizeOfMarshalledData());
            _ownsData       = true;

            // It is a safe assumption that if we are initialized without incoming data,
            // we are on the client side.  If this changes, we can make this an explicit parameter.
            _onClientSide = true;
        }
コード例 #8
0
        public UiaParameterHelper(UIAutomationType type, IntPtr marshalledData)
        {
            _uiaType        = type;
            _clrType        = ClrTypeFromUiaType(type);
            _marshalledData = marshalledData;
            _ownsData       = false;
            GC.SuppressFinalize(this);

            // It is a safe assumption that if we are initialized with incoming data,
            // we are on the provider side.  If this changes, we can make this an explicit parameter.
            _onClientSide = false;
        }
コード例 #9
0
        public UiaParameterHelper(UIAutomationType type, IntPtr marshalledData)
        {
            _uiaType = type;
            _clrType = ClrTypeFromUiaType(type);
            _marshalledData = marshalledData;
            _ownsData = false;
            GC.SuppressFinalize(this);

            // It is a safe assumption that if we are initialized with incoming data,
            // we are on the provider side.  If this changes, we can make this an explicit parameter.
            _onClientSide = false;
        }
コード例 #10
0
ファイル: Registrar.cs プロジェクト: chingucoding/axe-windows
        public int RegisterCustomProperty(Guid id, string name, UIAutomationType type)
        {
            UIAutomationPropertyInfo info = new UIAutomationPropertyInfo
            {
                guid = id,
                pProgrammaticName = name,
                type = type,
            };

            _uiaRegistrar.RegisterProperty(ref info, out int dynamicId);

            return dynamicId;
        }
コード例 #11
0
        public void RegisterCustomProperty_SamePropertyTwise_ReturnsSameNonZeroValue()
        {
            using (Registrar r = new Registrar())
            {
                Guid                   id   = Guid.NewGuid();
                const string           name = "My property name";
                const UIAutomationType type = UIAutomationType.UIAutomationType_Bool;

                int dynamicId1 = r.RegisterCustomProperty(id, name, type);
                int dynamicId2 = r.RegisterCustomProperty(id, name, type);
                Assert.AreNotEqual(0, dynamicId1);
                Assert.AreEqual(dynamicId1, dynamicId2);
            }
        }
コード例 #12
0
 /// <summary>
 /// Suitable for standalone properties that do not require handlers, hence no need to use ISchemaMember.DispatchCallToProvider() ever.
 /// </summary>
 public UiaPropertyInfoHelper(Guid propertyGuid, string programmaticName, UIAutomationType propertyType)
     : this(propertyGuid, programmaticName, propertyType, null)
 {
 }
コード例 #13
0
        // Compute a CLR type from its UIA type
        private Type ClrTypeFromUiaType(UIAutomationType uiaType)
        {
            // Mask off the out flag, which we don't care about.
            uiaType = (UIAutomationType) ((int) uiaType & (int) ~UIAutomationType.UIAutomationType_Out);

            switch (uiaType)
            {
                case UIAutomationType.UIAutomationType_Int:
                    return typeof (int);
                case UIAutomationType.UIAutomationType_Bool:
                    return typeof (int); // These are BOOL, not bool
                case UIAutomationType.UIAutomationType_String:
                    return typeof (string);
                case UIAutomationType.UIAutomationType_Double:
                    return typeof (double);
                case UIAutomationType.UIAutomationType_Element:
                    return (_onClientSide) ? typeof (IUIAutomationElement) : typeof (IRawElementProviderSimple);
                default:
                    throw new ArgumentException("Type not supported by UIAutomationType");
            }
        }
コード例 #14
0
 public static bool IsInType(UIAutomationType type)
 {
     return(!IsOutType(type));
 }
コード例 #15
0
 public static bool IsOutType(UIAutomationType type)
 {
     return((type & UIAutomationType.UIAutomationType_Out) != 0);
 }
コード例 #16
0
 public UiaParameterDescription(string name, UIAutomationType type)
 {
     _name    = name;
     _uiaType = type;
 }
コード例 #17
0
 public UiaParameterDescription(string name, UIAutomationType type)
 {
     _name = name;
     _uiaType = type;
 }
コード例 #18
0
 /// <summary>
 /// Suitable for standalone properties that do not require handlers, hence no need to use ISchemaMember.DispatchCallToProvider() ever.
 /// </summary>
 public UiaPropertyInfoHelper(Guid propertyGuid, string programmaticName, UIAutomationType propertyType)
     : this(propertyGuid, programmaticName, propertyType, null)
 {
 }
コード例 #19
0
 public static bool IsInType(UIAutomationType type)
 {
     return !IsOutType(type);
 }
コード例 #20
0
 public static bool IsOutType(UIAutomationType type)
 {
     return (type & UIAutomationType.UIAutomationType_Out) != 0;
 }