Пример #1
0
 internal void Validate()
 {
     if (string.IsNullOrEmpty(this.Name) || string.IsNullOrEmpty(this.Version))
     {
         throw new DlpPolicyParsingException(Strings.DlpPolicyXmlMissingElements);
     }
     if (new Version(this.Version) > DlpUtils.MaxSupportedVersion)
     {
         throw new DlpPolicyParsingException(Strings.DlpPolicyVersionUnsupported);
     }
     if (this.Keywords.Any(new Func <string, bool>(string.IsNullOrEmpty)))
     {
         throw new DlpPolicyParsingException(Strings.DlpPolicyContainsEmptyKeywords);
     }
     DlpPolicyTemplateMetaData.ValidateFieldSize("name", this.Name, 64);
     DlpPolicyTemplateMetaData.ValidateFieldSize("version", this.Version, 16);
     DlpPolicyTemplateMetaData.ValidateFieldSize("contentVersion", this.ContentVersion, 16);
     DlpPolicyTemplateMetaData.ValidateFieldSize("publisherName", this.PublisherName, 256);
     DlpPolicyTemplateMetaData.ValidateFieldSize("description", this.Description, 1024);
     this.Keywords.ForEach(delegate(string x)
     {
         DlpPolicyTemplateMetaData.ValidateFieldSize("keyword", x, 64);
     });
     this.PolicyCommands.ForEach(delegate(string command)
     {
         DlpPolicyTemplateMetaData.ValidateFieldSize("commandBlock", command, 4096);
     });
     this.PolicyCommands.ForEach(delegate(string command)
     {
         DlpPolicyTemplateMetaData.ValidateCmdletParameters(command);
     });
 }
        internal void Validate()
        {
            if (this.LocalizedNames == null || !this.LocalizedNames.Any <KeyValuePair <string, string> >() || string.IsNullOrEmpty(this.Version) || this.ImmutableId == Guid.Empty || string.IsNullOrEmpty(this.ContentVersion) || string.IsNullOrEmpty(this.PublisherName) || this.LocalizedDescriptions == null || !this.LocalizedDescriptions.Any <KeyValuePair <string, string> >() || this.PolicyCommands == null || !this.PolicyCommands.Any <string>())
            {
                throw new DlpPolicyParsingException(Strings.DlpPolicyXmlMissingElements);
            }
            if (new Version(this.Version) > DlpUtils.MaxSupportedVersion)
            {
                throw new DlpPolicyParsingException(Strings.DlpPolicyVersionUnsupported);
            }
            if (this.LocalizedKeywords.Any((Dictionary <string, string> keywords) => keywords.Any((KeyValuePair <string, string> keyword) => string.IsNullOrEmpty(keyword.Value))))
            {
                throw new DlpPolicyParsingException(Strings.DlpPolicyContainsEmptyKeywords);
            }
            DlpPolicyTemplateMetaData.ValidateFieldSize("version", this.Version, 16);
            DlpPolicyTemplateMetaData.ValidateFieldSize("contentVersion", this.ContentVersion, 16);
            DlpPolicyTemplateMetaData.ValidateFieldSize("publisherName", this.PublisherName, 256);
            this.LocalizedNames.Values.ToList <string>().ForEach(delegate(string x)
            {
                DlpPolicyTemplateMetaData.ValidateFieldSize("name", x, 64);
            });
            this.LocalizedDescriptions.Values.ToList <string>().ForEach(delegate(string x)
            {
                DlpPolicyTemplateMetaData.ValidateFieldSize("description", x, 1024);
            });
            this.LocalizedKeywords.ToList <Dictionary <string, string> >().ForEach(delegate(Dictionary <string, string> keywords)
            {
                keywords.Values.ToList <string>().ForEach(delegate(string keyword)
                {
                    DlpPolicyTemplateMetaData.ValidateFieldSize("keyword", keyword, 64);
                });
            });
            List <DlpTemplateRuleParameter> list = this.RuleParameters.ToList <DlpTemplateRuleParameter>();

            list.ForEach(delegate(DlpTemplateRuleParameter x)
            {
                DlpPolicyTemplateMetaData.ValidateFieldSize("type", x.Type, 32);
            });
            list.ForEach(delegate(DlpTemplateRuleParameter x)
            {
                DlpPolicyTemplateMetaData.ValidateFieldSize("token", x.Token, 32);
            });
            list.ForEach(delegate(DlpTemplateRuleParameter x)
            {
                x.LocalizedDescriptions.ToList <KeyValuePair <string, string> >().ForEach(delegate(KeyValuePair <string, string> y)
                {
                    DlpPolicyTemplateMetaData.ValidateFieldSize("description", y.Value, 1024);
                });
            });
            this.LocalizedPolicyCommandResources.Values.ToList <Dictionary <string, string> >().ForEach(delegate(Dictionary <string, string> resources)
            {
                resources.Values.ToList <string>().ForEach(delegate(string resource)
                {
                    DlpPolicyTemplateMetaData.ValidateFieldSize("resource", resource, 1024);
                });
            });
            List <string> list2 = this.PolicyCommands.ToList <string>();

            list2.ForEach(delegate(string x)
            {
                DlpPolicyTemplateMetaData.ValidateFieldSize("commandBlock", x, 4096);
            });
            list2.ForEach(delegate(string command)
            {
                DlpPolicyTemplateMetaData.ValidateCmdletParameters(command);
            });
        }