当前位置: 首页>>代码示例>>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;未经允许,请勿转载。