ALM Open Test Architecture API Reference Version 12.55
C# Check out
Example Title
Copy Code
/*
 * How to call:
     TestFactory tF = (TestFactory)tdConnection.TestFactory;
     TDFilter tFilter = tF.Filter;
     tFilter["TS_NAME"] = "test5";
     List tList = tFilter.NewList();
     Test tTest = (Test)tList[1];
     CheckoutEntity(tTest, "Hello", true);
 */
public IVersionControl CheckoutEntity(Object Entity, String comment, bool CanContinue)
{
  /*
   Check an object out for editing

   This example demonstrates the behaviour when getting 
   an IVersionControl reference in a project without 
   version control enabled. For production code, you
   may wish to check once if version control is enabled
   and not attempt checkouts if it is not.
   See the VB example,"Check if version control is enabled"

      --------------------------------------------------------
       If the project has version control enabled, this routine
       checks out the entity and returns the version
       control object.
       The CanContinue argument is set to true if the Entity
       is successfully checked out or if the project does not
       have version control enabled.
       If the project has version control enabled and the checkout
       throws an exception, CanContinue is set to false.
      --------------------------------------------------------
   */
  try
  {
    CanContinue = true;
    IVersionControl oVerControl;
    IVersionedEntity oVE;

    oVE = (IVersionedEntity)Entity;
    oVerControl = oVE.VC;
    //If the connected project does not have version control enabled, oVE.Vc returns null.
    if (oVerControl == null)
    {
      return null;
    }
    oVerControl.CheckOut(comment);
    return oVerControl;
  }
  catch (Exception)
  {
    CanContinue = false;
    return null;
  }
}