Exemplo n.º 1
0
            public HtmlInputItem(HtmlButtonGroup group, IHtmlElement element)
            {
                _group = group;

                if (!element.Name.EqualsIgnoreCase("input"))
                {
                    throw new InvalidOperationException();
                }

                var type = element.Attribute("type").Value();

                if (type.EqualsIgnoreCase("radio"))
                {
                    radio = true;
                }

                else if (type.EqualsIgnoreCase("checkbox"))
                {
                    radio = false;
                }

                else
                {
                    throw new InvalidOperationException();
                }

                if (string.IsNullOrEmpty(element.Attribute("name").Value()))
                {
                    throw new InvalidOperationException();
                }

                _element = element;
            }
Exemplo n.º 2
0
        private static IHtmlContainer FindContainer(HtmlButtonGroup group)
        {
            var container = group.Items.Select(i => i.Element).Aggregate((item1, item2) =>
            {
                return(item1.AncestorsAndSelf().FirstOrDefault(e => e.IsAncestorOf(item2) || e.Equals(item2)));
            });

            return(container);//没有处理文档为公共容器的情况。
        }
Exemplo n.º 3
0
        /// <summary>
        /// 重新扫描表单中所有控件
        /// </summary>
        public void RefreshForm()
        {
            textControls =
                Element.Find("input[type=text][name] , input[type=password][name] , input[type=hidden][name]")
                .Select(e => new HtmlInputText(this, e)).Cast <IHtmlTextControl>()
                .Union(Element.Find("textarea[name]").Select(e => new HtmlTextArea(this, e)).Cast <IHtmlTextControl>())
                .ForAll(control => controlsTable.Add(control.Name, control))
                .ToArray();


            groupControls =
                Element.Find("select[name]")
                .Select(select => new HtmlSelect(this, select)).Cast <IHtmlGroupControl>()
                .Union(HtmlButtonGroup.CaptureInputGroups(this).Cast <IHtmlGroupControl>())
                .ForAll(control => controlsTable.Add(control.Name, control))
                .ToArray();



            labels = Element.Find("label[for]").Select(e => new HtmlLabel(this, e)).ToArray();

            labels.GroupBy(l => l.ForElementId).ForAll(grouping =>
                                                       labelsTable.Add(grouping.Key, grouping.ToArray()));
        }
Exemplo n.º 4
0
            public HtmlInputItem( HtmlButtonGroup group, IHtmlElement element )
            {
                _group = group;

                if ( !element.Name.EqualsIgnoreCase( "input" ) )
                  throw new InvalidOperationException();

                var type = element.Attribute( "type" ).Value();

                if ( type.EqualsIgnoreCase( "radio" ) )
                  radio = true;

                else if ( type.EqualsIgnoreCase( "checkbox" ) )
                  radio = false;

                else
                  throw new InvalidOperationException();

                if ( string.IsNullOrEmpty( element.Attribute( "name" ).Value() ) )
                  throw new InvalidOperationException();

                _element = element;
            }
Exemplo n.º 5
0
        private static IHtmlContainer FindContainer( HtmlButtonGroup group )
        {
            var container = group.Items.Select( i => i.Element ).Aggregate( ( item1, item2 ) =>
            {
              return item1.AncestorsAndSelf().FirstOrDefault( e => e.IsAncestorOf( item2 ) || e.Equals( item2 ) );

            } );

              return container;//没有处理文档为公共容器的情况。
        }