public void Generate(bool updateAssembly)
        {
            if (useLocalAssembly&&!updateAssembly)
            {
                if (File.Exists(GetDllOutPutPath()))
                {
                    proxyAssembly = Assembly.LoadFrom(GetDllOutPutPath().ToString());
                    CheckPoint(MessageType.Success, "Local Assembly Path:" + GetDllOutPutPath().ToString());
                    return;
                }
            }

            CheckPoint(MessageType.Begin, "Initializing");
            ServiceDescriptionCollection collection1 = new ServiceDescriptionCollection();
            XmlSchemas schemas1 = new XmlSchemas();
            StringCollection collection2 = new StringCollection();
            StringCollection collection3 = new StringCollection();
            GetPaths(collection3, collection2);
            collection1.Clear();
            schemas1.Clear();
            if ((collection3 != null) && (collection3.Count > 0))
            {
                string text1 = collection3[0];
                string text2 = Path.GetExtension(text1);
                if ((string.Compare(text2, ".exe", true) == 0) || (string.Compare(text2, ".dll", true) == 0))
                {
                    CheckPoint(MessageType.Begin, "Loading Assembly");
                    proxyAssembly = Assembly.LoadFrom(text1);

                    if (proxyAssembly != null)
                    {
                        CheckPoint(MessageType.Success, "Loaded Assembly");
                    }
                    else
                    {
                        CheckPoint(MessageType.Failure, "Failed to load Assembly");
                    }
                    return;
                }
            }
            CheckPoint(MessageType.Begin, "Generating WSDL");
            try
            {
                DiscoveryClientProtocol protocol1 = CreateDiscoveryClient();
                ProcessLocalPaths(protocol1, collection3, schemas1, collection1);
                ProcessRemoteUrls(protocol1, collection2, schemas1, collection1);
            }
            catch (Exception exception1)
            {
                CheckPoint(MessageType.Failure, exception1.ToString());
                return;
            }
            try
            {
                ICodeGenerator generator1;
                string text3;
                CheckPoint(MessageType.Begin, "Generating Proxy");
                CreateCodeGenerator(out generator1, out text3);
                XmlSchemas schemas2 = new XmlSchemas();
                schemas2.Add(schemas1);
                foreach (ServiceDescription description1 in collection1)
                {
                    schemas2.Add(description1.Types.Schemas);
                }
                Hashtable hashtable1 = new Hashtable();
                foreach (XmlSchema schema1 in schemas2)
                {
                    CollectIncludes(schema1, hashtable1);
                }
                Compile(schemas2);
                GenerateCode(collection1, schemas1, "http://tempuri.org", generator1, text3);
                CheckPoint(MessageType.Begin, "Compiling Proxy");
                //if (proxyCode.Length < 1000)
                //{
                //    CheckPoint(MessageType.Failure, "Empty Assembly");
                //    return;
                //}

                if (updateAssembly)
                {
                    GenerateAssembly(true);
                }
                else
                {
                    GenerateAssembly();
                }
                CheckPoint(MessageType.Success, "Generated Assembly");
            }
            catch (Exception exception2)
            {
                CheckPoint(MessageType.Failure, exception2.ToString());
                return;
            }
        }
Esempio n. 2
0
 public void Generate()
 {
     this.CheckPoint(MessageType.Begin, "Initializing");
     ServiceDescriptionCollection descriptions = new ServiceDescriptionCollection();
     XmlSchemas schemas = new XmlSchemas();
     StringCollection urls = new StringCollection();
     StringCollection localPaths = new StringCollection();
     this.GetPaths(localPaths, urls);
     descriptions.Clear();
     schemas.Clear();
     if ((localPaths != null) && (localPaths.Count > 0))
     {
         string path = localPaths[0];
         string extension = Path.GetExtension(path);
         if ((string.Compare(extension, ".exe", true) == 0) || (string.Compare(extension, ".dll", true) == 0))
         {
             this.CheckPoint(MessageType.Begin, "Loading Assembly");
             this.proxyAssembly = Assembly.LoadFrom(path);
             if (this.proxyAssembly != null)
             {
                 this.CheckPoint(MessageType.Success, "Loaded Assembly");
             }
             else
             {
                 this.CheckPoint(MessageType.Failure, "Failed to load Assembly");
             }
             return;
         }
     }
     this.CheckPoint(MessageType.Begin, "Generating WSDL");
     try
     {
         DiscoveryClientProtocol client = this.CreateDiscoveryClient();
         this.ProcessLocalPaths(client, localPaths, schemas, descriptions);
         this.ProcessRemoteUrls(client, urls, schemas, descriptions);
     }
     catch (Exception exception)
     {
         this.CheckPoint(MessageType.Failure, exception.ToString());
         return;
     }
     try
     {
         this.CheckPoint(MessageType.Begin, "Generating Proxy");
         this.CreateCodeGenerator();
         XmlSchemas userSchemas = new XmlSchemas();
         userSchemas.Add(schemas);
         foreach (ServiceDescription description in descriptions)
         {
             userSchemas.Add(description.Types.Schemas);
         }
         Hashtable includeSchemas = new Hashtable();
         foreach (XmlSchema schema in userSchemas)
         {
             CollectIncludes(schema, includeSchemas);
         }
         this.Compile(userSchemas);
         this.GenerateCode(descriptions, schemas, "http://tempuri.org");
         this.CheckPoint(MessageType.Begin, "Compiling Proxy");
         this.GenerateAssembly();
         this.CheckPoint(MessageType.Success, "Generated Assembly");
     }
     catch (Exception exception2)
     {
         this.CheckPoint(MessageType.Failure, exception2.ToString());
     }
 }
        public void Generate()
        {
            var descriptions = new ServiceDescriptionCollection();
            var schemas = new XmlSchemas();
            var urls = new StringCollection();
            var localPaths = new StringCollection();

            GetPaths(localPaths, urls);

            descriptions.Clear();
            schemas.Clear();

            try
            {
                var client = CreateDiscoveryClient();
                ProcessLocalPaths(client, localPaths, schemas, descriptions);
                //ProcessRemoteUrls(client, urls, schema, descriptions);
            }
            catch (Exception)
            {
                // warn of error
                return;
            }
            try
            {
                var ext = CodeProvider.FileExtension;
                var userSchemas = new XmlSchemas {schemas};
                foreach (ServiceDescription description in descriptions)
                {
                    userSchemas.Add(description.Types.Schemas);
                }
                var includeSchemas = new Hashtable();
                foreach (XmlSchema userSchema in userSchemas)
                {
                    CollectIncludes(userSchema, includeSchemas);
                }
                Compile(userSchemas);
                GenerateCode(descriptions, schemas, "http://tempuri.org", ext);
                GenerateAssembly();
            }
            catch (Exception)
            {
                return;
            }
        }