コード例 #1
0
 public WebServiceDiscoveryResultWCF(DiscoveryClientProtocol protocol, MetadataSet metadata, WebReferenceItem item, ReferenceGroup refGroup, ClientOptions defaultOptions) : base(WebReferencesService.WcfEngine, item)
 {
     this.refGroup       = refGroup;
     this.protocol       = protocol;
     this.metadata       = metadata;
     this.defaultOptions = defaultOptions;
 }
コード例 #2
0
		public WebServiceDiscoveryResultWCF (DiscoveryClientProtocol protocol, MetadataSet metadata, WebReferenceItem item, ReferenceGroup refGroup, ClientOptions defaultOptions): base (WebReferencesService.WcfEngine, item)
		{
			this.refGroup = refGroup;
			this.protocol = protocol;
			this.metadata = metadata;
			this.defaultOptions = defaultOptions;
		}
コード例 #3
0
		public override WebServiceDiscoveryResult Load (WebReferenceItem item)
		{
			FilePath basePath = item.MapFile.FilePath.ParentDirectory;
			ReferenceGroup resfile = ReferenceGroup.Read (item.MapFile.FilePath);
			
			// TODO: Read as MetadataSet
			
			DiscoveryClientProtocol protocol = new DiscoveryClientProtocol ();
			
			foreach (MetadataFile dcr in resfile.Metadata)
			{
				DiscoveryReference dr;
				switch (dcr.MetadataType) {
					case "Wsdl":
						dr = new System.Web.Services.Discovery.ContractReference ();
						break;
					case "Disco":
						dr = new System.Web.Services.Discovery.DiscoveryDocumentReference ();
						break;
					case "Schema":
						dr = new System.Web.Services.Discovery.SchemaReference ();
						break;
					default:
						continue;
				}

				dr.Url = dcr.SourceUrl;
				FileStream fs = new FileStream (basePath.Combine (dcr.FileName), FileMode.Open, FileAccess.Read);
				protocol.Documents.Add (dr.Url, dr.ReadDocument (fs));
				fs.Close ();
				protocol.References.Add (dr.Url, dr);
			}
			return new WebServiceDiscoveryResultWCF (protocol, null, item, resfile);
		}
コード例 #4
0
        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);
        }
コード例 #5
0
        public override string GetServiceURL()
        {
            ReferenceGroup resfile = ReferenceGroup.Read(Item.MapFile.FilePath);

            if (resfile.MetadataSources.Count == 0)
            {
                return(null);
            }
            return(resfile.MetadataSources [0].Address);
        }
コード例 #6
0
        protected override string GenerateDescriptionFiles(DotNetProject project, FilePath basePath)
        {
            if (!project.Items.GetAll <WCFMetadata> ().Any())
            {
                WCFMetadata met = new WCFMetadata();
                met.Path = basePath.ParentDirectory;
                project.Items.Add(met);
            }

            WCFMetadataStorage metStor = project.Items.GetAll <WCFMetadataStorage> ().FirstOrDefault(m => m.Path.CanonicalPath == basePath);

            if (metStor == null)
            {
                project.Items.Add(new WCFMetadataStorage()
                {
                    Path = basePath
                });
            }

            string file = Path.Combine(basePath, "Reference.svcmap");

            if (protocol != null)
            {
                protocol.ResolveAll();
                protocol.WriteAll(basePath, "Reference.svcmap");
                refGroup = ConvertMapFile(file);
            }
            else
            {
                // TODO
                ReferenceGroup map = new ReferenceGroup();
                map.ClientOptions = InitialClientOptions;
                map.Save(file);
                map.ID   = Guid.NewGuid().ToString();
                refGroup = map;
            }
            foreach (MetadataFile mfile in refGroup.Metadata)
            {
                project.AddFile(new FilePath(mfile.FileName).ToAbsolute(basePath), BuildAction.None);
            }

            return(file);
        }
コード例 #7
0
        public override void Update()
        {
            ReferenceGroup resfile = ReferenceGroup.Read(Item.MapFile.FilePath);

            if (resfile.MetadataSources.Count == 0)
            {
                return;
            }
            string url = resfile.MetadataSources [0].Address;
            WebServiceDiscoveryResultWCF wref = (WebServiceDiscoveryResultWCF)WebReferencesService.WcfEngine.Discover(url);

            if (wref == null)
            {
                return;
            }

            metadata = wref.metadata;
            protocol = wref.protocol;
            GenerateFiles(Item.Project, Item.MapFile.Project.Name, Item.Name);
        }
コード例 #8
0
		protected override string GenerateDescriptionFiles (DotNetProject dotNetProject, FilePath basePath)
		{
			if (!dotNetProject.Items.GetAll<WCFMetadata> ().Any ()) {
				var met = new WCFMetadata ();
				met.Path = basePath.ParentDirectory;
				dotNetProject.Items.Add (met);
			}
			
			WCFMetadataStorage metStor = dotNetProject.Items.GetAll<WCFMetadataStorage> ().FirstOrDefault (m => m.Path.CanonicalPath == basePath);
			if (metStor == null)
				dotNetProject.Items.Add (new WCFMetadataStorage { Path = basePath });
			
			string file = Path.Combine (basePath, "Reference.svcmap");
			if (protocol != null) {
				protocol.ResolveAll ();
				protocol.WriteAll (basePath, "Reference.svcmap");
				refGroup = ConvertMapFile (file);
			} else {
				// TODO
				var map = new ReferenceGroup ();
				map.ClientOptions = defaultOptions;
				map.Save (file);
				map.ID = Guid.NewGuid ().ToString ();
				refGroup = map;
			}
			foreach (MetadataFile mfile in refGroup.Metadata)
				dotNetProject.AddFile (new FilePath (mfile.FileName).ToAbsolute (basePath), BuildAction.None);
			
			return file;
		}
コード例 #9
0
		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;
		}