public static bool TryParse(string uri, out CmUri cmUri)
        {
            cmUri = null;
            if (string.IsNullOrEmpty(uri))
            {
                return(false);
            }
            string ns;
            int    version = -1;

            try
            {
                Match match = UriRegEx.Match(uri);
                if (!match.Success)
                {
                    return(false);
                }
                ns = match.Groups["namespace"].Value;
                var      publicationId = int.Parse(match.Groups["pubId"].Value);
                var      itemId        = int.Parse(match.Groups["itemId"].Value);
                ItemType itemType;
                if (match.Groups["itemType"].Captures.Count > 0)
                {
                    itemType = (ItemType)Enum.Parse(typeof(ItemType), match.Groups["itemType"].Value);
                }
                else
                {
                    itemType = ItemType.Component;
                }
                if (match.Groups["version"].Captures.Count > 0)
                {
                    version = int.Parse(match.Groups["version"].Value);
                }

                cmUri = new CmUri(ns, publicationId, itemId, itemType, version);
            }
            catch
            {
                return(false);
            }
            return(true);
        }
        public static CmUri FromString(string uriString)
        {
            CmUri uri = null;

            if (string.IsNullOrEmpty(uriString))
            {
                Logger.Warn("Trying to create CmUri from empty string.");
            }
            else
            {
                try
                {
                    uri = new CmUri(uriString);
                }
                catch (FormatException e)
                {
                    Logger.Error($"CmUri '{uriString}' cannot be parsed.", e);
                }
            }
            return(uri);
        }
 public CmUri(CmUri uri)
     : this(uri.Namespace, uri.PublicationId, uri.ItemId, uri.ItemType, uri.Version)
 {
 }