示例#1
0
 public string GetRuleXml(string locale, ETRToPNRTranslator.IMessageStrings messageStrings, ETRToPNRTranslator.IDistributionListResolver distributionListResolver, ETRToPNRTranslator.IDataClassificationResolver dataClassificationResolver, bool needFullPnrXml, out PolicyNudgeRule.References references)
 {
     if (this.localeToPnrMap == null)
     {
         lock (this.etrXml)
         {
             if (this.localeToPnrMap == null)
             {
                 this.localeToPnrMap = new Dictionary <string, PolicyNudgeRule.CacheEntry>();
             }
         }
     }
     PolicyNudgeRule.CacheEntry cacheEntry;
     if (this.localeToPnrMap.TryGetValue(locale, out cacheEntry))
     {
         references = new PolicyNudgeRule.References(cacheEntry.usedMessages, cacheEntry.usedDistributionLists.SelectMany((string dl) => distributionListResolver.Get(dl)));
         if (!needFullPnrXml)
         {
             return(cacheEntry.PnrXml);
         }
         return(cacheEntry.FullPnrXml);
     }
     else
     {
         List <PolicyTipMessage> usedMessagesList          = new List <PolicyTipMessage>();
         List <string>           usedDistributionListsList = new List <string>();
         ETRToPNRTranslator      etrtoPNRTranslator        = new ETRToPNRTranslator(this.etrXml, new ETRToPNRTranslator.MessageStringCallbackImpl(messageStrings.OutlookCultureTag, (ETRToPNRTranslator.OutlookActionTypes action) => PolicyNudgeRule.Track <PolicyTipMessage>(messageStrings.Get(action), usedMessagesList), () => PolicyNudgeRule.Track <PolicyTipMessage>(messageStrings.Url, usedMessagesList)), new ETRToPNRTranslator.DistributionListResolverCallbackImpl(delegate(string distributionList)
         {
             PolicyNudgeRule.Track <string>(distributionList, usedDistributionListsList);
             return(null);
         }, (string distributionList) => distributionListResolver.IsMemberOf(distributionList)), dataClassificationResolver);
         string pnrXml = etrtoPNRTranslator.PnrXml;
         this.IsPnrXmlValid = !string.IsNullOrEmpty(pnrXml);
         string fullPnrXml = etrtoPNRTranslator.FullPnrXml;
         lock (this.localeToPnrMap)
         {
             if (!this.localeToPnrMap.ContainsKey(locale))
             {
                 this.localeToPnrMap.Add(locale, new PolicyNudgeRule.CacheEntry
                 {
                     PnrXml                = pnrXml,
                     FullPnrXml            = fullPnrXml,
                     usedMessages          = usedMessagesList.ToArray(),
                     usedDistributionLists = usedDistributionListsList.ToArray()
                 });
             }
         }
         references = new PolicyNudgeRule.References(usedMessagesList, usedDistributionListsList.SelectMany((string dl) => distributionListResolver.Get(dl)));
         if (!needFullPnrXml)
         {
             return(pnrXml);
         }
         return(fullPnrXml);
     }
 }
 internal ETRToPNRTranslator(string etrXml, ETRToPNRTranslator.IMessageStrings messageStrings, ETRToPNRTranslator.IDistributionListResolver distributionListResolver = null, ETRToPNRTranslator.IDataClassificationResolver dataClassificationResolver = null)
 {
     this.etrXml                     = etrXml;
     this.messageStrings             = messageStrings;
     this.distributionListResolver   = distributionListResolver;
     this.dataClassificationResolver = dataClassificationResolver;
     this.fullPnrXml                 = new Lazy <string>(new Func <string>(this.TryTransform));
 }