コード例 #1
0
        /// <summary>
        /// Verifies that the pre/post-processors are compatible with this version of the bootstrapper
        /// </summary>
        /// <remarks>Older C# plugins will not have the file contain the supported versions -
        /// in this case we fail because we are not backwards compatible with those versions</remarks>
        /// <param name="versionFilePath">path to the XML file containing the supported versions</param>
        /// <param name="bootstrapperVersion">current version</param>
        public bool CheckBootstrapperApiVersion(string versionFilePath, Version bootstrapperVersion)
        {
            if (string.IsNullOrWhiteSpace(versionFilePath))
            {
                throw new ArgumentNullException("versionFilePath");
            }
            if (bootstrapperVersion == null)
            {
                throw new ArgumentNullException("bootstrapperVersion");
            }

            // The Bootstrapper 1.0+ does not support versions of the C# plugin that don't have this file
            if (!File.Exists(versionFilePath))
            {
                return(false);
            }

            BootstrapperSupportedVersions supportedVersions = BootstrapperSupportedVersions.Load(versionFilePath);

            foreach (string stringVersion in supportedVersions.Versions)
            {
                // parse to version to make sure they are in the right format and to ease with comparisons
                Version version = null;
                if (Version.TryParse(stringVersion, out version) && version.Equals(bootstrapperVersion))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Loads and returns the versions from the specified XML file
        /// </summary>
        public static BootstrapperSupportedVersions Load(string fileName)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            BootstrapperSupportedVersions model = Serializer.LoadModel <BootstrapperSupportedVersions>(fileName);

            return(model);
        }