Exemple #1
0
        private static void ValidateItemHasKnownEntityRule(XmlNode xmlNode, RequestedCapabilities requestedCapabilities, ref HashSet <string> entitiesRegExNames, ref int regexCount)
        {
            if (requestedCapabilities == RequestedCapabilities.Restricted)
            {
                XmlAttribute attribute = xmlNode.Attributes["EntityType"];
                string       item;
                if (!ExtensionDataHelper.TryGetAttributeValue(attribute, out item) || !SchemaParser.AllowedEntityTypesInRestricted.Contains(item))
                {
                    throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonOnlySelectedEntitiesInRestricted));
                }
            }
            XmlAttribute attribute2 = xmlNode.Attributes["RegExFilter"];
            XmlAttribute attribute3 = xmlNode.Attributes["FilterName"];
            string       text;
            bool         flag = ExtensionDataHelper.TryGetAttributeValue(attribute3, out text);
            string       regexPattern;
            bool         flag2 = ExtensionDataHelper.TryGetAttributeValue(attribute2, out regexPattern);

            if (flag != flag2)
            {
                throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonRegExNameAndValueRequiredInEntitiesRules));
            }
            if (!flag)
            {
                XmlAttribute attribute4 = xmlNode.Attributes["IgnoreCase"];
                string       text2;
                if (ExtensionDataHelper.TryGetAttributeValue(attribute4, out text2))
                {
                    throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonIgnoreCaseWithoutRegExInEntitiesRules));
                }
                return;
            }
            else
            {
                regexCount++;
                if (entitiesRegExNames == null)
                {
                    entitiesRegExNames = new HashSet <string>();
                }
                else if (regexCount > 5)
                {
                    throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonTooManyRegexRule(5)));
                }
                if (!entitiesRegExNames.Add(text))
                {
                    throw new OwaExtensionOperationException(Strings.ErrorInvalidManifestData(Strings.ErrorReasonMultipleRulesWithSameFilterName(text)));
                }
                SchemaParser.ValidateRegEx(text, regexPattern, "ItemHasKnownEntity", "RegExFilter");
                return;
            }
        }
        // Token: 0x06000A76 RID: 2678 RVA: 0x00028E3C File Offset: 0x0002703C
        internal static bool TryGetNameSpaceStrippedAttributeValue(XmlAttribute attribute, out string value)
        {
            if (!ExtensionDataHelper.TryGetAttributeValue(attribute, out value))
            {
                return(false);
            }
            int num = value.LastIndexOf(':');

            if (-1 != num)
            {
                num++;
                value = value.Substring(num, value.Length - num);
                if (string.IsNullOrEmpty(value))
                {
                    return(false);
                }
            }
            return(true);
        }