summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-11-15 20:39:48 +0100
committerJason Smith <jason.smith@xamarin.com>2016-11-15 11:39:48 -0800
commita6bbed029c64d2d64b74eeb67e27a099abf70664 (patch)
tree551c3924c055e2d39592b3f1c726cca46924dd73 /Xamarin.Forms.Xaml
parent14e21dcebd4a706aaa5eed384b142957d84df002 (diff)
downloadxamarin-forms-a6bbed029c64d2d64b74eeb67e27a099abf70664.tar.gz
xamarin-forms-a6bbed029c64d2d64b74eeb67e27a099abf70664.tar.bz2
xamarin-forms-a6bbed029c64d2d64b74eeb67e27a099abf70664.zip
[XamlC] TypedBindings, some tests, a compiler, ... (#489)
Diffstat (limited to 'Xamarin.Forms.Xaml')
-rw-r--r--Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs3
-rw-r--r--Xamarin.Forms.Xaml/ExpandMarkupsVisitor.cs3
-rw-r--r--Xamarin.Forms.Xaml/MarkupExtensions/BindingExtension.cs14
-rw-r--r--Xamarin.Forms.Xaml/XamlCompilationAttribute.cs2
-rw-r--r--Xamarin.Forms.Xaml/XamlNode.cs5
-rw-r--r--Xamarin.Forms.Xaml/XamlParser.cs71
-rw-r--r--Xamarin.Forms.Xaml/XmlName.cs1
7 files changed, 57 insertions, 42 deletions
diff --git a/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs b/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
index 36f5b7fd..154ba023 100644
--- a/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
+++ b/Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs
@@ -19,7 +19,8 @@ namespace Xamarin.Forms.Xaml
XmlName.xTypeArguments,
XmlName.xArguments,
XmlName.xFactoryMethod,
- XmlName.xName
+ XmlName.xName,
+ XmlName.xDataType
};
public ApplyPropertiesVisitor(HydratationContext context, bool stopOnResourceDictionary = false)
diff --git a/Xamarin.Forms.Xaml/ExpandMarkupsVisitor.cs b/Xamarin.Forms.Xaml/ExpandMarkupsVisitor.cs
index 36e8fc17..81893506 100644
--- a/Xamarin.Forms.Xaml/ExpandMarkupsVisitor.cs
+++ b/Xamarin.Forms.Xaml/ExpandMarkupsVisitor.cs
@@ -17,7 +17,8 @@ namespace Xamarin.Forms.Xaml
XmlName.xKey,
XmlName.xTypeArguments,
XmlName.xFactoryMethod,
- XmlName.xName
+ XmlName.xName,
+ XmlName.xDataType
};
Dictionary<INode, object> Values
diff --git a/Xamarin.Forms.Xaml/MarkupExtensions/BindingExtension.cs b/Xamarin.Forms.Xaml/MarkupExtensions/BindingExtension.cs
index 5b519e62..df82771d 100644
--- a/Xamarin.Forms.Xaml/MarkupExtensions/BindingExtension.cs
+++ b/Xamarin.Forms.Xaml/MarkupExtensions/BindingExtension.cs
@@ -1,4 +1,5 @@
using System;
+using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Xaml
{
@@ -25,9 +26,20 @@ namespace Xamarin.Forms.Xaml
public string UpdateSourceEventName { get; set; }
+ public TypedBindingBase TypedBinding { get; set; }
+
BindingBase IMarkupExtension<BindingBase>.ProvideValue(IServiceProvider serviceProvider)
{
- return new Binding(Path, Mode, Converter, ConverterParameter, StringFormat, Source) { UpdateSourceEventName = UpdateSourceEventName };
+ if (TypedBinding == null)
+ return new Binding(Path, Mode, Converter, ConverterParameter, StringFormat, Source) { UpdateSourceEventName = UpdateSourceEventName };
+
+ TypedBinding.Mode = Mode;
+ TypedBinding.Converter = Converter;
+ TypedBinding.ConverterParameter = ConverterParameter;
+ TypedBinding.StringFormat = StringFormat;
+ TypedBinding.Source = Source;
+ TypedBinding.UpdateSourceEventName = UpdateSourceEventName;
+ return TypedBinding;
}
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
diff --git a/Xamarin.Forms.Xaml/XamlCompilationAttribute.cs b/Xamarin.Forms.Xaml/XamlCompilationAttribute.cs
index 76199039..79cc87bd 100644
--- a/Xamarin.Forms.Xaml/XamlCompilationAttribute.cs
+++ b/Xamarin.Forms.Xaml/XamlCompilationAttribute.cs
@@ -21,7 +21,7 @@ namespace Xamarin.Forms.Xaml
public XamlCompilationOptions XamlCompilationOptions { get; set; }
}
- internal static class XamlCExtensions
+ static class XamlCExtensions
{
public static bool IsCompiled(this Type type)
{
diff --git a/Xamarin.Forms.Xaml/XamlNode.cs b/Xamarin.Forms.Xaml/XamlNode.cs
index a19e7d5c..752f3845 100644
--- a/Xamarin.Forms.Xaml/XamlNode.cs
+++ b/Xamarin.Forms.Xaml/XamlNode.cs
@@ -42,7 +42,7 @@ namespace Xamarin.Forms.Xaml
}
[DebuggerDisplay("{NamespaceUri}:{Name}")]
- internal class XmlType
+ class XmlType
{
public XmlType(string namespaceUri, string name, IList<XmlType> typeArguments)
{
@@ -53,8 +53,7 @@ namespace Xamarin.Forms.Xaml
public string NamespaceUri { get; }
public string Name { get; }
- public IList<XmlType> TypeArguments { get; private set; }
-
+ public IList<XmlType> TypeArguments { get; }
}
internal abstract class BaseNode : IXmlLineInfo, INode
diff --git a/Xamarin.Forms.Xaml/XamlParser.cs b/Xamarin.Forms.Xaml/XamlParser.cs
index 60424754..f2ac3197 100644
--- a/Xamarin.Forms.Xaml/XamlParser.cs
+++ b/Xamarin.Forms.Xaml/XamlParser.cs
@@ -197,47 +197,48 @@ namespace Xamarin.Forms.Xaml
if (reader.NamespaceURI == "http://schemas.microsoft.com/winfx/2006/xaml")
{
- switch (reader.Name)
- {
- case "x:Key":
- propertyName = XmlName.xKey;
- break;
- case "x:Name":
- propertyName = XmlName.xName;
- break;
- case "x:Class":
- continue;
- default:
- Debug.WriteLine("Unhandled {0}", reader.Name);
- continue;
+ switch (reader.Name) {
+ case "x:Key":
+ propertyName = XmlName.xKey;
+ break;
+ case "x:Name":
+ propertyName = XmlName.xName;
+ break;
+ case "x:Class":
+ continue;
+ default:
+ Debug.WriteLine("Unhandled attribute {0}", reader.Name);
+ continue;
}
}
if (reader.NamespaceURI == "http://schemas.microsoft.com/winfx/2009/xaml")
{
- switch (reader.Name)
- {
- case "x:Key":
- propertyName = XmlName.xKey;
- break;
- case "x:Name":
- propertyName = XmlName.xName;
- break;
- case "x:TypeArguments":
- propertyName = XmlName.xTypeArguments;
- value = TypeArgumentsParser.ParseExpression((string)value, (IXmlNamespaceResolver)reader, (IXmlLineInfo)reader);
- break;
- case "x:Class":
- continue;
- case "x:FactoryMethod":
- propertyName = XmlName.xFactoryMethod;
- break;
- case "x:Arguments":
- propertyName = XmlName.xArguments;
+ switch (reader.Name) {
+ case "x:Key":
+ propertyName = XmlName.xKey;
+ break;
+ case "x:Name":
+ propertyName = XmlName.xName;
break;
- default:
- Debug.WriteLine("Unhandled {0}", reader.Name);
- continue;
+ case "x:TypeArguments":
+ propertyName = XmlName.xTypeArguments;
+ value = TypeArgumentsParser.ParseExpression((string)value, (IXmlNamespaceResolver)reader, (IXmlLineInfo)reader);
+ break;
+ case "x:DataType":
+ propertyName = XmlName.xDataType;
+ break;
+ case "x:Class":
+ continue;
+ case "x:FactoryMethod":
+ propertyName = XmlName.xFactoryMethod;
+ break;
+ case "x:Arguments":
+ propertyName = XmlName.xArguments;
+ break;
+ default:
+ Debug.WriteLine("Unhandled attribute {0}", reader.Name);
+ continue;
}
}
diff --git a/Xamarin.Forms.Xaml/XmlName.cs b/Xamarin.Forms.Xaml/XmlName.cs
index 09cf3bca..92e1fc04 100644
--- a/Xamarin.Forms.Xaml/XmlName.cs
+++ b/Xamarin.Forms.Xaml/XmlName.cs
@@ -11,6 +11,7 @@ namespace Xamarin.Forms.Xaml
public static readonly XmlName xTypeArguments = new XmlName("x", "TypeArguments");
public static readonly XmlName xArguments = new XmlName("x", "Arguments");
public static readonly XmlName xFactoryMethod = new XmlName("x", "xFactoryMethod");
+ public static readonly XmlName xDataType = new XmlName("x", "DataType");
public static readonly XmlName Empty = new XmlName();
public string NamespaceURI { get; }