Exemple #1
0
        public override void Init(TemplateParser parser,
                                  ControlBuilder parentBuilder,
                                  Type type,
                                  string tagName,
                                  string id,
                                  IDictionary attribs)
        {
            base.Init(parser, parentBuilder, type, tagName, id, attribs);

            PropertyInfo prop = parentBuilder.ControlType.GetProperty(tagName, FlagsNoCase);

            SetControlType(prop.PropertyType);

            MemberInfo[] mems = ControlType.GetMember("Item", MemberTypes.Property, FlagsNoCase & ~BindingFlags.IgnoreCase);
            if (mems.Length > 0)
            {
                possibleElementTypes = new Type [mems.Length];
                for (int i = 0; i < mems.Length; ++i)
                {
                    possibleElementTypes [i] = ((PropertyInfo)mems [i]).PropertyType;
                }
            }
            else
            {
                throw new HttpException("Collection of type '" + ControlType + "' does not have an indexer.");
            }
        }