/// <summary> /// 添加所有资源引用 /// </summary> /// <param name="document"></param> /// <param name="clearReferenceFirst"></param> public void AddAllReference(IHtmlDocument document, bool clearReferenceFirst = true) { if (document == null) { return; } if (clearReferenceFirst) { ClearAllReference(document); } var headElement = document.FindFirstOrDefault("head"); if (headElement == null) { var firstElement = document.Elements().FirstOrDefault(); if (firstElement != null) { headElement = firstElement.AddElementBeforeSelf("head"); } else { headElement = document.AddElement(0, "head"); } } AddStyleReferences(headElement, styleFiles); AddScriptReferences(headElement, scriptFiles); }
/// <summary> /// 对文档进行数据绑定 /// </summary> /// <param name="document">要进行数据绑定的文档</param> protected virtual void DataBind( IHtmlDocument document, object dataContext ) { var bindings = FindBindings( document ).OrderBy( b => b.Priority ); var context = new BindingContext( this, dataContext ); bindings.ForAll( b => b.DataBind( context ) ); document.Elements().ForAll( e => DataBind( e, context ) ); }
/// <summary> /// 对文档进行数据绑定 /// </summary> /// <param name="document">要进行数据绑定的文档</param> protected virtual void DataBind(IHtmlDocument document, object dataContext) { var bindings = FindBindings(document).OrderBy(b => b.Priority); var context = new BindingContext(this, dataContext); bindings.ForAll(b => b.DataBind(context)); document.Elements().ForAll(e => DataBind(e, context)); }
/// <summary> /// 添加所有资源引用 /// </summary> /// <param name="document"></param> /// <param name="clearReferenceFirst"></param> public void AddAllReference( IHtmlDocument document, bool clearReferenceFirst = true ) { if ( document == null ) return; if ( clearReferenceFirst ) ClearAllReference( document ); var headElement = document.FindFirstOrDefault( "head" ); if ( headElement == null ) { var firstElement = document.Elements().FirstOrDefault(); if ( firstElement != null ) headElement = firstElement.AddElementBeforeSelf( "head" ); else headElement = document.AddElement( 0, "head" ); } AddStyleReferences( headElement, styleFiles ); AddScriptReferences( headElement, scriptFiles ); }