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); }
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); }
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; }
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; }