Esempio n. 1
0
        //  ---------------------
        //  GetVersionInfo method
        //  ---------------------

        /// <summary>
        /// Gets information for the specified SQL Server Express LocalDB
        /// version, such as whether it exists and the full LocalDB version
        /// number (including build and release numbers).
        /// </summary>
        /// <param name="version">The LocalDB version name.</param>
        /// <returns>The information about the specified LocalDB version.
        ///     </returns>

        public VersionInfo GetVersionInfo(string version)
        {
            var info = new LocalDBVersionInfo();
            var hr   = library.GetFunction(nameof(LocalDBGetVersionInfo), ref localDBGetVersionInfo)(version, out info, Marshal.SizeOf(typeof(LocalDBVersionInfo)));

            return(ValidateHResult(hr) ? new VersionInfo(info) : null);
        }
        //  ------------
        //  construction
        //  ------------

        internal VersionInfo(LocalDBVersionInfo info)
        {
            Name    = info.Version.ToString(Encoding.Unicode);
            Exists  = info.Exists;
            Version = new Version((int)info.Major, (int)info.Minor, (int)info.Build, (int)info.Revision);
        }