Beispiel #1
0
        /// <summary>
        /// Adds the definitions to the list (called on Register directive)
        /// </summary>
        public void AddTagPrefixDefinition(TagPrefixDefinition def)
        {
            if (def == null)
            {
                throw new ArgumentNullException("def");
            }

            definitions.Add(def);
        }
Beispiel #2
0
        /// <summary>
        /// Determines whether specified attribute has specified type
        /// </summary>
        /// <param name="prefix">Prefix of the element where attribute is located</param>
        /// <param name="element">Element name</param>
        /// <param name="attribute">Attribute name</param>
        /// <param name="targetType">Type to check</param>
        /// <param name="isLocalizableFalse">Output - true, if given property has [Localizable(false)] set</param>
        /// <returns>True, if attribute has specified type, null in case of inconclusive results, false otherwise</returns>
        public bool?IsTypeof(string prefix, string element, string attribute, Type targetType, out bool isLocalizableFalse)
        {
            isLocalizableFalse = false;

            // looking for exact match in source definitions
            TagPrefixDefinition exclusiveDefinition = null;

            foreach (TagPrefixSourceDefinition definition in definitions.OfType <TagPrefixSourceDefinition>())
            {
                if (definition.TagPrefix == prefix && definition.TagName == element)
                {
                    exclusiveDefinition = definition;
                    break;
                }
            }

            if (exclusiveDefinition != null)   // found -> resolve the type
            {
                return(exclusiveDefinition.Resolve(element, attribute, targetType, out isLocalizableFalse));
            }
            else     // not found -> try all definitions and return first conclusive (true or false) result
            {
                foreach (TagPrefixDefinition definition in definitions)
                {
                    if (definition.TagPrefix == prefix)
                    {
                        bool?result = definition.Resolve(element, attribute, targetType, out isLocalizableFalse);
                        if (result != null)
                        {
                            return(result);
                        }
                    }
                }
            }

            return(null);
        }