Ejemplo n.º 1
0
        /// <summary>
        /// Increments the specified version.
        /// </summary>
        /// <param name="currentVersion">The current version.</param>
        /// <param name="buildStartDate">The build start date.</param>
        /// <param name="projectStartDate">The project start date.</param>
        /// <returns>The incremented version.</returns>
        internal StringVersion Increment(StringVersion currentVersion, DateTime buildStartDate, DateTime projectStartDate, SolutionItem solutionItem)
        {
            IncrementContext context = new IncrementContext(currentVersion, buildStartDate, projectStartDate, solutionItem.Filename);

            BaseIncrementor[] incrementors = new BaseIncrementor[] { Major, Minor, Build, Revision };

            for (int i = 0; i < 4; i++)
            {
                BaseIncrementor incrementor = incrementors[i];

                if (incrementor == null)
                {
                    continue;
                }

                VersionComponent component = (VersionComponent)i;

                incrementor.Increment(context, component);

                if (!context.Continue)
                {
                    break;
                }
            }

            return(context.NewVersion);

            /*int major = Major == null ? currentVersion.Major : Major.Increment(currentVersion.Major, buildStartDate, projectStartDate, solutionItem.Filename);
             * int minor = Minor == null ? currentVersion.Minor : Minor.Increment(currentVersion.Minor, buildStartDate, projectStartDate, solutionItem.Filename);
             * int build = Build == null ? currentVersion.Build : Build.Increment(currentVersion.Build, buildStartDate, projectStartDate, solutionItem.Filename);
             * int revision = Revision == null ? currentVersion.Revision : Revision.Increment(currentVersion.Revision, buildStartDate, projectStartDate, solutionItem.Filename);
             *
             * return new Version(major, minor, build, revision);*/
        }
        internal void FromGlobalVariable(string value)
        {
            if (!string.IsNullOrEmpty(value))
            {
                if (value.Contains("."))
                {
                    string[] array = value.Split(".".ToCharArray());
                    if (array.Length != 4)
                    {
                        throw new ApplicationException("Invalid versioning style \"" + value + "\".");
                    }
                    this.Major    = BuildVersionIncrementor.Instance.Incrementors[array[0]];
                    this.Minor    = BuildVersionIncrementor.Instance.Incrementors[array[1]];
                    this.Build    = BuildVersionIncrementor.Instance.Incrementors[array[2]];
                    this.Revision = BuildVersionIncrementor.Instance.Incrementors[array[3]];
                }
                else
                {
                    OLD_BuildVersioningStyleType oLD_BuildVersioningStyleType = (OLD_BuildVersioningStyleType)Enum.Parse(typeof(OLD_BuildVersioningStyleType), value);
                    OLD_IncrementStyle           major    = OLD_IncrementStyle.None;
                    OLD_IncrementStyle           minor    = OLD_IncrementStyle.None;
                    OLD_IncrementStyle           revision = OLD_IncrementStyle.None;
                    OLD_IncrementStyle           build;
                    switch (oLD_BuildVersioningStyleType)
                    {
                    case OLD_BuildVersioningStyleType.DeltaBaseDate:
                        build    = OLD_IncrementStyle.DeltaBaseDate;
                        revision = OLD_IncrementStyle.TimeStamp;
                        break;

                    case OLD_BuildVersioningStyleType.YearDayOfYear_Timestamp:
                        build    = OLD_IncrementStyle.YearDayOfYear;
                        revision = OLD_IncrementStyle.TimeStamp;
                        break;

                    case OLD_BuildVersioningStyleType.DeltaBaseYear:
                        build    = OLD_IncrementStyle.DeltaBaseYearDayOfYear;
                        revision = OLD_IncrementStyle.TimeStamp;
                        break;

                    case OLD_BuildVersioningStyleType.YearDayOfYear_AutoIncrement:
                        build    = OLD_IncrementStyle.YearDayOfYear;
                        revision = OLD_IncrementStyle.Increment;
                        break;

                    case OLD_BuildVersioningStyleType.AutoIncrementBuildVersion:
                        build = OLD_IncrementStyle.Increment;
                        break;

                    default:
                        throw new ApplicationException("Unknown (old) versioning type: " + oLD_BuildVersioningStyleType.ToString());
                    }
                    this.FromOldIncrementStyle(major, minor, build, revision);
                }
            }
            else
            {
                this.Major = (this.Minor = (this.Build = (this.Revision = null)));
            }
        }
 public VersioningStyle(VersioningStyle other)
 {
     this.Major    = other.Major;
     this.Minor    = other.Minor;
     this.Build    = other.Build;
     this.Revision = other.Revision;
 }
 internal void FromOldIncrementStyle(OLD_IncrementStyle major, OLD_IncrementStyle minor, OLD_IncrementStyle build, OLD_IncrementStyle revision)
 {
     this.Major    = BuildVersionIncrementor.Instance.Incrementors[major];
     this.Minor    = BuildVersionIncrementor.Instance.Incrementors[minor];
     this.Build    = BuildVersionIncrementor.Instance.Incrementors[build];
     this.Revision = BuildVersionIncrementor.Instance.Incrementors[revision];
 }
        internal StringVersion Increment(StringVersion currentVersion, DateTime buildStartDate, DateTime projectStartDate, SolutionItem solutionItem)
        {
            IncrementContext incrementContext = new IncrementContext(currentVersion, buildStartDate, projectStartDate, solutionItem.Filename);

            BaseIncrementor[] array = new BaseIncrementor[]
            {
                this.Major,
                this.Minor,
                this.Build,
                this.Revision
            };
            for (int i = 0; i < 4; i++)
            {
                BaseIncrementor baseIncrementor = array[i];
                if (baseIncrementor != null)
                {
                    VersionComponent versionComponent = (VersionComponent)i;
                    baseIncrementor.Increment(incrementContext, versionComponent);
                    if (!incrementContext.Continue)
                    {
                        break;
                    }
                }
            }
            return(incrementContext.NewVersion);
        }