本文整理汇总了C#中SerializableDictionary.ReadXml方法的典型用法代码示例。如果您正苦于以下问题:C# SerializableDictionary.ReadXml方法的具体用法?C# SerializableDictionary.ReadXml怎么用?C# SerializableDictionary.ReadXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializableDictionary
的用法示例。
在下文中一共展示了SerializableDictionary.ReadXml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertFromStorageType
public override object ConvertFromStorageType(object value)
{
var masterModel = ModelDifferenceModule.MasterModel;
var layer = masterModel.CreatorInstance.CreateModelApplication();
if (!(string.IsNullOrEmpty(value as string)))
{
masterModel.AddLayerBeforeLast(layer);
var serializableDictionary = new SerializableDictionary<string, string>();
var xmlReader = XmlReader.Create(new StringReader((string)value), new XmlReaderSettings { ConformanceLevel = ConformanceLevel.Auto });
serializableDictionary.ReadXml(xmlReader);
var aspects = serializableDictionary["aspects"].Split(',').ToList();
var defaultAspect = serializableDictionary["DefaultAspect"];
defaultAspect = GetDefaultAspectFromVersion9(serializableDictionary, aspects, defaultAspect);
if (!string.IsNullOrEmpty(defaultAspect))
new ModelXmlReader().ReadFromString(layer, String.Empty, defaultAspect);
foreach (var aspect in aspects.Where(aspect => !string.IsNullOrEmpty(aspect) && !string.IsNullOrEmpty(serializableDictionary[aspect]))){
new ModelXmlReader().ReadFromString(layer, aspect, serializableDictionary[aspect]);
}
}
return layer;
}
示例2: UpdateDatabaseBeforeUpdateSchema
public override void UpdateDatabaseBeforeUpdateSchema() {
base.UpdateDatabaseBeforeUpdateSchema();
if (CurrentDBVersion > new Version(0, 0, 0, 0) && CurrentDBVersion <= new Version(10, 1, 6)) {
var differenceObjects = new Dictionary<object, string>();
using (var reader = ExecuteReader("select [Oid], [Model] from [ModelDifferenceObject] where [Model] is not null", false)) {
while (reader.Read()) {
differenceObjects.Add(reader[0], reader[1] as string);
}
}
using (var uow = new UnitOfWork(((ObjectSpace)ObjectSpace).Session.DataLayer)) {
foreach (var differenceObject in differenceObjects) {
var modelDifferenceObject = uow.GetObjectByKey<ModelDifferenceObject>(differenceObject.Key);
var serializableDictionary = new SerializableDictionary<string, string>();
var xmlReader = XmlReader.Create(new StringReader(differenceObject.Value), new XmlReaderSettings { ConformanceLevel = ConformanceLevel.Auto });
serializableDictionary.ReadXml(xmlReader);
var aspects = serializableDictionary["aspects"].Split(',').ToList();
var defaultAspect = serializableDictionary["DefaultAspect"];
defaultAspect = GetDefaultAspectFromVersion9(serializableDictionary, aspects, defaultAspect);
if (!string.IsNullOrEmpty(defaultAspect))
modelDifferenceObject.AspectObjects.Add(new AspectObject(uow) { Name = CaptionHelper.DefaultLanguage, Xml = defaultAspect });
foreach (var aspect in aspects.Where(aspect => !string.IsNullOrEmpty(aspect) && !string.IsNullOrEmpty(serializableDictionary[aspect]))) {
modelDifferenceObject.AspectObjects.Add(new AspectObject(uow) { Name = aspect, Xml = serializableDictionary[aspect] });
}
}
uow.CommitChanges();
}
}
}
示例3: ConvertFromStorageType
public override object ConvertFromStorageType(object value){
if (!(string.IsNullOrEmpty(value as string)))
{
var settings = new XmlReaderSettings{ConformanceLevel = ConformanceLevel.Auto};
var reader = XmlReader.Create(new StringReader((string) value), settings);
var serializableDictionary = new SerializableDictionary<string, string>();
serializableDictionary.ReadXml(reader);
var schema = new Schema(new DictionaryXmlReader().ReadFromString(serializableDictionary["Schema"].Replace(":","")));
var commonSchema = Schema.GetCommonSchema();
commonSchema.CombineWith(schema);
var helper = new DictionaryHelper();
var aspects = serializableDictionary["aspects"].Split(',').ToList();
string aspectFromXml = helper.GetAspectFromXml(aspects, serializableDictionary["DefaultAspect"]);
var dictionary = new Dictionary(new DictionaryXmlReader().ReadFromString(aspectFromXml), commonSchema);
foreach (var aspectValue in aspects.Where(s => !string.IsNullOrEmpty(s))){
string xml = serializableDictionary[aspectValue];
if (!(string.IsNullOrEmpty(xml)))
dictionary.AddAspect(aspectValue, new DictionaryXmlReader().ReadFromString(xml));
}
return dictionary;
}
return null;
}