From ab0fabac610b5c24c086c1cbf5e88b1d48511f2a Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Thu, 6 Apr 2017 23:22:50 +0200 Subject: [Xaml[C]] supports 'using:' xmlns declarations (#851) --- Xamarin.Forms.Xaml/XmlnsHelper.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Xamarin.Forms.Xaml') diff --git a/Xamarin.Forms.Xaml/XmlnsHelper.cs b/Xamarin.Forms.Xaml/XmlnsHelper.cs index e29dbc0c..5f7efd48 100644 --- a/Xamarin.Forms.Xaml/XmlnsHelper.cs +++ b/Xamarin.Forms.Xaml/XmlnsHelper.cs @@ -20,6 +20,19 @@ namespace Xamarin.Forms.Xaml { typeName = ns = asm = targetPlatform = null; + xmlns = xmlns.Trim(); + + if (xmlns.StartsWith("using:", StringComparison.Ordinal)) { + ParseUsing(xmlns, out typeName, out ns, out asm, out targetPlatform); + return; + } + ParseClrNamespace(xmlns, out typeName, out ns, out asm, out targetPlatform); + } + + static void ParseClrNamespace(string xmlns, out string typeName, out string ns, out string asm, out string targetPlatform) + { + typeName = ns = asm = targetPlatform = null; + foreach (var decl in xmlns.Split(';')) { if (decl.StartsWith("clr-namespace:", StringComparison.Ordinal)) @@ -46,5 +59,17 @@ namespace Xamarin.Forms.Xaml typeName = decl; } } + + static void ParseUsing(string xmlns, out string typeName, out string ns, out string asm, out string targetPlatform) + { + typeName = ns = asm = targetPlatform = null; + + foreach (var decl in xmlns.Split(';')) { + if (decl.StartsWith("using:", StringComparison.Ordinal)) { + ns = decl.Substring(6, decl.Length - 6); + continue; + } + } + } } } \ No newline at end of file -- cgit v1.2.3