Example #1
0
        // Called to process register directive on pages
        internal void ProcessTagNamespaceRegistration(TagNamespaceRegisterEntry nsRegisterEntry)
        {
            string tagPrefix = nsRegisterEntry.TagPrefix;

            // See if there are entries registered in config with same tag prefix
            ArrayList registerEntries = null;

            if (_tagNamespaceRegisterEntries != null)
            {
                registerEntries = (ArrayList)_tagNamespaceRegisterEntries[tagPrefix];
            }

            // If there are config-based entries, and theres no mapper for them, make sure
            // a mapper has been created
            // We need all namespaces for a particular tag prefix to have a mapper, so we
            // can look for ambiguous types when a tag is parsed.
            if ((registerEntries != null) &&
                ((_prefixedMappers == null) || (_prefixedMappers[tagPrefix] == null)))
            {
                ProcessTagNamespaceRegistration(registerEntries);
            }
            ProcessTagNamespaceRegistrationCore(nsRegisterEntry);
        }
Example #2
0
        private void ProcessTagNamespaceRegistrationCore(TagNamespaceRegisterEntry nsRegisterEntry)
        {
            // Load the assembly if it was specified
            Assembly assembly = null;

            if (!String.IsNullOrEmpty(nsRegisterEntry.AssemblyName))
            {
                assembly = _parser.AddAssemblyDependency(nsRegisterEntry.AssemblyName);
            }

            // Import the namespace if there is one
            if (!String.IsNullOrEmpty(nsRegisterEntry.Namespace))
            {
                _parser.AddImportEntry(nsRegisterEntry.Namespace);
            }

            // Create a mapper for this specific namespace/assembly pair
            NamespaceTagNameToTypeMapper mapper = new NamespaceTagNameToTypeMapper(nsRegisterEntry, assembly, _parser);

            // Figure out which prefix mapper this new namespace mapper goes into
            if (_prefixedMappers == null)
            {
                _prefixedMappers = new Hashtable(StringComparer.OrdinalIgnoreCase);
            }

            TagPrefixTagNameToTypeMapper prefixMapper = (TagPrefixTagNameToTypeMapper)_prefixedMappers[nsRegisterEntry.TagPrefix];

            if (prefixMapper == null)
            {
                prefixMapper = new TagPrefixTagNameToTypeMapper(nsRegisterEntry.TagPrefix);
                _prefixedMappers[nsRegisterEntry.TagPrefix] = prefixMapper;
            }

            prefixMapper.AddNamespaceMapper(mapper);

            TagRegisterEntries.Add(nsRegisterEntry);
        }
 internal void FillInRegisterEntries()
 {
     TagNamespaceRegisterEntryTable table = new TagNamespaceRegisterEntryTable();
     foreach (TagNamespaceRegisterEntry entry in DefaultTagNamespaceRegisterEntries)
     {
         table[entry.TagPrefix] = new ArrayList(new object[] { entry });
     }
     Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);
     foreach (TagPrefixInfo info in this.Controls)
     {
         if (!string.IsNullOrEmpty(info.TagName))
         {
             UserControlRegisterEntry entry2 = new UserControlRegisterEntry(info.TagPrefix, info.TagName) {
                 ComesFromConfig = true
             };
             try
             {
                 entry2.UserControlSource = VirtualPath.CreateNonRelative(info.Source);
             }
             catch (Exception exception)
             {
                 throw new ConfigurationErrorsException(exception.Message, exception, info.ElementInformation.Properties["src"].Source, info.ElementInformation.Properties["src"].LineNumber);
             }
             hashtable[entry2.Key] = entry2;
         }
         else if (!string.IsNullOrEmpty(info.Namespace))
         {
             TagNamespaceRegisterEntry entry3 = new TagNamespaceRegisterEntry(info.TagPrefix, info.Namespace, info.Assembly);
             ArrayList list = null;
             list = (ArrayList) table[info.TagPrefix];
             if (list == null)
             {
                 list = new ArrayList();
                 table[info.TagPrefix] = list;
             }
             list.Add(entry3);
         }
     }
     this._tagNamespaceRegisterEntries = table;
     this._userControlRegisterEntries = hashtable;
 }
 internal NamespaceTagNameToTypeMapper(TagNamespaceRegisterEntry nsRegisterEntry, Assembly assembly, TemplateParser parser) {
     _nsRegisterEntry = nsRegisterEntry;
     _assembly = assembly;
     _parser = parser;
 }
        private void ProcessTagNamespaceRegistrationCore(TagNamespaceRegisterEntry nsRegisterEntry) {
            // Load the assembly if it was specified
            Assembly assembly = null;
            if (!String.IsNullOrEmpty(nsRegisterEntry.AssemblyName))
                assembly = _parser.AddAssemblyDependency(nsRegisterEntry.AssemblyName);

            // Import the namespace if there is one
            if (!String.IsNullOrEmpty(nsRegisterEntry.Namespace))
                _parser.AddImportEntry(nsRegisterEntry.Namespace);

            // Create a mapper for this specific namespace/assembly pair
            NamespaceTagNameToTypeMapper mapper = new NamespaceTagNameToTypeMapper(nsRegisterEntry, assembly, _parser);

            // Figure out which prefix mapper this new namespace mapper goes into
            if (_prefixedMappers == null) {
                _prefixedMappers = new Hashtable(StringComparer.OrdinalIgnoreCase);
            }

            TagPrefixTagNameToTypeMapper prefixMapper = (TagPrefixTagNameToTypeMapper)_prefixedMappers[nsRegisterEntry.TagPrefix];
            if (prefixMapper == null) {
                prefixMapper = new TagPrefixTagNameToTypeMapper(nsRegisterEntry.TagPrefix);
                _prefixedMappers[nsRegisterEntry.TagPrefix] = prefixMapper;
            }

            prefixMapper.AddNamespaceMapper(mapper);

            TagRegisterEntries.Add(nsRegisterEntry);
        }
        // Called to process register directive on pages
        internal void ProcessTagNamespaceRegistration(TagNamespaceRegisterEntry nsRegisterEntry) {
            string tagPrefix = nsRegisterEntry.TagPrefix;

            // See if there are entries registered in config with same tag prefix
            ArrayList registerEntries = null;
            if (_tagNamespaceRegisterEntries != null) {
                registerEntries = (ArrayList)_tagNamespaceRegisterEntries[tagPrefix];
            }

            // If there are config-based entries, and theres no mapper for them, make sure
            // a mapper has been created
            // We need all namespaces for a particular tag prefix to have a mapper, so we
            // can look for ambiguous types when a tag is parsed.
            if ((registerEntries != null) &&
                ((_prefixedMappers == null) || (_prefixedMappers[tagPrefix] == null))) {
                ProcessTagNamespaceRegistration(registerEntries);
            }
            ProcessTagNamespaceRegistrationCore(nsRegisterEntry);
        }
Example #7
0
 internal NamespaceTagNameToTypeMapper(TagNamespaceRegisterEntry nsRegisterEntry, Assembly assembly, TemplateParser parser)
 {
     _nsRegisterEntry = nsRegisterEntry;
     _assembly        = assembly;
     _parser          = parser;
 }
        internal void FillInRegisterEntries() {
            // 





            TagNamespaceRegisterEntryTable tagNamespaceRegisterEntries = new TagNamespaceRegisterEntryTable();
            foreach (TagNamespaceRegisterEntry entry in DefaultTagNamespaceRegisterEntries) {
                tagNamespaceRegisterEntries[entry.TagPrefix] = new ArrayList(new object[] { entry });
            }

            Hashtable userControlRegisterEntries = new Hashtable(StringComparer.OrdinalIgnoreCase);

            // Fill in the collection
            foreach (TagPrefixInfo tpi in Controls) {
                if (!String.IsNullOrEmpty(tpi.TagName)) {
                    UserControlRegisterEntry ucRegisterEntry = new UserControlRegisterEntry(tpi.TagPrefix, tpi.TagName);
                    ucRegisterEntry.ComesFromConfig = true;
                    try {
                        ucRegisterEntry.UserControlSource = VirtualPath.CreateNonRelative(tpi.Source);
                    }
                    catch (Exception e) {
                        throw new ConfigurationErrorsException(e.Message, e,
                            tpi.ElementInformation.Properties["src"].Source,
                            tpi.ElementInformation.Properties["src"].LineNumber);
                    }

                    userControlRegisterEntries[ucRegisterEntry.Key] = ucRegisterEntry;
                }
                else if (!String.IsNullOrEmpty(tpi.Namespace)) {
                    TagNamespaceRegisterEntry nsRegisterEntry = new TagNamespaceRegisterEntry(tpi.TagPrefix, tpi.Namespace, tpi.Assembly);
                    ArrayList entries = null;

                    entries = (ArrayList)tagNamespaceRegisterEntries[tpi.TagPrefix];
                    if (entries == null) {
                        entries = new ArrayList();
                        tagNamespaceRegisterEntries[tpi.TagPrefix] = entries;
                    }

                    entries.Add(nsRegisterEntry);
                }
            }

            _tagNamespaceRegisterEntries = tagNamespaceRegisterEntries;
            _userControlRegisterEntries = userControlRegisterEntries;
        }
 private void ProcessTagNamespaceRegistrationCore(TagNamespaceRegisterEntry nsRegisterEntry)
 {
     Assembly assembly = null;
     if (!string.IsNullOrEmpty(nsRegisterEntry.AssemblyName))
     {
         assembly = this._parser.AddAssemblyDependency(nsRegisterEntry.AssemblyName);
     }
     if (!string.IsNullOrEmpty(nsRegisterEntry.Namespace))
     {
         this._parser.AddImportEntry(nsRegisterEntry.Namespace);
     }
     NamespaceTagNameToTypeMapper mapper = new NamespaceTagNameToTypeMapper(nsRegisterEntry, assembly, this._parser);
     if (this._prefixedMappers == null)
     {
         this._prefixedMappers = new Hashtable(StringComparer.OrdinalIgnoreCase);
     }
     TagPrefixTagNameToTypeMapper mapper2 = (TagPrefixTagNameToTypeMapper) this._prefixedMappers[nsRegisterEntry.TagPrefix];
     if (mapper2 == null)
     {
         mapper2 = new TagPrefixTagNameToTypeMapper(nsRegisterEntry.TagPrefix);
         this._prefixedMappers[nsRegisterEntry.TagPrefix] = mapper2;
     }
     mapper2.AddNamespaceMapper(mapper);
     this.TagRegisterEntries.Add(nsRegisterEntry);
 }
 internal void ProcessTagNamespaceRegistration(TagNamespaceRegisterEntry nsRegisterEntry)
 {
     string tagPrefix = nsRegisterEntry.TagPrefix;
     ArrayList nsRegisterEntries = null;
     if (this._tagNamespaceRegisterEntries != null)
     {
         nsRegisterEntries = (ArrayList) this._tagNamespaceRegisterEntries[tagPrefix];
     }
     if ((nsRegisterEntries != null) && ((this._prefixedMappers == null) || (this._prefixedMappers[tagPrefix] == null)))
     {
         this.ProcessTagNamespaceRegistration(nsRegisterEntries);
     }
     this.ProcessTagNamespaceRegistrationCore(nsRegisterEntry);
 }
        internal override void ProcessDirective(string directiveName, IDictionary directive) {
            if (StringUtil.EqualsIgnoreCase(directiveName, "register")) {
                // Register directive

                // Get the tagprefix, which is required
                string tagPrefix = Util.GetAndRemoveNonEmptyIdentifierAttribute(directive,
                    "tagprefix", true /*required*/);

                string tagName = Util.GetAndRemoveNonEmptyIdentifierAttribute(directive,
                    _tagnameString, false /*required*/);

                VirtualPath src = Util.GetAndRemoveVirtualPathAttribute(directive, 
                    _sourceString, false /*required*/);

                string ns = Util.GetAndRemoveNonEmptyNoSpaceAttribute(directive, 
                    _namespaceString, false /*required*/);

                // An Assembly can optionally be specified (ASURT 61326/VSWhidbey 87050)
                string assemblyName = Util.GetAndRemoveNonEmptyAttribute(directive, "assembly",
                    false /*required*/);

                RegisterDirectiveEntry registerEntry;
                if (tagName != null) {
                    // It's a user control registration

                    // 'src' is required
                    if (src == null) {
                        throw new HttpException(SR.GetString(SR.Missing_attr, _sourceString));
                    }

                    // 'namespace' is not allowed
                    if (ns != null) {
                        throw new HttpException(
                            SR.GetString(SR.Invalid_attr, _namespaceString, "tagname"));
                    }

                    // 'assembly' is not allowed
                    if (assemblyName != null) {
                        throw new HttpException(
                            SR.GetString(SR.Invalid_attr, "assembly", "tagname"));
                    }

                    UserControlRegisterEntry ucRegisterEntry = new UserControlRegisterEntry(tagPrefix, tagName);
                    ucRegisterEntry.UserControlSource = src;
                    registerEntry = ucRegisterEntry;

                    TypeMapper.ProcessUserControlRegistration(ucRegisterEntry);
                }
                else if (src != null) {
                    // It's missing the tagname attribute.
                    throw new HttpException(SR.GetString(SR.Missing_attr, _tagnameString));
                }
                else {
                    // It's a namespace prefix registration
                    // 'namespace' is required
                    if (ns == null) {
                        throw new HttpException(SR.GetString(SR.Missing_attr, _namespaceString));
                    }

                    TagNamespaceRegisterEntry nsRegisterEntry = new TagNamespaceRegisterEntry(tagPrefix, ns, assemblyName);
                    registerEntry = nsRegisterEntry;

                    TypeMapper.ProcessTagNamespaceRegistration(nsRegisterEntry);
                }

                registerEntry.Line = _lineNumber;
                registerEntry.VirtualPath = CurrentVirtualPathString;

                // If there are some attributes left, fail
                Util.CheckUnknownDirectiveAttributes(directiveName, directive);
            }
            else {
                base.ProcessDirective(directiveName, directive);
            }
        }
 internal override void ProcessDirective(string directiveName, IDictionary directive)
 {
     if (StringUtil.EqualsIgnoreCase(directiveName, "register"))
     {
         RegisterDirectiveEntry entry;
         string tagPrefix = System.Web.UI.Util.GetAndRemoveNonEmptyIdentifierAttribute(directive, "tagprefix", true);
         string tagName = System.Web.UI.Util.GetAndRemoveNonEmptyIdentifierAttribute(directive, "tagname", false);
         VirtualPath path = System.Web.UI.Util.GetAndRemoveVirtualPathAttribute(directive, "src", false);
         string namespaceName = System.Web.UI.Util.GetAndRemoveNonEmptyNoSpaceAttribute(directive, "namespace", false);
         string assemblyName = System.Web.UI.Util.GetAndRemoveNonEmptyAttribute(directive, "assembly", false);
         if (tagName != null)
         {
             if (path == null)
             {
                 throw new HttpException(System.Web.SR.GetString("Missing_attr", new object[] { "src" }));
             }
             if (namespaceName != null)
             {
                 throw new HttpException(System.Web.SR.GetString("Invalid_attr", new object[] { "namespace", "tagname" }));
             }
             if (assemblyName != null)
             {
                 throw new HttpException(System.Web.SR.GetString("Invalid_attr", new object[] { "assembly", "tagname" }));
             }
             UserControlRegisterEntry ucRegisterEntry = new UserControlRegisterEntry(tagPrefix, tagName) {
                 UserControlSource = path
             };
             entry = ucRegisterEntry;
             base.TypeMapper.ProcessUserControlRegistration(ucRegisterEntry);
         }
         else
         {
             if (path != null)
             {
                 throw new HttpException(System.Web.SR.GetString("Missing_attr", new object[] { "tagname" }));
             }
             if (namespaceName == null)
             {
                 throw new HttpException(System.Web.SR.GetString("Missing_attr", new object[] { "namespace" }));
             }
             TagNamespaceRegisterEntry nsRegisterEntry = new TagNamespaceRegisterEntry(tagPrefix, namespaceName, assemblyName);
             entry = nsRegisterEntry;
             base.TypeMapper.ProcessTagNamespaceRegistration(nsRegisterEntry);
         }
         entry.Line = base._lineNumber;
         entry.VirtualPath = base.CurrentVirtualPathString;
         System.Web.UI.Util.CheckUnknownDirectiveAttributes(directiveName, directive);
     }
     else
     {
         base.ProcessDirective(directiveName, directive);
     }
 }
        internal override void ProcessDirective(string directiveName, IDictionary directive)
        {
            if (StringUtil.EqualsIgnoreCase(directiveName, "register"))
            {
                // Register directive

                // Get the tagprefix, which is required
                string tagPrefix = Util.GetAndRemoveNonEmptyIdentifierAttribute(directive,
                                                                                "tagprefix", true /*required*/);

                string tagName = Util.GetAndRemoveNonEmptyIdentifierAttribute(directive,
                                                                              _tagnameString, false /*required*/);

                VirtualPath src = Util.GetAndRemoveVirtualPathAttribute(directive,
                                                                        _sourceString, false /*required*/);

                string ns = Util.GetAndRemoveNonEmptyNoSpaceAttribute(directive,
                                                                      _namespaceString, false /*required*/);

                // An Assembly can optionally be specified (ASURT 61326/VSWhidbey 87050)
                string assemblyName = Util.GetAndRemoveNonEmptyAttribute(directive, "assembly",
                                                                         false /*required*/);

                RegisterDirectiveEntry registerEntry;
                if (tagName != null)
                {
                    // It's a user control registration

                    // 'src' is required
                    if (src == null)
                    {
                        throw new HttpException(SR.GetString(SR.Missing_attr, _sourceString));
                    }

                    // 'namespace' is not allowed
                    if (ns != null)
                    {
                        throw new HttpException(
                                  SR.GetString(SR.Invalid_attr, _namespaceString, "tagname"));
                    }

                    // 'assembly' is not allowed
                    if (assemblyName != null)
                    {
                        throw new HttpException(
                                  SR.GetString(SR.Invalid_attr, "assembly", "tagname"));
                    }

                    UserControlRegisterEntry ucRegisterEntry = new UserControlRegisterEntry(tagPrefix, tagName);
                    ucRegisterEntry.UserControlSource = src;
                    registerEntry = ucRegisterEntry;

                    TypeMapper.ProcessUserControlRegistration(ucRegisterEntry);
                }
                else if (src != null)
                {
                    // It's missing the tagname attribute.
                    throw new HttpException(SR.GetString(SR.Missing_attr, _tagnameString));
                }
                else
                {
                    // It's a namespace prefix registration
                    // 'namespace' is required
                    if (ns == null)
                    {
                        throw new HttpException(SR.GetString(SR.Missing_attr, _namespaceString));
                    }

                    TagNamespaceRegisterEntry nsRegisterEntry = new TagNamespaceRegisterEntry(tagPrefix, ns, assemblyName);
                    registerEntry = nsRegisterEntry;

                    TypeMapper.ProcessTagNamespaceRegistration(nsRegisterEntry);
                }

                registerEntry.Line        = _lineNumber;
                registerEntry.VirtualPath = CurrentVirtualPathString;

                // If there are some attributes left, fail
                Util.CheckUnknownDirectiveAttributes(directiveName, directive);
            }
            else
            {
                base.ProcessDirective(directiveName, directive);
            }
        }