//======================================= Construction ======================================= internal NodeToken(int nodeId, int nodeTypeId, int contentListId, int contentListTypeId, int versionId, VersionNumber version) { this.NodeId = nodeId; this.NodeTypeId = nodeTypeId; this.ContentListId = contentListId; this.ContentListTypeId = contentListTypeId; this.VersionId = versionId; this.VersionNumber = version; }
private static string FormatMessage(Exception inner, int nodeId, string path, int versionId, VersionNumber versionNumber, long timestamp) { string message = null; if (inner != null) { message = inner.Message; } if (String.IsNullOrEmpty(message)) { message = "Node is out of date"; } return(String.Format("{0} NodeId: {1}, VersionId: {2}, Version: {3}, Path: {4}, Invalid timestamp: {5}", message, nodeId, versionId, versionNumber, path, timestamp)); }
/// <summary> /// Parses the specified version string. Valid format is the following: /// ((['V'|'v'])?[majornumber][.][minornumber]([.][*]+)?)|'lastmajor'|'lastminor' /// For example: V1.0, 2.3, v12.3456, lastmajor /// </summary> /// <param name="versionString">The version string</param> /// <param name="version">Parsed VersionNumber if conversion was successful.</param> /// <returns>True if versionString was converted successfully; otherwise, false.</returns> public static bool TryParse(string versionString, out VersionNumber version) { version = null; var input = versionString.ToLower(); if (input == "lastmajor") { version = VersionNumber.LastMajor; return(true); } if (input == "lastminor") { version = VersionNumber.LastMinor; return(true); } if (input[0] == 'v') { input = input.Substring(1); } var sa = input.Split('.'); if (sa.Length < 2) { return(false); } int major, minor; if (!int.TryParse(sa[0], out major)) { return(false); } if (!int.TryParse(sa[1], out minor)) { return(false); } if (sa.Length == 2) { version = new VersionNumber(major, minor); return(true); } VersionStatus status; switch (sa[2]) { case "a": case "approved": status = VersionStatus.Approved; break; case "l": case "locked": status = VersionStatus.Locked; break; case "d": case "draft": status = VersionStatus.Draft; break; case "r": case "rejected": status = VersionStatus.Rejected; break; case "p": case "pending": status = VersionStatus.Pending; break; default: return(false); } version = new VersionNumber(major, minor, status); return(true); }
public NodeIsOutOfDateException(int nodeId, string path, int versionId, VersionNumber versionNumber, Exception inner, long timestamp) : base(FormatMessage(inner, nodeId, path, versionId, versionNumber, timestamp), inner) { }