コード例 #1
0
ファイル: HtmlSelect.cs プロジェクト: ajayumi/Jumony
    internal HtmlSelect( HtmlForm form, IHtmlElement element )
      : base( form )
    {

      Element = element;
      options = element.Find( "option" ).Select( e => new HtmlOption( this, e ) ).ToArray();

    }
コード例 #2
0
ファイル: HtmlSelect.cs プロジェクト: neo2018/Jumony
        public HtmlSelect( HtmlForm form, IHtmlElement element )
        {
            if ( !element.Name.EqualsIgnoreCase( "select" ) )
            throw new InvalidOperationException();

              _form = form;

              _element = element;

              options = element.Find( "option" ).Select( e => new HtmlOption( this, e ) ).ToArray();
        }
コード例 #3
0
ファイル: HtmlSelect.cs プロジェクト: toddfsy/Jumony
        public HtmlSelect(HtmlForm form, IHtmlElement element)
        {
            if (!element.Name.EqualsIgnoreCase("select"))
            {
                throw new InvalidOperationException();
            }

            _form = form;

            _element = element;

            options = element.Find("option").Select(e => new HtmlOption(this, e)).ToArray();
        }
コード例 #4
0
ファイル: ContentAdapter.cs プロジェクト: zpzgone/Jumony
        /// <summary>
        /// 合并内容视图与母板视图的文档头
        /// </summary>
        /// <param name="masterHead">母板视图的文档头</param>
        /// <param name="contentHead">内容视图的文档头</param>
        /// <returns>合并后的 &lt;head&gt; 元素</returns>
        protected virtual IHtmlElement MergeHead(IHtmlElement masterHead, IHtmlElement contentHead)
        {
            var head = masterHead.Document.CreateFragment().AddElement("head");

            head.AddCopy(contentHead.Elements().Where(e => e.Attribute("ignore") == null));

            if (!head.Find("title").Any())
            {
                var title = masterHead.Find("title").FirstOrDefault();
                head.AddCopy(title);
            }


            {
                var existsStyleSheets = new HashSet <string>(head.Find("link[rel=stylesheet]").Select(e => e.Attribute("href").Value()), StringComparer.OrdinalIgnoreCase);
                foreach (var element in masterHead.Find("link[rel=stylesheet]"))
                {
                    if (!existsStyleSheets.Contains(element.Attribute("href").Value()))
                    {
                        head.AddCopy(element);
                    }
                }
            }

            {
                var existsScripts = new HashSet <string>(head.Find("script[src]").Select(e => e.Attribute("src").Value()), StringComparer.OrdinalIgnoreCase);
                foreach (var element in masterHead.Find("script[src]"))
                {
                    if (!existsScripts.Contains(element.Attribute("src").Value()))
                    {
                        head.AddCopy(element);
                    }
                }
            }

            return(head);
        }
コード例 #5
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()));
        }
コード例 #6
0
        private void GetUrlText_2(IHtmlDocument document, List <Class1> L_Class)
        {
            IEnumerable <IHtmlElement> result1 = document.Find(".list-items");

            foreach (var item in result1)
            {
                #region MyRegion
                Class1       _class  = new Class1();
                IHtmlElement item_a  = item.FindFirst("a");
                string       img_str = item.Exists("img") ? item.FindFirst("img").Attribute("src").Value() : "";
                _class.Image_Count = img_str.Length > 0 ? img_str.IndexOf("default.jpg") > 0?0:1:0;
                IEnumerable <IHtmlElement> div = item.Find("div");
                List <string> ls = new List <string>();
                foreach (var d in div)
                {
                    ls.Add(d.InnerText());
                }
                _class.TextName = ls[2];
                _class.SumMoney = ls[4];
                _class.Quyu     = "赶集";
                _class.Allpm    = ls[1];
                _class.Address  = ls[0];
                _class.href     = item_a.Attribute("href").Value().Trim();

                IEnumerable <IHtmlElement> ssa = item_a.Find("span");

                string item_aa = item_a.ToString().Replace("<!--", "stu1").Replace("-->", "stp2");
                item_aa         = item_aa.Substring(item_aa.IndexOf("stu1") + 4);
                item_aa         = item_aa.Substring(0, item_aa.IndexOf("stp2"));
                item_aa         = item_aa.Substring(item_aa.IndexOf(">") + 1);
                item_aa         = item_aa.Substring(0, item_aa.IndexOf("<"));
                _class.datetime = item_aa;
                string[] pm = _class.Allpm.Split(' ');

                double pm_int = Convert.ToDouble(pm[6].Replace('㎡', ' ').Trim().Length <= 0 ? pm[5].Replace('㎡', ' ').Trim() : pm[6].Replace('㎡', ' ').Trim());
                double ss     = ((Convert.ToDouble(_class.SumMoney.Replace("万元", "").Trim()) / pm_int));
                _class.PingMoney = "≈" + Convert.ToInt32(ss * 10000).ToString();
                _class.Image_str = _class.Image_Count > 0 ? "有" : string.Empty;

                L_Class.Add(_class);
                r++;
                #endregion
            }
        }
コード例 #7
0
ファイル: ContentAdapter.cs プロジェクト: ajayumi/Jumony
    /// <summary>
    /// 合并内容视图与母板视图的文档头
    /// </summary>
    /// <param name="masterHead">母板视图的文档头</param>
    /// <param name="contentHead">内容视图的文档头</param>
    /// <returns>合并后的 &lt;head&gt; 元素</returns>
    protected virtual IHtmlElement MergeHead( IHtmlElement masterHead, IHtmlElement contentHead )
    {

      var head = masterHead.Document.CreateFragment().AddElement( "head" );

      head.AddCopy( contentHead.Elements().Where( e => e.Attribute( "ignore" ) == null ) );

      if ( !head.Find( "title" ).Any() )
      {
        var title = masterHead.Find( "title" ).FirstOrDefault();
        head.AddCopy( title );
      }


      {
        var existsStyleSheets = new HashSet<string>( head.Find( "link[rel=stylesheet]" ).Select( e => e.Attribute( "href" ).Value() ), StringComparer.OrdinalIgnoreCase );
        foreach ( var element in masterHead.Find( "link[rel=stylesheet]" ) )
        {
          if ( !existsStyleSheets.Contains( element.Attribute( "href" ).Value() ) )
            head.AddCopy( element );
        }
      }

      {
        var existsScripts = new HashSet<string>( head.Find( "script[src]" ).Select( e => e.Attribute( "src" ).Value() ), StringComparer.OrdinalIgnoreCase );
        foreach ( var element in masterHead.Find( "script[src]" ) )
        {
          if ( !existsScripts.Contains( element.Attribute( "src" ).Value() ) )
            head.AddCopy( element );
        }
      }

      return head;
    }
コード例 #8
0
ファイル: HtmlSelect.cs プロジェクト: zpzgone/Jumony
 internal HtmlSelect(HtmlForm form, IHtmlElement element)
     : base(form)
 {
     Element = element;
     options = element.Find("option").Select(e => new HtmlOption(this, e)).ToArray();
 }