Ejemplo n.º 1
0
 internal DlpPolicyMetaData(DlpPolicyTemplateMetaData dlpTemplate, CultureInfo culture = null)
 {
     this.Name           = DlpPolicyTemplateMetaData.GetLocalizedStringValue(dlpTemplate.LocalizedNames, culture);
     this.Description    = DlpPolicyTemplateMetaData.GetLocalizedStringValue(dlpTemplate.LocalizedDescriptions, culture);
     this.ContentVersion = dlpTemplate.ContentVersion;
     this.Version        = dlpTemplate.Version;
     this.Mode           = dlpTemplate.Mode;
     this.State          = dlpTemplate.State;
     this.PublisherName  = dlpTemplate.PublisherName;
     this.ImmutableId    = Guid.NewGuid();
     this.Keywords       = (from keyword in dlpTemplate.LocalizedKeywords
                            select DlpPolicyTemplateMetaData.GetLocalizedStringValue(keyword, culture)).ToArray <string>().ToList <string>();
     this.PolicyCommands = dlpTemplate.PolicyCommands;
 }
        internal ADComplianceProgram ToAdObject()
        {
            string transportRulesXml;

            using (MemoryStream memoryStream = new MemoryStream(DlpPolicyParser.SerializeDlpPolicyTemplate(this)))
            {
                StreamReader streamReader = new StreamReader(memoryStream);
                transportRulesXml = streamReader.ReadToEnd();
            }
            ADComplianceProgram adcomplianceProgram = new ADComplianceProgram();

            adcomplianceProgram.Name        = DlpPolicyTemplateMetaData.GetLocalizedStringValue(this.LocalizedNames, null);
            adcomplianceProgram.Description = DlpPolicyTemplateMetaData.GetLocalizedStringValue(this.LocalizedDescriptions, null);
            adcomplianceProgram.ImmutableId = this.ImmutableId;
            adcomplianceProgram.Keywords    = (from keyword in this.LocalizedKeywords
                                               select DlpPolicyTemplateMetaData.GetLocalizedStringValue(keyword, DlpPolicyTemplateMetaData.DefaultCulture)).ToArray <string>();
            adcomplianceProgram.PublisherName     = this.PublisherName;
            adcomplianceProgram.State             = DlpUtils.RuleStateToDlpState(this.State, this.Mode);
            adcomplianceProgram.TransportRulesXml = transportRulesXml;
            adcomplianceProgram.Version           = this.Version;
            return(adcomplianceProgram);
        }
        internal static IEnumerable <string> LocalizeCmdlets(IEnumerable <string> policyCommands, Dictionary <string, Dictionary <string, string> > policyCommandResources, CultureInfo culture)
        {
            IDictionary <string, string> localizedResources = (from localizedResource in policyCommandResources
                                                               select new KeyValuePair <string, string>(localizedResource.Key, DlpPolicyTemplateMetaData.GetLocalizedStringValue(localizedResource.Value, culture))).ToDictionary((KeyValuePair <string, string> pair) => pair.Key, (KeyValuePair <string, string> pair) => pair.Value, StringComparer.OrdinalIgnoreCase);

            return(from cmdlet in policyCommands
                   select localizedResources.Aggregate(cmdlet, (string current, KeyValuePair <string, string> parameter) => current.Replace(parameter.Key, parameter.Value).Trim()));
        }