private void btnInvoke_Click(object sender, EventArgs e) { SetControlsEnabled(false); try { IDictionary <string, ReflectionUtils.Parameter> parameters = GetParameters(); object instance = m_Operation.Contract.Proxy.CreateInstance(); object result; using (instance as IDisposable) { result = ReflectionUtils.InvokeMethod(instance, m_Operation.Method.Name, parameters); } if (result == null) { Instance returnValue = m_Operation.Method.ReturnValue; PopulateTree(new List <Member> { new Property { Definition = returnValue.Definition, Type = returnValue.Type } }, outputControl, true); } else { Class @class = ReflectionUtils.GetClassDefinition(result.GetType()); Parameter parameter; if (@class.IsClass) { parameter = new Parameter { Definition = @class, Name = "(return)", Type = @class.Type }; } else { parameter = new Parameter { Name = "(return)", Type = @class.Type }; } List <MemberInfo> memberInfos = new List <MemberInfo> { new MemberInfo { Member = parameter, Value = result } }; PopulateTree(memberInfos, outputControl, true); } } catch (Exception exception) { ShowErrorForm.ShowDialog(ParentForm, exception); } SetControlsEnabled(true); }
private void btnOk_Click(object sender, EventArgs e) { try { ServiceClientProxyFactoryGenerator proxyFactoryGenerator = new ServiceClientProxyFactoryGenerator(new ServiceMetadataDownloader(), new ServiceMetadataImporter(new CSharpCodeDomProviderFactory()), new ServiceClientProxyCompiler()); ServiceClientProxyFactory proxyFactory = proxyFactoryGenerator.GenerateProxyFactory(Wsdl); List <ServiceInfo> serviceInfos = new List <ServiceInfo>(); ServiceInfo serviceInfo = new ServiceInfo { Wsdl = Wsdl, Config = proxyFactory.Config }; for (int index = 0; index < proxyFactory.Contracts.Count; index++) { ContractDescription contractDescription = proxyFactory.Contracts[index]; string contractName = contractDescription.Name; ServiceClientProxy proxy = proxyFactory.CreateProxy(contractName, contractDescription.Namespace); string[] operationNames = contractDescription.Operations.Select(x => x.Name).ToArray(); ContractInfo contractInfo = new ContractInfo { Proxy = proxy, ContractName = contractName }; for (int i = 0; i < operationNames.Length; i++) { string operationName = operationNames[i]; object instance = proxy.CreateInstance(); using (instance as IDisposable) { Method method = ReflectionUtils.GetMethodDefinition(instance, operationName); contractInfo.Operations.Add(new OperationInfo { Contract = contractInfo, Method = method }); } } serviceInfo.Contracts.Add(contractInfo); } serviceInfos.Add(serviceInfo); m_Services = serviceInfos.AsReadOnly(); } catch (Exception exception) { ShowErrorForm.ShowDialog(this, exception); } }
public static DialogResult ShowDialog(Form owner, Exception exception) { ShowErrorForm showErrorForm = new ShowErrorForm(owner, exception); return(showErrorForm.ShowDialog(owner)); }
public static DialogResult ShowDialog(Form owner, Exception exception) { ShowErrorForm showErrorForm = new ShowErrorForm(owner, exception); return showErrorForm.ShowDialog(owner); }