internal static DlpPolicyTemplateMetaData ParseDlpPolicyTemplate(string data)
        {
            DlpPolicyTemplateMetaData result;

            try
            {
                XElement root = XDocument.Parse(data).Root;
                DlpPolicyTemplateMetaData dlpPolicyTemplateMetaData = new DlpPolicyTemplateMetaData();
                dlpPolicyTemplateMetaData.Version               = root.Attribute("version").Value.Trim();
                dlpPolicyTemplateMetaData.State                 = (RuleState)Enum.Parse(typeof(RuleState), root.Attribute("state").Value.Trim());
                dlpPolicyTemplateMetaData.Mode                  = (RuleMode)Enum.Parse(typeof(RuleMode), root.Attribute("mode").Value.Trim());
                dlpPolicyTemplateMetaData.ImmutableId           = ((root.Attribute("id") == null) ? Guid.Empty : Guid.Parse(root.Attribute("id").Value.Trim()));
                dlpPolicyTemplateMetaData.ContentVersion        = root.Element("contentVersion").Value.Trim();
                dlpPolicyTemplateMetaData.PublisherName         = root.Element("publisherName").Value.Trim();
                dlpPolicyTemplateMetaData.LocalizedNames        = DlpPolicyParser.ParseLocalizedString(root.Element("name"));
                dlpPolicyTemplateMetaData.LocalizedDescriptions = DlpPolicyParser.ParseLocalizedString(root.Element("description"));
                dlpPolicyTemplateMetaData.LocalizedKeywords     = (from localizedKeyword in root.Element("keywords").Elements("keyword")
                                                                   select DlpPolicyParser.ParseLocalizedString(localizedKeyword)).ToList <Dictionary <string, string> >();
                dlpPolicyTemplateMetaData.RuleParameters = (from ruleParameter in root.Element("ruleParameters").Elements("ruleParameter")
                                                            select new DlpTemplateRuleParameter
                {
                    Type = ruleParameter.Attribute("type").Value.Trim(),
                    Required = bool.Parse(ruleParameter.Attribute("required").Value),
                    Token = ruleParameter.Attribute("token").Value.Trim(),
                    LocalizedDescriptions = DlpPolicyParser.ParseLocalizedString(ruleParameter.Element("description"))
                }).ToList <DlpTemplateRuleParameter>();
                dlpPolicyTemplateMetaData.PolicyCommands = (from policyCommand in root.Element("policyCommands").Elements("commandBlock")
                                                            select policyCommand.Value.Trim()).ToList <string>();
                dlpPolicyTemplateMetaData.LocalizedPolicyCommandResources = (from localizedResource in root.Element("policyCommandsResources").Elements("resource")
                                                                             select new KeyValuePair <string, Dictionary <string, string> >(localizedResource.Attribute("token").Value.Trim(), DlpPolicyParser.ParseLocalizedString(localizedResource))).ToDictionary((KeyValuePair <string, Dictionary <string, string> > pair) => pair.Key, (KeyValuePair <string, Dictionary <string, string> > pair) => pair.Value, StringComparer.OrdinalIgnoreCase);
                DlpPolicyTemplateMetaData dlpPolicyTemplateMetaData2 = dlpPolicyTemplateMetaData;
                dlpPolicyTemplateMetaData2.Validate();
                result = dlpPolicyTemplateMetaData2;
            }
            catch (ArgumentException innerException)
            {
                throw new DlpPolicyParsingException(Strings.DlpPolicyStateStateInvalid, innerException);
            }
            catch (NullReferenceException innerException2)
            {
                throw new DlpPolicyParsingException(Strings.DlpPolicyXmlMissingElements, innerException2);
            }
            catch (XmlException innerException3)
            {
                throw new DlpPolicyParsingException(Strings.DlpPolicyXmlInvalid, innerException3);
            }
            return(result);
        }