本文整理汇总了C#中SerializableDictionary.WriteXml方法的典型用法代码示例。如果您正苦于以下问题:C# SerializableDictionary.WriteXml方法的具体用法?C# SerializableDictionary.WriteXml怎么用?C# SerializableDictionary.WriteXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializableDictionary
的用法示例。
在下文中一共展示了SerializableDictionary.WriteXml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToStorageType
public override object ConvertToStorageType(object value)
{
var model = value as ModelApplicationBase;
if (model != null)
{
var writer = new ModelXmlWriter();
var serializableDictionary = new SerializableDictionary<string, string>();
serializableDictionary["aspects"] = string.Empty;
for (int i = 0; i < model.AspectCount; ++i)
{
var aspect = model.GetAspect(i);
if (string.IsNullOrEmpty(aspect) || aspect == CaptionHelper.DefaultLanguage){
serializableDictionary["DefaultAspect"] = writer.WriteToString(model, i);
}
else{
serializableDictionary["aspects"] += aspect + ",";
serializableDictionary[aspect] = writer.WriteToString(model, i);
}
}
serializableDictionary["aspects"] = serializableDictionary["aspects"].TrimEnd(',');
var stringWriter = new StringWriter();
serializableDictionary.WriteXml(new XmlTextWriter(stringWriter));
return stringWriter.GetStringBuilder().ToString();
}
return null;
}
示例2: ConvertToStorageType
public override object ConvertToStorageType(object value){
var dictionary = value as Dictionary;
if (dictionary != null){
string fullXml = new DictionaryXmlWriterEx().GetFullXml(dictionary.RootNode);
var schemaXml = dictionary.Schema.RootNode.ToXml().Replace(@" IsNewNode="":True""","");
var serializableDictionary = new SerializableDictionary<string, string>{
{"Schema", schemaXml},
{"DefaultAspect", fullXml}
};
serializableDictionary["aspects"] = "";
foreach (var aspect in dictionary.Aspects.Where(s1 => s1!=DictionaryAttribute.DefaultLanguage)){
serializableDictionary["aspects"] += aspect + ",";
serializableDictionary[aspect] = new DictionaryXmlWriter().GetAspectXml(dictionary.GetAspectIndex(aspect), dictionary.RootNode);
}
serializableDictionary["aspects"] = serializableDictionary["aspects"].TrimEnd(',');
var stringWriter = new StringWriter();
var writer = new XmlTextWriter(stringWriter);
serializableDictionary.WriteXml(writer);
var s = stringWriter.GetStringBuilder().ToString();
return s;
}
return null;
}