服务:
2 |
public string HelloWorld() |
silverlight中代码:
03 |
public partial class MainPage : UserControl |
07 |
InitializeComponent(); |
10 |
private void button1_Click( object sender, RoutedEventArgs e) |
12 |
CallService( "DynamicDemo.Server.RefServiceSoapClient" , "HelloWorld" , new object [] { }, new EventHandler<DynamicDemo.Server.HelloWorldCompletedEventArgs>(aa_HelloWorldCompleted)); |
15 |
void aa_HelloWorldCompleted( object sender, Server.HelloWorldCompletedEventArgs e) |
17 |
MessageBox.Show( "吹风说:" + e.Result); |
20 |
public void CallService( string classstring, string methodstring, object [] paramstring,Delegate completedel) |
22 |
Type tp = Type.GetType(classstring); |
24 |
EventInfo Event = tp.GetEvent(methodstring+ "Completed" ); |
26 |
MethodInfo method = tp.GetMethod(methodstring+ "Async" , new Type[] { }, new ParameterModifier[] { }); |
28 |
var chuifeng = tp.Assembly.CreateInstance(classstring); |
30 |
Event.AddEventHandler(chuifeng, completedel); |
32 |
method.Invoke(chuifeng, paramstring); |
Powered By D&J (URL:http://www.cnblogs.com/Areas/)