Esempio n. 1
0
        /// <summary>
        /// Returns a value indicating whether this instance is equal to the specified ResourceKey.
        /// </summary>
        /// <param name="resourceKey">A ResourceKey to compare with this instance.</param>
        /// <returns><b>true</b> if resourceKey equals the value of this instance; otherwise, <b>false</b>.</returns>
        public bool Equals(ResourceKey resourceKey)
        {
            if (resourceKey == null)
            {
                return false;
            }

            if (resourceKey.resourceName != resourceName)
            {
                return false;
            }

            if (resourceKey.cultureInfo.LCID != cultureInfo.LCID)
            {
                return false;
            }

            return true;
        }
Esempio n. 2
0
        /// <summary>
        /// Determines if the specified value matches the specified Regex.
        /// </summary>
        /// <param name="value">The value to match.</param>
        /// <param name="resourceName">The name of the Regex to match against.</param>
        /// <returns><b>true</b> if the value matches the Regex; otherwise, <b>false</b>.</returns>
        private static bool IsMatch(string value, string pattern)
        {
            ValidationUtility.ValidateArgument("value", value, false);

            ResourceKey resourceKey = new ResourceKey(pattern, CultureInfo.CurrentUICulture);
            Regex regex = GetRegex(resourceKey);
            return regex.IsMatch(value);
        }
Esempio n. 3
0
        /// <summary>
        /// Retrieves a Regex identified by pattern.
        /// </summary>
        /// <param name="resourceKey">The resource key of the Regex.</param>
        /// <returns>The Regex for the specified resource key.</returns>
        private static Regex GetRegex(ResourceKey resourceKey)
        {
            Regex regex;

            if (regexes.TryGetValue(resourceKey, out regex) == false)
            {
                regex = new Regex(resourceKey.ResourceName, RegexOptions.Compiled);
                regexes.Add(resourceKey, regex);
            }

            return regex;
        }