本文整理汇总了C#中System.Xaml.XamlObjectReader类的典型用法代码示例。如果您正苦于以下问题:C# XamlObjectReader类的具体用法?C# XamlObjectReader怎么用?C# XamlObjectReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XamlObjectReader类属于System.Xaml命名空间,在下文中一共展示了XamlObjectReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SerializeToXaml
public static string SerializeToXaml(object objectToSerialize, bool fullyQualifiedClrNamespaces = true)
{
var stringWriter = new StringWriter();
var xamlSchemaContextCWithFullyQualifiedNameSupport =
new XamlSchemaContext(new XamlSchemaContextSettings { FullyQualifyAssemblyNamesInClrNamespaces = fullyQualifiedClrNamespaces });
using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }))
using (var xamlWriter = new XamlXmlWriter(xmlWriter, xamlSchemaContextCWithFullyQualifiedNameSupport))
using (var builderWriter = ActivityXamlServices.CreateBuilderWriter(xamlWriter)) // transform to x:Class representation
using (var objectReader = new XamlObjectReader(objectToSerialize, xamlSchemaContextCWithFullyQualifiedNameSupport))
{
XamlServices.Transform(objectReader, builderWriter);
return stringWriter.ToString();
}
}
开发者ID:barbarossia,项目名称:CWF,代码行数:14,代码来源:XamlService.cs
示例2: InternalPrepareForUpdate
private static void InternalPrepareForUpdate(object definitionToBeUpdated, bool forImplementation)
{
// Clone the definition
object clone;
using (XamlObjectReader reader = new XamlObjectReader(definitionToBeUpdated))
{
using (XamlObjectWriter writer = new XamlObjectWriter(reader.SchemaContext))
{
XamlServices.Transform(reader, writer);
clone = writer.Result;
}
}
// Calculate the match info
// Set the match info as attached properties so it is serializable,
// and available when the user calls CreateUpdateMap
IDictionary<object, DynamicUpdateMapItem> mapItems;
if (!forImplementation)
{
DynamicUpdateInfo.SetOriginalDefinition(definitionToBeUpdated, (Activity)clone);
mapItems = DynamicUpdateMap.CalculateMapItems((Activity)definitionToBeUpdated);
}
else
{
DynamicUpdateInfo.SetOriginalActivityBuilder(definitionToBeUpdated, (ActivityBuilder)clone);
mapItems = DynamicUpdateMap.CalculateImplementationMapItems(GetDynamicActivity((ActivityBuilder)definitionToBeUpdated));
}
foreach (KeyValuePair<object, DynamicUpdateMapItem> objectInfo in mapItems)
{
DynamicUpdateInfo.SetMapItem(objectInfo.Key, objectInfo.Value);
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:34,代码来源:DynamicUpdateServices.cs
示例3: ReadSubtree3
public void ReadSubtree3 ()
{
var xr = new XamlObjectReader (5);
xr.Read ();
xr.Read ();
var sr = xr.ReadSubtree ();
Assert.AreEqual (XamlNodeType.None, sr.NodeType, "#1-2");
Assert.AreEqual (XamlNodeType.StartObject, xr.NodeType, "#1-3");
Assert.IsTrue (sr.Read (), "#2");
Assert.AreEqual (XamlNodeType.StartObject, sr.NodeType, "#2-2");
Assert.AreEqual (XamlNodeType.StartObject, xr.NodeType, "#2-3");
Assert.IsTrue (sr.Read (), "#3");
Assert.AreEqual (XamlNodeType.StartMember, sr.NodeType, "#3-2");
Assert.AreEqual (XamlNodeType.StartMember, xr.NodeType, "#3-3");
Assert.IsTrue (sr.Read (), "#4");
Assert.AreEqual (XamlNodeType.Value, sr.NodeType, "#4-2");
Assert.AreEqual (XamlNodeType.Value, xr.NodeType, "#4-3");
Assert.IsTrue (sr.Read (), "#5");
Assert.AreEqual (XamlNodeType.EndMember, sr.NodeType, "#5-2");
Assert.AreEqual (XamlNodeType.EndMember, xr.NodeType, "#5-3");
Assert.IsTrue (sr.Read (), "#6");
Assert.AreEqual (XamlNodeType.EndObject, sr.NodeType, "#6-2");
Assert.AreEqual (XamlNodeType.EndObject, xr.NodeType, "#6-3");
Assert.IsFalse (sr.Read (), "#7");
Assert.AreEqual (XamlNodeType.None, xr.NodeType, "#7-2");
}
开发者ID:nobled,项目名称:mono,代码行数:26,代码来源:XamlReaderTest.cs
示例4: ReadSubtree1
public void ReadSubtree1 ()
{
var xr = new XamlObjectReader (5);
var sr = xr.ReadSubtree ();
Assert.AreEqual (XamlNodeType.None, sr.NodeType, "#1-2");
Assert.AreEqual (XamlNodeType.None, xr.NodeType, "#1-3");
Assert.IsTrue (sr.Read (), "#2");
Assert.AreEqual (XamlNodeType.None, sr.NodeType, "#2-2");
Assert.AreEqual (XamlNodeType.None, xr.NodeType, "#2-3");
Assert.IsFalse (sr.Read (), "#3");
Assert.AreEqual (XamlNodeType.NamespaceDeclaration, xr.NodeType, "#3-2");
}
开发者ID:nobled,项目名称:mono,代码行数:12,代码来源:XamlReaderTest.cs
示例5: MainWindow
public MainWindow()
{
InitializeComponent();
using (var reader = new XamlXmlReader("./Button.xaml"))
using (var writer = new XamlXmlWriter(new FileStream("./Test.xaml", FileMode.Create), reader.SchemaContext))
{
while (reader.Read())
{
writer.WriteNode(reader);
}
}
using (var reader = new XamlObjectReader(new Button()))
using (var writer = new XamlObjectWriter(reader.SchemaContext))
{
while (reader.Read())
{
writer.WriteNode(reader);
}
var button = (Button)writer.Result;
}
using (var reader = new XamlXmlReader(new StringReader("<Button xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">This is a button</Button>")))
using (var writer = new XamlObjectWriter(reader.SchemaContext))
{
while (reader.Read())
{
writer.WriteNode(reader);
}
var button = (Button)writer.Result;
}
var button1 = (Button)XamlServices.Load("./Button.xaml");
var button2 = XamlServices.Load(new XamlObjectReader(new Button()));
var button3 = XamlServices.Load(new StringReader("<Button xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">This is a button</Button>"));
var button4 = XamlServices.Parse("<Button xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">This is a button</Button>");
XamlServices.Save("./Test2.xaml", new Button());
//DispatcherObject methods, hidden from intellisense via the EditorBrowsableAttribute
button1.CheckAccess();
button1.VerifyAccess();
}
开发者ID:jchristian,项目名称:wpf_experimentation,代码行数:45,代码来源:MainWindow.xaml.cs
示例6: GetService
public void GetService ()
{
var obj = new TestValueSerialized ();
var xr = new XamlObjectReader (obj);
while (!xr.IsEof)
xr.Read ();
Assert.IsNotNull (Context, "premise#1");
GetServiceCoreReader ();
Context = null;
var ctx = new XamlSchemaContext ();
var xw = new XamlObjectWriter (ctx);
var xt = ctx.GetXamlType (obj.GetType ());
xw.WriteStartObject (xt);
xw.WriteStartMember (XamlLanguage.Initialization);
xw.WriteValue ("v");
xw.WriteEndMember ();
xw.Close ();
Assert.IsNotNull (Provider, "premise#2"); // cannot get Context, it does not give IValueSerializerContext in the test.
GetServiceCoreWriter ();
}
开发者ID:nobled,项目名称:mono,代码行数:21,代码来源:ValueSerializerContextTest.cs
示例7: Read_NamedItems2
public void Read_NamedItems2 ()
{
// i1
// - i2
// -- i3
// - i4
// -- i3
var obj = new NamedItem2 ("i1");
var obj2 = new NamedItem2 ("i2");
var obj3 = new NamedItem2 ("i3");
var obj4 = new NamedItem2 ("i4");
obj.References.Add (obj2);
obj.References.Add (obj4);
obj2.References.Add (obj3);
obj4.References.Add (obj3);
var xr = new XamlObjectReader (obj);
Read_NamedItems2 (xr, true);
}
开发者ID:telurmasin,项目名称:mono,代码行数:19,代码来源:XamlObjectReaderTest.cs
示例8: Read_EventContainer
public void Read_EventContainer ()
{
var obj = new EventContainer ();
obj.Run += delegate { Console.Error.WriteLine ("done"); };
var xr = new XamlObjectReader (obj);
Read_EventContainer (xr);
}
开发者ID:telurmasin,项目名称:mono,代码行数:7,代码来源:XamlObjectReaderTest.cs
示例9: Read_NamedItems
public void Read_NamedItems ()
{
// foo
// - bar
// -- foo
// - baz
var obj = new NamedItem ("foo");
var obj2 = new NamedItem ("bar");
obj.References.Add (obj2);
obj.References.Add (new NamedItem ("baz"));
obj2.References.Add (obj);
var xr = new XamlObjectReader (obj);
Read_NamedItems (xr, true);
}
开发者ID:telurmasin,项目名称:mono,代码行数:15,代码来源:XamlObjectReaderTest.cs
示例10: Read_ArgumentAttributed
public void Read_ArgumentAttributed ()
{
var obj = new ArgumentAttributed ("foo", "bar");
var r = new XamlObjectReader (obj);
Read_ArgumentAttributed (r, obj);
}
开发者ID:telurmasin,项目名称:mono,代码行数:6,代码来源:XamlObjectReaderTest.cs
示例11: Read_TypeExtensionWrapper
public void Read_TypeExtensionWrapper ()
{
var obj = new TypeExtensionWrapper () { Param = new TypeExtension ("Foo") };
var r = new XamlObjectReader (obj);
Read_TypeExtensionWrapper (r);
}
开发者ID:telurmasin,项目名称:mono,代码行数:6,代码来源:XamlObjectReaderTest.cs
示例12: are
[Test] // List contents are (sort of) treated as top-level too, so it is not serialized as IXmlSerializable(!)
public void Read_ListXmlSerializable ()
{
var obj = new List<XmlSerializable> ();
obj.Add (new XmlSerializable ("<root/>"));
var xr = new XamlObjectReader (obj);
Read_ListXmlSerializable (xr);
}
开发者ID:telurmasin,项目名称:mono,代码行数:8,代码来源:XamlObjectReaderTest.cs
示例13: Read_CommonXamlType
// from initial to StartObject
protected void Read_CommonXamlType (XamlObjectReader r)
{
Read_CommonXamlType (r, delegate {
Assert.IsNull (r.Instance, "ct#4");
});
}
开发者ID:imphasing,项目名称:mono,代码行数:7,代码来源:XamlReaderTestBase.cs
示例14: Read_ListWrapper
public void Read_ListWrapper ()
{
var obj = new ListWrapper (new List<int> (new int [] {5, -3, 0}));
var r = new XamlObjectReader (obj);
Read_ListWrapper (r);
}
开发者ID:telurmasin,项目名称:mono,代码行数:6,代码来源:XamlObjectReaderTest.cs
示例15: Read_ListWrapper2
public void Read_ListWrapper2 () // read-write list member.
{
var obj = new ListWrapper2 (new List<int> (new int [] {5, -3, 0}));
var r = new XamlObjectReader (obj);
Read_ListWrapper2 (r);
}
开发者ID:telurmasin,项目名称:mono,代码行数:6,代码来源:XamlObjectReaderTest.cs
示例16: PositionalParameters2
public void PositionalParameters2 ()
{
var obj = new PositionalParametersWrapper ("foo", 5);
var r = new XamlObjectReader (obj);
PositionalParameters2 (r);
}
开发者ID:telurmasin,项目名称:mono,代码行数:6,代码来源:XamlObjectReaderTest.cs
示例17: ComplexPositionalParameters
public void ComplexPositionalParameters ()
{
var obj = new ComplexPositionalParameterWrapper () { Param = new ComplexPositionalParameterClass (new ComplexPositionalParameterValue () { Foo = "foo" })};
var r = new XamlObjectReader (obj);
ComplexPositionalParameters (r);
}
开发者ID:telurmasin,项目名称:mono,代码行数:6,代码来源:XamlObjectReaderTest.cs
示例18: PositionalParameters1
public void PositionalParameters1 ()
{
// Note: this can be read, but cannot be written to XML.
var obj = new PositionalParametersClass1 ("foo", 5);
var r = new XamlObjectReader (obj);
PositionalParameters1 (r);
}
开发者ID:telurmasin,项目名称:mono,代码行数:7,代码来源:XamlObjectReaderTest.cs
示例19: Read_Dictionary2
public void Read_Dictionary2 ()
{
var obj = new Dictionary<string,Type> ();
obj ["Foo"] = typeof (int);
obj ["Bar"] = typeof (Dictionary<Type,XamlType>);
var r = new XamlObjectReader (obj);
Read_Dictionary2 (r, XamlLanguage.PositionalParameters);
}
开发者ID:telurmasin,项目名称:mono,代码行数:8,代码来源:XamlObjectReaderTest.cs
示例20: Read_Dictionary
public void Read_Dictionary ()
{
var obj = new Dictionary<string,object> ();
obj ["Foo"] = 5.0;
obj ["Bar"] = -6.5;
var r = new XamlObjectReader (obj);
Read_Dictionary (r);
}
开发者ID:telurmasin,项目名称:mono,代码行数:8,代码来源:XamlObjectReaderTest.cs
注:本文中的System.Xaml.XamlObjectReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论