Ejemplo n.º 1
0
        /// <summary>
        /// Finds a URL from MSDN documentation.
        /// </summary>
        /// <param name="assetId">The asset id in the form "T:System.String"</param>
        /// <returns>A URL to MSDN or null if no URL was found</returns>
        public string FindUrl(string assetId)
        {
            // Only look for T:System.
            if (assetId.Length < 3 || !assetId.Substring(2).StartsWith("System.") || IsDisabled)
            {
                return(null);
            }

            string contentId;

            if (!_mapAssetIdToContentId.TryGetValue(assetId, out contentId))
            {
                try
                {
                    Logger.Message("Get MSDN URL for id [{0}]", assetId);
                    var request = new getContentRequest {
                        contentIdentifier = "AssetId:" + HttpUtility.UrlEncode(assetId), locale = Locale
                    };

                    var appId = new appId()
                    {
                        value = AppId
                    };
                    var response = msdnClient.GetContent(appId, request);
                    contentId = response.contentId;
                }
                catch (EndpointNotFoundException endpointNotFound)
                {
                    Logger.Warning("Unable to connect to MTPS service. MSDN resolver disabled : {0}", endpointNotFound.Message);
                    IsDisabled = true;
                }
                catch (Exception ex)
                {
                    Logger.Warning("Error while getting MSDN URL [{0}] : {1}", assetId, ex.Message);
                }
                _mapAssetIdToContentId[assetId] = contentId;

                SaveCacheToDisk();
            }

            if (string.IsNullOrEmpty(contentId))
            {
                return(null);
            }

            return(string.Format(MsdnUrlFormat, Locale, contentId));
        }
 /// <summary>
 /// Creates a new MTPS member model repository.
 /// </summary>
 /// <param name="rootAssetId">The root asset ID for the .NET framework.</param>
 /// <param name="version">The desired documentation version.</param>
 /// <param name="locale">The desired documentation locale.</param>
 /// <param name="serviceUrl">The MTPS service URL.</param>
 public MsdnCodeDocMemberRepository(string rootAssetId = null, string version = null, string locale = null, string serviceUrl = null)
 {
     RootAssetId = String.IsNullOrEmpty(rootAssetId) ? DefaultRootAssetId : rootAssetId;
     Version = String.IsNullOrEmpty(version) ? DefaultVersion : version;
     Locale = String.IsNullOrEmpty(locale) ? DefaultLocale : locale;
     ServiceUrl = String.IsNullOrEmpty(serviceUrl) ? DefaultServiceUrl : serviceUrl;
     _appId = new appId();
     _clientGenerator = new Lazy<ContentServicePortTypeClient>(
         () => new ContentServicePortTypeClient(
             new BasicHttpBinding{
                 MaxReceivedMessageSize = 1024 * 1024
             },
             new EndpointAddress(ServiceUrl)
         ),
         true
     );
 }
Ejemplo n.º 3
0
 => Invoke(token => DoBatchGetUserInfo(token, openIds, lang), appId, secret);
Ejemplo n.º 4
0
 => Invoke(token => DoGetUsers(token, nextOpenId), appId, secret);
Ejemplo n.º 5
0
 => Invoke(token => DoGetTagsByUser(token, openId), appId, secret);
Ejemplo n.º 6
0
 => Invoke(token => DoGetUsersWithTag(token, tagId, nextOpenId), appId, secret);
Ejemplo n.º 7
0
 => Invoke(token => DoGetTags(token), appId, secret);
Ejemplo n.º 8
0
 => Invoke(token => DoCreateTag(token, name), appId, secret);
Ejemplo n.º 9
0
 VirtualRoot.RaiseEvent(new SpeedDatasMqEvent(appId, clientIdIps, ea.GetTimestamp()));
Ejemplo n.º 10
0
        /// <summary>
        /// Finds an URL from MSDN documentation.
        /// </summary>
        /// <param name="assetId">The asset id in the form "T:System.String"</param>
        /// <returns>An url to MSDN or null if no url was found</returns>
        public string FindUrl(string assetId)
        {
            // Only look for T:System. 
            if (assetId.Length < 3 || !assetId.Substring(2).StartsWith("System.") || IsDisabled)
                return null;

            string contentId;
            if (!_mapAssetIdToContentId.TryGetValue(assetId, out contentId))
            {
                try
                {
                    Logger.Message("Get MSDN URL for id [{0}]", assetId);
                    var request = new getContentRequest { contentIdentifier = "AssetId:" + HttpUtility.UrlEncode(assetId), locale = Locale };

                    var appId = new appId() { value = AppId };
                    var response = msdnClient.GetContent(appId, request);
                    contentId = response.contentId;
                }
                catch (EndpointNotFoundException endpointNotFound)
                {
                    Logger.Warning("Unable to connect to MTPS service. Msnd resolver disabled : {0}", endpointNotFound.Message);
                    IsDisabled = true;
                }
                catch (Exception ex)
                {
                    Logger.Warning("Error while getting msdn url [{0}] : {1}", assetId, ex.Message);
                }
                _mapAssetIdToContentId[assetId] = contentId;

                SaveCacheToDisk();
            }

            if (string.IsNullOrEmpty(contentId))
                return null;

            return string.Format(MsdnUrlFormat, Locale, contentId);
        }
 private getContentResponse CachedGetContentRequest(appId appId, getContentRequest request)
 {
     var requestKey = CreateGetContentRequestKey(request);
     var rawResult = Cache[requestKey] as getContentResponse;
     if (rawResult == null) {
         rawResult = Client.GetContent(appId, request);
         if (rawResult != null)
             Cache[requestKey] = rawResult;
     }
     return rawResult;
 }
Ejemplo n.º 12
0
 => Invoke(token => DoGetIndustry(token), appId, secret);
Ejemplo n.º 13
0
 => Invoke(token => DoGetAllPrivateTemplate(token), appId, secret);
Ejemplo n.º 14
0
 => Invoke(token => DoAddTemplate(token, templateIdShort), appId, secret);
Ejemplo n.º 15
0
 => Invoke(token => DoSend(token, input), appId, secret);