예제 #1
0
        public static bool TryParse(string input, out VersionString version)
        {
            VersionString temp = new VersionString();

            version = null;
            if (temp.Parse(input))
            {
                version = temp;
            }
            return(version != null);
        }
예제 #2
0
        public static bool UpdateLineWithRule(ref string line, CSharpVersionUpdateRule rule)
        {
            VersionString v       = null;
            bool          updated = false;
            var           g       = GetVersionString(line, rule.AttributeName);

            if (g != null)
            {
                VersionString.TryParse(g.Value, out v);
            }
            if (v != null)
            {
                string newVersion = rule.Update(v);
                line    = line.Substring(0, g.Index) + newVersion + line.Substring(g.Index + g.Length);
                updated = true;
            }
            return(updated);
        }
예제 #3
0
        public string Update(VersionString version)
        {
            List <string> inParts = new List <string>()
            {
                version.Major, version.Minor, version.Build, version.Revision
            };
            List <string> outParts = new List <string>();

            for (int index = 0; index < partRules.Length; index++)
            {
                var rule   = partRules[index];
                var inPart = inParts[index];
                if (rule == "=")
                {
                    if (inPart.Length > 0)
                    {
                        outParts.Add(inParts[index]);
                    }
                }
                else if (rule == "+")
                {
                    if (inPart.Length == 0)
                    {
                        throw new ArgumentException("Can't increment missing value");
                    }
                    int inNumber = 0;
                    int.TryParse(inPart, out inNumber); // * gets turned into a zero
                    inNumber++;
                    outParts.Add(inNumber.ToString());
                }
                else
                {
                    // must be a numeric literal
                    outParts.Add(partRules[index]);
                }
            }
            return(String.Join(".", outParts.ToArray()));
        }
예제 #4
0
 public string Update(VersionString v)
 {
     return(this.updateRule.Update(v));
 }