本文整理汇总了C#中Scope.ReadXmlString方法的典型用法代码示例。如果您正苦于以下问题:C# Scope.ReadXmlString方法的具体用法?C# Scope.ReadXmlString怎么用?C# Scope.ReadXmlString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scope
的用法示例。
在下文中一共展示了Scope.ReadXmlString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test
public void Test()
{
var scope = new Scope();
scope.Element<Custom>(new CustomSurrogate());
scope.Element<Item>()
.Elements()
.Add(x => x.Name)
.Add(x => x.Custom)
.Add(x => x.Value)
.End();
var obj = new Item
{
Name = "item",
Value = "test",
Custom = new Custom
{
InnerXml = "<test></test>"
}
};
var xml = scope.ToXmlString(obj);
var obj2 = new Item();
scope.ReadXmlString(xml, obj2);
Assert.AreEqual(obj.Name, obj2.Name);
Assert.AreEqual(obj.Value, obj2.Value);
Assert.AreEqual(obj.Custom.InnerXml, obj2.Custom.InnerXml);
}
示例2: Test
public void Test()
{
var schema = new Scope();
var entity = schema.Element<Entity>()
.Elements()
.Add(x => x.Name)
.Add(x => x.Element)
.End();
entity.Element<Element>()
.Elements()
.Add(x => x.Text)
.End();
var obj1 = new Entity
{
Name = "test",
Element = new Element {Text = "hi"}
};
var xml = schema.ToXmlString(obj1);
var obj2 = new Entity();
schema.ReadXmlString(xml, obj2);
Assert.AreEqual(obj1.Name, obj2.Name);
Assert.AreEqual(obj1.Element.Text, obj2.Element.Text);
}
示例3: SkipUnknownElement
public string SkipUnknownElement(string xml)
{
var scope = new Scope();
scope.Element<Entity>()
.Elements()
.Add(x => x.Value)
.End();
var obj = new Entity();
scope.ReadXmlString(xml, obj);
return obj.Value;
}
示例4: MultipleNamespaces
public string MultipleNamespaces(string xml)
{
var scope = new Scope("A", "B");
scope.Element<Entity>()
.Elements()
.Add(x => x.Value)
.End();
var obj = new Entity();
scope.ReadXmlString(xml, obj);
return obj.Value;
}
示例5: MultiplePropertyNames
public string MultiplePropertyNames(string xml)
{
var ns1 = XNamespace.Get("A");
var ns2 = XNamespace.Get("B");
var scope = new Scope();
scope.Element<Entity>()
.Elements()
.Add(x => x.Value, ns1 + "Value", ns2 + "Value", ns1 + "Text", ns2 + "Text")
.End();
var obj = new Entity();
scope.ReadXmlString(xml, obj);
return obj.Value;
}