internal bool AreExistingFilesOutOfDate(IInstallSettings currentInstallSettings, string localFilePath)
        {
            if (currentInstallSettings == null)
            {
                throw new ArgumentNullException("currentInstallSettings");
            }
            if (string.IsNullOrWhiteSpace(localFilePath))
            {
                throw new ArgumentNullException("localFilePath");
            }

            bool isOutOfDate = true;

            FileInfo localInstallFile = new FileInfo(localFilePath);

            if (localInstallFile.Exists)
            {
                // See if the version is up to date
                IInstallSettings localSettings = this.ReadInstallSettings(localInstallFile);

                if (localSettings.Version >= currentInstallSettings.Version)
                {
                    isOutOfDate = false;
                }
            }

            return(isOutOfDate);
        }
        /// <summary>
        /// This method is responsible for dropping the files locally
        /// </summary>
        internal void InstallFiles(IInstallSettings settings)
        {
            Assembly assembly = this.GetType().Assembly;
            Type     resxType = typeof(Resources);

            string installManifestResxName = this.GetFullResourceNamefor(Consts.InstallManifestResxName);
            string installXml = assembly.GetResourceAsString(installManifestResxName);

            settings.FilesToInstall.ToList().ForEach(file => {
                // write the file to disk from the resx
                string fullResxName = this.GetFullResourceNamefor(file.ResxName);
                string fullFilePath = Path.Combine(this.InstallRoot, file.Path);

                FileInfo fileInfo = new FileInfo(fullFilePath);
                if (!fileInfo.Directory.Exists)
                {
                    fileInfo.Directory.Create();
                }

                switch (file.FileType)
                {
                case FileType.Text:
                    assembly.WriteTextResourceToFile(fullResxName, fullFilePath);
                    break;

                case FileType.Binary:
                    assembly.WriteBinaryResourceToFile(fullResxName, fullFilePath);
                    break;

                default:
                    string message = string.Format("Invalid value [{0}] for FileType enum", file.FileType);
                    throw new UnknownValueException("");
                }
            });
        }
        public void AreFilesOutOfDate_LocalLessThan_Current()
        {
            PackageInstaller pkgInstaller    = new PackageInstaller();
            IInstallSettings currentSettings = pkgInstaller.ReadInstallSettings(Consts.settingsXml01);
            string           filePath        = this.WriteTextToTempFile(Consts.settingsXml_Version05);
            bool             result          = pkgInstaller.AreExistingFilesOutOfDate(currentSettings, filePath);

            Assert.IsTrue(result);
        }
        internal bool AreExistingFilesOutOfDate(IInstallSettings installSettings)
        {
            if (installSettings == null)
            {
                throw new ArgumentNullException("installSettings");
            }

            string localPath = Path.Combine(this.InstallRoot, Consts.InstallManifestFileName);

            return(this.AreExistingFilesOutOfDate(installSettings, localPath));
        }
        public void Install()
        {
            // read the settings file
            IInstallSettings currentSettings = this.ReadInstallSettings();

            // determine if files on disk are out of date (or missing)
            if (this.AreExistingFilesOutOfDate(currentSettings))
            {
                // Update the files which reside localy
                this.InstallFiles(currentSettings);
            }
        }
Example #6
0
        internal static void AssertAreEqual(IInstallSettings expected, IInstallSettings actual)
        {
            Assert.IsNotNull(expected);
            Assert.IsNotNull(actual);
            Assert.IsNotNull(expected.FilesToInstall);
            Assert.AreEqual(expected.FilesToInstall.Count, actual.FilesToInstall.Count);

            for (int i = 0; i < expected.FilesToInstall.Count; i++) {
                IInstallFile expectedFile = expected.FilesToInstall[i];
                IInstallFile actualFile = actual.FilesToInstall[i];
                AssertAreEqual(expectedFile, actualFile);
            }
        }
Example #7
0
        internal static void AssertAreEqual(IInstallSettings expected, IInstallSettings actual)
        {
            Assert.IsNotNull(expected);
            Assert.IsNotNull(actual);
            Assert.IsNotNull(expected.FilesToInstall);
            Assert.AreEqual(expected.FilesToInstall.Count, actual.FilesToInstall.Count);

            for (int i = 0; i < expected.FilesToInstall.Count; i++)
            {
                IInstallFile expectedFile = expected.FilesToInstall[i];
                IInstallFile actualFile   = actual.FilesToInstall[i];
                AssertAreEqual(expectedFile, actualFile);
            }
        }
        public void InstallFilesTest01()
        {
            // TODO: delete files which reside in the install location locally

            try {
                PackageInstaller pkgInstaller = new PackageInstaller();

                IInstallSettings settings = pkgInstaller.ReadInstallSettings(Consts.settingsXml01);
                pkgInstaller.InstallFiles(settings);
            }
            catch (Exception ex) {
                throw ex;
            }
            // TODO: Some assertions here
        }
        /// <summary>
        /// This method is responsible for dropping the files locally
        /// </summary>
        internal void InstallFiles(IInstallSettings settings)
        {
            Assembly assembly = this.GetType().Assembly;
            Type resxType = typeof(Resources);

            string installManifestResxName = this.GetFullResourceNamefor(Consts.InstallManifestResxName);
            string installXml = assembly.GetResourceAsString(installManifestResxName);

            settings.FilesToInstall.ToList().ForEach(file => {
                // write the file to disk from the resx
                string fullResxName = this.GetFullResourceNamefor(file.ResxName);
                string fullFilePath = Path.Combine(this.InstallRoot, file.Path);

                FileInfo fileInfo = new FileInfo(fullFilePath);
                if (!fileInfo.Directory.Exists) {
                    fileInfo.Directory.Create();
                }

                switch (file.FileType) {
                    case FileType.Text:
                        assembly.WriteTextResourceToFile(fullResxName, fullFilePath);
                        break;

                    case FileType.Binary:
                        assembly.WriteBinaryResourceToFile(fullResxName, fullFilePath);
                        break;

                    default:
                        string message = string.Format("Invalid value [{0}] for FileType enum", file.FileType);
                        throw new UnknownValueException("");
                }

            });
        }
        internal bool AreExistingFilesOutOfDate(IInstallSettings currentInstallSettings, string localFilePath)
        {
            if (currentInstallSettings == null) { throw new ArgumentNullException("currentInstallSettings"); }
            if (string.IsNullOrWhiteSpace(localFilePath)) { throw new ArgumentNullException("localFilePath"); }

            bool isOutOfDate = true;

            FileInfo localInstallFile = new FileInfo(localFilePath);
            if (localInstallFile.Exists) {
                // See if the version is up to date
                IInstallSettings localSettings = this.ReadInstallSettings(localInstallFile);

                if (localSettings.Version >= currentInstallSettings.Version) {
                    isOutOfDate = false;
                }
            }

            return isOutOfDate;
        }
        internal bool AreExistingFilesOutOfDate(IInstallSettings installSettings)
        {
            if (installSettings == null) { throw new ArgumentNullException("installSettings"); }

            string localPath = Path.Combine(this.InstallRoot, Consts.InstallManifestFileName);

            return this.AreExistingFilesOutOfDate(installSettings, localPath);
        }