<Compile Include="ExpandMarkupsVisitor.cs" />
<Compile Include="XamlCompilationAttribute.cs" />
<Compile Include="TypeArgumentsParser.cs" />
+ <Compile Include="IXamlFileProvider.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<ItemGroup>
internal static class XamlLoader
{
static readonly Dictionary<Type, string> XamlResources = new Dictionary<Type, string>();
+ internal static bool DoNotThrowOnExceptions { get; set; }
+ internal static IXamlFileProvider XamlFileProvider { get; set; }
public static void Load(object view, Type callingType)
{
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 = XamlLoader.DoNotThrowOnExceptions
+ });
break;
}
}
}
+ [Obsolete ("Use the XamlFileProvider to provide xaml files")]
public static object Create (string xaml, bool doNotThrow = false)
{
object inflatedView = null;
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 (XamlFileProvider != null && (xaml = XamlFileProvider.GetXamlFor(type)) != null)
+ return xaml;
+
var assembly = type.GetTypeInfo().Assembly;
string resourceId;
// 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))