Match() public method

Checks if the certicate meets the filter criteria.
public Match ( X509Certificate2 certificate ) : bool
certificate System.Security.Cryptography.X509Certificates.X509Certificate2 The certificate.
return bool
        /// <summary>
        /// Sets the filter.
        /// </summary>
        /// <param name="filter">The filter.</param>
        internal void SetFilter(CertificateListFilter filter)
        {
            if (m_items == null || m_items.Count == 0)
            {
                return;
            }

            if (ItemsLV.View == View.List)
            {
                ItemsLV.Items.Clear();
                ItemsLV.View = View.Details;
            }

            for (int ii = 0; ii < m_items.Count; ii++)
            {
                ListViewItem item = m_items[ii];

                X509Certificate2 certificate = item.Tag as X509Certificate2;

                if (certificate == null)
                {
                    continue;
                }

                if (item.ListView != null)
                {
                    if (!filter.Match(certificate))
                    {
                        item.Remove();
                    }
                }
                else
                {
                    if (filter.Match(certificate))
                    {
                        ItemsLV.Items.Add(item);
                    }
                }
            }

            if (ItemsLV.Items.Count == 0)
            {
                Instructions = "No certificates meet the current filter criteria.";
                AdjustColumns();
                return;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the filter.
        /// </summary>
        /// <param name="filter">The filter.</param>
        internal void SetFilter(CertificateListFilter filter)
        {
            if (m_items == null || m_items.Count == 0)
            {
                return;
            }

            if (ItemsLV.View == View.List)
            {
                ItemsLV.Items.Clear();
                ItemsLV.View = View.Details;
            }

            for (int ii = 0; ii < m_items.Count; ii++)
            {
                ListViewItem item = m_items[ii];

                X509Certificate2 certificate = item.Tag as X509Certificate2;
                
                if (certificate == null)
                {
                    continue;
                }

                if (item.ListView != null)
                {
                    if (!filter.Match(certificate))
                    {
                        item.Remove();
                    }
                }
                else
                {
                    if (filter.Match(certificate))
                    {
                        ItemsLV.Items.Add(item);
                    }
                }
            }

            if (ItemsLV.Items.Count == 0)
            {
                Instructions = "No certificates meet the current filter criteria.";
                AdjustColumns();
                return;
            }
        }