internal IInstallSettings ReadInstallSettings(string xmlContents) { try { XNamespace xmlNamespace = XmlConsts.XmlNamespace; XDocument doc = XDocument.Parse(xmlContents); XElement rootElement = doc.Element(xmlNamespace + XmlConsts.InstallManifest); var r = from e in rootElement.Elements(xmlNamespace + XmlConsts.FilesToInstall) from f in e.Elements(xmlNamespace + XmlConsts.File) select new InstallFile( f.Attribute(XmlConsts.Path).Value, f.Attribute(XmlConsts.Name).Value, (FileType)Enum.Parse(typeof(FileType), f.Attribute(XmlConsts.Type).Value)); IInstallSettings settings = new InstallSettings { Version = Convert.ToDouble(rootElement.Attribute(XmlConsts.Version).Value, System.Globalization.CultureInfo.InvariantCulture) }; r.ToList().ForEach(file => { settings.FilesToInstall.Add(file); }); return(settings); } catch (FormatException fe) { throw new SlowCheetahCustomException("Format exception trying to parse Install Settings", fe, xmlContents); } }
public void TestGetInstallerSettingsFromResx() { IInstallSettings settings = new PackageInstaller().ReadInstallSettings(); Assert.IsNotNull(settings); InstallSettings expected = new InstallSettings { Version = 1.4 }; expected.FilesToInstall.Add(new InstallFile(@"Install-Manifest.xml", "Install.Install-Manifest.xml", FileType.Text)); expected.FilesToInstall.Add(new InstallFile(@"SlowCheetah.Transforms.targets", "Install.SlowCheetah.Transforms.targets", FileType.Text)); expected.FilesToInstall.Add(new InstallFile(@"SlowCheetah.Tasks.dll", "Install.SlowCheetah.Tasks.dll", FileType.Binary)); CustomAssert.AssertAreEqual(expected, settings); }
public void TestGetInstallerSettingsFromXml() { IInstallSettings settings = new PackageInstaller().ReadInstallSettings(Consts.settingsXml01); Assert.IsNotNull(settings); InstallSettings expected = new InstallSettings { Version =1.0 }; expected.FilesToInstall.Add(new InstallFile (@"Install-Manifest.xml","Install.Install-Manifest.xml",FileType.Text)); expected.FilesToInstall.Add(new InstallFile(@"SlowCheetah.Transforms.targets", "Install.SlowCheetah.Transforms.targets", FileType.Text)); expected.FilesToInstall.Add(new InstallFile(@"Microsoft.Web.XmlTransform.dll", "Install.Microsoft.Web.XmlTransform.dll", FileType.Binary)); expected.FilesToInstall.Add(new InstallFile(@"SlowCheetah.Xdt.dll", "Install.SlowCheetah.Xdt.dll", FileType.Binary)); CustomAssert.AssertAreEqual(expected, settings); }
public void TestReadInstallSettingsFromFile() { string filePath = this.WriteTextToTempFile(Consts.settingsXml01); IInstallSettings settings = new PackageInstaller().ReadInstallSettings(new FileInfo(filePath)); InstallSettings expected = new InstallSettings { Version = 1.0 }; expected.FilesToInstall.Add(new InstallFile(@"Install-Manifest.xml", "Install.Install-Manifest.xml", FileType.Text)); expected.FilesToInstall.Add(new InstallFile(@"SlowCheetah.Transforms.targets", "Install.SlowCheetah.Transforms.targets", FileType.Text)); expected.FilesToInstall.Add(new InstallFile(@"Microsoft.Web.XmlTransform.dll", "Install.Microsoft.Web.XmlTransform.dll", FileType.Binary)); expected.FilesToInstall.Add(new InstallFile(@"SlowCheetah.Xdt.dll", "Install.SlowCheetah.Xdt.dll", FileType.Binary)); CustomAssert.AssertAreEqual(expected, settings); }
internal IInstallSettings ReadInstallSettings(string xmlContents) { try { XNamespace xmlNamespace = XmlConsts.XmlNamespace; XDocument doc = XDocument.Parse(xmlContents); XElement rootElement = doc.Element(xmlNamespace + XmlConsts.InstallManifest); var r = from e in rootElement.Elements(xmlNamespace + XmlConsts.FilesToInstall) from f in e.Elements(xmlNamespace + XmlConsts.File) select new InstallFile( f.Attribute(XmlConsts.Path).Value, f.Attribute(XmlConsts.Name).Value, (FileType)Enum.Parse(typeof(FileType), f.Attribute(XmlConsts.Type).Value)); IInstallSettings settings = new InstallSettings { Version = Convert.ToDouble(rootElement.Attribute(XmlConsts.Version).Value, System.Globalization.CultureInfo.InvariantCulture) }; r.ToList().ForEach(file => { settings.FilesToInstall.Add(file); }); return settings; } catch (FormatException fe) { throw new SlowCheetahCustomException("Format exception trying to parse Install Settings", fe,xmlContents); } }