AsnEncodedDataCollection Class
Represents a collection of AsnEncodedData objects. This class cannot be inherited.
Assembly: System (in System.dll)
| 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[Int32] | 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(AsnEncodedData^) | Adds an AsnEncodedData object to the AsnEncodedDataCollection object. |
![]() | CopyTo(array<AsnEncodedData^>^, Int32) | Copies the AsnEncodedDataCollection object into an array. |
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | GetEnumerator() | Returns an AsnEncodedDataEnumerator object that can be used to navigate the AsnEncodedDataCollection object. |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | Remove(AsnEncodedData^) | Removes an AsnEncodedData object from the AsnEncodedDataCollection object. |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | ICollection::CopyTo(Array^, Int32) | Copies the AsnEncodedDataCollection object into an array. |
![]() ![]() | IEnumerable::GetEnumerator() | Returns an AsnEncodedDataEnumerator object that can be used to navigate the AsnEncodedDataCollection object. |
| Name | Description | |
|---|---|---|
![]() | AsParallel() | Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.) |
![]() | AsQueryable() | Overloaded. 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.) |
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; }
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.



