summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Xaml')
-rw-r--r--Xamarin.Forms.Xaml/XamlLoader.cs22
1 files changed, 20 insertions, 2 deletions
diff --git a/Xamarin.Forms.Xaml/XamlLoader.cs b/Xamarin.Forms.Xaml/XamlLoader.cs
index 37bea4e4..40414092 100644
--- a/Xamarin.Forms.Xaml/XamlLoader.cs
+++ b/Xamarin.Forms.Xaml/XamlLoader.cs
@@ -33,6 +33,15 @@ using System.Reflection;
using System.Text.RegularExpressions;
using System.Xml;
+namespace Xamarin.Forms.Xaml.Internals
+{
+ public static class XamlLoader
+ {
+ public static Func<Type, string> XamlFileProvider { get; internal set; }
+ internal static bool DoNotThrowOnExceptions { get; set; }
+ }
+}
+
namespace Xamarin.Forms.Xaml
{
internal static class XamlLoader
@@ -64,12 +73,16 @@ namespace Xamarin.Forms.Xaml
var rootnode = new RuntimeRootNode (new XmlType (reader.NamespaceURI, reader.Name, null), view, (IXmlNamespaceResolver)reader);
XamlParser.ParseXaml (rootnode, reader);
- Visit (rootnode, new HydratationContext { RootElement = view });
+ Visit (rootnode, new HydratationContext {
+ RootElement = view,
+ DoNotThrowOnExceptions = Xamarin.Forms.Xaml.Internals.XamlLoader.DoNotThrowOnExceptions
+ });
break;
}
}
}
+ [Obsolete ("Use the XamlFileProvider to provide xaml files. We will remove this when Cycle 8 hits Stable.")]
public static object Create (string xaml, bool doNotThrow = false)
{
object inflatedView = null;
@@ -113,6 +126,12 @@ namespace Xamarin.Forms.Xaml
static string GetXamlForType(Type type)
{
+ string xaml = null;
+
+ //the Previewer might want to provide it's own xaml for this... let them do that
+ if (Xamarin.Forms.Xaml.Internals.XamlLoader.XamlFileProvider != null && (xaml = Xamarin.Forms.Xaml.Internals.XamlLoader.XamlFileProvider(type)) != null)
+ return xaml;
+
var assembly = type.GetTypeInfo().Assembly;
string resourceId;
@@ -129,7 +148,6 @@ namespace Xamarin.Forms.Xaml
// first pass, pray to find it because the user named it correctly
- string xaml = null;
foreach (var resource in resourceNames)
{
if (ResourceMatchesFilename(assembly, resource, likelyResourceName))