コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();

            ServiceReference1.IService1 test = new ServiceReference1.Service1Client();
            MethodInfo[] methods             = typeof(ServiceReference1.IService1).GetMethods();

            foreach (var m in methods)
            {
                //Console.WriteLine(m.Name);
                MethodesListBox.Items.Add(m.Name);

                ParameterInfo[] listParam = m.GetParameters();
                foreach (var p in listParam)
                {
                    //Dynamique pour créer Label et TextBox
                    //LabelTestParam.Content = LabelTestParam.Content.ToString() + p;
                }
                //GetData
                //GetDataAsync
                //GetDataUsingDataContract
                //GetDataUsingDataContractAsync
            }

            var result    = methods.Where(m => !m.Name.EndsWith("Async"));
            var maMethode = result.First();

            ParameterInfo[] param = maMethode.GetParameters();
            foreach (var p in param)
            {
                //Console.WriteLine(p);
            }
            object[] ob = new object[] { 5 };
            //pi.
            //String paramTest = "test";
            object objet = maMethode.Invoke(test, ob);



            //MethodInfo[] methodsOK = { };
            //foreach (var m in methods)
            //{
            //    string nom = m.Name;
            //    if(nom.Contains("Async"))
            //    {
            //        //oui
            //    } else
            //    {
            //        //non
            //        methodsOK[] = m;
            //    }
            //}



            using (var svc = new ServiceReference1.Service1Client())
            {
                LabelResult.Content = svc.GetData(2);
                //svc.GetDataUsingDataContract();
                //svc.GetDataUsingDataContractAsync(null);
            }
        }