本文整理汇总了C#中XDoc.Save方法的典型用法代码示例。如果您正苦于以下问题:C# XDoc.Save方法的具体用法?C# XDoc.Save怎么用?C# XDoc.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDoc
的用法示例。
在下文中一共展示了XDoc.Save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveUsersAndGroupsToXML
private void SaveUsersAndGroupsToXML()
{
XDoc doc = new XDoc(UsersAndGroupsXMLRootName);
foreach (string confluenceUserName in _convertedUsers.Keys)
{
ACConverterUserInfo userInfo = _convertedUsers[confluenceUserName];
XDoc userDoc = new XDoc(UserXMLTagName);
userDoc.Attr(ConfluenceUserNameXMLAttributeName, confluenceUserName);
userDoc.Attr(DekiUserNameXMLAttributeName, userInfo.DekiUserName);
doc.Add(userDoc);
}
foreach (string confluenceGroupName in _convertedGroups.Keys)
{
ACConverterGroupInfo groupInfo = _convertedGroups[confluenceGroupName];
XDoc groupDoc = new XDoc(GroupXMLTagName);
groupDoc.Attr(ConfluenceGroupNameXMLAttributeName, confluenceGroupName);
groupDoc.Attr(DekiGroupNameXMLAttributeName, groupInfo.DekiGroupName);
doc.Add(groupDoc);
}
doc.Save(ConvertedUsersAndGroupsFileName);
}
示例2: SaveConvertedUsersAndGroups
private void SaveConvertedUsersAndGroups()
{
XDoc usersDoc = new XDoc(ConvertedUsersRootName);
foreach (string tWikiUserName in _convertedUsers.Keys)
{
XDoc userDoc = new XDoc(ConvertedUserTagName);
userDoc.Attr(TWikiUserNameAttribute, tWikiUserName);
userDoc.Attr(DekiUserNameAttribute, _convertedUsers[tWikiUserName].DekiName);
usersDoc.Add(userDoc);
}
foreach (string tWikiGroupName in _convertedGroups.Keys)
{
XDoc groupDoc = new XDoc(ConvertedGroupTagName);
groupDoc.Attr(TWikiGroupNameAttribute, tWikiGroupName);
groupDoc.Attr(DekiGroupNameAttribute, _convertedGroups[tWikiGroupName].DekiName);
usersDoc.Add(groupDoc);
}
usersDoc.Save(ConvertedUsersFileName);
}
示例3: WriteConfig
public void WriteConfig() {
XDoc exportDocument = new XDoc("config")
.Attr("archive", Archive)
.Add(ExportDocument);
switch(Mode) {
case Mode.Export:
exportDocument.Attr("export", true);
break;
case Mode.Copy:
exportDocument.Attr("copy", true);
break;
}
if(DekiApi != null) {
exportDocument.Attr("uri", DekiApi.Uri);
}
if(!string.IsNullOrEmpty(User)) {
exportDocument.Attr("user", User);
}
if(!string.IsNullOrEmpty(Password)) {
exportDocument.Attr("password", Password);
}
if(!string.IsNullOrEmpty(AuthToken)) {
exportDocument.Attr("authtoken", AuthToken);
}
if(!string.IsNullOrEmpty(FilePath)) {
exportDocument.Elem("target", FilePath);
}
if(Mode != Import.Mode.Export && !string.IsNullOrEmpty(ImportReltoPath)) {
exportDocument.Attr("importreltopath", ImportReltoPath);
}
if(Mode != Import.Mode.Import && !string.IsNullOrEmpty(ExportReltoPath)) {
exportDocument.Attr("exportreltopath", ExportReltoPath);
}
if(ImportRelto.HasValue) {
exportDocument.Attr("importrelto", ImportRelto.Value);
}
if(ExportRelto.HasValue) {
exportDocument.Attr("exportrelto", ExportRelto.Value);
}
string dir = Path.GetDirectoryName(Path.GetFullPath(_genConfigPath));
if(!Directory.Exists(dir)) {
Directory.CreateDirectory(dir);
}
exportDocument.Save(_genConfigPath);
}
示例4: SaveBlueprint
private static void SaveBlueprint(string path, XUri uri, XDoc blueprint)
{
// check if uri is valid
if(uri == null) {
Console.WriteLine("ERROR: invalid SID ({0}) for {1}", uri, blueprint["class"].AsText);
return;
}
// combine uri segments into a path and create folders
for(int i = 0; i < uri.Segments.Length; ++i) {
path = Path.Combine(path, uri.Segments[i]);
}
if(!Directory.Exists(path)) {
Directory.CreateDirectory(path);
}
path = Path.Combine(path, "blueprint.xml");
blueprint.Save(path);
Console.WriteLine("Create blueprint for {0}", blueprint["class"].AsText);
}
示例5: AttachMusicXmlHelper
private Yield AttachMusicXmlHelper(IScore aScore, XDoc aMusicXmlDoc, bool overwriteMusicXmlValues, Result<IScore> aResult)
{
XScore musicXml = new XScore(aMusicXmlDoc);
bool hasNotes = false;
foreach (var p in musicXml.Parts)
{
foreach (var m in p.Measures)
{
if (m.Notes.Count() > 0)
{
hasNotes = true;
break;
}
}
if(hasNotes)
break;
}
if(!hasNotes)
{
aResult.Return(aScore);
yield break;
}
if (overwriteMusicXmlValues)
{
aScore.CodageMelodiqueRISM = musicXml.GetCodageMelodiqueRISM();
aScore.CodageParIntervalles = musicXml.GetCodageParIntervalle();
//aScore.Title = musicXml.MovementTitle;
//aScore.Composer = musicXml.Identification.Composer;
aScore.Verses = musicXml.GetText();
}
Result<IScore> result = new Result<IScore>();
if (aScore.Id != null)
{
yield return Update(aScore.Id, aScore.Rev, aScore, result);
}
else
{
yield return Insert(aScore, result);
}
using(TemporaryFile inputFile = new TemporaryFile(".xml",false))
using(TemporaryFile outputFile = new TemporaryFile(".png",false))
{
theLogger.Info("Saving xdoc to " + inputFile.Path);
File.Delete(inputFile.Path);
aMusicXmlDoc.Save(inputFile.Path);
theLogger.Info("XDoc saved");
theLogger.Info("Getting Converter and converting");
//yield return Context.Current.Instance.SourceController.Exists("bla", new Result<bool>());
IList<string> pngsFilePath = Context.Current.Instance.ConverterFactory.GetConverter(MimeType.PNG).Convert(inputFile.Path, outputFile.Path);
int i = 1;
foreach (string pngFile in pngsFilePath)
{
using(Stream pngStream = File.OpenRead(pngFile))
{
yield return AddAttachment(result.Value.Id, pngStream,pngStream.Length, "$partition" + i + ".png", new Result<bool>());
}
File.Delete(pngFile);
i++;
}
}
//attach music xml to the created /updated score
using(Stream stream = new MemoryStream(aMusicXmlDoc.ToBytes()))
{
yield return AddAttachment(result.Value.Id, stream,stream.Length, "$musicxml.xml", new Result<bool>());
}
aResult.Return(result.Value);
}
示例6: WriteMeta
private void WriteMeta(string filePath, TimeSpan? ttl, DateTime? when)
{
lock(_expirationEntries) {
var metaPath = GetMetaPath(filePath);
if(ttl.HasValue) {
// set up expiration and write to meta file
if(when.HasValue) {
_expirationEntries.SetOrUpdate(filePath, when.Value, ttl.Value);
} else {
_expirationEntries.SetOrUpdate(filePath, ttl.Value);
when = _expirationEntries[filePath].When;
}
var meta = new XDoc("meta")
.Elem("expire.ttl", ttl.Value.TotalSeconds)
.Elem("expire.date", when.Value);
Directory.CreateDirectory(Path.GetDirectoryName(metaPath));
meta.Save(metaPath);
} else {
// remove expiration and remove it from meta file
_expirationEntries.Delete(filePath);
if(File.Exists(metaPath)) {
try {
File.Delete(metaPath);
} catch {
// ignore file deletion exception
// BUG #806: we should try again in a few seconds; however, we need to be smart about it and count how often
// we tried, otherwise we run the risk of bogging down the system b/c we're attempting to delete undeletable files.
}
}
}
}
}
示例7: PersistManifestToDisk
public void PersistManifestToDisk(string space, XDoc spaceManifest) {
if(string.IsNullOrEmpty(space)) {
space = "_global";
}
if(!Directory.Exists("data")) {
Directory.CreateDirectory("data");
}
string filename = string.Format(@"data\{0}.manifest.xml", space.ToLowerInvariant());
spaceManifest.Save(filename);
}
示例8: SaveToFileSystem
private void SaveToFileSystem(string key, XDoc doc)
{
string fullPath = BuildSavePath(key);
if (fullPath != null && doc != null)
doc.Save(fullPath);
}
示例9: WritePackageDoc_Helper
protected override Yield WritePackageDoc_Helper(XDoc package, Result result) {
package.Save(Path.Combine(_packageDirectory, "package.xml"), true);
result.Return();
yield break;
}