Пример #1
0
        /// <summary>
        /// Apply downloaded updates. Method will execute behavior method after files are unpacked.
        /// </summary>
        /// <param name="behavior">Defines behavior of update method after files are unpacked. For example you can backup your database etc.</param>
        /// <param name="publicToken">Public token is used to unpack files in UpdatePackage. Public token can be obtained while using BitsUpdatePacker app and creating package.</param>
        /// <returns>True if everything went well.</returns>
        public bool Update(IUpdateBehavior behavior, string publicToken)
        {
            if (_status.NextVersion > Assembly.GetEntryAssembly().GetName().Version&& File.Exists(GetUpdateSaveLocation()))
            {
                UpdatePackage.Extract(new DirectoryInfo(string.Format(_updateDirectory, _status.NextVersion)), _status.NextVersion, publicToken);

                if (behavior != null)
                {
                    behavior.Execute();
                }

                return(true);
            }

            return(false);
        }