Skip to content

Commit b0cc6ce

Browse files
author
Jonathan Peppers
committed
XamlLoader is now public-facing
XamlLoader is public instead of internal Added overloads to pass a TextReader instead of string
1 parent 8d11b1d commit b0cc6ce

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Xamarin.Forms.Xaml/XamlLoader.cs

+14-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
namespace Xamarin.Forms.Xaml
3737
{
38-
internal static class XamlLoader
38+
public static class XamlLoader
3939
{
4040
static readonly Dictionary<Type, string> XamlResources = new Dictionary<Type, string>();
4141

@@ -49,7 +49,12 @@ public static void Load(BindableObject view, Type callingType)
4949

5050
public static void Load(BindableObject view, string xaml)
5151
{
52-
using (var reader = XmlReader.Create(new StringReader(xaml)))
52+
Load(view, new StringReader(xaml));
53+
}
54+
55+
public static void Load(BindableObject view, TextReader textReader)
56+
{
57+
using (var reader = XmlReader.Create(textReader))
5358
{
5459
while (reader.Read())
5560
{
@@ -71,9 +76,14 @@ public static void Load(BindableObject view, string xaml)
7176
}
7277

7378
public static object Create (string xaml, bool doNotThrow = false)
79+
{
80+
return Create (new StringReader(xaml), doNotThrow);
81+
}
82+
83+
public static object Create (TextReader textReader, bool doNotThrow = false)
7484
{
7585
object inflatedView = null;
76-
using (var reader = XmlReader.Create (new StringReader (xaml))) {
86+
using (var reader = XmlReader.Create (textReader)) {
7787
while (reader.Read ()) {
7888
//Skip until element
7989
if (reader.NodeType == XmlNodeType.Whitespace)
@@ -225,7 +235,7 @@ static string ReadResourceAsXaml(Type type, Assembly assembly, string likelyTarg
225235
return null;
226236
}
227237

228-
public class RuntimeRootNode : RootNode
238+
internal class RuntimeRootNode : RootNode
229239
{
230240
public RuntimeRootNode(XmlType xmlType, object root, IXmlNamespaceResolver resolver) : base (xmlType, resolver)
231241
{

0 commit comments

Comments
 (0)