/// <summary> /// Creates a new correlation vector by extending an existing value. This should be /// done at the entry point of an operation. /// </summary> /// <param name="correlationVector"> /// Taken from the message header indicated by <see cref="HeaderName"/>. /// </param> /// <returns>A new correlation vector extended from the current vector.</returns> public new static CorrelationVectorV1 Extend(string correlationVector) { if (CorrelationVectorV1.IsImmutable(correlationVector)) { return(CorrelationVectorV1.Parse(correlationVector)); } if (CorrelationVectorV1.ValidateCorrelationVectorDuringCreation) { CorrelationVectorV1.Validate(correlationVector); } if (CorrelationVectorV1.IsOversized(correlationVector, 0)) { return(CorrelationVectorV1.Parse(correlationVector + CorrelationVectorV1.TerminationSign)); } return(new CorrelationVectorV1(correlationVector, 0, false)); }
/// <summary> /// Creates a new correlation vector by parsing its string representation /// </summary> /// <param name="correlationVector">correlationVector</param> /// <returns>CorrelationVector</returns> public new static CorrelationVectorV1 Parse(string correlationVector) { if (!string.IsNullOrEmpty(correlationVector)) { int p = correlationVector.LastIndexOf('.'); bool immutable = CorrelationVectorV1.IsImmutable(correlationVector); if (p > 0) { string extensionValue = immutable ? correlationVector.Substring(p + 1, correlationVector.Length - p - 1 - CorrelationVectorV1.TerminationSign.Length) : correlationVector.Substring(p + 1); int extension; if (int.TryParse(extensionValue, out extension) && extension >= 0) { return(new CorrelationVectorV1(correlationVector.Substring(0, p), extension, immutable)); } } } return(new CorrelationVectorV1()); }