/// <summary>
        /// Uses the specified ITypeDiscoveryService service provider to discover MaskDescriptor objects from
        /// the referenced assemblies.
        /// </summary>
        public void DiscoverMaskDescriptors(ITypeDiscoveryService discoveryService)
        {
            if (discoveryService is null)
            {
                return;
            }

            ICollection descriptors = DesignerUtils.FilterGenericTypes(discoveryService.GetTypes(typeof(MaskDescriptor), false /* excludeGlobalTypes */));

            // Note: This code assumes DesignerUtils.FilterGenericTypes return a valid ICollection (collection of MaskDescriptor types).
            foreach (Type t in descriptors)
            {
                if (t.IsAbstract || !t.IsPublic)
                {
                    continue;
                }

                // Since mask descriptors can be provided from external sources, we need to guard against
                // possible exceptions when accessing an external descriptor.
                try
                {
                    MaskDescriptor maskDescriptor = (MaskDescriptor)Activator.CreateInstance(t);
                    InsertMaskDescriptor(0, maskDescriptor);
                }
                catch (Exception ex)
                {
                    if (ClientUtils.IsCriticalException(ex))
                    {
                        throw;
                    }
                }
            }
        }
        private void PopulateColumnTypesCombo()
        {
            this.columnTypesCombo.Items.Clear();
            IDesignerHost host = (IDesignerHost)this.liveDataGridView.Site.GetService(iDesignerHostType);

            if (host != null)
            {
                ITypeDiscoveryService service = (ITypeDiscoveryService)host.GetService(iTypeDiscoveryServiceType);
                if (service != null)
                {
                    foreach (System.Type type in DesignerUtils.FilterGenericTypes(service.GetTypes(dataGridViewColumnType, false)))
                    {
                        if (((type != dataGridViewColumnType) && !type.IsAbstract) && (type.IsPublic || type.IsNestedPublic))
                        {
                            DataGridViewColumnDesignTimeVisibleAttribute attribute = TypeDescriptor.GetAttributes(type)[dataGridViewColumnDesignTimeVisibleAttributeType] as DataGridViewColumnDesignTimeVisibleAttribute;
                            if ((attribute == null) || attribute.Visible)
                            {
                                this.columnTypesCombo.Items.Add(new ComboBoxItem(type));
                            }
                        }
                    }
                    this.columnTypesCombo.SelectedIndex = this.TypeToSelectedIndex(typeof(DataGridViewTextBoxColumn));
                }
            }
        }
 public void Start(IWindowsFormsEditorService edSvc, ITypeDiscoveryService discoveryService, System.Type defaultType)
 {
     this.edSvc = edSvc;
     this.typesListBox.Items.Clear();
     foreach (System.Type type in DesignerUtils.FilterGenericTypes(discoveryService.GetTypes(dataGridViewColumnType, false)))
     {
         if (((type != dataGridViewColumnType) && !type.IsAbstract) && (type.IsPublic || type.IsNestedPublic))
         {
             DataGridViewColumnDesignTimeVisibleAttribute attribute = TypeDescriptor.GetAttributes(type)[typeof(DataGridViewColumnDesignTimeVisibleAttribute)] as DataGridViewColumnDesignTimeVisibleAttribute;
             if ((attribute == null) || attribute.Visible)
             {
                 this.typesListBox.Items.Add(new ListBoxItem(type));
             }
         }
     }
     this.typesListBox.SelectedIndex = this.TypeToSelectedIndex(defaultType);
     this.selectedType = null;
     base.Width        = Math.Max(base.Width, this.PreferredWidth + (SystemInformation.VerticalScrollBarWidth * 2));
 }
Esempio n. 4
0
 public void DiscoverMaskDescriptors(ITypeDiscoveryService discoveryService)
 {
     if (discoveryService != null)
     {
         foreach (System.Type type in DesignerUtils.FilterGenericTypes(discoveryService.GetTypes(typeof(MaskDescriptor), false)))
         {
             if (!type.IsAbstract && type.IsPublic)
             {
                 try
                 {
                     MaskDescriptor maskDescriptor = (MaskDescriptor)Activator.CreateInstance(type);
                     this.InsertMaskDescriptor(0, maskDescriptor);
                 }
                 catch (Exception exception)
                 {
                     if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
                     {
                         throw;
                     }
                 }
             }
         }
     }
 }