本文整理汇总了C#中RocksmithToolkitLib.Xml.Song2014.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# Song2014.Serialize方法的具体用法?C# Song2014.Serialize怎么用?C# Song2014.Serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RocksmithToolkitLib.Xml.Song2014
的用法示例。
在下文中一共展示了Song2014.Serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
public void Convert(string zigSrcPath, string destPath)
{
var deser = new XmlSerializer(typeof(ZpeSong));
ZpeSong zigSong;
using (FileStream stream = new FileStream(zigSrcPath, FileMode.Open))
{
zigSong = (ZpeSong)deser.Deserialize(stream);
}
if (zigSong.PueVersion != 46)
throw new Exception("Incompatable version of Ziggy Pro Editor XML file");
bool foundTrack = false;
StringBuilder sb = new StringBuilder();
// cross matching arrangment arrays
string[] rsArray = new string[] { "Lead", "Rhythm", "Bass" };
string[] zigArray = new string[] { "PART REAL_GUITAR_22", "PART REAL_GUITAR", "PART REAL_BASS_22" };
int arrIndex = -1;
foreach (var arrangement in zigArray)
{
arrIndex++;
var guitarTrack = zigSong.Tracks.SingleOrDefault(tr => arrangement.Equals(tr.Name));
if (guitarTrack == null)
{
continue;
//throw new Exception("Couldn't find a guitar track");
}
foundTrack = true;
var rsSong = new Song2014();
AddSongMetadata(rsSong, zigSong, rsArray[arrIndex]);
AddEbeats(rsSong, zigSong, arrangement);
AddNotes(rsSong, zigSong, arrangement);
AddToneProps(rsSong, rsArray[arrIndex]);
var destDir = Path.GetDirectoryName(destPath);
var destName = Path.GetFileNameWithoutExtension(destPath);
var xmlDestPath = String.Format("{0}_{1}.xml", Path.Combine(destDir, destName), rsArray[arrIndex]);
using (FileStream stream = new FileStream(xmlDestPath, FileMode.Create))
{
rsSong.Serialize(stream, true);
}
}
if (!foundTrack)
throw new NullReferenceException("Did not find any Rocksmith 2014 compatible Ziggy Pro tracks in " + Path.GetFileName(zigSrcPath) + Environment.NewLine);
}
示例2: Song2014ToXml
/// <summary>
/// Convert RS2014 (Song2014) to XML file
/// </summary>
/// <param name="rs2014Song"></param>
/// <param name="outputPath"></param>
/// <param name="overWrite"></param>
/// <returns>RS2014 XML file path</returns>
public string Song2014ToXml(Song2014 rs2014Song, string outputPath, bool overWrite)
{
if (File.Exists(outputPath) && overWrite)
File.Delete(outputPath);
else
{
var outputDir = Path.GetDirectoryName(outputPath);
var outputFile = String.Format("{0}_{1}", rs2014Song.Title, rs2014Song.Arrangement);
outputFile = String.Format("{0}{1}", outputFile.GetValidName(false, true).ToLower(), "_rs2014.xml");
outputPath = Path.Combine(outputDir, outputFile);
}
using (var stream = File.OpenWrite(outputPath))
{
rs2014Song.Serialize(stream, false);
}
return outputPath;
}
示例3: SongFile2Song2014File
public string SongFile2Song2014File(string songFilePath, bool overWrite)
{
Song2014 song2014 = new Song2014();
using (var obj = new Rs1Converter())
song2014 = obj.SongToSong2014(Song.LoadFromFile(songFilePath));
if (!overWrite)
{
var srcDir = Path.GetDirectoryName(songFilePath);
var srcName = Path.GetFileNameWithoutExtension(songFilePath);
var backupSrcPath = String.Format("{0}_{1}.xml", Path.Combine(srcDir, srcName), "RS1");
// backup original RS1 file
File.Copy(songFilePath, backupSrcPath);
}
// write converted RS1 file
using (FileStream stream = new FileStream(songFilePath, FileMode.Create))
song2014.Serialize(stream, true);
return songFilePath;
}