Esempio n. 1
0
        public IndexPropertyObserver(Type propertyContainingType, IndexPropertyPathElement propertyPathElement, XamlNamespaces namespaces)
        {
            baseObserver = CreateBaseObserver(propertyContainingType, propertyPathElement.PropertyName);

            PropertyInfo indexPropertyInfo = baseObserver != null?baseObserver.ValueType.GetDefaultIndexProperty() :
                                                 propertyPathElement.PropertyName.IsEmpty ? propertyContainingType.GetDefaultIndexProperty() : propertyContainingType.GetInstanceProperty(propertyPathElement.PropertyName.MemberName);

            if (indexPropertyInfo == null)
            {
                throw new Granular.Exception("Property \"{0}.{1}\" does not have an indexer", propertyContainingType.Name, propertyPathElement.PropertyName.MemberName);
            }

            if (indexPropertyInfo.GetIndexParameters().Count() != propertyPathElement.IndexRawValues.Count())
            {
                throw new Granular.Exception("Invalid number of index parameters for \"{0}.{1}\"", indexPropertyInfo.DeclaringType.Name, indexPropertyInfo.Name);
            }

            indexerObserver = new ClrPropertyObserver(indexPropertyInfo, propertyPathElement.ParseIndexValues(indexPropertyInfo));
            indexerObserver.ValueChanged += (sender, oldValue, newValue) => ValueChanged.Raise(this, oldValue, newValue);

            if (baseObserver != null)
            {
                baseObserver.ValueChanged += (sender, oldValue, newValue) => indexerObserver.SetBaseValue(baseObserver.Value);
                indexerObserver.SetBaseValue(baseObserver.Value);
            }
        }
Esempio n. 2
0
 public object ConvertFrom(XamlNamespaces namespaces, Uri sourceUri, object value)
 {
     return(Size.Parse(value.ToString().Trim()));
 }
Esempio n. 3
0
 public object ConvertFrom(XamlNamespaces namespaces, Uri sourceUri, object value)
 {
     return(new MatrixTransform {
         Matrix = Matrix.Parse(value.ToString())
     });
 }
Esempio n. 4
0
 public object ConvertFrom(XamlNamespaces namespaces, object value)
 {
     return(new PropertyPathElement(XamlName.FromPrefixedName((string)value, namespaces)));
 }
Esempio n. 5
0
 public object ConvertFrom(XamlNamespaces namespaces, object value)
 {
     return(PropertyPath.Parse((string)value, namespaces));
 }
Esempio n. 6
0
        public static PropertyPath Parse(string value, XamlNamespaces namespaces = null)
        {
            PropertyPathParser parser = new PropertyPathParser(value, namespaces ?? XamlNamespaces.Empty);

            return(new PropertyPath(parser.Parse()));
        }
Esempio n. 7
0
 public IndexPropertyPathElement(XamlName propertyName, IEnumerable <string> indexRawValues, XamlNamespaces namespaces)
 {
     this.PropertyName   = propertyName;
     this.IndexRawValues = indexRawValues;
     this.namespaces     = namespaces;
 }