Import与

Export 神奇之处?

 

输出:

[Export]

public Action<Func<int,int,int>> ExecuteCommandExport

{

get { return ExecuteCommand; }

}

 

public void ExecuteCommand(Func<int, int, int> command)

{

…..

}

 

 

输入:

 

[Import]

public Action<Func<int, int, int>> ExecuteCommandImport { get; set; }

 

[Export]

public Tuple<string, ICommand> AddCommand

{

get

{

return Tuple.Create("*",

(ICommand)new ActionCommand<object>(

obj =>

ExecuteCommandImport((oldValue, newValue) => oldValue * newValue)));

}

}

 

相关文章: