using System;
using System.Collections.Generic;
#if WinRT
using Windows.UI.Xaml;
#else
using System.Windows;
#endif
namespace Caliburn.Micro
{
///
/// Represents a resolver that takes a control and returns it's children
///
public class ChildResolver {
private readonly Func filter;
private readonly Func> resolver;
///
/// Creates the ChildResolver using the given anonymous methods.
///
/// The filter
/// The resolver
public ChildResolver(Func filter, Func> resolver) {
this.filter = filter;
this.resolver = resolver;
}
///
/// Can this resolve appy to the given type.
///
/// The visual tree type.
/// Returns true if this resolver applies.
public bool CanResolve(Type type) {
return filter(type);
}
///
/// The element from the visual tree for the children to resolve.
///
///
///
public IEnumerable Resolve(DependencyObject obj) {
return resolver(obj);
}
}
///
/// Generic strongly typed child resolver
///
/// The type to filter on
public class ChildResolver : ChildResolver where T : DependencyObject {
///
/// Creates a
///
///
public ChildResolver(Func> resolver) : base(
t => typeof(T).IsAssignableFrom(t),
o => resolver((T)o)){
}
}
}