public static object createAction(IServiceProvider provider, Action method) { string s = ExtensionTool.getDestinationType(provider).Name; switch (ExtensionTool.getDestinationType(provider).Name) { case "ICommand": return((object)(new RelayCommand(param => method()))); case "Delegate": return(ExtensionTool.createDelegate(ExtensionTool.getDestinationType(provider), (object sender, object args) => method())); case "EventHandler": return(ExtensionTool.createDelegate(ExtensionTool.getDestinationType(provider), (object sender, object args) => method())); case "MouseButtonEventHandler": return(ExtensionTool.createDelegate(ExtensionTool.getDestinationType(provider), (object sender, object args) => method())); case "RoutedEventHandler": return(ExtensionTool.createDelegate(ExtensionTool.getDestinationType(provider), (object sender, object args) => method())); default: return(null); } }
public override object ProvideValue(IServiceProvider provider) { var executeWithParam = ExtensionTool.actions().executeWithParam(Key); if (executeWithParam == null) { return(null); } return(ExtensionTool.createActionWithParam(provider, executeWithParam)); }
public static object createActionWithParam(IServiceProvider provider, Action <object> method) { switch (ExtensionTool.getDestinationType(provider).Name) { case "ICommand": return((object)(new RelayCommand(param => method(param)))); default: return(null); } }
public static object createEventAction(IServiceProvider provider, Action <object> method) { switch (ExtensionTool.getDestinationType(provider).Name) { case "ICommand": return(null); case "Delegate": return(ExtensionTool.createDelegate(ExtensionTool.getDestinationType(provider), (object sender, object args) => method(args))); default: return(null); } }
public override object ProvideValue(IServiceProvider provider) { Action <object> executeWithParam; if (DataModule.allMethods.ContainsKey(Key)) { executeWithParam = (Action <object>)DataModule.allMethods[Key]; } else { Debug.WriteLine("■■■未找到键:" + Key + "。已采用默认值。"); executeWithParam = null; } if (executeWithParam == null) { return(null); } return(ExtensionTool.createActionWithParam(provider, executeWithParam)); }