Пример #1
0
        private void ExtractDescriptionAndVersionFromScriptContents()
        {
            var lines = EntireScript.Split(new [] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            if (!lines[0].StartsWith(VersionKey))
            {
                throw new InvalidPatchException(locationInAssembly, "Script does not start with " + VersionKey);
            }

            string versionNumber = lines[0].Substring(VersionKey.Length).Trim(':', ' ', '\n', '\r');

            try
            {
                DatabaseVersionNumber = new Version(versionNumber);
            }
            catch (Exception e)
            {
                throw new InvalidPatchException(locationInAssembly, "Could not process the scripts --Version: entry ('" + versionNumber + "') into a valid C# Version object", e);
            }

            if (lines.Length >= 2)
            {
                if (!lines[1].StartsWith(DescriptionKey))
                {
                    throw new InvalidPatchException(locationInAssembly, "Second line of patch scripts must start with " + DescriptionKey);
                }

                string description = lines[1].Substring(DescriptionKey.Length);
                Description = description;
            }
        }
Пример #2
0
 /// <summary>
 /// Returns the body without the header text "--Version:1.2.0 etc".
 /// </summary>
 /// <returns></returns>
 public string GetScriptBody()
 {
     return(string.Join(Environment.NewLine,
                        EntireScript.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Skip(2)));
 }