TypeToAutomationType() публичный статический Метод

public static TypeToAutomationType ( Type type ) : UIAutomationType
type System.Type
Результат UIAutomationType
        private static IEnumerable <UiaParameterDescription> BuildParamsFromProviderMethodInfo(MethodInfo mInfo)
        {
            // Accordingly to UIA docs, In params should go before any Out params

            var inParams = from parameterInfo in mInfo.GetParameters()
                           where !parameterInfo.IsOut
                           let uiaType = UiaTypesHelper.TypeToAutomationType(parameterInfo.ParameterType)
                                         select new UiaParameterDescription(parameterInfo.Name, uiaType);

            var outParams = from parameterInfo in mInfo.GetParameters()
                            where parameterInfo.IsOut
                            let uiaType = UiaTypesHelper.TypeToOutAutomationType(parameterInfo.ParameterType.GetElementType())
                                          select new UiaParameterDescription(parameterInfo.Name, uiaType);

            var retParam = Enumerable.Empty <UiaParameterDescription>();

            if (mInfo.ReturnType != typeof(void))
            {
                var uiaRetType    = UiaTypesHelper.TypeToOutAutomationType(mInfo.ReturnType);
                var retParamDescr = new UiaParameterDescription(UiaTypesHelper.RetParamUnspeakableName, uiaRetType);
                retParam = new[] { retParamDescr };
            }

            return(inParams.Concat(outParams).Concat(retParam));
        }
        private UiaPropertyInfoHelper GetPropertyHelper(PropertyInfo pInfo)
        {
            var propertyAttr     = pInfo.GetAttribute <PatternPropertyAttribute>(); // can'be null as otherwise it wouldn't get into this method
            var guid             = propertyAttr.Guid;
            var programmaticName = pInfo.Name;
            var uiaType          = UiaTypesHelper.TypeToAutomationType(pInfo.PropertyType);

            return(new UiaPropertyInfoHelper(guid, programmaticName, uiaType, pInfo.GetPropertyGetter()));
        }
Пример #3
0
        private void ReflectStandaloneProperties()
        {
            var t  = GetType();
            var fs = t.GetStaticFieldsMarkedWith <StandalonePropertyAttribute>();
            var standaloneProps = new List <UiaPropertyInfoHelper>();

            foreach (var fieldInfo in fs)
            {
                if (!fieldInfo.Name.EndsWith("Property"))
                {
                    throw new ArgumentException("Field {0} marked with StandalonePropertyAttribute but named incorrectly. Should be XxxProperty, where Xxx is the programmatic name of the property being registered");
                }
                var programmaticName = fieldInfo.Name.Remove(fieldInfo.Name.Length - "Property".Length);
                var attr             = fieldInfo.GetAttribute <StandalonePropertyAttribute>();
                var uiaType          = UiaTypesHelper.TypeToAutomationType(attr.Type);
                standaloneProps.Add(new UiaPropertyInfoHelper(attr.Guid, programmaticName, uiaType));
            }
            if (standaloneProps.Count > 0)
            {
                _standaloneProperties = standaloneProps.ToArray();
            }
        }