Exemplo n.º 1
0
        /// <summary>
        ///     Validates the solution version.
        /// </summary>
        /// <param name="solution">The solution.</param>
        private void ValidateSolutionVersion(Solution solution)
        {
            IEntityInternal entityInternal = solution as IEntityInternal;
            string          version;

            if (entityInternal == null)
            {
                throw new Exception("Could not convert Solution entity to IEntityInternal.");
            }

            if (entityInternal.TryGetField(Solution.SolutionVersionString_Field, out version))
            {
                if (!string.IsNullOrEmpty(version))
                {
                    Version ver;

                    string stringVersion = version.Trim().TrimStart('.').TrimEnd('.');

                    if (!Version.TryParse(stringVersion, out ver))
                    {
                        int intValue;

                        if (int.TryParse(stringVersion, out intValue))
                        {
                            ver = new Version(intValue, 0, 0, 0);
                        }
                        else
                        {
                            ver = new Version(1, 0, 0, 0);
                        }
                    }

                    int major    = ver.Major >= 0 ? ver.Major : 1;
                    int minor    = ver.Minor >= 0 ? ver.Minor : 0;
                    int build    = ver.Build >= 0 ? ver.Build : 0;
                    int revision = ver.Revision >= 0 ? ver.Revision : 0;

                    var canonicalVersion = new Version(major, minor, build, revision);

                    string canonicalVersionString = canonicalVersion.ToString();

                    if (canonicalVersionString != version)
                    {
                        solution.SolutionVersionString = canonicalVersionString;
                    }
                }
            }
        }
Exemplo n.º 2
0
 bool IEntityInternalGeneric <IEntityRef> .TryGetField(IEntityRef field, out object value)
 {
     return(_entityInternal.TryGetField(field, out value));
 }