protected override XmlNode GetFormSettingsParentNode(FormSettings.FormSettingsType formSettingsType) { string b = SchemaParser1_1.FormSettingsTypeToXmlTypeName[formSettingsType]; foreach (XmlNode xmlNode in this.GetFormNodesInFormSettings()) { XmlAttribute attribute = xmlNode.Attributes["type", "http://www.w3.org/2001/XMLSchema-instance"]; string a; if (ExtensionDataHelper.TryGetNameSpaceStrippedAttributeValue(attribute, out a) && string.Equals(a, b)) { return(xmlNode); } } return(null); }
private bool TryCreateActivationRuleInternal(XmlNode node, out ActivationRule activationRule) { activationRule = null; if (node == null || node.Attributes == null) { return(false); } XmlAttribute xmlAttribute = node.Attributes["type", "http://www.w3.org/2001/XMLSchema-instance"]; string a; if (!ExtensionDataHelper.TryGetNameSpaceStrippedAttributeValue(xmlAttribute, out a)) { return(false); } if (!string.Equals(a, "ItemIs", StringComparison.Ordinal)) { if (string.Equals(a, "ItemHasKnownEntity", StringComparison.Ordinal)) { KnownEntityType entityType; if (EnumValidator.TryParse <KnownEntityType>(node.Attributes["EntityType"].Value, EnumParseOptions.Default, out entityType)) { XmlAttribute xmlAttribute2 = node.Attributes["FilterName"]; XmlAttribute xmlAttribute3 = node.Attributes["RegExFilter"]; bool ignoreCase = SchemaParser.ParseBoolFromXmlAttribute(node.Attributes["IgnoreCase"]); activationRule = new ItemHasKnownEntityRule(entityType, (xmlAttribute2 != null) ? xmlAttribute2.Value : null, (xmlAttribute3 != null) ? xmlAttribute3.Value : null, ignoreCase); return(true); } } else if (string.Equals(a, "ItemHasRegularExpressionMatch", StringComparison.Ordinal)) { RegExPropertyName propertyName; if (EnumValidator.TryParse <RegExPropertyName>(node.Attributes["PropertyName"].Value, EnumParseOptions.Default, out propertyName)) { bool ignoreCase2 = SchemaParser.ParseBoolFromXmlAttribute(node.Attributes["IgnoreCase"]); activationRule = new ItemHasRegularExpressionMatchRule(node.Attributes["RegExName"].Value, node.Attributes["RegExValue"].Value, propertyName, ignoreCase2); return(true); } } else { if (string.Equals(a, "ItemHasAttachment", StringComparison.Ordinal)) { activationRule = new ItemHasAttachmentRule(); return(true); } if (node.ChildNodes != null && 0 < node.ChildNodes.Count && string.Equals(a, "RuleCollection", StringComparison.Ordinal)) { ActivationRule[] array = new ActivationRule[node.ChildNodes.Count]; int num = 0; foreach (object obj in node.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; ActivationRule activationRule2; if (this.IsExpectedOweNamespace(xmlNode.NamespaceURI) && string.Equals(xmlNode.LocalName, "Rule", StringComparison.Ordinal) && this.TryCreateActivationRuleInternal(xmlNode, out activationRule2)) { array[num++] = activationRule2; } } xmlAttribute = node.Attributes["Mode"]; activationRule = new CollectionRule((xmlAttribute == null) ? "Or" : xmlAttribute.Value, array); return(true); } } return(false); } ItemIsRuleItemType itemType; if (EnumValidator.TryParse <ItemIsRuleItemType>(node.Attributes["ItemType"].Value, EnumParseOptions.Default, out itemType)) { XmlAttribute xmlAttribute4 = node.Attributes["FormType"]; ItemIsRuleFormType formType; if (xmlAttribute4 == null || !EnumValidator.TryParse <ItemIsRuleFormType>(xmlAttribute4.Value, EnumParseOptions.Default, out formType)) { formType = ItemIsRuleFormType.Read; } bool includeSubClasses = SchemaParser.ParseBoolFromXmlAttribute(node.Attributes["IncludeSubClasses"]); XmlAttribute xmlAttribute5 = node.Attributes["ItemClass"]; activationRule = new ItemIsRule(itemType, (xmlAttribute5 != null) ? xmlAttribute5.Value : null, includeSubClasses, formType); return(true); } return(false); }
public void ValidateRules() { RequestedCapabilities requestedCapabilities = this.GetRequestedCapabilities(); using (XmlNodeList xmlNodeList = this.xmlDoc.SelectNodes(this.GetOweXpath("Rule"), this.namespaceManager)) { int num = 0; int num2 = 0; HashSet <string> hashSet = null; HashSet <string> hashSet2 = null; int num3 = 0; foreach (object obj in xmlNodeList) { XmlNode xmlNode = (XmlNode)obj; XmlAttribute attribute = xmlNode.Attributes["type", "http://www.w3.org/2001/XMLSchema-instance"]; string a; if (ExtensionDataHelper.TryGetNameSpaceStrippedAttributeValue(attribute, out a)) { if (string.Equals(a, "RuleCollection", StringComparison.Ordinal)) { num2++; } else { num++; } if (num > 15 || num2 > 15) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonTooManyRule(15))); } if (string.Equals(a, "ItemIs", StringComparison.Ordinal)) { SchemaParser.ValidateItemIsRule(xmlNode); } else if (string.Equals(a, "ItemHasKnownEntity", StringComparison.Ordinal)) { SchemaParser.ValidateItemHasKnownEntityRule(xmlNode, requestedCapabilities, ref hashSet2, ref num3); } else if (string.Equals(a, "ItemHasRegularExpressionMatch", StringComparison.Ordinal)) { num3++; if (hashSet == null) { hashSet = new HashSet <string>(); } string attributeStringValue = ExtensionData.GetAttributeStringValue(xmlNode, "RegExName"); if (!hashSet.Add(attributeStringValue)) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonMultipleRulesWithSameRegExName(attributeStringValue))); } if (requestedCapabilities == RequestedCapabilities.Restricted) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonNoRegexRuleInRestricted)); } if (num3 > 5) { throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonTooManyRegexRule(5))); } SchemaParser.ValidateRegEx(attributeStringValue, ExtensionData.GetAttributeStringValue(xmlNode, "RegExValue"), "ItemHasRegularExpressionMatch", "RegExValue"); } } } } }