Skip to content

Commit

Permalink
XamlLoader is now public-facing
Browse files Browse the repository at this point in the history
XamlLoader is public instead of internal
Added overloads to pass a TextReader instead of string
  • Loading branch information
Jonathan Peppers committed Jun 16, 2016
1 parent 8d11b1d commit b0cc6ce
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Xamarin.Forms.Xaml/XamlLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

namespace Xamarin.Forms.Xaml
{
internal static class XamlLoader
public static class XamlLoader
{
static readonly Dictionary<Type, string> XamlResources = new Dictionary<Type, string>();

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

public static void Load(BindableObject view, string xaml)
{
using (var reader = XmlReader.Create(new StringReader(xaml)))
Load(view, new StringReader(xaml));
}

public static void Load(BindableObject view, TextReader textReader)
{
using (var reader = XmlReader.Create(textReader))
{
while (reader.Read())
{
Expand All @@ -71,9 +76,14 @@ public static void Load(BindableObject view, string xaml)
}

public static object Create (string xaml, bool doNotThrow = false)
{
return Create (new StringReader(xaml), doNotThrow);
}

public static object Create (TextReader textReader, bool doNotThrow = false)
{
object inflatedView = null;
using (var reader = XmlReader.Create (new StringReader (xaml))) {
using (var reader = XmlReader.Create (textReader)) {
while (reader.Read ()) {
//Skip until element
if (reader.NodeType == XmlNodeType.Whitespace)
Expand Down Expand Up @@ -225,7 +235,7 @@ static string ReadResourceAsXaml(Type type, Assembly assembly, string likelyTarg
return null;
}

public class RuntimeRootNode : RootNode
internal class RuntimeRootNode : RootNode
{
public RuntimeRootNode(XmlType xmlType, object root, IXmlNamespaceResolver resolver) : base (xmlType, resolver)
{
Expand Down

0 comments on commit b0cc6ce

Please sign in to comment.