This documentation is archived and is not being maintained.
AsnEncodedDataCollection Class
Visual Studio 2010
Represents a collection of AsnEncodedData objects. This class cannot be inherited.
Assembly: System (in System.dll)
The AsnEncodedDataCollection type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | AsnEncodedDataCollection() | Initializes a new instance of the AsnEncodedDataCollection class. |
![]() | AsnEncodedDataCollection(AsnEncodedData) | Initializes a new instance of the AsnEncodedDataCollection class and adds an AsnEncodedData object to the collection. |
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of AsnEncodedData objects in a collection. |
![]() | IsSynchronized | Gets a value that indicates whether access to the AsnEncodedDataCollection object is thread safe. |
![]() | Item | Gets an AsnEncodedData object from the AsnEncodedDataCollection object. |
![]() | SyncRoot | Gets an object that can be used to synchronize access to the AsnEncodedDataCollection object. |
| Name | Description | |
|---|---|---|
![]() | Add | Adds an AsnEncodedData object to the AsnEncodedDataCollection object. |
![]() | CopyTo | Copies the AsnEncodedDataCollection object into an array. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetEnumerator | Returns an AsnEncodedDataEnumerator object that can be used to navigate the AsnEncodedDataCollection object. |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | Remove | Removes an AsnEncodedData object from the AsnEncodedDataCollection object. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() | AsParallel | Enables parallelization of a query. (Defined by ParallelEnumerable.) |
![]() | AsQueryable | Converts an IEnumerable to an IQueryable. (Defined by Queryable.) |
![]() | Cast<TResult> | Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.) |
![]() | OfType<TResult> | Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.) |
| Name | Description | |
|---|---|---|
![]() ![]() | ICollection::CopyTo | Copies the AsnEncodedDataCollection object into an array. |
![]() ![]() | IEnumerable::GetEnumerator | Returns an AsnEncodedDataEnumerator object that can be used to navigate the AsnEncodedDataCollection object. |
This class implements the ICollection interface.
The following code example shows how to use the AsnEncodedDataCollection class.
#using <System.dll> #using <System.Security.dll> using namespace System; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::X509Certificates; int main() { //The following example demonstrates the usage of the AsnEncodedData classes. // Asn encoded data is read from the extensions of an X509 certificate. try { // Open the certificate store. X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser ); store->Open( static_cast<OpenFlags>(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) ); X509Certificate2Collection^ collection = dynamic_cast<X509Certificate2Collection^>(store->Certificates); X509Certificate2Collection^ fcollection = dynamic_cast<X509Certificate2Collection^>(collection->Find( X509FindType::FindByTimeValid, DateTime::Now, false )); // Select one or more certificates to display extensions information. X509Certificate2Collection^ scollection = X509Certificate2UI::SelectFromCollection(fcollection, L"Certificate Select",L"Select certificates from the following list to get extension information on that certificate",X509SelectionFlag::MultiSelection); // Create a new AsnEncodedDataCollection object. AsnEncodedDataCollection^ asncoll = gcnew AsnEncodedDataCollection; for ( int i = 0; i < scollection->Count; i++ ) { // Display certificate information. Console::ForegroundColor = ConsoleColor::Red; Console::WriteLine( L"Certificate name: {0}", scollection[i]->GetName() ); Console::ResetColor(); // Display extensions information. System::Collections::IEnumerator^ myEnum = scollection[i]->Extensions->GetEnumerator(); while ( myEnum->MoveNext() ) { X509Extension^ extension = safe_cast<X509Extension ^>(myEnum->Current); // Create an AsnEncodedData object using the extensions information. AsnEncodedData^ asndata = gcnew AsnEncodedData( extension->Oid,extension->RawData ); Console::ForegroundColor = ConsoleColor::Green; Console::WriteLine( L"Extension type: {0}", extension->Oid->FriendlyName ); Console::WriteLine( L"Oid value: {0}", asndata->Oid->Value ); Console::WriteLine( L"Raw data length: {0} {1}", asndata->RawData->Length, Environment::NewLine ); Console::ResetColor(); Console::WriteLine( asndata->Format(true) ); Console::WriteLine( Environment::NewLine ); // Add the AsnEncodedData object to the AsnEncodedDataCollection object. asncoll->Add( asndata ); } Console::WriteLine( Environment::NewLine ); } Console::ForegroundColor = ConsoleColor::Red; Console::WriteLine( L"Number of AsnEncodedData items in the collection: {0} {1}", asncoll->Count, Environment::NewLine ); Console::ResetColor(); store->Close(); //Create an enumerator for moving through the collection. AsnEncodedDataEnumerator^ asne = asncoll->GetEnumerator(); //You must execute a MoveNext() to get to the first item in the collection. asne->MoveNext(); // Write out AsnEncodedData in the collection. Console::ForegroundColor = ConsoleColor::Blue; Console::WriteLine( L"First AsnEncodedData in the collection: {0}", asne->Current->Format(true) ); Console::ResetColor(); asne->MoveNext(); Console::ForegroundColor = ConsoleColor::DarkBlue; Console::WriteLine( L"Second AsnEncodedData in the collection: {0}", asne->Current->Format(true) ); Console::ResetColor(); //Return index in the collection to the beginning. asne->Reset(); } catch ( CryptographicException^ ) { Console::WriteLine( L"Information could not be written out for this certificate." ); } return 1; }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show:
