Example #1
0
 // Gets the value at the given property path segment
 private object _getSegmentValue(BplObject source, BplPropertyPath.PathSegment segment) {
    if (source != null) {
       var property = source.Class.GetProperty(segment.Name);
       if (property != null) {
          var value = property.GetValue(source);
          if (segment.IsA<BplPropertyPath.SingleItemSegment>()) {
             return value;
          } else {
             var collection = value as IBplCollection;
             if (collection != null) {
                if (segment.IsA<BplPropertyPath.CollectionSegment>()) {
                   return collection;
                } else if (segment.IsA<BplPropertyPath.IndexedItemSegment>()) {
                   var index = ((BplPropertyPath.IndexedItemSegment)segment).Index;
                   if (index >= 0 && index < collection.Count) {
                      return collection[index];
                   }
                } else if (segment.IsA<BplPropertyPath.CurrentItemSegment>()) {
                   var collectionView = CollectionViewSource.GetDefaultView(collection);
                   if (collectionView != null) {
                      return collectionView.CurrentItem;
                   }
                }
             }
          }
       }
    }
    return DependencyProperty.UnsetValue;
 }