/// <summary>
        /// Converts the assembly attribute representation into a general VersionParameters representation.
        /// </summary>
        /// <returns>A VersionParameters instance containing the encoded information.</returns>
        public VersionParameters ToParameters()
        {
            var parameters = new VersionParameters
            {
                ProductName = ProductName,
                Description = Description,
                Company     = Company,
                Copyright   = Copyright,
                Config      = Config
            };

            var buffer = new VersionParserBuffer(InformationalVersion, "InformationalVersion");

            buffer.ReadVersionMajor(out parameters.Major);
            buffer.ReadVersionMinor(out parameters.Minor);
            buffer.ReadVersionUpdate(out parameters.Update);
            buffer.TryReadVersionHotfix(out parameters.Hotfix);
            buffer.TryReadBuildType(out parameters.BuildType, out parameters.BuildNumber);
            buffer.TryReadSourceFlag(out parameters.IsSource);
            buffer.TryReadFancyName(out parameters.FancyName, ' ');
            buffer.ReadDate(out parameters.Date, ' ');
            buffer.ReadRevision(out parameters.Revision);
            buffer.AssertEnd();

            if (FileVersion != null)
            {
                VerifyMainVersion(FileVersion, parameters);
            }

            return(parameters);
        }
Beispiel #2
0
        /// <summary>
        /// Converts the file name representation into a general VersionParameters representation.
        /// </summary>
        /// <returns>A VersionParameters instance containing the encoded information.</returns>
        public VersionParameters ToParameters()
        {
            var parameters = new VersionParameters();

            var buffer = new VersionParserBuffer(FileName, "FileName");

            buffer.ReadProductName(out parameters.ProductName);
            buffer.AssertChar('_');
            buffer.ReadVersionMajor(out parameters.Major);
            buffer.ReadVersionMinor(out parameters.Minor);
            buffer.ReadVersionUpdate(out parameters.Update);
            buffer.TryReadVersionHotfix(out parameters.Hotfix);
            buffer.TryReadBuildType(out parameters.BuildType, out parameters.BuildNumber);
            buffer.TryReadSourceFlag(out parameters.IsSource);
            buffer.TryReadFancyName(out parameters.FancyName, '_');
            buffer.ReadDate(out parameters.Date, '_');
            buffer.AssertEnd();

            return(parameters);
        }
        private static void VerifyMainVersion(string fileVersion, VersionParameters parameters)
        {
            var buffer = new VersionParserBuffer(fileVersion, "FileVersion");

            int major;

            buffer.ReadVersionMajor(out major);
            AssertEqual(major, parameters.Major, "Major", buffer.Name);

            int minor;

            buffer.ReadVersionMinor(out minor);
            AssertEqual(minor, parameters.Minor, "Minor", buffer.Name);

            int update;

            buffer.ReadVersionUpdate(out update);
            AssertEqual(update, parameters.Update, "Update", buffer.Name);

            int hotfix;

            buffer.TryReadVersionHotfix(out hotfix);
            AssertEqual(hotfix, parameters.Hotfix, "Hotfix", buffer.Name);

            VersionBuildType buildType;
            int buildNumber;

            buffer.TryReadBuildType(out buildType, out buildNumber);
            AssertEqual(buildType, parameters.BuildType, "BuildType", buffer.Name);
            AssertEqual(buildNumber, parameters.BuildNumber, "BuildNumber", buffer.Name);

            bool isSource;

            buffer.TryReadSourceFlag(out isSource);
            AssertEqual(isSource, parameters.IsSource, "IsSource", buffer.Name);

            buffer.AssertEnd();
        }