summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-04-06 23:22:50 +0200
committerRui Marinho <me@ruimarinho.net>2017-04-06 22:22:50 +0100
commitab0fabac610b5c24c086c1cbf5e88b1d48511f2a (patch)
treec5715dc2432c434e8474d178f50ec398031c331e /Xamarin.Forms.Xaml
parent0ee636003b6d1083ea4caeed85ef3efbc815ed06 (diff)
downloadxamarin-forms-ab0fabac610b5c24c086c1cbf5e88b1d48511f2a.tar.gz
xamarin-forms-ab0fabac610b5c24c086c1cbf5e88b1d48511f2a.tar.bz2
xamarin-forms-ab0fabac610b5c24c086c1cbf5e88b1d48511f2a.zip
[Xaml[C]] supports 'using:' xmlns declarations (#851)
Diffstat (limited to 'Xamarin.Forms.Xaml')
-rw-r--r--Xamarin.Forms.Xaml/XmlnsHelper.cs25
1 files changed, 25 insertions, 0 deletions
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