AddProperty() публичный Метод

Add a property to this pattern
public AddProperty ( UiaPropertyInfoHelper property ) : void
property UiaPropertyInfoHelper
Результат void
Пример #1
0
        /// <summary>
        /// Helper method to register this pattern.
        /// </summary>
        public void Register()
        {
            if (_registered)
            {
                return;
            }

            // Get our pointer to the registrar
            IUIAutomationRegistrar registrar = new CUIAutomationRegistrarClass();

            // Set up the pattern struct
            var patternInfo = new UiaPatternInfoHelper(PatternGuid,
                                                       PatternName,
                                                       PatternClientGuid,
                                                       PatternProviderGuid,
                                                       Handler);

            // Populate it with properties and methods
            uint index = 0;

            foreach (var propertyInfo in Properties)
            {
                patternInfo.AddProperty(propertyInfo);
                propertyInfo.Index = index++;
                if (propertyInfo.SupportsDispatch)
                {
                    _members[propertyInfo.Index] = propertyInfo;
                }
            }
            foreach (var methodInfo in Methods)
            {
                patternInfo.AddMethod(methodInfo);
                methodInfo.Index = index++;
                if (methodInfo.SupportsDispatch)
                {
                    _members[methodInfo.Index] = methodInfo;
                }
            }

            // Add the events, too, although they are not indexed
            foreach (var eventInfo in Events)
            {
                patternInfo.AddEvent(eventInfo);
            }

            // Register the pattern
            var patternData = patternInfo.Data;

            // Call register pattern
            int[] propertyIds = new int[patternData.cProperties];
            int[] eventIds    = new int[patternData.cEvents];
            registrar.RegisterPattern(ref patternData,
                                      out _patternId,
                                      out _patternAvailablePropertyId,
                                      patternData.cProperties,
                                      propertyIds,
                                      patternData.cEvents,
                                      eventIds);

            // Write the property IDs back
            for (uint i = 0; i < propertyIds.Length; ++i)
            {
                Properties[i].PropertyId = propertyIds[i];
            }
            for (var i = 0; i < eventIds.Length; ++i)
            {
                Events[i].EventId = eventIds[i];
            }

            if (StandaloneProperties != null)
            {
                RegisterStandaloneProperties(registrar);
            }

            _registered = true;
        }
        /// <summary>
        /// Helper method to register this pattern.
        /// </summary>
        public void Register()
        {
            if (_registered) return;

            // Get our pointer to the registrar
            IUIAutomationRegistrar registrar = new CUIAutomationRegistrarClass();

            // Set up the pattern struct
            var patternInfo = new UiaPatternInfoHelper(PatternGuid,
                                                       PatternName,
                                                       PatternClientGuid,
                                                       PatternProviderGuid,
                                                       Handler);

            // Populate it with properties and methods
            uint index = 0;
            foreach (var propertyInfo in Properties)
            {
                patternInfo.AddProperty(propertyInfo);
                propertyInfo.Index = index++;
                if (propertyInfo.SupportsDispatch)
                    _members[propertyInfo.Index] = propertyInfo;
            }
            foreach (var methodInfo in Methods)
            {
                patternInfo.AddMethod(methodInfo);
                methodInfo.Index = index++;
                if (methodInfo.SupportsDispatch)
                    _members[methodInfo.Index] = methodInfo;
            }

            // Add the events, too, although they are not indexed
            foreach (var eventInfo in Events)
            {
                patternInfo.AddEvent(eventInfo);
            }

            // Register the pattern
            var patternData = patternInfo.Data;

            // Call register pattern
            int[] propertyIds = new int[patternData.cProperties];
            int[] eventIds = new int[patternData.cEvents];
            registrar.RegisterPattern(ref patternData,
                                      out _patternId,
                                      out _patternAvailablePropertyId,
                                      patternData.cProperties,
                                      propertyIds,
                                      patternData.cEvents,
                                      eventIds);

            // Write the property IDs back
            for (uint i = 0; i < propertyIds.Length; ++i)
            {
                Properties[i].PropertyId = propertyIds[i];
            }
            for (var i = 0; i < eventIds.Length; ++i)
            {
                Events[i].EventId = eventIds[i];
            }

            if (StandaloneProperties != null)
                RegisterStandaloneProperties(registrar);

            _registered = true;
        }