/// <summary> /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> method. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that can be used to gain additional context information.</param> /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> that this editor can use to obtain services.</param> /// <param name="value">The object to edit.</param> /// <returns> /// The new value of the object. If the value of the object has not changed, this should return the same object it was passed. /// </returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { object svc = provider.GetService(typeof(IWindowsFormsEditorService)); if (svc == null) { return(base.EditValue(context, provider, value)); } string serviceURL; int num1; IVsAddWebReferenceDlg dlg1 = provider.GetService (typeof(IVsAddWebReferenceDlg)) as IVsAddWebReferenceDlg; if (((dlg1 != null) && ErrorHandler.Succeeded(dlg1.AddWebReferenceDlg (out serviceURL, out num1))) && (num1 == 0)) { return(serviceURL); } else { if (value != null) { return(value.ToString()); } else { return(string.Empty); } } }
/// <summary> /// Execute the command /// </summary> public void Exec() { ILogger logger = ServiceLocator.Instance.GetService <ILogger>(); try { IVsAddWebReferenceDlg dlg = (IVsAddWebReferenceDlg)_serviceProvider.GetService(typeof(SVsAddWebReferenceDlg)); if (dlg == null) { return; } int pfCanceled; string wsdlAddress; if (dlg.AddWebReferenceDlg(out wsdlAddress, out pfCanceled) != Microsoft.VisualStudio.VSConstants.S_OK || pfCanceled != 0) { return; } if (String.IsNullOrEmpty(wsdlAddress)) { return; } if (_component == null) { CreateComponent(); } using (Transaction transaction = _model.Store.TransactionManager.BeginTransaction("Import wsdl")) { _model.BaseAddress = wsdlAddress; //if (wsdlAddress.EndsWith("?wsdl", StringComparison.CurrentCultureIgnoreCase)) // model.BaseAddress = wsdlAddress.Substring(0, wsdlAddress.Length - 5); ServiceDescriptionImporter sdi = new ServiceDescriptionImporter(); _codeNamespace = new CodeNamespace(_component.Namespace); CheckForImports(wsdlAddress, sdi); sdi.Import(_codeNamespace, null); if (sdi.ServiceDescriptions.Count > 0) { _model.Comment = sdi.ServiceDescriptions[0].Documentation; } InterfaceLayer iLayer = EnsureInterfaceLayer(); EnsureDefaultPackage(); foreach (CodeTypeDeclaration ctDecl in _codeNamespace.Types) { if (ctDecl.IsClass && ctDecl.BaseTypes.Count > 0) { if (ctDecl.BaseTypes[0].BaseType == "System.Web.Services.Protocols.SoapHttpClientProtocol") { ServiceContract contract = new ServiceContract(_component.Store); contract.Name = ctDecl.Name; iLayer.ServiceContracts.Add(contract); foreach (CodeMemberMethod method in ctDecl.Members) { if (method.ReturnType.BaseType == "System.IAsyncResult" || method.Name == ".ctor") { continue; } bool ignore = false; foreach (CodeParameterDeclarationExpression parm in method.Parameters) { if (parm.Type.BaseType == "System.IAsyncResult") { ignore = true; break; } } if (ignore) { continue; } Operation op = new Operation(_component.Store); contract.Operations.Add(op); op.Name = method.Name; op.Type = ValidateType(op, method.ReturnType); foreach (CodeParameterDeclarationExpression parm in method.Parameters) { Argument arg = new Argument(_component.Store); op.Arguments.Add(arg); arg.Name = parm.Name; arg.Type = ValidateType(arg, parm.Type); switch (parm.Direction) { case FieldDirection.In: arg.Direction = ArgumentDirection.In; break; case FieldDirection.Out: arg.Direction = ArgumentDirection.Out; break; case FieldDirection.Ref: arg.Direction = ArgumentDirection.InOut; break; } } } } } else if (ctDecl.IsClass) { Entity entity = new Entity(_component.Store); entity.Name = ctDecl.Name; Package package = EnsureDefaultPackage(); package.Types.Add(entity); foreach (CodeMemberField member in ctDecl.Members) { Property p = new Property(_component.Store); entity.Properties.Add(p); p.Name = member.Name; p.Type = ValidateType(p, member.Type); } } else if (ctDecl.IsEnum) { Enumeration e = new Enumeration(_component.Store); e.Name = ctDecl.Name; Package package = EnsureDefaultPackage(); package.Types.Add(e); foreach (CodeTypeMember member in ctDecl.Members) { EnumValue p = new EnumValue(_component.Store); p.Type = "System.Int32"; e.Values.Add(p); p.Name = member.Name; } } } transaction.Commit(); } if (_nodeShape != null) { using (Transaction transaction = _component.Store.TransactionManager.BeginTransaction("Arrange shapes")) { _nodeShape.ArrangeShapes(); transaction.Commit(); } } } catch (Exception ex) { if (logger != null) { logger.WriteError("Import WSDL", "Import Canceled", ex); } } }