private static void InitializeNewFile(string filepath) { _installationId = Guid.NewGuid(); string directory = Path.GetDirectoryName(filepath); if (C1Directory.Exists(directory) == false) { C1Directory.CreateDirectory(directory); } XDocument doc = new XDocument( new XElement("InstallationInformation", new XAttribute("installationId", _installationId) ) ); doc.SaveToFile(filepath); }
/// <summary> /// This class is used to create <see cref="XmlDataTypeStore"/>. /// Either for existing stores or for just newly created/added stores. /// There exist one store for each data type that the provider handles. /// While the <see cref="XmlDataTypeStore"/> is created, the input and /// configuration is validated. /// </summary> /// <param name="dataTypeDescriptor"></param> /// <param name="dataProviderHelperClassType">The runtime type for the generated implementation of <see cref="IXmlDataProviderHelper"/></param> /// <param name="dataIdClassType">The runtime type for the generated data id class.</param> /// <param name="xmlDataTypeStoreDataScopes">If this is null, default values will be created.</param> /// <returns> /// Returns a <see cref="XmlDataTypeStore"/> if it is valid, else null /// </returns> public XmlDataTypeStore CreateStoreResult(DataTypeDescriptor dataTypeDescriptor, Type dataProviderHelperClassType, Type dataIdClassType, IEnumerable<XmlDataTypeStoreDataScope> xmlDataTypeStoreDataScopes) { if (xmlDataTypeStoreDataScopes == null) { var defaultDataScopes = new List<XmlDataTypeStoreDataScope>(); IEnumerable<string> cultureNames; if (dataTypeDescriptor.Localizeable) { cultureNames = DataLocalizationFacade.ActiveLocalizationNames; } else { cultureNames = new[] { CultureInfo.InvariantCulture.Name }; } foreach (DataScopeIdentifier dataScopeIdentifier in dataTypeDescriptor.DataScopes.Distinct()) { foreach (string cultureName in cultureNames) { var defaultXmlDataTypeStoreDataScope = new XmlDataTypeStoreDataScope { DataScopeName = dataScopeIdentifier.Name, CultureName = cultureName, ElementName = NamesCreator.MakeElementName(dataTypeDescriptor), Filename = Path.Combine(_fileStoreDirectory, NamesCreator.MakeFileName(dataTypeDescriptor, dataScopeIdentifier, cultureName)) }; var document = new XDocument(new XElement(defaultXmlDataTypeStoreDataScope.ElementName)); document.SaveToFile(defaultXmlDataTypeStoreDataScope.Filename); defaultDataScopes.Add(defaultXmlDataTypeStoreDataScope); } } xmlDataTypeStoreDataScopes = defaultDataScopes; } return new XmlDataTypeStore(dataTypeDescriptor, dataProviderHelperClassType, dataIdClassType, xmlDataTypeStoreDataScopes, dataTypeDescriptor.IsCodeGenerated); }
private static void InheritRRLogger(ref XDocument xmlDoc, string outPath, string inheritIdent, string newIdent) { try { //inherit from a base file //todo add list of exemptions to skip??? string path = "/logger/protocols/protocol[@id='SSM']/ecuparams/ecuparam/ecu[contains(@id, '" + inheritIdent + "')]"; IEnumerable<XElement> pexp = xmlDoc.XPathSelectElements(path); foreach (XElement xel in pexp) { xel.Attribute("id").Value += ',' + newIdent; } xmlDoc.SaveToFile(outPath); } catch (Exception e) { Trace.WriteLine(e.Message); } }
/// <summary> /// This method is used to record the very first time the system is started. /// Ths time can later be used to several things like finding files that have been written to etc. /// </summary> public static void SetFirstTimeStart() { if (!C1File.Exists(FirstTimeStartFilePath)) { string directory = Path.GetDirectoryName(FirstTimeStartFilePath); if (!C1Directory.Exists(directory)) { C1Directory.CreateDirectory(directory); } var doc = new XDocument(new XElement("Root", new XAttribute("time", DateTime.Now))); doc.SaveToFile(FirstTimeStartFilePath); } }
private void PersistFormData() { var resources = _resourceLocker.Resources; List<Guid> instanceIds = (from kvp in resources.WorkflowPersistingTypeDictionary where kvp.Value != WorkflowPersistingType.Never select kvp.Key).ToList(); // Copying collection since it may be modified why execution of forech-statement var formDataSetToBePersisted = resources.FormData.Where(f => instanceIds.Contains(f.Key)).ToList(); foreach (var kvp in formDataSetToBePersisted) { Guid instanceid = kvp.Key; try { XElement element = kvp.Value.Serialize(); string filename = Path.Combine(SerializedWorkflowsDirectory, string.Format("{0}.xml", instanceid)); XDocument doc = new XDocument(element); doc.SaveToFile(filename); Log.LogVerbose(LogTitle, "FormData persisted for workflow id = " + instanceid); } catch (Exception ex) { // Stop trying serializing this workflow AbortWorkflow(instanceid); Log.LogCritical(LogTitle, ex); } } }
private static void ValidateConfigurationFile(XDocument resultDocument) { string tempValidationFilePath = TempRandomConfigFilePath; resultDocument.SaveToFile(tempValidationFilePath); try { IConfigurationSource testConfigSource = new FileConfigurationSource(tempValidationFilePath); foreach (XElement sectionElement in resultDocument.Root.Element("configSections").Elements()) { if (sectionElement.Attribute("name") != null) { string sectionName = sectionElement.Attribute("name").Value; try { testConfigSource.GetSection(sectionName); } catch (ConfigurationErrorsException exception) { if(exception.InnerException != null && exception.InnerException is AppCodeTypeNotFoundConfigurationException) { // App_Code classes aren't compiled during package installation, therefore related exceptions are ignored } else { throw; } } } } DeleteTempConfigurationFile(tempValidationFilePath); } catch (Exception) { DeleteTempConfigurationFile(tempValidationFilePath); throw; } }
private void PersistFormData(Guid instanceId) { var resources = _resourceLocker.Resources; bool shouldPersist = resources.WorkflowPersistingTypeDictionary .Any(f => f.Key == instanceId && f.Value != WorkflowPersistingType.Never); if (!shouldPersist) return; FormData formData = resources.FormData. Where(f => f.Key == instanceId). Select(f => f.Value). SingleOrDefault(); if (formData == null) return; try { XElement element = formData.Serialize(); string filename = Path.Combine(SerializedWorkflowsDirectory, string.Format("{0}.xml", instanceId)); XDocument doc = new XDocument(element); doc.SaveToFile(filename); } catch (Exception ex) { // Stop trying serializing this workflow AbortWorkflow(instanceId); Log.LogCritical(LogTitle, ex); } }
/// <exclude /> public static PackageManagerInstallProcess Install(Stream zipFileStream, bool isLocalInstall, string packageServerAddress) { if (!isLocalInstall && string.IsNullOrEmpty(packageServerAddress)) throw new ArgumentException("Non local install needs a packageServerAddress"); string zipFilename = null; try { PackageFragmentValidationResult packageFragmentValidationResult = SaveZipFile(zipFileStream, out zipFilename); if (packageFragmentValidationResult != null) return new PackageManagerInstallProcess(new List<PackageFragmentValidationResult> { packageFragmentValidationResult }, null); XElement installContent; packageFragmentValidationResult = XmlHelper.LoadInstallXml(zipFilename, out installContent); if (packageFragmentValidationResult != null) return new PackageManagerInstallProcess(new List<PackageFragmentValidationResult> { packageFragmentValidationResult }, zipFilename); PackageInformation packageInformation; packageFragmentValidationResult = ValidatePackageInformation(installContent, out packageInformation); if (packageFragmentValidationResult != null) return new PackageManagerInstallProcess(new List<PackageFragmentValidationResult> { packageFragmentValidationResult }, zipFilename); if (RuntimeInformation.ProductVersion < packageInformation.MinCompositeVersionSupported || RuntimeInformation.ProductVersion > packageInformation.MaxCompositeVersionSupported) { return new PackageManagerInstallProcess(new List<PackageFragmentValidationResult> { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, Texts.PackageManager_CompositeVersionMisMatch( RuntimeInformation.ProductVersion, packageInformation.MinCompositeVersionSupported, packageInformation.MaxCompositeVersionSupported)) }, zipFilename); } bool updatingInstalledPackage = false; if (IsInstalled(packageInformation.Id)) { string currentVersionString = GetCurrentVersion(packageInformation.Id); Version currentVersion = new Version(currentVersionString); Version newVersion = new Version(packageInformation.Version); if (newVersion <= currentVersion) { string validationError = newVersion == currentVersion ? Texts.PackageManager_PackageAlreadyInstalled : Texts.PackageManager_NewerVersionInstalled; return new PackageManagerInstallProcess( new List<PackageFragmentValidationResult> { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, validationError) }, zipFilename); } updatingInstalledPackage = true; } string originalInstallDirectory = null; string packageInstallDirectory = CreatePackageDirectoryName(packageInformation); if (updatingInstalledPackage) { originalInstallDirectory = packageInstallDirectory; packageInstallDirectory += "-" + packageInformation.Version; } C1Directory.CreateDirectory(packageInstallDirectory); string packageZipFilename = Path.Combine(packageInstallDirectory, Path.GetFileName(zipFilename)); C1File.Copy(zipFilename, packageZipFilename, true); string username = "******"; if (UserValidationFacade.IsLoggedIn()) { username = UserValidationFacade.GetUsername(); } var doc = new XDocument(); XElement packageInfoElement = new XElement(XmlUtils.GetXName(PackageSystemSettings.XmlNamespace, PackageSystemSettings.PackageInfoElementName)); doc.Add(packageInfoElement); packageInfoElement.Add( new XAttribute(PackageSystemSettings.PackageInfo_NameAttributeName, packageInformation.Name), new XAttribute(PackageSystemSettings.PackageInfo_GroupNameAttributeName, packageInformation.GroupName), new XAttribute(PackageSystemSettings.PackageInfo_VersionAttributeName, packageInformation.Version), new XAttribute(PackageSystemSettings.PackageInfo_AuthorAttributeName, packageInformation.Author), new XAttribute(PackageSystemSettings.PackageInfo_WebsiteAttributeName, packageInformation.Website), new XAttribute(PackageSystemSettings.PackageInfo_DescriptionAttributeName, packageInformation.Description), new XAttribute(PackageSystemSettings.PackageInfo_InstallDateAttributeName, DateTime.Now), new XAttribute(PackageSystemSettings.PackageInfo_InstalledByAttributeName, username), new XAttribute(PackageSystemSettings.PackageInfo_IsLocalInstalledAttributeName, isLocalInstall), new XAttribute(PackageSystemSettings.PackageInfo_CanBeUninstalledAttributeName, packageInformation.CanBeUninstalled), new XAttribute(PackageSystemSettings.PackageInfo_FlushOnCompletionAttributeName, packageInformation.FlushOnCompletion), new XAttribute(PackageSystemSettings.PackageInfo_ReloadConsoleOnCompletionAttributeName, packageInformation.ReloadConsoleOnCompletion), new XAttribute(PackageSystemSettings.PackageInfo_SystemLockingAttributeName, packageInformation.SystemLockingType.Serialize())); if (!string.IsNullOrEmpty(packageServerAddress)) { packageInfoElement.Add(new XAttribute(PackageSystemSettings.PackageInfo_PackageServerAddressAttributeName, packageServerAddress)); } string infoFilename = Path.Combine(packageInstallDirectory, PackageSystemSettings.PackageInformationFilename); doc.SaveToFile(infoFilename); var packageInstaller = new PackageInstaller(new PackageInstallerUninstallerFactory(), packageZipFilename, packageInstallDirectory, TempDirectoryFacade.CreateTempDirectory(), packageInformation); return new PackageManagerInstallProcess( packageInstaller, packageInformation.SystemLockingType, zipFilename, packageInstallDirectory, packageInformation.Name, packageInformation.Version, packageInformation.Id, originalInstallDirectory); } catch (Exception ex) { return new PackageManagerInstallProcess(new List<PackageFragmentValidationResult> { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, ex) }, zipFilename); } }
private PackageFragmentValidationResult DoInstall() { using (var transactionScope = TransactionsFacade.Create(true, TimeSpan.FromMinutes(30.0))) { string uninstallFilename = Path.Combine(this.PackageInstallDirectory, PackageSystemSettings.UninstallFilename); Exception installException = null; XElement uninstallElements = new XElement(XmlUtils.GetXName(PackageSystemSettings.XmlNamespace, PackageSystemSettings.PackageFragmentUninstallersElementName)); try { foreach (var kvp in _packageFramentInstallers) { List<XElement> uninstallInformation = kvp.Key.Install().ToList(); if (this.CanBeUninstalled) { XElement uninstallElement = new XElement(XmlUtils.GetXName(PackageSystemSettings.XmlNamespace, PackageSystemSettings. PackageFragmentUninstallersAddElementName)); uninstallElement.Add(new XAttribute(PackageSystemSettings.UninstallerTypeAttributeName, TypeManager.SerializeType(kvp.Value))); uninstallElement.Add(uninstallInformation); uninstallElements.Add(uninstallElement); } } } catch (Exception ex) { installException = ex; LoggingService.LogError("Package installation failed", ex); } finally { if (this.CanBeUninstalled) { XDocument doc = new XDocument( new XElement( XmlUtils.GetXName(PackageSystemSettings.XmlNamespace, PackageSystemSettings.PackageInstallerElementName), uninstallElements)); doc.SaveToFile(uninstallFilename); } } if (installException != null) { if (this.CanBeUninstalled) { IPackageUninstaller packageUninstaller = this.PackageInstallerUninstallerFactory.CreateUninstaller( this.ZipFilename, uninstallFilename, this.PackageInstallDirectory, TempDirectoryFacade. CreateTempDirectory(), this.FlushOnCompletion, this.ReloadConsoleOnCompletion, false, this.PackageInformation); List<PackageFragmentValidationResult> validationResult = null; try { validationResult = packageUninstaller.Validate().ToList(); } catch (Exception ex) { return new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, ex); } if (validationResult.Count == 0) { try { packageUninstaller.Uninstall(SystemLockingType.None); } catch (Exception ex) { return new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, ex); } } else { LoggingService.LogError(LogTitle, "Failed to perform installation rollback."); foreach(var valResult in validationResult) { if(valResult.Exception != null) { LoggingService.LogError(LogTitle, new InvalidOperationException(valResult.Message ?? string.Empty, valResult.Exception)); } else { LoggingService.LogWarning(LogTitle, valResult.Message); } } return new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, "Could not perform installation rollback. The details are in the log.") {InnerResult = validationResult}; } } return new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, installException); } transactionScope.Complete(); } return null; }
//TODO: USE table ID instead private static void PopulateRRLogDefTables(ref XDocument xmlDoc, string outPath, Dictionary<string, Table> ramTableList, string ident) { foreach (KeyValuePair<string, Table> table in ramTableList) { string xp = "./logger/protocols/protocol/ecuparams/ecuparam[@name='" + table.Key.ToString() + "']"; XElement exp = xmlDoc.XPathSelectElement(xp); string cxp = "./logger/protocols/protocol/ecuparams/ecuparam[@name='" + table.Key.ToString() + "']/conversions"; XElement cexp = xmlDoc.XPathSelectElement(cxp); if (exp != null) { string ch = "//ecuparam[@id='" + table.Key.ToString() + "']/ecu[@id='" + ident + "']"; XElement check = exp.XPathSelectElement(ch); if (check != null) { if (check.Value != table.Value.xml.Value) check.Remove(); else continue; } cexp.AddBeforeSelf(table.Value.xml); } } xmlDoc.SaveToFile(outPath); }
/// <exclude /> public override IEnumerable<XElement> Install() { if (_xslTransformations == null) throw new InvalidOperationException("FileXslTransformationPackageFragmentInstaller has not been validated"); Stream stream; foreach (XslTransformation xslfile in _xslTransformations) { string messageFormat = xslfile.InputXmlPath == xslfile.OutputXmlPath ? "Performing XSL-transformation. xml-file: '{1}'; xsl-file: '{0}'" : "Performing XSL-transformation. xsl-file: '{0}'; input xml file: '{1}'; output xml file: '{2}'"; Log.LogVerbose(LogTitle, string.Format(messageFormat, xslfile.XslPath, xslfile.InputXmlPath, xslfile.OutputXmlPath)); string inputXml = PathUtil.Resolve(xslfile.InputXmlPath); string outputXml = PathUtil.Resolve(xslfile.OutputXmlPath); using (stream = this.InstallerContext.ZipFileSystem.GetFileStream(xslfile.XslPath)) { var xslt = new XslCompiledTransform(); using (XmlReader xslReader = XmlReader.Create(stream)) { xslt.Load(xslReader); } var resultDocument = new XDocument(); using (XmlWriter writer = resultDocument.CreateWriter()) { xslt.Transform(inputXml, writer); } resultDocument.SaveToFile(outputXml); Log.LogVerbose(LogTitle, resultDocument.ToString()); } } return new[] { this.Configuration.FirstOrDefault() }; }
private static void InheritRRLogger(ref XDocument xmlDoc, string outPath, string inheritIdent, string newIdent) { //inherit from a base file //todo add list of exemptions to skip??? string paramxp = "./logger/protocols/protocol/ecuparams"; XElement pexp = xmlDoc.XPathSelectElement(paramxp); try { foreach (XElement xel in pexp.Elements()) { if (xel.Elements("ecu") != null) { foreach (XElement xecu in xel.Elements("ecu")) { string id = xecu.Attribute("id").Value.ToString(); if (id == inheritIdent)//parentMod.InitialEcuId.ToString()) { //found hit, copy the ecu xel XElement newxecu = new XElement(xecu); newxecu.Attribute("id").SetValue(newIdent);///parentMod.FinalEcuId.ToString()); xel.AddFirst(newxecu); } } } } xmlDoc.SaveToFile(outPath); } catch (Exception e) { Trace.WriteLine(e.Message); } }
private static void AddRRLogDefBase(ref XDocument xmlDoc, string outPath, string templatePath) { XDocument xmlBase = XDocument.Load(templatePath);//, LoadOptions.PreserveWhitespace); string bxp = "./logger/protocols/protocol/ecuparams/ecuparam"; IEnumerable<XElement> xbase = xmlBase.XPathSelectElements(bxp); foreach (XElement xb in xbase) { xmlDoc.XPathSelectElement("./logger/protocols/protocol/ecuparams").Add(xb); } xmlDoc.SaveToFile(outPath); }
/// <exclude /> public override void Uninstall() { if (_xsls == null) throw new InvalidOperationException("FileXslTransformationPackageFragmentUninstaller has not been validated"); Stream stream; foreach (XslTransformation xslfile in _xsls) { Log.LogVerbose("XsltPackageFragmentInstaller", string.Format("Performing XSL-transformation. xml-file: '{0}'; xsl-file: '{1}'", xslfile.pathXml, xslfile.pathXsl)); string xmlFilePath = PathUtil.Resolve(xslfile.pathXml); using (stream = this.UninstallerContext.ZipFileSystem.GetFileStream(xslfile.pathXsl)) { var xslt = new XslCompiledTransform(); using (XmlReader xslReader = XmlReader.Create(stream)) { xslt.Load(xslReader); } var resultDocument = new XDocument(); using (XmlWriter writer = resultDocument.CreateWriter()) { xslt.Transform(xmlFilePath, writer); } resultDocument.SaveToFile(xmlFilePath); Log.LogVerbose("XsltTransformationResult", resultDocument.ToString()); } } }
//TODO: USE table ID instead private static void PopulateRRLogDefTables(ref XDocument xmlDoc, string outPath, Dictionary<string, TableMetaData> ramTableList, string ident, Dictionary<string,string> ExtIdentifiers) { var items = from pair in ExtIdentifiers where pair.Value.ContainsCI("merpmod") orderby pair.Key descending select pair.Key; List<string> list = new List<string>(); list.AddRange(items); int lastMerpModExt; if(list.Count > 0) lastMerpModExt = ((int.Parse(list[0].Replace("E","")) +100) / 10 ) * 10 ; else lastMerpModExt = 2000; foreach (KeyValuePair<string, TableMetaData> table in ramTableList) { string xp = "./logger/protocols/protocol/ecuparams/ecuparam[@name='" + table.Key.ToString() + "']"; XElement exp = xmlDoc.XPathSelectElement(xp); string cxp = "./logger/protocols/protocol/ecuparams/ecuparam[@name='" + table.Key.ToString() + "']/conversions"; XElement cexp = xmlDoc.XPathSelectElement(cxp); if (exp != null) { string ch = "//ecuparam[@id='" + table.Key.ToString() + "']/ecu[@id='" + ident + "']"; XElement check = exp.XPathSelectElement(ch); if (check != null) { if (check.Value != table.Value.RomRaiderXML().Value) check.Remove(); else continue; } cexp.AddBeforeSelf(table.Value.RomRaiderXML()); } else { /*<ecuparam id="E21511" name="MerpMod TEST char4" desc="E2000" target="1"> <ecu id="14418178FF"> <address length="1">0xFF97B7</address> </ecu> <conversions> <conversion units="rawdata" expr="x" format="0" /> </conversions> </ecuparam>*/ XElement newParam = new XElement("ecuparam"); newParam.SetAttributeValue("id","E"+lastMerpModExt); newParam.SetAttributeValue("name", table.Key); newParam.SetAttributeValue("desc", "E"+lastMerpModExt); newParam.SetAttributeValue("target","1"); XElement conv = XElement.Parse(@" <conversions> <conversion units=""rawdata"" expr=""x"" format=""0.00"" /> </conversions>"); if(table.Value.storageTypeString.EqualsCI("float")) conv.Element("conversion").SetAttributeValue("storagetype", "float"); newParam.Add(table.Value.RomRaiderXML()); newParam.Add(conv); xmlDoc.XPathSelectElement("./logger/protocols/protocol/ecuparams").Add(newParam); lastMerpModExt++; } } xmlDoc.SaveToFile(outPath); }
public static void StoreLicenseDefinition(PackageLicenseDefinition licenseDefinition) { XDocument doc = new XDocument( new XElement("License", new XElement("Name", licenseDefinition.ProductName), new XElement("InstallationId", licenseDefinition.InstallationId), new XElement("ProductId", licenseDefinition.ProductId), new XElement("Permanent", licenseDefinition.Permanent), new XElement("Expires", licenseDefinition.Expires), new XElement("LicenseKey", licenseDefinition.LicenseKey), new XElement("PurchaseUrl", licenseDefinition.PurchaseUrl) ) ); string filename = GetLicenseFilename(licenseDefinition); licenseDefinition.LicenseFileName = filename; doc.SaveToFile(filename); }
//TODO add check for existing def!! private static void PopulateRRLogDefTables(ref XDocument xmlDoc, string outPath, Dictionary<string, string> ramTableList, string ident) { foreach (KeyValuePair<string, string> table in ramTableList) { string xp = "./logger/protocols/protocol/ecuparams/ecuparam[@id='" + table.Key.ToString() + "']"; XElement exp = xmlDoc.XPathSelectElement(xp); string cxp = "./logger/protocols/protocol/ecuparams/ecuparam[@id='" + table.Key.ToString() + "']/conversions"; XElement cexp = xmlDoc.XPathSelectElement(cxp); if (exp != null) { string ch = "//ecuparam[@id='" + table.Key.ToString() + "']/ecu[@id='" + ident + "']"; XElement check = exp.XPathSelectElement(ch); XElement ad; if (check != null) { ad = new XElement(check); ad.Attribute("id").Value = ident; ad.Descendants().First().Value = "0x" + table.Value; if (check.Value != ad.Value) check.Remove(); else continue; } else { ad = new XElement(exp.Descendants("ecu").First()); ad.Attribute("id").Value = ident; ad.Descendants().First().Value = "0x" + table.Value; } cexp.AddBeforeSelf(ad); } } xmlDoc.SaveToFile(outPath); }
/// <summary> /// Transforms the current configuration file based on the supplied XSLT document. The resulting /// configuration document is validated and no errors are tollerated. Configurationerrors are handled /// as exceptions. /// </summary> /// <param name="xsltDocument">XSLT document to apply to the configuration document</param> /// <param name="simulationOnly">When true the configuration transformation will only be validated, not executed. When false, the configuration change will be persisted.</param> public static void TransformConfiguration(XDocument xsltDocument, bool simulationOnly) { using (GlobalInitializerFacade.CoreLockScope) { lock (_lock) { XslCompiledTransform transformer = new XslCompiledTransform(); XDocument resultDocument = new XDocument(); using (XmlReader reader = xsltDocument.CreateReader()) { transformer.Load(reader); } using (XmlWriter writer = resultDocument.CreateWriter()) { transformer.Transform(ConfigurationServices.FileConfigurationSourcePath, writer); } ValidateConfigurationFile(resultDocument); if (simulationOnly == false) { // Kill monitoring of file changes: // FileConfigurationSource.ResetImplementation(ConfigurationServices.FileConfigurationSourcePath, false); resultDocument.SaveToFile(ConfigurationServices.FileConfigurationSourcePath); _configurationSource = new FileConfigurationSource(ConfigurationServices.FileConfigurationSourcePath); // Kill monitoring of file changes: // FileConfigurationSource.ResetImplementation(ConfigurationServices.FileConfigurationSourcePath, false); } } } }