本文整理汇总了C#中LanguageElement.ToXmlString方法的典型用法代码示例。如果您正苦于以下问题:C# LanguageElement.ToXmlString方法的具体用法?C# LanguageElement.ToXmlString怎么用?C# LanguageElement.ToXmlString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LanguageElement
的用法示例。
在下文中一共展示了LanguageElement.ToXmlString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessSubmit
protected ActionResult ProcessSubmit(LanguageEditorModel model, LanguageElement entity)
{
Mandate.ParameterNotNull(model, "model");
//bind it's data
model.BindModel(this);
// Check to see if a language already exists with the given ISO code
if (model.Id.IsNullValueOrEmpty() || model.Id.Value.ToString() != model.IsoCode)
{
if (BackOfficeRequestContext.Application.Settings.Languages.Any(x => x.IsoCode == model.IsoCode))
{
ModelState.AddModelError("DuplicateLanguage", "A language with the ISO code '" + model.IsoCode + "' already exists.");
}
}
//if there's model errors, return the view
if (!ModelState.IsValid)
{
AddValidationErrorsNotification();
return View("Edit", model);
}
// Map the language
if (entity == null)
{
entity = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map<LanguageEditorModel, LanguageElement>(model);
}
else
{
//map to existing entity
BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map(model, entity);
}
// Persist the entity
var configFile = Path.Combine(HttpContext.Server.MapPath("~/App_Data/Rebel/Config"), "rebel.cms.languages.config");
var configXml = XDocument.Load(configFile);
// Remove previous entry
configXml.Descendants("language").Where(x => x.Attribute("isoCode").Value == model.Id.Value.ToString()).Remove();
// Add new entry
configXml.Element("languages").Add(XElement.Parse(entity.ToXmlString()));
//TODO: When updating and name changes, should we reassign any fallbacks linked to old iso code? or orphan them? Or just prevent language from being changed?
configXml.Save(configFile);
Notifications.Add(new NotificationMessage(
"Language.Save.Message".Localize(this),
"Language.Save.Title".Localize(this),
NotificationType.Success));
var id = new HiveId(entity.IsoCode);
//add path for entity for SupportsPathGeneration (tree syncing) to work,
//we need to manually contruct the path because of the static root node id.
GeneratePathsForCurrentEntity(new EntityPathCollection(id, new[]{ new EntityPath(new[]
{
new HiveId(FixedSchemaTypes.SystemRoot, null, new HiveIdValue(new Guid(CorePluginConstants.LanguageTreeRootNodeId))),
id
})
}));
return RedirectToAction("Edit", new { id });
}