summaryrefslogtreecommitdiffstats
path: root/tools/Sandcastle/Source/BuildAssembler/BuildComponents/MsdnResolver.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-09-20 21:18:59 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-09-21 08:06:22 -0700
commitbbe3f9cc9c8a1e5909273c1a162a63ea7a66afd8 (patch)
treec91f66e642c4d26fca266e226b3f2765f546d700 /tools/Sandcastle/Source/BuildAssembler/BuildComponents/MsdnResolver.cs
parent627014f0bbc3fd576277375e70f8391d150b0a67 (diff)
downloadDotNetOpenAuth-bbe3f9cc9c8a1e5909273c1a162a63ea7a66afd8.zip
DotNetOpenAuth-bbe3f9cc9c8a1e5909273c1a162a63ea7a66afd8.tar.gz
DotNetOpenAuth-bbe3f9cc9c8a1e5909273c1a162a63ea7a66afd8.tar.bz2
Switched out the Sandcastle binaries for the source code.
Diffstat (limited to 'tools/Sandcastle/Source/BuildAssembler/BuildComponents/MsdnResolver.cs')
-rw-r--r--tools/Sandcastle/Source/BuildAssembler/BuildComponents/MsdnResolver.cs73
1 files changed, 73 insertions, 0 deletions
diff --git a/tools/Sandcastle/Source/BuildAssembler/BuildComponents/MsdnResolver.cs b/tools/Sandcastle/Source/BuildAssembler/BuildComponents/MsdnResolver.cs
new file mode 100644
index 0000000..95ad854
--- /dev/null
+++ b/tools/Sandcastle/Source/BuildAssembler/BuildComponents/MsdnResolver.cs
@@ -0,0 +1,73 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Web.Services.Protocols;
+
+namespace Microsoft.Ddue.Tools {
+
+ public class MsdnResolver {
+
+ public MsdnResolver () {
+ msdnService = new ContentService();
+ msdnService.appIdValue = new appId();
+ msdnService.appIdValue.value = "Sandcastle";
+ msdnService.SoapVersion = SoapProtocolVersion.Soap11;
+ }
+
+ public bool IsDisabled {
+ get {
+ return ((msdnService == null));
+ }
+ }
+
+ public string Locale {
+ get {
+ return (locale);
+ }
+ set {
+ locale = value;
+ }
+ }
+
+ public string GetMsdnUrl (string id) {
+
+ if (cachedMsdnUrls.ContainsKey(id)) return (String.Format(urlFormat, locale, cachedMsdnUrls[id]));
+
+ if (msdnService == null) return(null);
+
+ getContentRequest msdnRequest = new getContentRequest();
+ msdnRequest.contentIdentifier = "AssetId:" + id;
+ msdnRequest.locale = locale;
+
+ string endpoint = null;
+ try {
+ getContentResponse msdnResponse = msdnService.GetContent(msdnRequest);
+ endpoint = msdnResponse.contentId;
+ } catch (WebException e) {
+ msdnService = null;
+ } catch (SoapException) {
+ // lookup failed
+ }
+
+ cachedMsdnUrls[id] = endpoint;
+
+ if (String.IsNullOrEmpty(endpoint)) {
+ return (null);
+ } else {
+ return (String.Format(urlFormat, locale, endpoint));
+ }
+ }
+
+ private ContentService msdnService;
+
+ private string locale = "en-us";
+
+ private static string urlFormat = "http://msdn2.microsoft.com/{0}/library/{1}";
+
+ private Dictionary<string, string> cachedMsdnUrls = new Dictionary<string, string>();
+
+ }
+
+}