2009-10-22 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Thu, 22 Oct 2009 18:32:35 +0000 (18:32 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Thu, 22 Oct 2009 18:32:35 +0000 (18:32 -0000)
* WsdlBuildProvider.cs: a different way to generate code from
wsdl. Code is generated in the top-level namespace to match .NET

svn path=/trunk/mcs/; revision=144662

mcs/class/System.Web/System.Web.Compilation/ChangeLog
mcs/class/System.Web/System.Web.Compilation/WsdlBuildProvider.cs

index 239e9d344ba6a3deb5399180e82124754f5539e8..f7b36b2571eb8ebef5b69d63ee3a6d9410a4a288 100644 (file)
@@ -1,3 +1,8 @@
+2009-10-22  Marek Habersack  <mhabersack@novell.com>
+
+       * WsdlBuildProvider.cs: a different way to generate code from
+       wsdl. Code is generated in the top-level namespace to match .NET
+
 2009-10-12  Marek Habersack  <mhabersack@novell.com>
 
        * BuildManager.cs: make sure to construct correct physical path
index 0e21d0854a11e5b267b886deeb1b6d91175105b7..5938a929ba056ae8691121e841c2b74f85f448bd 100644 (file)
@@ -39,6 +39,7 @@ using System.Reflection;
 using System.Web.Configuration;
 using System.Web.UI;
 using System.Web.Services.Description;
+using System.Web.Services.Discovery;
 using System.Xml.Serialization;
 using System.Web.Util;
 
@@ -67,40 +68,25 @@ namespace System.Web.Compilation {
                {
                }
 
-               string GetNamespace ()
-               {
-                       var vp = new System.Web.VirtualPath (VirtualPath);
-                       string vpDirectory = vp.Directory;
-                       string path;
-                       
-                       if (StrUtils.StartsWith (vpDirectory, "/App_Code/"))
-                               path = vpDirectory.Substring (10);
-                       else if (StrUtils.StartsWith (vpDirectory, "/App_WebReferences/"))
-                               path = vpDirectory.Substring (19);
-                       else
-                               path = vpDirectory;
-
-                       path = path.Replace ("/", ".");
-                       if (path.EndsWith ("."))
-                               return path.Substring (0, path.Length - 1);
-
-                       return path;
-               }
-               
                public override void GenerateCode (AssemblyBuilder assemblyBuilder)
                {
                        CodeCompileUnit unit = new CodeCompileUnit ();
-                       CodeNamespace proxyCode = new CodeNamespace (GetNamespace ());
-                       unit.Namespaces.Add (proxyCode);                        
+                       CodeNamespace proxyCode = new CodeNamespace ();
+                       unit.Namespaces.Add (proxyCode);        
+
+                       var description = ServiceDescription.Read (OpenReader ());
+                       var discCollection = new DiscoveryClientDocumentCollection () {
+                                       {VirtualPath, description}
+                               };
+                       
+                       var webref = new WebReferenceCollection () {
+                                       new WebReference (discCollection, proxyCode)
+                               };
+
+                       var options = new WebReferenceOptions ();
+                       options.Style = ServiceDescriptionImportStyle.Client;
+                       ServiceDescriptionImporter.GenerateWebReferences (webref, assemblyBuilder.CodeDomProvider, unit, options);
 
-                       ServiceDescription description = ServiceDescription.Read (OpenReader ());
-                       ServiceDescriptionImporter importer = new ServiceDescriptionImporter ();
-                               
-                       importer.AddServiceDescription (description, null, null);
-                       importer.Style = ServiceDescriptionImportStyle.Client;
-                       importer.CodeGenerator = assemblyBuilder.CodeDomProvider;
-                       importer.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateNewAsync;
-                       importer.Import (proxyCode, unit);
                        assemblyBuilder.AddCodeCompileUnit (unit);
                }
        }