Inheritance: Services.Tokens.TokenReplace
Beispiel #1
0
 public override XmlReader Load(int moduleId, int portalId, Hashtable settings)
 {
     var xmlsrc = settings[Setting.SourceUrl].DefaultIfNullOrEmpty();
     XmlReader responseReader = null;
     if (!string.IsNullOrEmpty(xmlsrc))
     {
         try
         {
             switch (Globals.GetURLType(xmlsrc))
             {
                 case TabType.Url:
                     {
                         var paramList = new ParameterController(_providerName).GetParameters(moduleId);
                         paramList.Encoding = GetQueryStringEncoding(settings[Setting.UrlEncoding].DefaultIfNullOrEmpty());
                         xmlsrc = new TokenReplace().ReplaceEnvironmentTokens(xmlsrc);
                         if (paramList.IsValid())
                         {
                             xmlsrc += (xmlsrc.IndexOf("?") == -1 ? "?" : "&") + paramList;
                             var useCache = bool.Parse(settings[Setting.EnableCache].DefaultIfNullOrEmpty(bool.FalseString));
                             var credential = new Credential(settings[Setting.SourceAccount].DefaultIfNullOrEmpty(), settings[Setting.SourcePassWord].DefaultIfNullOrEmpty());
                             responseReader = GetXmlContent(xmlsrc,credential , useCache);
                         }
                         else
                         {
                             responseReader = NoDataReader("Parameter");
                         }
                     }
                     break;
                 default:
                     responseReader = NoDataReader("Unsupported Url");
                     break;
             }
         }
         catch (SecurityException)
         {
             throw;
         }
         catch (Exception ex)
         {
             Exceptions.LogException(ex);
             responseReader = NoDataReader("Exception");
         }
     }
     return responseReader;
 }
// ReSharper disable InconsistentNaming
        public string tokenReplace(string pattern)

        {
            var tr = new TokenReplace {ModuleInfo = _moduleConfiguration};
            return (tr.ReplaceEnvironmentTokens(pattern));
        }