当前位置: 首页>>代码示例>>C#>>正文


C# XDocument.SaveToFile方法代码示例

本文整理汇总了C#中System.Xml.Linq.XDocument.SaveToFile方法的典型用法代码示例。如果您正苦于以下问题:C# XDocument.SaveToFile方法的具体用法?C# XDocument.SaveToFile怎么用?C# XDocument.SaveToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Linq.XDocument的用法示例。


在下文中一共展示了XDocument.SaveToFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeNewFile

        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);
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:18,代码来源:InstallationInformationFacade.cs

示例2: CreateStoreResult

        /// <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);
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:54,代码来源:XmlDataTypeStoreCreator.cs

示例3: InheritRRLogger

 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);
     }
 }
开发者ID:nosajton,项目名称:SharpTune,代码行数:19,代码来源:ModDefinition.cs

示例4: SetFirstTimeStart

        /// <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);
            }
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:19,代码来源:SystemSetupFacade.cs

示例5: PersistFormData

        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);
                }
            }
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:36,代码来源:WorkflowFacadeImpl.cs

示例6: ValidateConfigurationFile

        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;
            }
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:44,代码来源:ConfigurationServices.cs

示例7: Install


//.........这里部分代码省略.........
                {
                    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 = "Composite";
                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);
            }
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:101,代码来源:PackageManager.cs

示例8: DoInstall

        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);
//.........这里部分代码省略.........
开发者ID:hitesh97,项目名称:C1-CMS,代码行数:101,代码来源:PackageInstaller.cs

示例9: PopulateRRLogDefTables

        //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);
        }
开发者ID:segapsh2,项目名称:SharpTune,代码行数:27,代码来源:ModDefinition.cs

示例10: Install

        /// <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() };
		}
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:39,代码来源:FileXslTransformationPackageFragmentInstaller.cs

示例11: InheritRRLogger

        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);
            }
        }
开发者ID:segapsh2,项目名称:SharpTune,代码行数:33,代码来源:ModDefinition.cs

示例12: AddRRLogDefBase

        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);
        }
开发者ID:segapsh2,项目名称:SharpTune,代码行数:12,代码来源:ModDefinition.cs

示例13: Uninstall

        /// <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());
				}
			}

		}
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:34,代码来源:FileXslTransformationPackageFragmentUninstaller.cs

示例14: PopulateRRLogDefTables

        //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);
        }
开发者ID:nosajton,项目名称:SharpTune,代码行数:70,代码来源:ModDefinition.cs

示例15: StoreLicenseDefinition

        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);
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:20,代码来源:LicenseDefinitionManager.cs


注:本文中的System.Xml.Linq.XDocument.SaveToFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。