當前位置: 首頁>>代碼示例>>C#>>正文


C# ServiceDescription.Write方法代碼示例

本文整理匯總了C#中System.Web.Services.Description.ServiceDescription.Write方法的典型用法代碼示例。如果您正苦於以下問題:C# ServiceDescription.Write方法的具體用法?C# ServiceDescription.Write怎麽用?C# ServiceDescription.Write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.Services.Description.ServiceDescription的用法示例。


在下文中一共展示了ServiceDescription.Write方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Convert

        public ServiceDescription Convert(XmlDocument wsdl2Xml)
        {
            CannonizePrefix(wsdl2Xml);
            var ser = new XmlSerializer(typeof(DescriptionType));
            var reader = new StringReader(wsdl2Xml.OuterXml);
            var wsdl2 = (DescriptionType)ser.Deserialize(reader);

            var wsdl1 = new ServiceDescription();

            ConvertDescription(wsdl2, wsdl1);
            ConvertImports(wsdl2, wsdl1);
            ConvertTypes(wsdl2, wsdl1);
            ConvertInterface(wsdl2, wsdl1);
            ConvertBinding(wsdl2, wsdl1);
            ConvertService(wsdl2, wsdl1);

            //not sure why needs to do it... but otherwise code generation fails
            var m = new MemoryStream();
            wsdl1.Write(m);
            string s = Encoding.UTF8.GetString(m.GetBuffer());
            wsdl1 = ServiceDescription.Read(new StringReader(s));

            return wsdl1;
        }
開發者ID:JnrNR,項目名稱:Wsdl20Wsdl11,代碼行數:24,代碼來源:WsdlConverter.cs

示例2: SimpleWrite

		public void SimpleWrite ()
		{
			ServiceDescription sd = new ServiceDescription ();
			Assert.IsNull (sd.Name);
			sd.Write (TextWriter.Null);
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:6,代碼來源:ServiceDescriptionTest.cs

示例3: GenerateWebProxyCode

        public static ArrayList GenerateWebProxyCode(Project project, ServiceDescription desc)
        {
            ArrayList fileList = null;

            string serviceName = String.Empty;
            if(desc.Services.Count > 0) {
                serviceName = desc.Services[0].Name;
            } else {
                serviceName = "UnknownService";
            }

            string webRefFolder = "Web References";
            string nmspace = GetNamespaceFromUri(desc.RetrievalUrl);

            StringBuilder savedir = new StringBuilder();
            savedir.Append(project.BaseDirectory);
            savedir.Append(Path.DirectorySeparatorChar);
            savedir.Append(webRefFolder);
            savedir.Append(Path.DirectorySeparatorChar);
            savedir.Append(GetDirectoryFromUri(desc.RetrievalUrl) + Path.DirectorySeparatorChar + serviceName);

            // second, create the path if it doesn't exist
            if(!Directory.Exists(savedir.ToString()))
                Directory.CreateDirectory(savedir.ToString());

            // generate the assembly
            ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
            importer.AddServiceDescription(desc, null, null);

            CodeNamespace codeNamespace = new CodeNamespace(nmspace);
            CodeCompileUnit codeUnit = new CodeCompileUnit();
            codeUnit.Namespaces.Add(codeNamespace);
            importer.Import(codeNamespace, codeUnit);

            CodeDomProvider provider;
            System.CodeDom.Compiler.ICodeGenerator generator;

            String ext = String.Empty;
            switch(project.ProjectType) {
                case "C#":
                    provider = new Microsoft.CSharp.CSharpCodeProvider();
                    ext = "cs";
                    break;
                case "VBNET":
                    provider = new Microsoft.VisualBasic.VBCodeProvider();
                    ext = "vb";
                    break;

                default:
                    // project type not supported error
                    provider = null;
                    break;
            }

            string filename = savedir.ToString() + Path.DirectorySeparatorChar + serviceName + "WebProxy." + ext;
            string wsdlfilename = savedir.ToString() + Path.DirectorySeparatorChar + serviceName + ".wsdl";

            if(provider != null) {
                StreamWriter sw = new StreamWriter(filename);

                generator = provider.CreateGenerator();
                CodeGeneratorOptions options = new CodeGeneratorOptions();
                options.BracingStyle = "C";
                generator.GenerateCodeFromCompileUnit(codeUnit, sw, options);
                sw.Close();

                if(File.Exists(filename))
                {
                    fileList = new ArrayList();

                    // add project files to the list
                    ProjectFile pfile = new ProjectFile();

                    pfile.Name = project.BaseDirectory + Path.DirectorySeparatorChar + webRefFolder;
                    pfile.BuildAction = BuildAction.Nothing;
                    pfile.Subtype = Subtype.WebReferences;
                    pfile.DependsOn = String.Empty;
                    pfile.Data = String.Empty;
                    fileList.Add(pfile);

                    /*
                    pfile = new ProjectFile();
                    pfile.Name = project.BaseDirectory + @"\Web References\" + nmspace;
                    pfile.BuildAction = BuildAction.Nothing;
                    pfile.Subtype = Subtype.Directory;
                    pfile.DependsOn = project.BaseDirectory + @"\Web References\";
                    pfile.WebReferenceUrl = String.Empty;
                    fileList.Add(pfile);
                    */
                    /*
                    pfile = new ProjectFile();
                    pfile.Name = project.BaseDirectory + @"\Web References\" + nmspace + @"\" + serviceName;
                    pfile.BuildAction = BuildAction.Nothing;
                    pfile.Subtype = Subtype.Directory;
                    pfile.DependsOn = project.BaseDirectory + @"\Web References\" + nmspace + @"\";
                    pfile.WebReferenceUrl = desc.RetrievalUrl;
                    fileList.Add(pfile);
                    */
                    // the Web Reference Proxy
                    pfile = new ProjectFile();
//.........這裏部分代碼省略.........
開發者ID:slluis,項目名稱:monodevelop-prehistoric,代碼行數:101,代碼來源:WebReference.cs


注:本文中的System.Web.Services.Description.ServiceDescription.Write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。