コード例 #1
0
        public override void Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, string tagName, string ID, IDictionary attribs)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            foreach (FilteredAttributeDictionary dictionary2 in ControlBuilder.ConvertDictionaryToParsedAttributeCollection(attribs).GetFilteredAttributeDictionaries())
            {
                string filter = dictionary2.Filter;
                foreach (DictionaryEntry entry in (IEnumerable)dictionary2)
                {
                    string key = (string)entry.Key;
                    if (StringUtil.EqualsIgnoreCase(key, "ContentPlaceHolderID"))
                    {
                        if (this._contentPlaceHolder != null)
                        {
                            throw new HttpException(System.Web.SR.GetString("Content_only_one_contentPlaceHolderID_allowed"));
                        }
                        this._contentPlaceHolder       = entry.Value.ToString();
                        this._contentPlaceHolderFilter = filter;
                    }
                    else if (attributesToPreserve.Contains <string>(key, StringComparer.OrdinalIgnoreCase))
                    {
                        dictionary[key] = entry.Value.ToString();
                    }
                }
            }
            if (!parser.FInDesigner)
            {
                if (this._contentPlaceHolder == null)
                {
                    throw new HttpException(System.Web.SR.GetString("Control_Missing_Attribute", new object[] { "ContentPlaceHolderID", type.Name }));
                }
                attribs.Clear();
                foreach (KeyValuePair <string, string> pair in dictionary)
                {
                    attribs[pair.Key] = pair.Value;
                }
            }
            base.Init(parser, parentBuilder, type, tagName, ID, attribs);
        }