private void ParsePath(string path, out IPropertyPathNode head, out IPropertyPathNode tail) { head = null; tail = null; var parser = new PropertyPathParser(path); PropertyNodeType type; while ((type = parser.Step(out string typeName, out string propertyName, out string index)) != PropertyNodeType.None) { IPropertyPathNode node; switch (type) { case PropertyNodeType.AttachedProperty: case PropertyNodeType.Property: node = new StandardPropertyPathNode(typeName, propertyName); break; case PropertyNodeType.Indexed: node = new IndexedPropertyPathNode(index); break; default: throw new InvalidOperationException(); } if (head == null) { head = tail = node; continue; } tail.Next = node; tail = node; } }
internal PropertyPathWalker(string path, bool isDatacontextBound) { Path = path; StandardPropertyPathNode lastNode; IsDataContextBound = isDatacontextBound; if (path == null || path == ".") { //bindsDirectlyToSource set to true means that the binding is directly made to the source (--> there is no path) lastNode = new StandardPropertyPathNode(); //what to put in there ? FirstNode = lastNode; FinalNode = lastNode; } else { PropertyNodeType type; var parser = new PropertyPathParser(path); string typeName; string propertyName; int index; //IPropertyPathNode node; while ((type = parser.Step(out typeName, out propertyName, out index)) != PropertyNodeType.None) { //we make node advance (when it is not the first step, otherwise it stays at null) //node = FinalNode; //var isViewProperty = false; //boolean isViewProperty = CollectionViewProperties.Any (prop => prop.Name == propertyName); // static readonly PropertyInfo[] CollectionViewProperties = typeof (ICollectionView).GetProperties (); switch (type) { case PropertyNodeType.AttachedProperty: case PropertyNodeType.Property: if (FinalNode == null) { FinalNode = new StandardPropertyPathNode(typeName, propertyName); } else { FinalNode.Next = new StandardPropertyPathNode(typeName, propertyName); } break; case PropertyNodeType.Indexed: throw new NotImplementedException("Indexed properties are not supported yet."); //todo: when we will handle the indexed properties, uncomment the following //node.Next = new IndexedPropertyPathNode(index); break; default: break; } if (FirstNode == null) { FirstNode = FinalNode; } if (FinalNode.Next != null) { FinalNode = FinalNode.Next; } } } this.FinalNode.Listen(this); }