X509Certificate2Collection.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / security / system / security / cryptography / x509 / X509Certificate2Collection.cs / 1 / X509Certificate2Collection.cs

                            // ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 

// 
// X509Certificate2Collection.cs 
//
 
namespace System.Security.Cryptography.X509Certificates {
    using System;
    using System.Collections;
    using System.Globalization; 
    using System.IO;
    using System.Runtime.InteropServices; 
    using System.Runtime.InteropServices.ComTypes; 
    using System.Security.Cryptography;
    using System.Security.Permissions; 
    using System.Text;

    using _FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
 
    public enum X509FindType {
        FindByThumbprint                = 0, 
        FindBySubjectName               = 1, 
        FindBySubjectDistinguishedName  = 2,
        FindByIssuerName                = 3, 
        FindByIssuerDistinguishedName   = 4,
        FindBySerialNumber              = 5,
        FindByTimeValid                 = 6,
        FindByTimeNotYetValid           = 7, 
        FindByTimeExpired               = 8,
        FindByTemplateName              = 9, 
        FindByApplicationPolicy         = 10, 
        FindByCertificatePolicy         = 11,
        FindByExtension                 = 12, 
        FindByKeyUsage                  = 13,
        FindBySubjectKeyIdentifier      = 14
    }
 
    public class X509Certificate2Collection : X509CertificateCollection {
        public X509Certificate2Collection() {} 
 
        public X509Certificate2Collection(X509Certificate2 certificate) {
            this.Add(certificate); 
        }

        public X509Certificate2Collection(X509Certificate2Collection certificates) {
            this.AddRange(certificates); 
        }
 
        public X509Certificate2Collection(X509Certificate2[] certificates) { 
            this.AddRange(certificates);
        } 

        public new X509Certificate2 this[int index] {
            get {
                return (X509Certificate2) List[index]; 
            }
            set { 
                if (value == null) 
                    throw new ArgumentNullException("value");
                List[index] = value; 
            }
        }

        public int Add(X509Certificate2 certificate) { 
            if (certificate == null)
                throw new ArgumentNullException("certificate"); 
 
            return List.Add(certificate);
        } 

        public void AddRange(X509Certificate2[] certificates) {
            if (certificates == null)
                throw new ArgumentNullException("certificates"); 

            int i=0; 
            try { 
                for (; i
        object IEnumerator.Current { 
            get {
                return baseEnumerator.Current;
            }
        } 

        public bool MoveNext() { 
            return baseEnumerator.MoveNext(); 
        }
 
        /// 
        bool IEnumerator.MoveNext() {
            return baseEnumerator.MoveNext();
        } 

        public void Reset() { 
            baseEnumerator.Reset(); 
        }
 
        /// 
        void IEnumerator.Reset() {
            baseEnumerator.Reset();
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 

// 
// X509Certificate2Collection.cs 
//
 
namespace System.Security.Cryptography.X509Certificates {
    using System;
    using System.Collections;
    using System.Globalization; 
    using System.IO;
    using System.Runtime.InteropServices; 
    using System.Runtime.InteropServices.ComTypes; 
    using System.Security.Cryptography;
    using System.Security.Permissions; 
    using System.Text;

    using _FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
 
    public enum X509FindType {
        FindByThumbprint                = 0, 
        FindBySubjectName               = 1, 
        FindBySubjectDistinguishedName  = 2,
        FindByIssuerName                = 3, 
        FindByIssuerDistinguishedName   = 4,
        FindBySerialNumber              = 5,
        FindByTimeValid                 = 6,
        FindByTimeNotYetValid           = 7, 
        FindByTimeExpired               = 8,
        FindByTemplateName              = 9, 
        FindByApplicationPolicy         = 10, 
        FindByCertificatePolicy         = 11,
        FindByExtension                 = 12, 
        FindByKeyUsage                  = 13,
        FindBySubjectKeyIdentifier      = 14
    }
 
    public class X509Certificate2Collection : X509CertificateCollection {
        public X509Certificate2Collection() {} 
 
        public X509Certificate2Collection(X509Certificate2 certificate) {
            this.Add(certificate); 
        }

        public X509Certificate2Collection(X509Certificate2Collection certificates) {
            this.AddRange(certificates); 
        }
 
        public X509Certificate2Collection(X509Certificate2[] certificates) { 
            this.AddRange(certificates);
        } 

        public new X509Certificate2 this[int index] {
            get {
                return (X509Certificate2) List[index]; 
            }
            set { 
                if (value == null) 
                    throw new ArgumentNullException("value");
                List[index] = value; 
            }
        }

        public int Add(X509Certificate2 certificate) { 
            if (certificate == null)
                throw new ArgumentNullException("certificate"); 
 
            return List.Add(certificate);
        } 

        public void AddRange(X509Certificate2[] certificates) {
            if (certificates == null)
                throw new ArgumentNullException("certificates"); 

            int i=0; 
            try { 
                for (; i
        object IEnumerator.Current { 
            get {
                return baseEnumerator.Current;
            }
        } 

        public bool MoveNext() { 
            return baseEnumerator.MoveNext(); 
        }
 
        /// 
        bool IEnumerator.MoveNext() {
            return baseEnumerator.MoveNext();
        } 

        public void Reset() { 
            baseEnumerator.Reset(); 
        }
 
        /// 
        void IEnumerator.Reset() {
            baseEnumerator.Reset();
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK