OidCollection Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Represents a collection of Oid objects. This class cannot be inherited.

Namespace:   System.Security.Cryptography
Assembly:  System (in System.dll)

System::Object
  System.Security.Cryptography::OidCollection

public ref class OidCollection sealed : ICollection, IEnumerable

NameDescription
System_CAPS_pubmethodOidCollection()

Initializes a new instance of the OidCollection class.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of Oid objects in a collection.

System_CAPS_pubpropertyIsSynchronized

Gets a value that indicates whether access to the OidCollection object is thread safe.

System_CAPS_pubpropertyItem[Int32]

Gets an Oid object from the OidCollection object.

System_CAPS_pubpropertyItem[String^]

Gets the first Oid object that contains a value of the Value property or a value of the FriendlyName property that matches the specified string value from the OidCollection object.

System_CAPS_pubpropertySyncRoot

Gets an object that can be used to synchronize access to the OidCollection object.

NameDescription
System_CAPS_pubmethodAdd(Oid^)

Adds an Oid object to the OidCollection object.

System_CAPS_pubmethodCopyTo(array<Oid^>^, Int32)

Copies the OidCollection object into an array.

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Returns an OidEnumerator object that can be used to navigate the OidCollection object.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection::CopyTo(Array^, Int32)

Copies the OidCollection object into an array.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable::GetEnumerator()

Returns an OidEnumerator object that can be used to navigate the OidCollection object.

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<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 OidCollection class.

#using <system.dll>

using namespace System;
using namespace System::Security::Cryptography;
int main()
{

   // Assign values to strings.
   String^ Value1 = "1.2.840.113549.1.1.1";
   String^ Name1 = "3DES";
   String^ Value2 = "1.3.6.1.4.1.311.20.2";
   String^ InvalidName = "This name is not a valid name";
   String^ InvalidValue = "1.1.1.1.1.1.1.1";

   // Create new Oid objects using the specified values.
   // Note that the corresponding Value or Friendly Name property is automatically added to the object.
   Oid ^ o1 = gcnew Oid( Value1 );
   Oid ^ o2 = gcnew Oid( Name1 );

   // Create a new Oid object using the specified Value and Friendly Name properties.
   // Note that the two are not compared to determine if the Value is associated 
   //  with the Friendly Name.
   Oid ^ o3 = gcnew Oid( Value2,InvalidName );

   //Create a new Oid object using the specified Value. Note that if the value
   //  is invalid or not known, no value is assigned to the Friendly Name property.
   Oid ^ o4 = gcnew Oid( InvalidValue );

   //Write out the property information of the Oid objects.
   Console::WriteLine( "Oid1: Automatically assigned Friendly Name: {0}, {1}", o1->FriendlyName, o1->Value );
   Console::WriteLine( "Oid2: Automatically assigned Value: {0}, {1}", o2->FriendlyName, o2->Value );
   Console::WriteLine( "Oid3: Name and Value not compared: {0}, {1}", o3->FriendlyName, o3->Value );
   Console::WriteLine( "Oid4: Invalid Value used: {0}, {1} {2}", o4->FriendlyName, o4->Value, Environment::NewLine );

   //Create an Oid collection and add several Oid objects.
   OidCollection ^ oc = gcnew OidCollection;
   oc->Add( o1 );
   oc->Add( o2 );
   oc->Add( o3 );
   Console::WriteLine( "Number of Oids in the collection: {0}", oc->Count );
   Console::WriteLine( "Is synchronized: {0} {1}", oc->IsSynchronized, Environment::NewLine );

   //Create an enumerator for moving through the collection.
   OidEnumerator ^ oe = oc->GetEnumerator();

   //You must execute a MoveNext() to get to the first item in the collection.
   oe->MoveNext();

   // Write out Oids in the collection.
   Console::WriteLine( "First Oid in collection: {0},{1}", oe->Current->FriendlyName, oe->Current->Value );
   oe->MoveNext();
   Console::WriteLine( "Second Oid in collection: {0},{1}", oe->Current->FriendlyName, oe->Current->Value );

   //Return index in the collection to the beginning.
   oe->Reset();
}

.NET Framework
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.

Return to top
Show: