当前位置: 首页>>代码示例>>C#>>正文


C# DiscoveryClientProtocol.ReadAll方法代码示例

本文整理汇总了C#中System.Web.Services.Discovery.DiscoveryClientProtocol.ReadAll方法的典型用法代码示例。如果您正苦于以下问题:C# DiscoveryClientProtocol.ReadAll方法的具体用法?C# DiscoveryClientProtocol.ReadAll怎么用?C# DiscoveryClientProtocol.ReadAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Services.Discovery.DiscoveryClientProtocol的用法示例。


在下文中一共展示了DiscoveryClientProtocol.ReadAll方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadWriteTest

		public void ReadWriteTest ()
		{
			string directory = Path.Combine (Path.GetTempPath (), Path.GetRandomFileName ());
			Directory.CreateDirectory (directory);
			try {
				string url = "http://www.w3schools.com/WebServices/TempConvert.asmx";
				var p1 = new DiscoveryClientProtocol ();
				p1.DiscoverAny (url);
				p1.ResolveAll ();

				p1.WriteAll (directory, "Reference.map");

				var p2 = new DiscoveryClientProtocol ();
				var results = p2.ReadAll (Path.Combine (directory, "Reference.map"));

				Assert.AreEqual (2, results.Count);
				Assert.AreEqual ("TempConvert.disco", results [0].Filename);
				Assert.AreEqual ("TempConvert.wsdl", results [1].Filename);
			} finally {
				Directory.Delete (directory, true);
			}
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:22,代码来源:DiscoveryClientProtocolTest.cs

示例2: ConvertMapFile

		ReferenceGroup ConvertMapFile (string mapFile)
		{
			DiscoveryClientResultCollection files;
			using (var prot = new DiscoveryClientProtocol ())
				files = prot.ReadAll (mapFile);
			
			var map = new ReferenceGroup ();
			
			if (refGroup != null) {
				map.ClientOptions = refGroup.ClientOptions;
				map.ID = refGroup.ID;
			} else {
				map.ClientOptions = defaultOptions;
				map.ID = Guid.NewGuid ().ToString ();
			}
			
			var sources = new Dictionary<string, int> ();
			foreach (DiscoveryClientResult res in files) {
				string url = res.Url;
				var uri = new Uri (url);
				if (!string.IsNullOrEmpty (uri.Query))
					url = url.Substring (0, url.Length - uri.Query.Length);
				int nSource;
				if (!sources.TryGetValue (url, out nSource)) {
					nSource = sources.Count + 1;
					sources [url] = nSource;
					var ms = new MetadataSource ();
					ms.Address = url;
					ms.Protocol = uri.Scheme;
					ms.SourceId = nSource.ToString ();
					map.MetadataSources.Add (ms);
				}
				var file = new MetadataFile ();
				file.FileName = res.Filename;
				file.ID = Guid.NewGuid ().ToString ();
				file.SourceId = nSource.ToString ();
				file.SourceUrl = res.Url;
				switch (Path.GetExtension (file.FileName).ToLower ()) {
					case ".disco": file.MetadataType = "Disco"; break;
					case ".wsdl": file.MetadataType = "Wsdl"; break;
					case ".xsd": file.MetadataType = "Schema"; break;
				}
				map.Metadata.Add (file);
			}
			map.Save (mapFile);
			return map;
		}
开发者ID:riverans,项目名称:monodevelop,代码行数:47,代码来源:WebServiceDiscoveryResultWCF.cs

示例3: GenerateCode

    public override void GenerateCode(AssemblyBuilder assemblyBuilder)  {

        // Only attempt to get the Indigo provider once
        if (!s_triedToGetWebRefType) {
            s_indigoWebRefProviderType = BuildManager.GetType(IndigoWebRefProviderTypeName, false /*throwOnError*/);
            s_triedToGetWebRefType = true;
        }

        // If we have an Indigo provider, instantiate it and forward the GenerateCode call to it
        if (s_indigoWebRefProviderType != null) {
            BuildProvider buildProvider = (BuildProvider)HttpRuntime.CreateNonPublicInstance(s_indigoWebRefProviderType);
            buildProvider.SetVirtualPath(VirtualPathObject);
            buildProvider.GenerateCode(assemblyBuilder);
        }

        // e.g "/MyApp/Application_WebReferences"
        VirtualPath rootWebRefDirVirtualPath = HttpRuntime.WebRefDirectoryVirtualPath;

        // e.g "/MyApp/Application_WebReferences/Foo/Bar"
        string currentWebRefDirVirtualPath = _vdir.VirtualPath;

        Debug.Assert(StringUtil.StringStartsWithIgnoreCase(
            currentWebRefDirVirtualPath, rootWebRefDirVirtualPath.VirtualPathString));

        string ns;

        if (rootWebRefDirVirtualPath.VirtualPathString.Length == currentWebRefDirVirtualPath.Length) {
            // If it's the root WebReferences dir, use the empty namespace
            ns = String.Empty;
        }
        else {
            // e.g. "Foo/Bar"
            Debug.Assert(rootWebRefDirVirtualPath.HasTrailingSlash);
            currentWebRefDirVirtualPath = UrlPath.RemoveSlashFromPathIfNeeded(currentWebRefDirVirtualPath);
            currentWebRefDirVirtualPath = currentWebRefDirVirtualPath.Substring(
                rootWebRefDirVirtualPath.VirtualPathString.Length);

            // Split it into chunks separated by '/'
            string[] chunks = currentWebRefDirVirtualPath.Split('/');

            // Turn all the relevant chunks into valid namespace chunks
            for (int i=0; i<chunks.Length; i++) {
                chunks[i] = Util.MakeValidTypeNameFromString(chunks[i]);
            }

            // Put the relevant chunks back together to form the namespace
            ns = String.Join(".", chunks);
        }
#if !FEATURE_PAL // FEATURE_PAL does not support System.Web.Services

        CodeNamespace codeNamespace = new CodeNamespace(ns);

        // for each discomap file, read all references and add them to the WebReferenceCollection
        WebReferenceCollection webs = new WebReferenceCollection();

        bool hasDiscomap = false;

        // Go through all the discomap in the directory
        foreach (VirtualFile child in _vdir.Files) {

            string extension = UrlPath.GetExtension(child.VirtualPath);
            extension = extension.ToLower(CultureInfo.InvariantCulture);

            if (extension == ".discomap") {
                // NOTE: the WebReferences code requires physical path, so this feature
                // cannot work with a non-file based VirtualPathProvider
                string physicalPath = HostingEnvironment.MapPath(child.VirtualPath);

                DiscoveryClientProtocol client = new DiscoveryClientProtocol();
                client.AllowAutoRedirect = true;
                client.Credentials = CredentialCache.DefaultCredentials;

                client.ReadAll(physicalPath);

                WebReference webRefTemp = new WebReference(client.Documents, codeNamespace);

                // 

                string fileName = System.IO.Path.ChangeExtension(UrlPath.GetFileName(child.VirtualPath), null);
                string appSetttingUrlKey = ns + "." + fileName;

                WebReference web = new WebReference(client.Documents, codeNamespace, webRefTemp.ProtocolName, appSetttingUrlKey, null);

                webs.Add(web);

                hasDiscomap = true;
            }
        }

        // If we didn't find any discomap files, we have nothing to generate
        if (!hasDiscomap)
            return;

        CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
        codeCompileUnit.Namespaces.Add(codeNamespace);

        //public static StringCollection GenerateWebReferences(WebReferenceCollection webReferences, CodeDomProvider codeProvider, CodeCompileUnit codeCompileUnit, WebReferenceOptions options) {
        WebReferenceOptions options = new WebReferenceOptions();
        options.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateNewAsync | CodeGenerationOptions.GenerateOldAsync;
        options.Style = ServiceDescriptionImportStyle.Client;
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:WebReferencesBuildProvider.cs

示例4: DiscoverMetadataFromMapFile

		private MetadataSet DiscoverMetadataFromMapFile(string file)
		{
			string mapFile = Path.ChangeExtension(file, MapFileExtension);

			using (DiscoveryClientProtocol discovery = new DiscoveryClientProtocol())
			{
				discovery.ReadAll(mapFile);
				MetadataSet metadataSet = new MetadataSet();
				foreach (object document in discovery.Documents.Values)
				{
					metadataSet.MetadataSections.Add(CreateMetadataSection(document));
				}
				return metadataSet;
			}
		}
开发者ID:Phidiax,项目名称:open-wssf-2015,代码行数:15,代码来源:MetadataDiscovery.cs

示例5: ProcessLocal

        /// <summary>
        /// Process local paths
        /// </summary>
        /// <param name="path"></param>
        /// <param name="discoveryClientProtocol"></param>
        private void ProcessLocal( string path, DiscoveryClientProtocol discoveryClientProtocol)
        {
            string extension = Path.GetExtension(path);

            if (string.Compare(extension, ".discomap", true) == 0)
            {
                discoveryClientProtocol.ReadAll(path);
            }
            else
            {
                object obj = null;
                if (string.Compare(extension, ".wsdl", true) == 0)
                {
                    obj = this.ReadLocalDocument(false, path);
                }
                else
                {
                    if (string.Compare(extension, ".xsd", true) != 0)
                        throw new InvalidOperationException("Unknown file type " + path);

                    obj = this.ReadLocalDocument(true, path);
                }

                if (obj != null)
                    this.AddDocument(path, obj);

            }
        }
开发者ID:nujmail,项目名称:xsd-to-classes,代码行数:33,代码来源:WsdlProxyGenerator.cs

示例6: ProcessLocalPaths

 private void ProcessLocalPaths(DiscoveryClientProtocol client, StringCollection localPaths, XmlSchemas schemas, ServiceDescriptionCollection descriptions)
 {
     StringEnumerator enumerator = localPaths.GetEnumerator();
     while (enumerator.MoveNext())
     {
         string current = enumerator.Current;
         string extension = Path.GetExtension(current);
         if (string.Compare(extension, ".discomap", true) == 0)
         {
             client.ReadAll(current);
         }
         else
         {
             object document = null;
             if (string.Compare(extension, ".wsdl", true) == 0)
             {
                 document = this.ReadLocalDocument(false, current);
             }
             else
             {
                 if (string.Compare(extension, ".xsd", true) != 0)
                 {
                     throw new InvalidOperationException("Unknown file type " + current);
                 }
                 document = this.ReadLocalDocument(true, current);
             }
             if (document != null)
             {
                 this.AddDocument(current, document, schemas, descriptions);
             }
         }
     }
 }
开发者ID:hdougie,项目名称:webservicestudio2,代码行数:33,代码来源:Wsdl.cs

示例7: ProcessLocalPaths

 private void ProcessLocalPaths(DiscoveryClientProtocol client, StringCollection localPaths, XmlSchemas schemas,
                                ServiceDescriptionCollection descriptions)
 {
     foreach (string text1 in localPaths)
     {
         string text2 = Path.GetExtension(text1);
         if (string.Compare(text2, ".discomap", true) == 0)
         {
             client.ReadAll(text1);
         }
         else
         {
             object obj1 = null;
             if (string.Compare(text2, ".wsdl", true) == 0)
             {
                 obj1 = ReadLocalDocument(false, text1);
             }
             else
             {
                 if (string.Compare(text2, ".xsd", true) != 0)
                 {
                     throw new InvalidOperationException("Unknown file type " + text1);
                 }
                 obj1 = ReadLocalDocument(true, text1);
             }
             if (obj1 != null)
             {
                 AddDocument(text1, obj1, schemas, descriptions);
             }
         }
     }
 }
开发者ID:irdetocustomercentral,项目名称:WebServiceStudio,代码行数:32,代码来源:Wsdl.cs

示例8: GenerateCode

 public override void GenerateCode(AssemblyBuilder assemblyBuilder)
 {
     string str2;
     if (!s_triedToGetWebRefType)
     {
         s_indigoWebRefProviderType = BuildManager.GetType("System.Web.Compilation.WCFBuildProvider", false);
         s_triedToGetWebRefType = true;
     }
     if (s_indigoWebRefProviderType != null)
     {
         BuildProvider provider = (BuildProvider) HttpRuntime.CreateNonPublicInstance(s_indigoWebRefProviderType);
         provider.SetVirtualPath(base.VirtualPathObject);
         provider.GenerateCode(assemblyBuilder);
     }
     VirtualPath webRefDirectoryVirtualPath = HttpRuntime.WebRefDirectoryVirtualPath;
     string virtualPath = this._vdir.VirtualPath;
     if (webRefDirectoryVirtualPath.VirtualPathString.Length == virtualPath.Length)
     {
         str2 = string.Empty;
     }
     else
     {
         string[] strArray = UrlPath.RemoveSlashFromPathIfNeeded(virtualPath).Substring(webRefDirectoryVirtualPath.VirtualPathString.Length).Split(new char[] { '/' });
         for (int i = 0; i < strArray.Length; i++)
         {
             strArray[i] = Util.MakeValidTypeNameFromString(strArray[i]);
         }
         str2 = string.Join(".", strArray);
     }
     CodeNamespace proxyCode = new CodeNamespace(str2);
     WebReferenceCollection webReferences = new WebReferenceCollection();
     bool flag = false;
     foreach (VirtualFile file in this._vdir.Files)
     {
         if (UrlPath.GetExtension(file.VirtualPath).ToLower(CultureInfo.InvariantCulture) == ".discomap")
         {
             string topLevelFilename = HostingEnvironment.MapPath(file.VirtualPath);
             DiscoveryClientProtocol protocol = new DiscoveryClientProtocol {
                 AllowAutoRedirect = true,
                 Credentials = CredentialCache.DefaultCredentials
             };
             protocol.ReadAll(topLevelFilename);
             WebReference reference = new WebReference(protocol.Documents, proxyCode);
             string str5 = Path.ChangeExtension(UrlPath.GetFileName(file.VirtualPath), null);
             string appSettingUrlKey = str2 + "." + str5;
             WebReference webReference = new WebReference(protocol.Documents, proxyCode, reference.ProtocolName, appSettingUrlKey, null);
             webReferences.Add(webReference);
             flag = true;
         }
     }
     if (flag)
     {
         CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
         codeCompileUnit.Namespaces.Add(proxyCode);
         WebReferenceOptions options = new WebReferenceOptions {
             CodeGenerationOptions = CodeGenerationOptions.GenerateOldAsync | CodeGenerationOptions.GenerateNewAsync | CodeGenerationOptions.GenerateProperties,
             Style = ServiceDescriptionImportStyle.Client,
             Verbose = true
         };
         ServiceDescriptionImporter.GenerateWebReferences(webReferences, assemblyBuilder.CodeDomProvider, codeCompileUnit, options);
         assemblyBuilder.AddCodeCompileUnit(this, codeCompileUnit);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:63,代码来源:WebReferencesBuildProvider.cs


注:本文中的System.Web.Services.Discovery.DiscoveryClientProtocol.ReadAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。