Esempio n. 1
0
        public static SvnPropertyValue Parse(XElement element)
        {
            var propName = element.Attribute("name").Value;
            var match    = Regex.Match(propName, @"(?<prefix>[^:]+:)(?<key>.+)", RegexOptions.ExplicitCapture);
            var prefix   = match.Groups["prefix"].Value.Trim();
            var name     = match.Groups["key"].Value.Trim();

            var obj = new SvnPropertyValue()
            {
                Value = element.Value,
            };

            if (prefix == string.Empty)
            {
                obj.Prefix = string.Empty;
                obj.Key    = propName;
            }
            else
            {
                obj.Prefix = prefix;
                obj.Key    = name;
            }

            return(obj);
        }
Esempio n. 2
0
        private static SvnLogInfo Parse(XElement element)
        {
            LogPropertyInfo[] props = null;
            var commentValue        = element.XPathSelectElement("msg").Value;
            var comment             = null as string;

            var obj = new SvnLogInfo()
            {
                Author   = element.XPathSelectElement("author").Value,
                Revision = element.Attribute("revision").Value,
                Comment  = comment ?? commentValue,
                DateTime = XmlConvert.ToDateTime(element.XPathSelectElement("date").Value, XmlDateTimeSerializationMode.Utc)
            };
            var pathItems       = element.XPathSelectElements("paths/path").ToArray();
            var changedItemList = new List <SvnChangeInfo>();

            foreach (var item in pathItems)
            {
                var changedItem = SvnChangeInfo.Parse(item);
                changedItemList.Add(changedItem);
            }
            obj.ChangedPaths = changedItemList.ToArray();

            if (props == null)
            {
                var propItems    = element.XPathSelectElements("revprops/property").ToArray();
                var propItemList = new List <SvnPropertyValue>();
                foreach (var item in propItems)
                {
                    var propItem = SvnPropertyValue.Parse(item);
                    propItemList.Add(propItem);

                    if (propItem.Prefix == propertyPrefix && propItem.Key == LogPropertyInfo.UserIDKey)
                    {
                        obj.Author = propItem.Value;
                    }
                }
                obj.Properties = propItemList.ToArray();
            }
            else
            {
                var propList = new List <SvnPropertyValue>();
                foreach (var item in props)
                {
                    propList.Add((SvnPropertyValue)item);
                }
                obj.Properties = propList.ToArray();
            }

            return(obj);
        }