我正在使用XAML创建一个对象树,其中一个节点如下所示:
public class ExecuteMethod : INode
{
#region Implementation of INode
public bool Evaluate()
{
return Function != null && Function();
}
public string Name { get; set; }
private string _type;
public string Type
{
get
{
if (string.IsNullOrEmpty(_type))
{
_type = GetType().Name;
}
return _type;
}
}
#endregion
public Func<bool> Function { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的目标是使XAML和代码尽可能干净是必不可少的,现在我不是在为每个函数创建包装器属性:
public static Func<bool> Func1 { get { return Method1; } }
public static bool Method1()
{
//Do stuff here
return true; …Run Code Online (Sandbox Code Playgroud)