本文整理汇总了C#中XmlSerializer.SerializeToXElemet方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSerializer.SerializeToXElemet方法的具体用法?C# XmlSerializer.SerializeToXElemet怎么用?C# XmlSerializer.SerializeToXElemet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlSerializer
的用法示例。
在下文中一共展示了XmlSerializer.SerializeToXElemet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNode
public int? AddNode(Node node)
{
var db = GetDbContext();
if (node.Sequencing == null)
{
var xs = new XmlSerializer(typeof (Sequencing));
node.Sequencing = xs.SerializeToXElemet(new Sequencing());
}
db.Nodes.InsertOnSubmit(node);
db.SubmitChanges();
if (!node.IsFolder)
{
var template = Path.Combine(GetTemplatesPath(), "iudico.html");
File.Copy(template, GetNodePath(node.Id) + ".html", true);
}
return node.Id;
}
示例2: AddNode
public virtual int? AddNode(Node node)
{
var db = this.GetDbContext();
if (node.Sequencing == null)
{
var xs = new XmlSerializer(typeof(Sequencing));
node.Sequencing = xs.SerializeToXElemet(new Sequencing());
}
db.Nodes.InsertOnSubmit(node);
db.SubmitChanges();
if (!node.IsFolder)
{
var template = Path.Combine(this.GetTemplatesPath(), "iudico.html");
File.Copy(template, this.GetNodePath(node.Id) + ".html", true);
}
this.LmsService.Inform(CourseNotifications.NodeCreate, node);
var course = node.Course;
this.UpdateCourse(course.Id, course);
return node.Id;
}
示例3: Parse
public virtual void Parse(int courseId)
{
var db = this.GetDbContext();
var course = db.Courses.Single(c => c.Id == courseId);
if (!course.Locked.Value)
{
return;
}
var coursePath = this.GetCoursePath(course.Id);
var courseTempPath = this.GetCourseTempPath(course.Id);
var manifestPath = Path.Combine(courseTempPath, SCORM.ImsManifset);
Zipper.ExtractZipFile(coursePath + ".zip", courseTempPath);
var manifest = Manifest.Deserialize(manifestPath);
var importer = new Importer(manifest, course, this);
importer.Import();
// QUICK FIX for importing images
var imagesPath = Path.Combine(courseTempPath, "Node");
if (Directory.Exists(imagesPath))
{
FileHelper.DirectoryCopy(imagesPath, Path.Combine(coursePath, "Node"));
}
// QUICK FIX for "Row not found or changed." exception
db = this.GetDbContext();
course = db.Courses.Single(c => c.Id == courseId);
course.Locked = false;
var xml = new XmlSerializer(typeof(Sequencing));
// try to apply sequencing from imported course
try
{
var sequencing = manifest.SequencingCollection.Sequencings[0];
course.Sequencing = xml.SerializeToXElemet(sequencing);
}
catch (Exception) // apply default sequencing if any errors occured
{
var sequencing = new Sequencing();
sequencing = SequencingPatternManager.ApplyDefaultChapterSequencing(sequencing);
course.Sequencing = xml.SerializeToXElemet(sequencing);
}
db.SubmitChanges();
}