Share via


IVSSCheckouts.GetEnumerator Method 

Gets an enumerator.

Namespace: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)

Syntax

'Declaration
Function GetEnumerator As IEnumerator
'Usage
Dim instance As IVSSCheckouts
Dim returnValue As IEnumerator

returnValue = instance.GetEnumerator
IEnumerator GetEnumerator ()
IEnumerator^ GetEnumerator ()
IEnumerator GetEnumerator ()
function GetEnumerator () : IEnumerator

Return Value

An enumerator.

Remarks

[IDL]

HRESULT _NewEnum ([out,retval]IUnknown **ppIEnum);

This method is used explicitly in Visual C++. Visual C# and Visual Basic use the foreach loop that uses the GetEnumerator method internally.

Example

The following example demonstrates how to iterate through the IVSSCheckouts collection of a file by using foreach loop that uses the GetEnumerator method internally.

To perform this test, the file $/A/a.txt must be checked out by two users. Multiple checkouts must be enabled by the VSS Administrator. To enable multiple checkouts, on the Tools menu, click Options, click the General tab, select the Allow Multiple Checkouts check box, and click OK.

using System;
using Microsoft.VisualStudio.SourceSafe.Interop;

public class IVSSTest
{
    public static void Main()
    {
        // Create a VSSDatabase object.
        IVSSDatabase vssDatabase = new VSSDatabase();

        // Open a VSS database using network name 
        // for automatic user login.
        vssDatabase.Open(@"C:\VSSTestDB\srcsafe.ini", 
                         Environment.UserName, ""); 
            
        IVSSItem vssFile = vssDatabase.get_VSSItem("$/A/a.txt", false);

        foreach(IVSSCheckout vssCheckout in vssFile.Checkouts)
        {
            Console.WriteLine("Checked out to :  {0}", vssCheckout.Username);
            Console.WriteLine("Comment        :  {0}", vssCheckout.Comment);
            Console.WriteLine("Date           :  {0}", vssCheckout.Date);
            Console.WriteLine("LocalSpec      :  {0}", vssCheckout.LocalSpec);
            Console.WriteLine("Machine        :  {0}", vssCheckout.Machine);
            Console.WriteLine("Project        :  {0}", vssCheckout.Project);
            Console.WriteLine("VersionNumber  :  {0}", vssCheckout.VersionNumber);
            Console.WriteLine();
        }    
        Console.WriteLine("Number of Checkouts: " + vssFile.Checkouts.Count);
        Console.WriteLine("\n");
    }
}

Output:

Checked out to :  Guest
Comment        :  Check out to working folder
Date           :  11/10/2003 10:52:40 AM
LocalSpec      :  C:\VSSTESTWF\A
Machine        :  Tester_01
Project        :  $/A
VersionNumber  :  1

Checked out to :  Admin
Comment        :  Check out to folder C:\1
Date           :  11/10/2003 10:51:56 AM
LocalSpec      :  C:\1
Machine        :  Tester_02
Project        :  $/A
VersionNumber  :  1

Number of checkouts: 2

See Also

Reference

IVSSCheckouts Interface
IVSSCheckouts Members
Microsoft.VisualStudio.SourceSafe.Interop Namespace