AcUtils
A high performance abstraction layer for AccuRev
Static Public Member Functions | List of all members
AcUtils.Extensions Class Reference

Custom query operators for use when using LINQ to XML. More...

Static Public Member Functions

static DateTime acxTime (this XElement element, XName name)
 Convert element's Epoch time name XML attribute value to a .NET DateTime object. More...
 
static ElementType acxType (this XElement element, XName name)
 Convert element's type name attribute value to an AcUtils.ElementType enum. More...
 
static bool acxIsPromote (this XElement transaction)
 Determine if transaction was a promote operation. More...
 
static string acxFromStream (this XElement transaction)
 Get the from-stream version for the promote transaction. More...
 
static string acxToStream (this XElement transaction)
 Get the to-stream version for the promote transaction. More...
 
static bool acxIsCheckOut (this XElement transaction)
 Determine if transaction was a co operation. More...
 
static string acxVirtualNamed (this XElement transaction)
 Get the virtual-named version for the promote or co transaction. More...
 
static string acxRealNamed (this XElement version)
 Get the real-named version for version. More...
 
static string acxAncestorNamed (this XElement version)
 Get the ancestor-named version for version. More...
 
static string acxMergedAgainstNamed (this XElement version)
 Get the merged-against-named version for version. More...
 
static string acxComment (this XElement element)
 Get the comment for the transaction or version element. More...
 
static string acxWSpaceName (this XElement version)
 Get the workspace name for version. More...
 
static string acxWSpaceOwner (this XElement version)
 Get the workspace owner's principal name for version. More...
 
static int[] acxStreamVersion (this XElement version, RealVirtual request)
 Get the real or virtual stream and version numbers for version. More...
 
static string acxStreamName (this XElement version, RealVirtual request)
 Get the real or virtual stream name for version. More...
 

Detailed Description

Custom query operators for use when using LINQ to XML.

See also
FileHist.cs, UserChanges.cs

Definition at line 46 of file Extensions.cs.

Member Function Documentation

static string AcUtils.Extensions.acxAncestorNamed ( this XElement  version)
inlinestatic

Get the ancestor-named version for version.

Parameters
versionThe version to query.
Returns
Formatted ancestor-named version, e.g. NEPTUNE_DEV4_thomas/6 (114/6), otherwise null if not found.

Definition at line 198 of file Extensions.cs.

static string AcUtils.Extensions.acxComment ( this XElement  element)
inlinestatic

Get the comment for the transaction or version element.

Parameters
elementThe transaction or version element to query.
Returns
The comment element value, e.g. <comment>Fix defect 452.</comment>, otherwise null if no comment exists or if element is a version element and the first in a promote transaction.
AccuNote:
For promote transactions, the comment element above the first version element listed in the parent transaction is the transaction comment and not the version comment. Therefore in this case, when querying version elements, the first version element in the transaction is ignored and null is returned.

Definition at line 235 of file Extensions.cs.

static string AcUtils.Extensions.acxFromStream ( this XElement  transaction)
inlinestatic

Get the from-stream version for the promote transaction.

Parameters
transactionThe transaction to query.
Returns
Formatted from-stream version, e.g. NEPTUNE_DEV2_thomas/7 (110/7), otherwise null if transaction was not a promote operation.

Definition at line 109 of file Extensions.cs.

static bool AcUtils.Extensions.acxIsCheckOut ( this XElement  transaction)
inlinestatic

Determine if transaction was a co operation.

Parameters
transactionThe transaction to query.
Returns
true if transaction was a co operation, false otherwise.

Definition at line 140 of file Extensions.cs.

static bool AcUtils.Extensions.acxIsPromote ( this XElement  transaction)
inlinestatic

Determine if transaction was a promote operation.

Parameters
transactionThe transaction to query.
Returns
true if transaction was a promote operation, false otherwise.

Definition at line 97 of file Extensions.cs.

static string AcUtils.Extensions.acxMergedAgainstNamed ( this XElement  version)
inlinestatic

Get the merged-against-named version for version.

Parameters
versionThe version to query.
Returns
Formatted merged-against-named version, e.g. JUPITER_DEV1_robert/5 (142/5), otherwise null if not found.

Definition at line 214 of file Extensions.cs.

static string AcUtils.Extensions.acxRealNamed ( this XElement  version)
inlinestatic

Get the real-named version for version.

Parameters
versionThe version to query.
Returns
Formatted real-named version, e.g. MARS_DEV3_barnyrd/2 (17/2), otherwise null if not found.
AccuNote:
For promote transactions, the realNamedVersion attribute value in the transaction's first version element is the same in the second version element. Therefore, in this case the first version element is ignored and null is returned.

Definition at line 179 of file Extensions.cs.

static string AcUtils.Extensions.acxStreamName ( this XElement  version,
RealVirtual  request 
)
inlinestatic

Get the real or virtual stream name for version.

Parameters
versionThe version to query.
requestWhether the real or virtual stream name should be returned.
Returns
The stream name as per request on success, otherwise null on error.
See also
Stat.getElement

Definition at line 315 of file Extensions.cs.

static int [] AcUtils.Extensions.acxStreamVersion ( this XElement  version,
RealVirtual  request 
)
inlinestatic

Get the real or virtual stream and version numbers for version.

Parameters
versionThe version to query.
requestWhether real or virtual values should be returned.
Returns
An array initialized as int[]={[real|virtual]StreamNumber, [real|virtual]VersionNumber} as per request on success, otherwise null on error.
See also
Stat.getElement

Definition at line 295 of file Extensions.cs.

static DateTime AcUtils.Extensions.acxTime ( this XElement  element,
XName  name 
)
inlinestatic

Convert element's Epoch time name XML attribute value to a .NET DateTime object.

Parameters
elementThe element with the name attribute value to convert.
nameThe name of the XML attribute, e.g. "time", "mtime", etc. emitted by the hist command.
Returns
On success a DateTime object with the converted value, otherwise null.
DateTime? mtime = version.acxTime("mtime"); // get version's last modified time
Precondition
When querying version elements include both -e: ("expanded") and -v: ("verbose") format directives in the hist command (i.e. -fevx) so the mtime attribute is included in the XML result.

Definition at line 59 of file Extensions.cs.

static string AcUtils.Extensions.acxToStream ( this XElement  transaction)
inlinestatic

Get the to-stream version for the promote transaction.

Parameters
transactionThe transaction to query.
Returns
Formatted to-stream version, e.g. NEPTUNE_DEV4/12 (8/12), otherwise null if transaction was not a promote operation.

Definition at line 125 of file Extensions.cs.

static ElementType AcUtils.Extensions.acxType ( this XElement  element,
XName  name 
)
inlinestatic

Convert element's type name attribute value to an AcUtils.ElementType enum.

Parameters
elementThe element with the name attribute value to convert.
nameThe name of the attribute, e.g. "elem_type", "elemType", etc.
Returns
On success an AcUtils.ElementType enum that is the converted value, otherwise ElementType.unknown.
ElementType type = v.acxType("elemType");
See also
XLinked.cs

Definition at line 78 of file Extensions.cs.

static string AcUtils.Extensions.acxVirtualNamed ( this XElement  transaction)
inlinestatic

Get the virtual-named version for the promote or co transaction.

Parameters
transactionThe transaction to query.
Returns
Formatted virtual-named version, e.g. MARS_UAT/4 (11/4) for the promote or co transaction, otherwise null if not found.
AccuNote:
For promote transactions, the virtualNamedVersion attribute value is correct only in the first version element listed in the parent transaction. In all other version elements, the virtualNamedVersion attribute has the same value as its realNamedVersion attribute sibling. This falls under AccuRev defect 18636, RPI # 1107275.

Definition at line 156 of file Extensions.cs.

static string AcUtils.Extensions.acxWSpaceName ( this XElement  version)
inlinestatic

Get the workspace name for version.

Parameters
versionThe version to query.
Returns
Name of the workspace.

Definition at line 264 of file Extensions.cs.

static string AcUtils.Extensions.acxWSpaceOwner ( this XElement  version)
inlinestatic

Get the workspace owner's principal name for version.

Parameters
versionThe version to query.
Returns
Name of the principal that owns the workspace, otherwise null if not found.

Definition at line 277 of file Extensions.cs.