// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+// This will provide extra information when trace is enabled. Might be too verbose.
+#define MONO_TRACE
+
using System;
using System.Collections;
using System.ComponentModel;
{
defaultNameArray = new string [100];
for (int i = 0 ; i < 100 ; i++)
- defaultNameArray [i] = "_ctrl" + i;
+ defaultNameArray [i] = "_ctl" + i;
}
public Control()
}
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- [EditorBrowsable (EditorBrowsableState.Never), Browsable (false)]\r
+ [EditorBrowsable (EditorBrowsableState.Never), Browsable (false)]
public Control BindingContainer {
get {
Control container = NamingContainer;
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
- [WebSysDescription ("An Identification of the control that is rendered.")]\r
- public virtual string ClientID {\r
- get {\r
- string client = UniqueID;\r
-\r
- if (client != null)\r
- client = client.Replace (':', '_');\r
-\r
- return client;\r
- }\r
- }\r
+ [WebSysDescription ("An Identification of the control that is rendered.")]
+ public virtual string ClientID {
+ get {
+ string client = UniqueID;
+
+ if (client != null)
+ client = client.Replace (':', '_');
+
+ return client;
+ }
+ }
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
- [WebSysDescription ("The child controls of this control.")]\r
- public virtual ControlCollection Controls //DIT\r
- {\r
- get\r
- {\r
- if (_controls == null) _controls = CreateControlCollection();\r
- return _controls;\r
- }\r
+ [WebSysDescription ("The child controls of this control.")]
+ public virtual ControlCollection Controls //DIT
+ {
+ get
+ {
+ if (_controls == null) _controls = CreateControlCollection();
+ return _controls;
+ }
}
[DefaultValue (true), WebCategory ("Behavior")]
- [WebSysDescription ("An Identification of the control that is rendered.")]\r
+ [WebSysDescription ("An Identification of the control that is rendered.")]
#if NET_2_0
[Themeable (true)]
#endif
}
[MergableProperty (false), ParenthesizePropertyName (true)]
- [WebSysDescription ("The name of the control that is rendered.")]\r
+ [WebSysDescription ("The name of the control that is rendered.")]
#if NET_2_0
[Filterable (true), Themeable (true)]
#endif
- public virtual string ID {\r
- get {\r
+ public virtual string ID {
+ get {
return (((stateMask & ID_SET) != 0) ? _userId : null);
- }\r
- \r
- set {\r
- if (value == "")\r
- value = null;\r
-\r
+ }
+
+ set {
+ if (value == "")
+ value = null;
+
stateMask |= ID_SET;
- _userId = value;\r
- NullifyUniqueID ();\r
- }\r
- }\r
+ _userId = value;
+ NullifyUniqueID ();
+ }
+ }
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
- [WebSysDescription ("The container that this control is part of. The control's name has to be unique within the container.")]\r
+ [WebSysDescription ("The container that this control is part of. The control's name has to be unique within the container.")]
public virtual Control NamingContainer {
get {
if (_namingContainer == null && _parent != null) {
}
return _namingContainer;
- }\r
+ }
}
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
- [WebSysDescription ("The webpage that this control resides on.")]\r
+ [WebSysDescription ("The webpage that this control resides on.")]
#if NET_2_0
[Bindable (true)]
#endif
- public virtual Page Page //DIT\r
- {\r
- get\r
- {\r
- if (_page == null && _parent != null) _page = _parent.Page;\r
- return _page;\r
- }\r
- set\r
- {\r
- _page = value;\r
- }\r
+ public virtual Page Page //DIT
+ {
+ get
+ {
+ if (_page == null && _parent != null) _page = _parent.Page;
+ return _page;
+ }
+ set
+ {
+ _page = value;
+ }
}
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
- [WebSysDescription ("The parent control of this control.")]\r
- public virtual Control Parent //DIT\r
- {\r
- get\r
- {\r
- return _parent;\r
- }\r
+ [WebSysDescription ("The parent control of this control.")]
+ public virtual Control Parent //DIT
+ {
+ get
+ {
+ return _parent;
+ }
}
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[EditorBrowsable (EditorBrowsableState.Advanced), Browsable (false)]
- [WebSysDescription ("The site this control is part of.")]\r
- public ISite Site //DIT\r
- {\r
- get\r
- {\r
- return _site;\r
- }\r
- set\r
- {\r
- _site = value;\r
- }\r
- }\r
+ [WebSysDescription ("The site this control is part of.")]
+ public ISite Site //DIT
+ {
+ get
+ {
+ return _site;
+ }
+ set
+ {
+ _site = value;
+ }
+ }
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
- [WebSysDescription ("The unique ID of the control.")]\r
- public virtual string UniqueID {\r
- get {\r
- if (uniqueID != null)\r
- return uniqueID;\r
-\r
- if (_namingContainer == null) {\r
- return _userId;\r
- }\r
-\r
- if (_userId == null)\r
- _userId = _namingContainer.GetDefaultName ();\r
-\r
- string prefix = _namingContainer.UniqueID;\r
- if (_namingContainer == _page || prefix == null) {\r
- uniqueID = _userId;\r
- return uniqueID;\r
- }\r
-\r
- uniqueID = prefix + ":" + _userId;\r
- return uniqueID;\r
- }\r
+ [WebSysDescription ("The unique ID of the control.")]
+ public virtual string UniqueID {
+ get {
+ if (uniqueID != null)
+ return uniqueID;
+
+ if (_namingContainer == null) {
+ return _userId;
+ }
+
+ if (_userId == null)
+ _userId = _namingContainer.GetDefaultName ();
+
+ string prefix = _namingContainer.UniqueID;
+ if (_namingContainer == _page || prefix == null) {
+ uniqueID = _userId;
+ return uniqueID;
+ }
+
+ uniqueID = prefix + ":" + _userId;
+ return uniqueID;
+ }
}
void SetMask (int m, bool val)
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- protected virtual HttpContext Context //DIT\r
- {\r
- get\r
- {\r
- HttpContext context;\r
- if (_context != null)\r
- return _context;\r
- if (_parent == null)\r
- return HttpContext.Current;\r
- context = _parent.Context;\r
- if (context != null)\r
- return context;\r
- return HttpContext.Current;\r
- }\r
- }\r
- protected EventHandlerList Events //DIT\r
- {\r
- get\r
- {\r
- if (_events == null)\r
- {\r
- _events = new EventHandlerList();\r
- }\r
- return _events;\r
- }\r
- }\r
- protected bool HasChildViewState //DIT\r
- {\r
- get\r
- {\r
- if (_childViewStates == null) return false;\r
- return true;\r
- }\r
- }\r
-
- protected bool IsTrackingViewState {\r
+ protected virtual HttpContext Context //DIT
+ {
+ get
+ {
+ HttpContext context;
+ if (_context != null)
+ return _context;
+ if (_parent == null)
+ return HttpContext.Current;
+ context = _parent.Context;
+ if (context != null)
+ return context;
+ return HttpContext.Current;
+ }
+ }
+ protected EventHandlerList Events //DIT
+ {
+ get
+ {
+ if (_events == null)
+ {
+ _events = new EventHandlerList();
+ }
+ return _events;
+ }
+ }
+ protected bool HasChildViewState //DIT
+ {
+ get
+ {
+ if (_childViewStates == null) return false;
+ return true;
+ }
+ }
+
+ protected bool IsTrackingViewState {
get { return ((stateMask & TRACK_VIEWSTATE) != 0); }
}
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription ("ViewState")]
- protected virtual StateBag ViewState\r
- {\r
- get\r
- {\r
- if(_viewState == null)\r
- _viewState = new StateBag (ViewStateIgnoresCase);\r
-\r
- if (IsTrackingViewState)\r
- _viewState.TrackViewState ();\r
-\r
- return _viewState;\r
- }\r
- }\r
-\r
+ protected virtual StateBag ViewState
+ {
+ get
+ {
+ if(_viewState == null)
+ _viewState = new StateBag (ViewStateIgnoresCase);
+
+ if (IsTrackingViewState)
+ _viewState.TrackViewState ();
+
+ return _viewState;
+ }
+ }
+
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- protected virtual bool ViewStateIgnoresCase\r
- {\r
- get {\r
- return false;\r
- }\r
- }\r
-\r
+ protected virtual bool ViewStateIgnoresCase
+ {
+ get {
+ return false;
+ }
+ }
+
internal bool AutoEventWireup {
get { return (stateMask & AUTO_EVENT_WIREUP) != 0; }
set { SetMask (AUTO_EVENT_WIREUP, value); }
SetMask (BINDING_CONTAINER, isBC);
}
- internal void ResetChildNames ()\r
- {\r
- defaultNumberID = 0;\r
- }\r
+ internal void ResetChildNames ()
+ {
+ defaultNumberID = 0;
+ }
string GetDefaultName ()
{
string defaultName;
if (defaultNumberID > 99) {
- defaultName = "_ctrl" + defaultNumberID++;
+ defaultName = "_ctl" + defaultNumberID++;
} else {
defaultName = defaultNameArray [defaultNumberID++];
}
return defaultName;
}
- void NullifyUniqueID ()\r
- {\r
- uniqueID = null;\r
- if (!HasControls ())\r
- return;\r
-\r
+ void NullifyUniqueID ()
+ {
+ uniqueID = null;
+ if (!HasControls ())
+ return;
+
foreach (Control c in Controls)
c.NullifyUniqueID ();
}
- protected internal virtual void AddedControl (Control control, int index)\r
- {\r
+ protected internal virtual void AddedControl (Control control, int index)
+ {
/* Ensure the control don't have more than 1 parent */
if (control._parent != null)
control._parent.Controls.Remove (control);
if (nc != null) {
control._namingContainer = nc;
if (control.AutoID == true && control._userId == null)
- control._userId = nc.GetDefaultName () + "a";
+ control._userId = nc.GetDefaultName ();
}
if ((stateMask & (INITING | INITED)) != 0)
control.PreRenderRecursiveInternal ();
}
- protected virtual void AddParsedSubObject(object obj) //DIT\r
- {\r
- WebTrace.PushContext ("Control.AddParsedSubobject ()");\r
- Control c = obj as Control;\r
- WebTrace.WriteLine ("Start: {0} -> {1}", obj, (c != null) ? c.ID : String.Empty);\r
- if (c != null) Controls.Add(c);\r
- WebTrace.WriteLine ("End");\r
- WebTrace.PopContext ();\r
- }\r
-
- protected void BuildProfileTree(string parentId, bool calcViewState)\r
- {\r
- //TODO\r
- }\r
+ protected virtual void AddParsedSubObject(object obj) //DIT
+ {
+ Control c = obj as Control;
+ if (c != null) Controls.Add(c);
+ }
+
+ protected void BuildProfileTree(string parentId, bool calcViewState)
+ {
+ //TODO
+ }
protected void ClearChildViewState ()
{
pendingVS = null;
}
- protected virtual void CreateChildControls() {} //DIT\r
- protected virtual ControlCollection CreateControlCollection() //DIT\r
- {\r
- return new ControlCollection(this);\r
- }\r
-\r
+ protected virtual void CreateChildControls() {} //DIT
+ protected virtual ControlCollection CreateControlCollection() //DIT
+ {
+ return new ControlCollection(this);
+ }
+
protected virtual void EnsureChildControls ()
{
if (ChildControlsCreated == false && (stateMask & CREATING_CONTROLS) == 0) {
return false;
}
- public virtual Control FindControl (string id)\r
- {\r
- return FindControl (id, 0);\r
- }\r
+ public virtual Control FindControl (string id)
+ {
+ return FindControl (id, 0);
+ }
Control LookForControlByName (string id)
{
return result;
}
- protected virtual Control FindControl (string id, int pathOffset)\r
- {\r
- EnsureChildControls ();\r
- Control namingContainer = null;\r
+ protected virtual Control FindControl (string id, int pathOffset)
+ {
+ EnsureChildControls ();
+ Control namingContainer = null;
if ((stateMask & IS_NAMING_CONTAINER) == 0) {
- namingContainer = NamingContainer;\r
- if (namingContainer == null)\r
- return null;\r
-\r
- return namingContainer.FindControl (id, pathOffset);\r
- }\r
+ namingContainer = NamingContainer;
+ if (namingContainer == null)
+ return null;
+
+ return namingContainer.FindControl (id, pathOffset);
+ }
if (!HasControls ())
return null;
- int colon = id.IndexOf (':', pathOffset);\r
- if (colon == -1)\r
- return LookForControlByName (id.Substring (pathOffset));\r
- \r
- string idfound = id.Substring (pathOffset, colon - pathOffset);\r
- namingContainer = LookForControlByName (idfound);\r
- if (namingContainer == null)\r
- return null;\r
-\r
- return namingContainer.FindControl (id, colon + 1);\r
+ int colon = id.IndexOf (':', pathOffset);
+ if (colon == -1)
+ return LookForControlByName (id.Substring (pathOffset));
+
+ string idfound = id.Substring (pathOffset, colon - pathOffset);
+ namingContainer = LookForControlByName (idfound);
+ if (namingContainer == null)
+ return null;
+
+ return namingContainer.FindControl (id, colon + 1);
}
protected virtual void LoadViewState(object savedState)
}
}
- [MonoTODO("Secure?")]\r
- protected string MapPathSecure(string virtualPath)\r
- {\r
- string combined = UrlUtils.Combine (TemplateSourceDirectory, virtualPath);\r
- return Context.Request.MapPath (combined);\r
- }\r
-\r
- protected virtual bool OnBubbleEvent(object source, EventArgs args) //DIT\r
- {\r
- return false;\r
- }\r
+ [MonoTODO("Secure?")]
+ protected string MapPathSecure(string virtualPath)
+ {
+ string combined = UrlUtils.Combine (TemplateSourceDirectory, virtualPath);
+ return Context.Request.MapPath (combined);
+ }
+
+ protected virtual bool OnBubbleEvent(object source, EventArgs args) //DIT
+ {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("OnBubbleEvent {0} {1}", _userId, type_name));
+ }
+#endif
+ return false;
+ }
protected virtual void OnDataBinding (EventArgs e)
{
if ((event_mask & databinding_mask) != 0) {
EventHandler eh = (EventHandler)(_events [DataBindingEvent]);
- if (eh != null) eh (this, e);
+ if (eh != null) {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("OnDataBinding {0} {1}", _userId, type_name));
+ }
+#endif
+ eh (this, e);
+ }
}
}
{
if ((event_mask & init_mask) != 0) {
EventHandler eh = (EventHandler)(_events [InitEvent]);
- if (eh != null) eh (this, e);
+ if (eh != null) {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("OnInit {0} {1}", _userId, type_name));
+ }
+#endif
+ eh (this, e);
+ }
}
}
{
if ((event_mask & load_mask) != 0) {
EventHandler eh = (EventHandler)(_events [LoadEvent]);
- if (eh != null) eh (this, e);
+ if (eh != null) {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("OnLoad {0} {1}", _userId, type_name));
+ }
+#endif
+ eh (this, e);
+ }
}
}
{
if ((event_mask & prerender_mask) != 0) {
EventHandler eh = (EventHandler)(_events [PreRenderEvent]);
- if (eh != null) eh (this, e);
+ if (eh != null) {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("OnPreRender {0} {1}", _userId, type_name));
+ }
+#endif
+ eh (this, e);
+ }
}
}
{
if ((event_mask & unload_mask) != 0) {
EventHandler eh = (EventHandler)(_events [UnloadEvent]);
- if (eh != null) eh (this, e);
+ if (eh != null) {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("OnUnload {0} {1}", _userId, type_name));
+ }
+#endif
+ eh (this, e);
+ }
}
}
- protected void RaiseBubbleEvent(object source, EventArgs args)\r
- {\r
- Control c = Parent;\r
- while (c != null) {\r
- if (c.OnBubbleEvent (source, args))\r
- break;\r
- c = c.Parent;\r
- }\r
- }\r
-\r
- protected virtual void Render(HtmlTextWriter writer) //DIT\r
- {\r
- RenderChildren(writer);\r
- }\r
+ protected void RaiseBubbleEvent(object source, EventArgs args)
+ {
+ Control c = Parent;
+ while (c != null) {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("RaiseBubbleEvent {0} {1}", _userId, type_name));
+ }
+#endif
+ if (c.OnBubbleEvent (source, args)) {
+#if MONO_TRACE
+ if (trace != null)
+ trace.Write ("control", String.Format ("End RaiseBubbleEvent (false) {0} {1}", _userId, type_name));
+#endif
+ break;
+ }
+#if MONO_TRACE
+ if (trace != null)
+ trace.Write ("control", String.Format ("End RaiseBubbleEvent (true) {0} {1}", _userId, type_name));
+#endif
+ c = c.Parent;
+ }
+ }
+
+ protected virtual void Render(HtmlTextWriter writer) //DIT
+ {
+ RenderChildren(writer);
+ }
protected virtual void RenderChildren (HtmlTextWriter writer) //DIT
{
return _viewState.SaveViewState ();
}
- protected virtual void TrackViewState()\r
- {\r
- if (_viewState != null)\r
- _viewState.TrackViewState ();\r
+ protected virtual void TrackViewState()
+ {
+ if (_viewState != null)
+ _viewState.TrackViewState ();
stateMask |= TRACK_VIEWSTATE;
- }\r
+ }
public virtual void Dispose ()
{
remove { Events.RemoveHandler (UnloadEvent, value); }
}
- public virtual void DataBind() //DIT\r
+ public virtual void DataBind() //DIT
{
#if NET_2_0
DataBind (true);
return _renderMethodDelegate != null;
}
- [EditorBrowsable (EditorBrowsableState.Advanced)]\r
- public void SetRenderMethodDelegate(RenderMethod renderMethod) //DIT\r
- {\r
- _renderMethodDelegate = renderMethod;\r
- }\r
-\r
- internal void LoadRecursive()\r
- {\r
- OnLoad (EventArgs.Empty);\r
- if (HasControls ()) {\r
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public void SetRenderMethodDelegate(RenderMethod renderMethod) //DIT
+ {
+ _renderMethodDelegate = renderMethod;
+ }
+
+ internal void LoadRecursive()
+ {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("LoadRecursive {0} {1}", _userId, type_name));
+ }
+#endif
+ OnLoad (EventArgs.Empty);
+ if (HasControls ()) {
int len = Controls.Count;
for (int i=0;i<len;i++)
- {\r
- Control c = Controls[i];\r
- c.LoadRecursive ();\r
- }\r
- }\r
+ {
+ Control c = Controls[i];
+ c.LoadRecursive ();
+ }
+ }
+
+#if MONO_TRACE
+ if (trace != null)
+ trace.Write ("control", String.Format ("End LoadRecursive {0} {1}", _userId, type_name));
+#endif
stateMask |= LOADED;
- }\r
-\r
- internal void UnloadRecursive(Boolean dispose)\r
- {\r
- if (HasControls ()) {\r
+ }
+
+ internal void UnloadRecursive(Boolean dispose)
+ {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("UnloadRecursive {0} {1}", _userId, type_name));
+ }
+#endif
+ if (HasControls ()) {
int len = Controls.Count;
for (int i=0;i<len;i++)
- {\r
- Control c = Controls[i]; \r
- c.UnloadRecursive (dispose);\r
+ {
+ Control c = Controls[i];
+ c.UnloadRecursive (dispose);
}
- }\r
-\r
- OnUnload (EventArgs.Empty);\r
- if (dispose)\r
- Dispose();\r
- }\r
+ }
+
+#if MONO_TRACE
+ if (trace != null)
+ trace.Write ("control", String.Format ("End UnloadRecursive {0} {1}", _userId, type_name));
+#endif
+ OnUnload (EventArgs.Empty);
+ if (dispose)
+ Dispose();
+ }
internal void PreRenderRecursiveInternal()
{
if ((stateMask & VISIBLE) != 0) {
EnsureChildControls ();
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("PreRenderRecursive {0} {1}", _userId, type_name));
+ }
+#endif
OnPreRender (EventArgs.Empty);
if (!HasControls ())
return;
int len = Controls.Count;
for (int i=0;i<len;i++)
- {\r
+ {
Control c = Controls[i];
c.PreRenderRecursiveInternal ();
}
+#if MONO_TRACE
+ if (trace != null)
+ trace.Write ("control", String.Format ("End PreRenderRecursive {0} {1}", _userId, type_name));
+#endif
}
stateMask |= PRERENDERED;
}
- internal void InitRecursive(Control namingContainer)\r
- {\r
- if (HasControls ()) {\r
+ internal void InitRecursive(Control namingContainer)
+ {
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("InitRecursive {0} {1}", _userId, type_name));
+ }
+#endif
+
+ if (HasControls ()) {
if ((stateMask & IS_NAMING_CONTAINER) != 0)
- namingContainer = this;\r
-\r
- if (namingContainer != null && \r
- namingContainer._userId == null &&\r
- namingContainer.AutoID)\r
- namingContainer._userId = namingContainer.GetDefaultName () + "b";\r
-\r
+ namingContainer = this;
+
+ if (namingContainer != null &&
+ namingContainer._userId == null &&
+ namingContainer.AutoID)
+ namingContainer._userId = namingContainer.GetDefaultName () + "b";
+
int len = Controls.Count;
for (int i=0;i<len;i++)
- {\r
- Control c = Controls[i];\r
- c._page = Page;\r
- c._namingContainer = namingContainer;\r
- if (namingContainer != null && c._userId == null && c.AutoID)\r
- c._userId = namingContainer.GetDefaultName () + "c";\r
- c.InitRecursive (namingContainer); \r
+ {
+ Control c = Controls[i];
+ c._page = Page;
+ c._namingContainer = namingContainer;
+ if (namingContainer != null && c._userId == null && c.AutoID)
+ c._userId = namingContainer.GetDefaultName () + "c";
+ c.InitRecursive (namingContainer);
}
- }\r
-\r
+ }
+
stateMask |= INITING;
- OnInit (EventArgs.Empty);\r
- TrackViewState ();\r
+ OnInit (EventArgs.Empty);
+#if MONO_TRACE
+ if (trace != null)
+ trace.Write ("control", String.Format ("End InitRecursive {0} {1}", _userId, type_name));
+#endif
+ TrackViewState ();
stateMask |= INITED;
stateMask &= ~INITING;
- }\r
+ }
internal object SaveViewStateRecursive ()
{
if (!EnableViewState)
return null;
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("SaveViewStateRecursive {0} {1}", _userId, type_name));
+ }
+#endif
+
ArrayList controlList = null;
ArrayList controlStates = null;
if (ctrlState == null)
continue;
- if (controlList == null) \r
+ if (controlList == null)
{
controlList = new ArrayList ();
controlStates = new ArrayList ();
}
object thisState = SaveViewState ();
- if (thisState == null && controlList == null && controlStates == null)
+ if (thisState == null && controlList == null && controlStates == null) {
+#if MONO_TRACE
+ if (trace != null) {
+ trace.Write ("control", String.Format ("End SaveViewStateRecursive {0} {1} saved nothing", _userId, type_name));
+ trace.SaveViewState (this, null);
+ }
+#endif
return null;
+ }
+#if MONO_TRACE
+ if (trace != null) {
+ trace.Write ("control", String.Format ("End SaveViewStateRecursive {0} {1} saved a Triplet", _userId, type_name));
+ trace.SaveViewState (this, thisState);
+ }
+#endif
return new Triplet (thisState, controlList, controlStates);
}
if (!EnableViewState || savedState == null)
return;
+#if MONO_TRACE
+ TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+ string type_name = null;
+ if (trace != null) {
+ type_name = GetType ().Name;
+ trace.Write ("control", String.Format ("LoadViewStateRecursive {0} {1}", _userId, type_name));
+ }
+#endif
Triplet savedInfo = (Triplet) savedState;
LoadViewState (savedInfo.First);
}
}
+#if MONO_TRACE
+ if (trace != null)
+ trace.Write ("control", String.Format ("End LoadViewStateRecursive {0} {1}", _userId, type_name));
+#endif
stateMask |= VIEWSTATE_LOADED;
}
- void IParserAccessor.AddParsedSubObject(object obj)\r
- {\r
- AddParsedSubObject(obj);\r
- }\r
- \r
- DataBindingCollection IDataBindingsAccessor.DataBindings\r
- {\r
- get\r
- {\r
- if(dataBindings == null)\r
- dataBindings = new DataBindingCollection();\r
- return dataBindings;\r
- }\r
- }\r
- \r
- bool IDataBindingsAccessor.HasDataBindings\r
- {\r
- get\r
- {\r
- return (dataBindings!=null && dataBindings.Count>0);\r
- }\r
- }\r
-
internal bool AutoID
{
get { return (stateMask & AUTOID) != 0; }
}
}
- internal void PreventAutoID()\r
- {\r
- AutoID = false;\r
- }\r
- \r
- protected internal virtual void RemovedControl (Control control)\r
- {\r
- control.UnloadRecursive (false);\r
- control._parent = null;\r
- control._page = null;\r
- control._namingContainer = null;\r
- }\r
-\r
+ internal void PreventAutoID()
+ {
+ AutoID = false;
+ }
+
+ protected internal virtual void RemovedControl (Control control)
+ {
+ control.UnloadRecursive (false);
+ control._parent = null;
+ control._page = null;
+ control._namingContainer = null;
+ }
+
+
#if NET_2_0
string skinId = string.Empty;
ExpressionBindingCollection IExpressionsAccessor.Expressions {
get {
if (expressionBindings == null)
- expressionBindings = new ExpressionBindingCollection ();\r
- return expressionBindings;\r
+ expressionBindings = new ExpressionBindingCollection ();
+ return expressionBindings;
}
}
bool IExpressionsAccessor.HasExpressions {
- get {\r
- return (expressionBindings != null && expressionBindings.Count > 0);\r
- }\r
+ get {
+ return (expressionBindings != null && expressionBindings.Count > 0);
+ }
}
[MonoTODO]
- public virtual void Focus()\r
- {\r
- throw new NotImplementedException();\r
+ public virtual void Focus()
+ {
+ throw new NotImplementedException();
}
protected internal virtual void LoadControlState (object state)
}
-#endif\r
- }\r
-}\r
+#endif
+ void IParserAccessor.AddParsedSubObject (object obj) {
+ this.AddParsedSubObject (obj);
+ }
+
+ DataBindingCollection IDataBindingsAccessor.DataBindings {
+ get {
+ if (dataBindings == null) {
+ dataBindings = new DataBindingCollection ();
+ }
+ return dataBindings;
+ }
+ }
+
+ bool IDataBindingsAccessor.HasDataBindings {
+ get {
+ if (dataBindings != null && dataBindings.Count > 0) {
+ return true;
+ }
+ return false;
+ }
+ }
+ }
+}
-
+//
+// System.Web.UI.HtmlTextWriter
+//
+// Author:
+// Ben Maurer <bmaurer@novell.com>
+//
+// (c) 2005 Novell
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-/* System.Web.UI\r
-* Authors\r
-* Leen Toelen (toelen@hotmail.com)\r
-*/\r
-\r
-using System;\r
-using System.IO;\r
-using System.Collections;\r
-using System.Web;\r
-using System.Web.UI;\r
-\r
-namespace System.Web.UI{\r
-\r
-public class HtmlTextWriter : System.IO.TextWriter {\r
-\r
-static HtmlTextWriter(){\r
- HtmlTextWriter._tagKeyLookupTable = new Hashtable(97,CaseInsensitiveHashCodeProvider.DefaultInvariant,
- CaseInsensitiveComparer.DefaultInvariant);
- HtmlTextWriter._tagNameLookupArray = new TagInformation[97];\r
- HtmlTextWriter.RegisterTag("", HtmlTextWriterTag.Unknown, TagType.Other);\r
- HtmlTextWriter.RegisterTag("a", HtmlTextWriterTag.A, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("acronym", HtmlTextWriterTag.Acronym, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("address", HtmlTextWriterTag.Address, TagType.Other);\r
- HtmlTextWriter.RegisterTag("area", HtmlTextWriterTag.Area, TagType.Other);\r
- HtmlTextWriter.RegisterTag("b", HtmlTextWriterTag.B, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("base", HtmlTextWriterTag.Base, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("basefont", HtmlTextWriterTag.Basefont, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("bdo", HtmlTextWriterTag.Bdo, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("bgsound", HtmlTextWriterTag.Bgsound, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("big", HtmlTextWriterTag.Big, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("blockquote", HtmlTextWriterTag.Blockquote, TagType.Other);\r
- HtmlTextWriter.RegisterTag("body", HtmlTextWriterTag.Body, TagType.Other);\r
- HtmlTextWriter.RegisterTag("br", HtmlTextWriterTag.Br, TagType.Other);\r
- HtmlTextWriter.RegisterTag("button", HtmlTextWriterTag.Button, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("caption", HtmlTextWriterTag.Caption, TagType.Other);\r
- HtmlTextWriter.RegisterTag("center", HtmlTextWriterTag.Center, TagType.Other);\r
- HtmlTextWriter.RegisterTag("cite", HtmlTextWriterTag.Cite, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("code", HtmlTextWriterTag.Code, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("col", HtmlTextWriterTag.Col, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("colgroup", HtmlTextWriterTag.Colgroup, TagType.Other);\r
- HtmlTextWriter.RegisterTag("del", HtmlTextWriterTag.Del, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("dd", HtmlTextWriterTag.Dd, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("dfn", HtmlTextWriterTag.Dfn, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("dir", HtmlTextWriterTag.Dir, TagType.Other);\r
- HtmlTextWriter.RegisterTag("div", HtmlTextWriterTag.Div, TagType.Other);\r
- HtmlTextWriter.RegisterTag("dl", HtmlTextWriterTag.Dl, TagType.Other);\r
- HtmlTextWriter.RegisterTag("dt", HtmlTextWriterTag.Dt, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("em", HtmlTextWriterTag.Em, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("embed", HtmlTextWriterTag.Embed, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("fieldset", HtmlTextWriterTag.Fieldset, TagType.Other);\r
- HtmlTextWriter.RegisterTag("font", HtmlTextWriterTag.Font, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("form", HtmlTextWriterTag.Form, TagType.Other);\r
- HtmlTextWriter.RegisterTag("frame", HtmlTextWriterTag.Frame, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("frameset", HtmlTextWriterTag.Frameset, TagType.Other);\r
- HtmlTextWriter.RegisterTag("h1", HtmlTextWriterTag.H1, TagType.Other);\r
- HtmlTextWriter.RegisterTag("h2", HtmlTextWriterTag.H2, TagType.Other);\r
- HtmlTextWriter.RegisterTag("h3", HtmlTextWriterTag.H3, TagType.Other);\r
- HtmlTextWriter.RegisterTag("h4", HtmlTextWriterTag.H4, TagType.Other);\r
- HtmlTextWriter.RegisterTag("h5", HtmlTextWriterTag.H5, TagType.Other);\r
- HtmlTextWriter.RegisterTag("h6", HtmlTextWriterTag.H6, TagType.Other);\r
- HtmlTextWriter.RegisterTag("head", HtmlTextWriterTag.Head, TagType.Other);\r
- HtmlTextWriter.RegisterTag("hr", HtmlTextWriterTag.Hr, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("html", HtmlTextWriterTag.Html, TagType.Other);\r
- HtmlTextWriter.RegisterTag("i", HtmlTextWriterTag.I, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("iframe", HtmlTextWriterTag.Iframe, TagType.Other);\r
- HtmlTextWriter.RegisterTag("img", HtmlTextWriterTag.Img, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("input", HtmlTextWriterTag.Input, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("ins", HtmlTextWriterTag.Ins, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("isindex", HtmlTextWriterTag.Isindex, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("kbd", HtmlTextWriterTag.Kbd, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("label", HtmlTextWriterTag.Label, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("legend", HtmlTextWriterTag.Legend, TagType.Other);\r
- HtmlTextWriter.RegisterTag("li", HtmlTextWriterTag.Li, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("link", HtmlTextWriterTag.Link, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("map", HtmlTextWriterTag.Map, TagType.Other);\r
- HtmlTextWriter.RegisterTag("marquee", HtmlTextWriterTag.Marquee, TagType.Other);\r
- HtmlTextWriter.RegisterTag("menu", HtmlTextWriterTag.Menu, TagType.Other);\r
- HtmlTextWriter.RegisterTag("meta", HtmlTextWriterTag.Meta, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("nobr", HtmlTextWriterTag.Nobr, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("noframes", HtmlTextWriterTag.Noframes, TagType.Other);\r
- HtmlTextWriter.RegisterTag("noscript", HtmlTextWriterTag.Noscript, TagType.Other);\r
- HtmlTextWriter.RegisterTag("object", HtmlTextWriterTag.Object, TagType.Other);\r
- HtmlTextWriter.RegisterTag("ol", HtmlTextWriterTag.Ol, TagType.Other);\r
- HtmlTextWriter.RegisterTag("option", HtmlTextWriterTag.Option, TagType.Other);\r
- HtmlTextWriter.RegisterTag("p", HtmlTextWriterTag.P, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("param", HtmlTextWriterTag.Param, TagType.Other);\r
- HtmlTextWriter.RegisterTag("pre", HtmlTextWriterTag.Pre, TagType.Other);\r
- HtmlTextWriter.RegisterTag("q", HtmlTextWriterTag.Q, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("rt", HtmlTextWriterTag.Rt, TagType.Other);\r
- HtmlTextWriter.RegisterTag("ruby", HtmlTextWriterTag.Ruby, TagType.Other);\r
- HtmlTextWriter.RegisterTag("s", HtmlTextWriterTag.S, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("samp", HtmlTextWriterTag.Samp, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("script", HtmlTextWriterTag.Script, TagType.Other);\r
- HtmlTextWriter.RegisterTag("select", HtmlTextWriterTag.Select, TagType.Other);\r
- HtmlTextWriter.RegisterTag("small", HtmlTextWriterTag.Small, TagType.Other);\r
- HtmlTextWriter.RegisterTag("span", HtmlTextWriterTag.Span, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("strike", HtmlTextWriterTag.Strike, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("strong", HtmlTextWriterTag.Strong, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("style", HtmlTextWriterTag.Style, TagType.Other);\r
- HtmlTextWriter.RegisterTag("sub", HtmlTextWriterTag.Sub, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("sup", HtmlTextWriterTag.Sup, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("table", HtmlTextWriterTag.Table, TagType.Other);\r
- HtmlTextWriter.RegisterTag("tbody", HtmlTextWriterTag.Tbody, TagType.Other);\r
- HtmlTextWriter.RegisterTag("td", HtmlTextWriterTag.Td, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("textarea", HtmlTextWriterTag.Textarea, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("tfoot", HtmlTextWriterTag.Tfoot, TagType.Other);\r
- HtmlTextWriter.RegisterTag("th", HtmlTextWriterTag.Th, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("thead", HtmlTextWriterTag.Thead, TagType.Other);\r
- HtmlTextWriter.RegisterTag("title", HtmlTextWriterTag.Title, TagType.Other);\r
- HtmlTextWriter.RegisterTag("tr", HtmlTextWriterTag.Tr, TagType.Other);\r
- HtmlTextWriter.RegisterTag("tt", HtmlTextWriterTag.Tt, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("u", HtmlTextWriterTag.U, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("ul", HtmlTextWriterTag.Ul, TagType.Other);\r
- HtmlTextWriter.RegisterTag("var", HtmlTextWriterTag.Var, TagType.Inline);\r
- HtmlTextWriter.RegisterTag("wbr", HtmlTextWriterTag.Wbr, TagType.NonClosing);\r
- HtmlTextWriter.RegisterTag("xml", HtmlTextWriterTag.Xml, TagType.Other);\r
-\r
-#if NET_2_0\r
- HtmlTextWriter._attrNameLookupArray = new AttributeInformation[54];\r
-#else\r
- HtmlTextWriter._attrNameLookupArray = new AttributeInformation[40];\r
-#endif\r
- HtmlTextWriter._attrKeyLookupTable = new Hashtable (HtmlTextWriter._attrNameLookupArray.Length,
- CaseInsensitiveHashCodeProvider.DefaultInvariant, CaseInsensitiveComparer.DefaultInvariant);
- HtmlTextWriter.RegisterAttribute("accesskey", HtmlTextWriterAttribute.Accesskey, true);\r
- HtmlTextWriter.RegisterAttribute("align", HtmlTextWriterAttribute.Align, false);\r
- HtmlTextWriter.RegisterAttribute("alt", HtmlTextWriterAttribute.Alt, true);\r
- HtmlTextWriter.RegisterAttribute("background", HtmlTextWriterAttribute.Background, true);\r
- HtmlTextWriter.RegisterAttribute("bgcolor", HtmlTextWriterAttribute.Bgcolor, false);\r
- HtmlTextWriter.RegisterAttribute("border", HtmlTextWriterAttribute.Border, false);\r
- HtmlTextWriter.RegisterAttribute("bordercolor", HtmlTextWriterAttribute.Bordercolor, false);\r
- HtmlTextWriter.RegisterAttribute("cellpadding", HtmlTextWriterAttribute.Cellpadding, false);\r
- HtmlTextWriter.RegisterAttribute("cellspacing", HtmlTextWriterAttribute.Cellspacing, false);\r
- HtmlTextWriter.RegisterAttribute("checked", HtmlTextWriterAttribute.Checked, false);\r
- HtmlTextWriter.RegisterAttribute("class", HtmlTextWriterAttribute.Class, true);\r
- HtmlTextWriter.RegisterAttribute("cols", HtmlTextWriterAttribute.Cols, false);\r
- HtmlTextWriter.RegisterAttribute("colspan", HtmlTextWriterAttribute.Colspan, false);\r
- HtmlTextWriter.RegisterAttribute("disabled", HtmlTextWriterAttribute.Disabled, false);\r
- HtmlTextWriter.RegisterAttribute("for", HtmlTextWriterAttribute.For, false);\r
- HtmlTextWriter.RegisterAttribute("height", HtmlTextWriterAttribute.Height, false);\r
- HtmlTextWriter.RegisterAttribute("href", HtmlTextWriterAttribute.Href, true);\r
- HtmlTextWriter.RegisterAttribute("id", HtmlTextWriterAttribute.Id, false);\r
- HtmlTextWriter.RegisterAttribute("maxlength", HtmlTextWriterAttribute.Maxlength, false);\r
- HtmlTextWriter.RegisterAttribute("multiple", HtmlTextWriterAttribute.Multiple, false);\r
- HtmlTextWriter.RegisterAttribute("name", HtmlTextWriterAttribute.Name, false);\r
- HtmlTextWriter.RegisterAttribute("nowrap", HtmlTextWriterAttribute.Nowrap, false);\r
- HtmlTextWriter.RegisterAttribute("onchange", HtmlTextWriterAttribute.Onchange, true);\r
- HtmlTextWriter.RegisterAttribute("onclick", HtmlTextWriterAttribute.Onclick, true);\r
- HtmlTextWriter.RegisterAttribute("readonly", HtmlTextWriterAttribute.ReadOnly, false);\r
- HtmlTextWriter.RegisterAttribute("rows", HtmlTextWriterAttribute.Rows, false);\r
- HtmlTextWriter.RegisterAttribute("rowspan", HtmlTextWriterAttribute.Rowspan, false);\r
- HtmlTextWriter.RegisterAttribute("rules", HtmlTextWriterAttribute.Rules, false);\r
- HtmlTextWriter.RegisterAttribute("selected", HtmlTextWriterAttribute.Selected, false);\r
- HtmlTextWriter.RegisterAttribute("size", HtmlTextWriterAttribute.Size, false);\r
- HtmlTextWriter.RegisterAttribute("src", HtmlTextWriterAttribute.Src, true);\r
- HtmlTextWriter.RegisterAttribute("style", HtmlTextWriterAttribute.Style, false);\r
- HtmlTextWriter.RegisterAttribute("tabindex", HtmlTextWriterAttribute.Tabindex, false);\r
- HtmlTextWriter.RegisterAttribute("target", HtmlTextWriterAttribute.Target, false);\r
- HtmlTextWriter.RegisterAttribute("title", HtmlTextWriterAttribute.Title, true);\r
- HtmlTextWriter.RegisterAttribute("type", HtmlTextWriterAttribute.Type, false);\r
- HtmlTextWriter.RegisterAttribute("valign", HtmlTextWriterAttribute.Valign, false);\r
- HtmlTextWriter.RegisterAttribute("value", HtmlTextWriterAttribute.Value, true);\r
- HtmlTextWriter.RegisterAttribute("width", HtmlTextWriterAttribute.Width, false);\r
- HtmlTextWriter.RegisterAttribute("wrap", HtmlTextWriterAttribute.Wrap, false);\r
-#if NET_2_0\r
- HtmlTextWriter.RegisterAttribute("abbr", HtmlTextWriterAttribute.Abbr, false);\r
- HtmlTextWriter.RegisterAttribute("autocomplete", HtmlTextWriterAttribute.AutoComplete, false);\r
- HtmlTextWriter.RegisterAttribute("axis", HtmlTextWriterAttribute.Axis, false);\r
- HtmlTextWriter.RegisterAttribute("content", HtmlTextWriterAttribute.Content, false);\r
- HtmlTextWriter.RegisterAttribute("coords", HtmlTextWriterAttribute.Coords, false);\r
- HtmlTextWriter.RegisterAttribute("_designerRegion", HtmlTextWriterAttribute.DesignerRegion, false);\r
- HtmlTextWriter.RegisterAttribute("dir", HtmlTextWriterAttribute.Dir, false);\r
- HtmlTextWriter.RegisterAttribute("headers", HtmlTextWriterAttribute.Headers, false);\r
- HtmlTextWriter.RegisterAttribute("longdesc", HtmlTextWriterAttribute.Longdesc, false);\r
- HtmlTextWriter.RegisterAttribute("rel", HtmlTextWriterAttribute.Rel, false);\r
- HtmlTextWriter.RegisterAttribute("scope", HtmlTextWriterAttribute.Scope, false);\r
- HtmlTextWriter.RegisterAttribute("shape", HtmlTextWriterAttribute.Shape, false);\r
- HtmlTextWriter.RegisterAttribute("usemap", HtmlTextWriterAttribute.Usemap, false);\r
- HtmlTextWriter.RegisterAttribute("vcard_name", HtmlTextWriterAttribute.VCardName, false);\r
-#endif\r
-\r
-#if NET_2_0\r
- HtmlTextWriter._styleNameLookupArray = new String[42];\r
-#else\r
- HtmlTextWriter._styleNameLookupArray = new String[14];\r
-#endif\r
- HtmlTextWriter._styleKeyLookupTable = new Hashtable (HtmlTextWriter._styleNameLookupArray.Length,
- CaseInsensitiveHashCodeProvider.DefaultInvariant, CaseInsensitiveComparer.DefaultInvariant);
- HtmlTextWriter.RegisterStyle("background-color", HtmlTextWriterStyle.BackgroundColor);\r
- HtmlTextWriter.RegisterStyle("background-image", HtmlTextWriterStyle.BackgroundImage);\r
- HtmlTextWriter.RegisterStyle("border-collapse", HtmlTextWriterStyle.BorderCollapse);\r
- HtmlTextWriter.RegisterStyle("border-color", HtmlTextWriterStyle.BorderColor);\r
- HtmlTextWriter.RegisterStyle("border-style", HtmlTextWriterStyle.BorderStyle);\r
- HtmlTextWriter.RegisterStyle("border-width", HtmlTextWriterStyle.BorderWidth);\r
- HtmlTextWriter.RegisterStyle("color", HtmlTextWriterStyle.Color);\r
- HtmlTextWriter.RegisterStyle("font-family", HtmlTextWriterStyle.FontFamily);\r
- HtmlTextWriter.RegisterStyle("font-size", HtmlTextWriterStyle.FontSize);\r
- HtmlTextWriter.RegisterStyle("font-style", HtmlTextWriterStyle.FontStyle);\r
- HtmlTextWriter.RegisterStyle("font-weight", HtmlTextWriterStyle.FontWeight);\r
- HtmlTextWriter.RegisterStyle("height", HtmlTextWriterStyle.Height);\r
- HtmlTextWriter.RegisterStyle("text-decoration", HtmlTextWriterStyle.TextDecoration);\r
- HtmlTextWriter.RegisterStyle("width", HtmlTextWriterStyle.Width);\r
-#if NET_2_0\r
- HtmlTextWriter.RegisterStyle("list-style-image", HtmlTextWriterStyle.ListStyleImage);\r
- HtmlTextWriter.RegisterStyle("list-style-type", HtmlTextWriterStyle.ListStyleType);\r
- HtmlTextWriter.RegisterStyle("cursor", HtmlTextWriterStyle.Cursor);\r
- HtmlTextWriter.RegisterStyle("direction", HtmlTextWriterStyle.Direction);\r
- HtmlTextWriter.RegisterStyle("display", HtmlTextWriterStyle.Display);\r
- HtmlTextWriter.RegisterStyle("filter", HtmlTextWriterStyle.Filter);\r
- HtmlTextWriter.RegisterStyle("font-variant", HtmlTextWriterStyle.FontVariant);\r
- HtmlTextWriter.RegisterStyle("left", HtmlTextWriterStyle.Left);\r
- HtmlTextWriter.RegisterStyle("margin", HtmlTextWriterStyle.Margin);\r
- HtmlTextWriter.RegisterStyle("margin-bottom", HtmlTextWriterStyle.MarginBottom);\r
- HtmlTextWriter.RegisterStyle("margin-left", HtmlTextWriterStyle.MarginLeft);\r
- HtmlTextWriter.RegisterStyle("margin-right", HtmlTextWriterStyle.MarginRight);\r
- HtmlTextWriter.RegisterStyle("margin-top", HtmlTextWriterStyle.MarginTop);\r
- HtmlTextWriter.RegisterStyle("overflow", HtmlTextWriterStyle.Overflow);\r
- HtmlTextWriter.RegisterStyle("overflow-x", HtmlTextWriterStyle.OverflowX);\r
- HtmlTextWriter.RegisterStyle("overflow-y", HtmlTextWriterStyle.OverflowY);\r
- HtmlTextWriter.RegisterStyle("padding", HtmlTextWriterStyle.Padding);\r
- HtmlTextWriter.RegisterStyle("padding-bottom", HtmlTextWriterStyle.PaddingBottom);\r
- HtmlTextWriter.RegisterStyle("padding-left", HtmlTextWriterStyle.PaddingLeft);\r
- HtmlTextWriter.RegisterStyle("padding-right", HtmlTextWriterStyle.PaddingRight);\r
- HtmlTextWriter.RegisterStyle("padding-top", HtmlTextWriterStyle.PaddingTop);\r
- HtmlTextWriter.RegisterStyle("position", HtmlTextWriterStyle.Position);\r
- HtmlTextWriter.RegisterStyle("text-align", HtmlTextWriterStyle.TextAlign);\r
- HtmlTextWriter.RegisterStyle("text-overflow", HtmlTextWriterStyle.TextOverflow);\r
- HtmlTextWriter.RegisterStyle("top", HtmlTextWriterStyle.Top);\r
- HtmlTextWriter.RegisterStyle("visibility", HtmlTextWriterStyle.Visibility);\r
- HtmlTextWriter.RegisterStyle("white-space", HtmlTextWriterStyle.WhiteSpace);\r
- HtmlTextWriter.RegisterStyle("z-index", HtmlTextWriterStyle.ZIndex);\r
-#endif\r
-}\r
-\r
-public HtmlTextWriter(TextWriter writer):this(writer, " "){}\r
-\r
-public HtmlTextWriter(TextWriter writer, string tabString) : base() {\r
- this.writer = writer;\r
- this.tabString = tabString;\r
- indentLevel = 0;\r
- tabsPending = false;\r
- _httpWriter = writer as HttpWriter;\r
- _isDescendant = GetType() == typeof(HtmlTextWriter) == false;\r
- _attrList = new RenderAttribute[20];\r
- _attrCount = 0;\r
- _styleList = new RenderStyle[20];\r
- _styleCount = 0;\r
- _endTags = new TagStackEntry[16];\r
- _endTagCount = 0;\r
- _inlineCount = 0;\r
-}\r
-\r
-public virtual void AddAttribute(HtmlTextWriterAttribute key, string value){\r
- if ((int) key >= 0 && (int) key < HtmlTextWriter._attrNameLookupArray.Length) {\r
- AttributeInformation attrInfo = HtmlTextWriter._attrNameLookupArray[(int) key];\r
- AddAttribute(attrInfo.name, value, key, attrInfo.encode);\r
- }\r
-}\r
-\r
-public virtual void AddAttribute(HtmlTextWriterAttribute key, string value, bool fEncode){\r
- if ((int) key >= 0 && (int) key < HtmlTextWriter._attrNameLookupArray.Length) {\r
- AddAttribute(HtmlTextWriter._attrNameLookupArray[(int) key].name, value, key, fEncode);\r
- }\r
-}\r
-\r
-public virtual void AddAttribute(string name, string value){\r
- HtmlTextWriterAttribute attr = GetAttributeKey(name);\r
- value = EncodeAttributeValue(GetAttributeKey(name), value);\r
- AddAttribute(name, value, attr);\r
-}\r
-\r
-public virtual void AddAttribute(string name, string value, bool fEndode){\r
- value = EncodeAttributeValue(value, fEndode);\r
- AddAttribute(name, value, GetAttributeKey(name));\r
-}\r
-\r
-protected virtual void AddAttribute(string name, string value, HtmlTextWriterAttribute key){\r
- AddAttribute(name, value, key, false);\r
-}\r
-\r
-private void AddAttribute(string name, string value, HtmlTextWriterAttribute key, bool encode){\r
- if (_attrCount >= (int) _attrList.Length) {\r
- RenderAttribute[] rAttrArr = new RenderAttribute[_attrList.Length * 2];\r
- System.Array.Copy(_attrList, rAttrArr, (int) _attrList.Length);\r
- _attrList = rAttrArr;\r
- }\r
- RenderAttribute rAttr;\r
- rAttr.name = name;\r
- rAttr.value = value;\r
- rAttr.key = key;\r
- rAttr.encode = encode;\r
- _attrList [_attrCount++] = rAttr;\r
-}\r
-\r
-public virtual void AddStyleAttribute(HtmlTextWriterStyle key, string value){\r
- AddStyleAttribute(GetStyleName(key), value, key);\r
-}\r
-\r
-public virtual void AddStyleAttribute(string name, string value){\r
- AddStyleAttribute(name, value, GetStyleKey(name));\r
-}\r
-\r
-protected virtual void AddStyleAttribute(string name, string value, HtmlTextWriterStyle key){\r
- if (_styleCount >= (int) _styleList.Length) {\r
- RenderStyle[] rAttrArr = new RenderStyle[_styleList.Length * 2];\r
- System.Array.Copy(_styleList, rAttrArr, (int) _styleList.Length);\r
- _styleList = rAttrArr;\r
- }\r
- RenderStyle rAttr;\r
- rAttr.name = name;\r
- rAttr.value = value;\r
- rAttr.key = key;\r
- _styleList [_styleCount++] = rAttr;\r
-}\r
-\r
-public override void Close(){\r
- writer.Close();\r
-}\r
-\r
-protected virtual string EncodeAttributeValue(HtmlTextWriterAttribute attrKey, string value){\r
- bool valid = true;\r
- if (0 <= (int) attrKey && (int) attrKey < HtmlTextWriter._attrNameLookupArray.Length)\r
- valid = HtmlTextWriter._attrNameLookupArray[(int) attrKey].encode;\r
- return EncodeAttributeValue(value, valid);\r
-}\r
-\r
-protected string EncodeAttributeValue(string value, bool fEncode){\r
- if (value == null)\r
- return null;\r
- if (!(fEncode))\r
- return value;\r
- return System.Web.HttpUtility.HtmlAttributeEncode(value);\r
-}\r
-\r
-protected string EncodeUrl(string url){\r
- if (url.IndexOf(SpaceChar) < 0)\r
- return url;\r
- System.Text.StringBuilder sb = new System.Text.StringBuilder();\r
- for(int i=0; i <= url.Length; i++){\r
- char temp = url[i];\r
- if (temp != 32)\r
- sb.Append(temp);\r
- else\r
- sb.Append("%20");\r
- }\r
- return sb.ToString();\r
-}\r
-\r
-protected virtual void FilterAttributes(){\r
- int count = 0;\r
- for(int i=0; i < _styleCount; i++){\r
- RenderStyle rStyle = _styleList[i];\r
- if (OnStyleAttributeRender(rStyle.name, rStyle.value, rStyle.key)) {\r
- count++;\r
- }\r
- }\r
- _styleCount = count;\r
- count = 0;\r
- for(int i=0; i <= _attrCount; i++){\r
- RenderAttribute rAttr = _attrList[i];\r
- if (OnAttributeRender(rAttr.name, rAttr.value, rAttr.key)) {\r
- count++;\r
- }\r
- }\r
- _attrCount = count;\r
-}\r
-\r
-public override void Flush(){\r
- writer.Flush();\r
-}\r
-\r
-protected HtmlTextWriterAttribute GetAttributeKey(string attrName){\r
- if (attrName != null && attrName.Length > 0) {\r
- object attr = HtmlTextWriter._attrKeyLookupTable[attrName];\r
- if (attr != null)\r
- return (HtmlTextWriterAttribute) attr;\r
- }\r
- return (HtmlTextWriterAttribute) (-1);\r
-}\r
-\r
-protected string GetAttributeName(HtmlTextWriterAttribute attrKey){\r
- if ((int) attrKey >= 0 && (int) attrKey < HtmlTextWriter._attrNameLookupArray.Length)\r
- return HtmlTextWriter._attrNameLookupArray[(int) attrKey].name;\r
- return System.String.Empty;\r
-}\r
-\r
-protected HtmlTextWriterStyle GetStyleKey(string styleName){\r
- if (styleName != null && styleName.Length > 0) {\r
- object style = HtmlTextWriter._styleKeyLookupTable[styleName];\r
- if (style != null)\r
- return (HtmlTextWriterStyle) style;\r
- }\r
- return (HtmlTextWriterStyle) (-1);\r
-}\r
-\r
-protected string GetStyleName(HtmlTextWriterStyle styleKey){\r
- return StaticGetStyleName (styleKey);\r
-}\r
-\r
-internal static string StaticGetStyleName (HtmlTextWriterStyle styleKey){\r
- if ((int) styleKey >= 0 && (int) styleKey < HtmlTextWriter._styleNameLookupArray.Length)\r
- return HtmlTextWriter._styleNameLookupArray[(int) styleKey];\r
- return System.String.Empty;\r
-}\r
-\r
-protected virtual HtmlTextWriterTag GetTagKey(string tagName){\r
- if (tagName != null && tagName.Length > 0) {\r
- object tag = HtmlTextWriter._tagKeyLookupTable[tagName];\r
- if (tag != null)\r
- return (HtmlTextWriterTag) tag;\r
- }\r
- return 0;\r
-}\r
-\r
-protected virtual string GetTagName(HtmlTextWriterTag tagKey){\r
- if ((int) tagKey >= 0 && (int) tagKey < HtmlTextWriter._tagNameLookupArray.Length)\r
- return HtmlTextWriter._tagNameLookupArray[(int) tagKey].name;\r
- return System.String.Empty;\r
-}\r
-\r
-protected bool IsAttributeDefined(HtmlTextWriterAttribute key){\r
- for (int i=0; i < _attrCount; i++) {\r
- if (_attrList[i].key == key)\r
- return true;\r
- }\r
- return false;\r
-}\r
-\r
-protected bool IsAttributeDefined(HtmlTextWriterAttribute key, out string value){\r
- value = null;\r
- for (int i=0; i < _attrCount; i++) {\r
- if (_attrList[i].key == key) {\r
- value = _attrList[i].value;\r
- return true;\r
- }\r
- }\r
- return false;\r
-}\r
-\r
-protected bool IsStyleAttributeDefined(HtmlTextWriterStyle key){\r
- for (int i= 0; i < _styleCount; i++) {\r
- if (_styleList[i].key == key)\r
- return true;\r
- }\r
- return false;\r
-}\r
-\r
-protected bool IsStyleAttributeDefined(HtmlTextWriterStyle key, out string value){\r
- value = null;\r
- for( int i=0; i < _styleCount; i++) {\r
- if (_styleList[i].key == key) {\r
- value = _styleList[i].value;\r
- return true;\r
- }\r
- }\r
- return false;\r
-}\r
-\r
-protected virtual bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key){\r
- return true;\r
-}\r
-\r
-protected virtual bool OnStyleAttributeRender(string name, string value, HtmlTextWriterStyle key){\r
- return true;\r
-}\r
-\r
-protected virtual bool OnTagRender(string name, HtmlTextWriterTag key){\r
- return true;\r
-}\r
-\r
-protected virtual void OutputTabs(){\r
- if (tabsPending) {\r
- for(int i=0; i < indentLevel; i++) {\r
- writer.Write(tabString);\r
- }\r
- tabsPending = false;\r
- }\r
-}\r
-\r
-protected string PopEndTag(){\r
- if (_endTagCount <= 0)\r
- throw new InvalidOperationException("A PopEndTag was called without a corresponding PushEndTag");\r
- _endTagCount--;\r
- TagKey = _endTags[_endTagCount].tagKey;\r
- return _endTags[_endTagCount].endTagText;\r
-}\r
-\r
-protected void PushEndTag(string endTag){\r
- if (_endTagCount >= (int) _endTags.Length) {\r
- TagStackEntry[] temp = new TagStackEntry[(int) _endTags.Length * 2];\r
- System.Array.Copy(_endTags, temp, (int) _endTags.Length);\r
- _endTags = temp;\r
- }\r
- _endTags[_endTagCount].tagKey = _tagKey;\r
- _endTags[_endTagCount].endTagText = endTag;\r
- _endTagCount++;\r
-}\r
-\r
-protected static void RegisterAttribute(string name, HtmlTextWriterAttribute key){\r
- HtmlTextWriter.RegisterAttribute(name, key, false);\r
-}\r
-\r
-private static void RegisterAttribute(string name, HtmlTextWriterAttribute key, bool fEncode){\r
- name = name.ToLower();\r
- HtmlTextWriter._attrKeyLookupTable.Add(name, key);\r
- if ((int) key < (int) HtmlTextWriter._attrNameLookupArray.Length)\r
- HtmlTextWriter._attrNameLookupArray[(int) key] = new AttributeInformation(name, fEncode);\r
-}\r
-\r
-protected static void RegisterStyle(string name, HtmlTextWriterStyle key){\r
- name = name.ToLower();\r
- HtmlTextWriter._styleKeyLookupTable.Add(name, key);\r
- if ((int) key < (int) HtmlTextWriter._styleNameLookupArray.Length)\r
- HtmlTextWriter._styleNameLookupArray[(int) key] = name;\r
-}\r
-\r
-protected static void RegisterTag(string name, HtmlTextWriterTag key){\r
- HtmlTextWriter.RegisterTag(name, key, TagType.Other);\r
-}\r
-\r
-private static void RegisterTag(string name, HtmlTextWriterTag key, TagType type){\r
- name = name.ToLower();\r
- HtmlTextWriter._tagKeyLookupTable.Add(name, key);\r
- string fullTag = null;\r
- if ((int) type != 1 && (int) key != 0) {\r
- fullTag = EndTagLeftChars + name + TagRightChar;\r
- }\r
- if ((int) key < HtmlTextWriter._tagNameLookupArray.Length)\r
- HtmlTextWriter._tagNameLookupArray[(int) key] = new TagInformation(name, type, fullTag);\r
-}\r
-\r
-protected virtual string RenderAfterContent(){\r
- return null;\r
-}\r
-\r
-protected virtual string RenderAfterTag(){\r
- return null;\r
-}\r
-\r
-protected virtual string RenderBeforeContent(){\r
- return null;\r
-}\r
-\r
-protected virtual string RenderBeforeTag(){\r
- return null;\r
-}\r
-\r
-public virtual void RenderBeginTag(HtmlTextWriterTag tagKey){\r
- TagKey = tagKey;\r
- bool tagRendered = true;\r
- bool tagRender = true;\r
- if (_isDescendant) {\r
- tagRender = OnTagRender(_tagName, _tagKey);\r
- FilterAttributes();\r
- string beforeTag = RenderBeforeTag();\r
- if (beforeTag != null) {\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(beforeTag);\r
- }\r
- }\r
- TagInformation currentTag = HtmlTextWriter._tagNameLookupArray[_tagIndex];\r
- if (currentTag.closingTag == null && currentTag.tagType == TagType.Other) {\r
- currentTag.closingTag = EndTagLeftChars + _tagName + TagRightChar;\r
- }\r
-\r
- if (tagRender) {\r
- tagRendered = false;\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(TagLeftChar);\r
- writer.Write(_tagName);\r
- RenderAttribute rAttr;\r
- string rAttrValue = null;\r
- for (int i=0; i < _attrCount; i++) {\r
- rAttr = _attrList[i];\r
- if (rAttr.key == HtmlTextWriterAttribute.Style)\r
- rAttrValue = rAttr.value;\r
- else {\r
- writer.Write(SpaceChar);\r
- writer.Write(rAttr.name);\r
- if (rAttr.value != null) {\r
- writer.Write(EqualsChar);\r
- writer.Write(DoubleQuoteChar);\r
- if (rAttr.encode) {\r
- if (_httpWriter == null) {\r
- System.Web.HttpUtility.HtmlAttributeEncode(rAttr.value, writer);\r
- }\r
- else {\r
- System.Web.HttpUtility.HtmlAttributeEncode(rAttr.value, (TextWriter) _httpWriter);\r
- }\r
- }\r
- else {\r
- writer.Write(rAttr.value);\r
- }\r
- writer.Write(DoubleQuoteChar);\r
- }\r
- }\r
- }\r
- if (_styleCount > 0 || rAttrValue != null) {\r
- writer.Write(SpaceChar);\r
- writer.Write("style");\r
- writer.Write(EqualsChar);\r
- writer.Write(DoubleQuoteChar);\r
- RenderStyle rStyle;\r
- for (int i=0; i < _styleCount; i++) {\r
- rStyle = _styleList[i];\r
- writer.Write(rStyle.name);\r
- writer.Write(StyleEqualsChar);\r
- writer.Write(rStyle.value);\r
- writer.Write(SemicolonChar);\r
- }\r
- if (rAttrValue != null)\r
- writer.Write(rAttrValue);\r
- writer.Write(DoubleQuoteChar);\r
- }\r
- if (currentTag.tagType == TagType.NonClosing) {\r
- writer.Write(SpaceChar);\r
- writer.Write(SlashChar);\r
- writer.Write(TagRightChar);\r
- }\r
- else\r
- writer.Write(TagRightChar);\r
- }\r
- string beforeContent = RenderBeforeContent();\r
- if (beforeContent != null) {\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(beforeContent);\r
- }\r
- if (tagRendered) {\r
- if (currentTag.tagType == TagType.Inline)\r
- _inlineCount++;\r
- else {\r
- WriteLine();\r
- Indent++;\r
- }\r
- if (currentTag.closingTag == null) {\r
- currentTag.closingTag = EndTagLeftChars + _tagName + TagRightChar;\r
- }\r
- }\r
- if (_isDescendant) {\r
- string afterContent = RenderAfterContent();\r
- if (afterContent != null) {\r
- if (currentTag.closingTag != null)\r
- currentTag.closingTag = afterContent;\r
- }\r
- string afterTag = RenderAfterTag();\r
- if (afterTag != null) {\r
- if (currentTag.closingTag != null)\r
- currentTag.closingTag = afterTag;\r
- }\r
- }\r
- PushEndTag(currentTag.closingTag);\r
- _attrCount = 0;\r
- _styleCount = 0;\r
-}\r
-\r
-public virtual void RenderBeginTag(string tagName){\r
- TagName = tagName;\r
- RenderBeginTag(_tagKey);\r
-}\r
-\r
-public virtual void RenderEndTag(){\r
- string endTagText = PopEndTag();\r
- if (endTagText != null) {\r
- if (HtmlTextWriter._tagNameLookupArray[_tagIndex].tagType == 0) {\r
- _inlineCount--;\r
- Write(endTagText);\r
- }\r
- else{\r
- WriteLine();\r
- Indent--;\r
- Write(endTagText);\r
- }\r
- }\r
-}\r
-\r
-public override void Write(bool value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(value);\r
-}\r
-\r
-public override void Write(char value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(value);\r
-}\r
-\r
-public override void Write(char[] buffer){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(buffer);\r
-}\r
-\r
-public override void Write(char[] buffer, int index, int count){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(buffer, index, count);\r
-}\r
-\r
-public override void Write(double value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(value);\r
-}\r
-\r
-public override void Write(int value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(value);\r
-}\r
-\r
-public override void Write(long value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(value);\r
-}\r
-\r
-public override void Write(object value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(value);\r
-}\r
-\r
-public override void Write(float value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(value);\r
-}\r
-\r
-public override void Write(string s){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(s);\r
-}\r
-\r
-public override void Write(string format, object arg0){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(format, arg0);\r
-}\r
-\r
-public override void Write(string format, object arg0, object arg1){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(format, arg0, arg1);\r
-}\r
-\r
-public override void Write(string format, params object[] arg){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(format, arg);\r
-}\r
-\r
-public virtual void WriteAttribute(string name, string value){\r
- WriteAttribute(name, value, false);\r
-}\r
-\r
-public virtual void WriteAttribute(string name, string value, bool fEncode){\r
- writer.Write(SpaceChar);\r
- writer.Write(name);\r
- if (value != null) {\r
- writer.Write(EqualsChar);\r
- writer.Write(DoubleQuoteChar);\r
- if (fEncode) {\r
- if (_httpWriter == null) {\r
- System.Web.HttpUtility.HtmlAttributeEncode(value, writer);\r
- }\r
- else{\r
- System.Web.HttpUtility.HtmlAttributeEncode(value, (TextWriter) _httpWriter);\r
- }\r
- }\r
- else{\r
- writer.Write(value);\r
- }\r
- writer.Write(DoubleQuoteChar);\r
- }\r
-}\r
-\r
-public virtual void WriteBeginTag(string tagName){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(TagLeftChar);\r
- writer.Write(tagName);\r
-}\r
-\r
-public virtual void WriteEndTag(string tagName){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(TagLeftChar);\r
- writer.Write(SlashChar);\r
- writer.Write(tagName);\r
- writer.Write(TagRightChar);\r
-}\r
-\r
-public virtual void WriteFullBeginTag(string tagName){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.Write(TagLeftChar);\r
- writer.Write(tagName);\r
- writer.Write(TagRightChar);\r
-}\r
-\r
-public override void WriteLine(){\r
- writer.WriteLine();\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(bool value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(value);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(char value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(value);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(char[] buffer){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(buffer);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(char[] buffer, int index, int count){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(buffer, index, count);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(double value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(value);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(int value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(value);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(long value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(value);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(object value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(value);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(float value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(value);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(string s){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(s);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(string format, object arg0){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(format, arg0);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(string format, object arg0, object arg1){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(format, arg0, arg1);\r
- tabsPending = true;\r
-}\r
-\r
-public override void WriteLine(string format, params object[] arg){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(format, arg);\r
- tabsPending = true;\r
-}\r
-\r
-[CLSCompliant(false)]\r
-public override void WriteLine(uint value){\r
- if (tabsPending)\r
- OutputTabs();\r
- writer.WriteLine(value);\r
- tabsPending = true;\r
-}\r
-\r
-public void WriteLineNoTabs(string s){\r
- writer.WriteLine(s);\r
-}\r
-\r
-public virtual void WriteStyleAttribute(string name, string value){\r
- WriteStyleAttribute(name, value, false);\r
-}\r
-\r
-public virtual void WriteStyleAttribute(string name, string value, bool fEncode){\r
- writer.Write(name);\r
- writer.Write(StyleEqualsChar);\r
- if (fEncode) {\r
- if (_httpWriter == null) {\r
- System.Web.HttpUtility.HtmlAttributeEncode(value, writer);\r
- }\r
- else{\r
- System.Web.HttpUtility.HtmlAttributeEncode(value, (TextWriter) _httpWriter);\r
- }\r
- }\r
- else {\r
- writer.Write(value);\r
- }\r
- writer.Write(SemicolonChar);\r
-}\r
-\r
-public override System.Text.Encoding Encoding { \r
- get{\r
- return writer.Encoding;\r
- }\r
-}\r
-\r
-public int Indent { \r
- get{\r
- return indentLevel;\r
- }\r
- set{\r
- if (value < 0)\r
- value = 0;\r
- indentLevel = value;\r
- }\r
-}\r
-\r
-public TextWriter InnerWriter { \r
- get{\r
- return writer;\r
- }\r
- set{\r
- writer = value;\r
- _httpWriter = value as HttpWriter;\r
- }\r
-}\r
-\r
-public override string NewLine { \r
- get{\r
- return writer.NewLine;\r
- }\r
- set{\r
- writer.NewLine = value;\r
- }\r
-}\r
-\r
-protected HtmlTextWriterTag TagKey { \r
- get{\r
- return _tagKey;\r
- }\r
- set{\r
- _tagIndex = (int) value;\r
- if (_tagIndex < 0 || _tagIndex >= (int) HtmlTextWriter._tagNameLookupArray.Length)\r
- throw new ArgumentOutOfRangeException("value");\r
- _tagKey = value;\r
- if (value != 0)\r
- _tagName = HtmlTextWriter._tagNameLookupArray[_tagIndex].name;\r
- }\r
-}\r
-\r
-protected string TagName { \r
- get{\r
- return _tagName;\r
- }\r
- set{\r
- _tagName = value;\r
- _tagKey = GetTagKey(_tagName);\r
- _tagIndex = (int) _tagKey;\r
- }\r
-}\r
-\r
-public const string DefaultTabString = "\t";\r
-public const char DoubleQuoteChar = '"';\r
-public const string EndTagLeftChars = "</";\r
-public const char EqualsChar = '=';\r
-public const string EqualsDoubleQuoteString = "=\"";\r
-public const string SelfClosingChars = " /";\r
-public const string SelfClosingTagEnd = " />";\r
-public const char SemicolonChar = ';';\r
-public const char SingleQuoteChar = '\'';\r
-public const char SlashChar = '/';\r
-public const char SpaceChar = ' ';\r
-public const char StyleEqualsChar = ':';\r
-public const char TagLeftChar = '<';\r
-public const char TagRightChar = '>';\r
-\r
-private int _attrCount;\r
-private int _endTagCount;\r
-private int _styleCount;\r
-private int indentLevel;\r
-private int _inlineCount;\r
-private int _tagIndex;\r
-\r
-private bool _isDescendant;\r
-private bool tabsPending;\r
-\r
-private HtmlTextWriterTag _tagKey;\r
-private TextWriter writer;\r
-private HttpWriter _httpWriter;\r
-\r
-private static Hashtable _attrKeyLookupTable;\r
-private static Hashtable _styleKeyLookupTable;\r
-private static Hashtable _tagKeyLookupTable;\r
-\r
-private string _tagName;\r
-private string tabString;\r
-private static string[] _styleNameLookupArray;\r
-\r
-private RenderAttribute[] _attrList;\r
-private static AttributeInformation[] _attrNameLookupArray;\r
-private static TagInformation[] _tagNameLookupArray;\r
-private TagStackEntry[] _endTags;\r
-private RenderStyle[] _styleList;\r
-\r
-} //HtmlTextWriter\r
-\r
-struct AttributeInformation {\r
- public bool encode;\r
- public string name;\r
-\r
- public AttributeInformation(string name, bool encode){\r
- this.encode = encode;\r
- this.name = name;\r
- }\r
-} \r
- \r
-struct RenderAttribute {\r
- public bool encode;\r
- public HtmlTextWriterAttribute key;\r
- public string name;\r
- public string value;\r
-} \r
- \r
-struct RenderStyle {\r
- public HtmlTextWriterStyle key;\r
- public string name;\r
- public string value;\r
-} \r
- \r
-struct TagInformation {\r
- public string closingTag;\r
- public string name;\r
- public TagType tagType;\r
-\r
- public TagInformation(string name, TagType tagType, string closingTag){\r
- this.name = name;\r
- this.tagType = tagType;\r
- this.closingTag = closingTag; \r
- }\r
-} \r
- \r
-struct TagStackEntry {\r
- public string endTagText;\r
- public HtmlTextWriterTag tagKey;\r
-} \r
- \r
-enum TagType {\r
- Inline,\r
- NonClosing,\r
- Other\r
-} \r
-\r
-\r
-} // namespace System.Web.UI.HtmlControls\r
-\r
+
+using System.IO;
+using System.Globalization;
+using System.Collections;
+using System.Text;
+
+namespace System.Web.UI {
+
+ public class HtmlTextWriter : TextWriter {
+
+ ArrayList styles = new ArrayList ();
+ ArrayList attrs = new ArrayList ();
+
+ class AddedStyle {
+ public string name;
+ public HtmlTextWriterStyle key;
+ public string value;
+ }
+
+ class AddedAttr {
+ public string name;
+ public HtmlTextWriterAttribute key;
+ public string value;
+ }
+
+ public HtmlTextWriter (TextWriter writer) : this (writer, DefaultTabString)
+ {
+ }
+
+ public HtmlTextWriter (TextWriter writer, string tabString)
+ {
+ if (writer == null)
+ throw new ArgumentNullException ();
+
+ b = writer;
+ tab_string = tabString;
+ }
+
+ [MonoTODO]
+ internal static string StaticGetStyleName (System.Web.UI.HtmlTextWriterStyle styleKey)
+ {
+ return "";
+ }
+
+ [MonoTODO]
+ protected static void RegisterAttribute (string name, HtmlTextWriterAttribute key)
+ {
+ }
+
+ [MonoTODO]
+ protected static void RegisterStyle (string name, HtmlTextWriterStyle key)
+ {
+ }
+
+ [MonoTODO]
+ protected static void RegisterTag (string name, HtmlTextWriterTag key)
+ {
+ }
+
+
+ public virtual void AddAttribute (HtmlTextWriterAttribute key, string value, bool fEncode)
+ {
+ if (fEncode)
+ value = EncodeAttributeValue (key, value);
+ AddAttribute (GetAttributeName (key), value, key);
+ }
+
+
+ public virtual void AddAttribute (HtmlTextWriterAttribute key, string value)
+ {
+ AddAttribute (key, value, true);
+ }
+
+
+ public virtual void AddAttribute (string name, string value, bool fEncode)
+ {
+ if (fEncode)
+ ; // FIXME
+
+ AddAttribute (name, value, GetAttributeKey (name));
+ }
+
+ public virtual void AddAttribute (string name, string value)
+ {
+ AddAttribute (name, value, true);
+ }
+
+ protected virtual void AddAttribute (string name, string value, HtmlTextWriterAttribute key)
+ {
+ AddedAttr a = new AddedAttr ();
+ a.name = name;
+ a.value = value;
+ a.key = key;
+ attrs.Add (a);
+ }
+
+
+ protected virtual void AddStyleAttribute (string name, string value, HtmlTextWriterStyle key)
+ {
+ AddedStyle a = new AddedStyle ();
+ a.name = name;
+ a.value = value;
+ a.key = key;
+ styles.Add (a);
+ }
+
+
+ public virtual void AddStyleAttribute (string name, string value)
+ {
+ AddStyleAttribute (name, value, GetStyleKey (name));
+ }
+
+ public virtual void AddStyleAttribute (HtmlTextWriterStyle key, string value)
+ {
+ AddStyleAttribute (GetStyleName (key), value, key);
+ }
+
+ public override void Close ()
+ {
+ b.Close ();
+ }
+
+ [MonoTODO]
+ protected virtual string EncodeAttributeValue (HtmlTextWriterAttribute attrKey, string value)
+ {
+ return value;
+ }
+
+ [MonoTODO]
+ protected string EncodeAttributeValue (string value, bool fEncode)
+ {
+ return value;
+ }
+
+ [MonoTODO]
+ protected string EncodeUrl (string url)
+ {
+ return url;
+ }
+
+
+ protected virtual void FilterAttributes ()
+ {
+ AddedAttr style_attr = null;
+
+ foreach (AddedAttr a in attrs) {
+ if (OnAttributeRender (a.name, a.value, a.key)) {
+ if (a.key == HtmlTextWriterAttribute.Style) {
+ style_attr = a;
+ continue;
+ }
+
+ WriteAttribute (a.name, a.value, false);
+ }
+ }
+
+ attrs.Clear ();
+
+ if (styles.Count != 0 || style_attr != null) {
+ Write (SpaceChar);
+ Write ("style");
+ Write (EqualsDoubleQuoteString);
+
+ foreach (AddedStyle a in styles)
+ if (OnStyleAttributeRender (a.name, a.value, a.key))
+ WriteStyleAttribute (a.name, a.value, false);
+
+ if (style_attr != null)
+ Write (style_attr.value);
+
+ Write (DoubleQuoteChar);
+ }
+
+ styles.Clear ();
+ }
+
+ public override void Flush ()
+ {
+ b.Flush ();
+ }
+
+ [MonoTODO]
+ protected HtmlTextWriterAttribute GetAttributeKey (string attrName)
+ {
+ // I don't think we want to binary search
+ // because there might be something added to
+ // the enum later. Do we really need anything
+ // faster than a linear search?
+
+ foreach (HtmlAttribute t in htmlattrs) {
+ if (t.name == attrName)
+ return t.key;
+ }
+
+ return 0;
+ }
+
+ [MonoTODO]
+ protected string GetAttributeName (HtmlTextWriterAttribute attrKey)
+ {
+ if ((int) attrKey < htmlattrs.Length)
+ return htmlattrs [(int) attrKey].name;
+
+ return null;
+ }
+
+ [MonoTODO]
+ protected HtmlTextWriterStyle GetStyleKey (string styleName)
+ {
+ // I don't think we want to binary search
+ // because there might be something added to
+ // the enum later. Do we really need anything
+ // faster than a linear search?
+
+ foreach (HtmlStyle t in htmlstyles) {
+ if (t.name == styleName)
+ return t.key;
+ }
+
+ return 0;
+ }
+
+ [MonoTODO]
+ protected string GetStyleName (HtmlTextWriterStyle styleKey)
+ {
+ if ((int) styleKey < htmlstyles.Length)
+ return htmlstyles [(int) styleKey].name;
+
+ return null;
+ }
+
+ [MonoTODO]
+ protected virtual HtmlTextWriterTag GetTagKey (string tagName)
+ {
+ // I don't think we want to binary search
+ // because there might be something added to
+ // the enum later. Do we really need anything
+ // faster than a linear search?
+
+ foreach (HtmlTag t in tags) {
+ if (t.name == tagName)
+ return t.key;
+ }
+
+ return HtmlTextWriterTag.Unknown;
+ }
+
+ internal static string StaticGetTagName (HtmlTextWriterTag tagKey)
+ {
+ if ((int) tagKey < tags.Length)
+ return tags [(int) tagKey].name;
+
+ return null;
+ }
+
+
+ [MonoTODO]
+ protected virtual string GetTagName (HtmlTextWriterTag tagKey)
+ {
+ if ((int) tagKey < tags.Length)
+ return tags [(int) tagKey].name;
+
+ return null;
+ }
+
+ protected bool IsAttributeDefined (HtmlTextWriterAttribute key)
+ {
+ string value;
+ return IsAttributeDefined (key, out value);
+ }
+
+ protected bool IsAttributeDefined (HtmlTextWriterAttribute key, out string value)
+ {
+ foreach (AddedAttr a in attrs)
+ if (a.key == key) {
+ value = a.value;
+ return true;
+ }
+
+ value = null;
+ return false;
+ }
+
+ protected bool IsStyleAttributeDefined (HtmlTextWriterStyle key)
+ {
+ string value;
+ return IsStyleAttributeDefined (key, out value);
+ }
+
+ protected bool IsStyleAttributeDefined (HtmlTextWriterStyle key, out string value)
+ {
+
+ foreach (AddedStyle a in styles)
+ if (a.key == key){
+ value = a.value;
+ return true;
+ }
+
+ value = null;
+ return false;
+ }
+
+ protected virtual bool OnAttributeRender (string name, string value, HtmlTextWriterAttribute key)
+ {
+ return true;
+ }
+
+ protected virtual bool OnStyleAttributeRender (string name, string value, HtmlTextWriterStyle key)
+ {
+ return true;
+ }
+
+ protected virtual bool OnTagRender (string name, HtmlTextWriterTag key)
+ {
+ return true;
+ }
+
+
+ protected virtual void OutputTabs ()
+ {
+ if (! newline)
+ return;
+ newline = false;
+
+ for (int i = 0; i < Indent; i ++)
+ b.Write (tab_string);
+ }
+
+ class TagStack {
+ public string name;
+ public HtmlTextWriterTag key;
+ public TagStack next;
+ }
+
+ TagStack cur_tag;
+
+ protected string PopEndTag ()
+ {
+ if (cur_tag == null)
+ throw new InvalidOperationException ();
+
+ string s = TagName;
+ cur_tag = cur_tag.next;
+ return s;
+ }
+
+ protected void PushEndTag (string endTag)
+ {
+ // TODO optimize -- too much memory!
+ TagStack ts = new TagStack ();
+ ts.next = cur_tag;
+ cur_tag = ts;
+ TagName = endTag;
+ }
+
+ void PushEndTag (HtmlTextWriterTag t)
+ {
+ // TODO optimize!
+ TagStack ts = new TagStack ();
+ ts.next = cur_tag;
+ cur_tag = ts;
+ TagKey = t;
+ }
+
+
+ protected virtual string RenderAfterContent ()
+ {
+ return null;
+ }
+
+ protected virtual string RenderAfterTag ()
+ {
+ return null;
+ }
+
+ protected virtual string RenderBeforeContent ()
+ {
+ return null;
+ }
+
+ protected virtual string RenderBeforeTag ()
+ {
+ return null;
+ }
+
+ public virtual void RenderBeginTag (string tagName)
+ {
+ if (! OnTagRender (tagName, GetTagKey (tagName)))
+ return;
+
+ PushEndTag (tagName);
+
+ DoBeginTag ();
+ }
+
+ public virtual void RenderBeginTag (HtmlTextWriterTag tagKey)
+ {
+ if (! OnTagRender (GetTagName (tagKey), tagKey))
+ return;
+
+ PushEndTag (tagKey);
+
+ DoBeginTag ();
+ }
+
+ void WriteIfNotNull (string s)
+ {
+ if (s != null)
+ Write (s);
+ }
+
+
+ void DoBeginTag ()
+ {
+ WriteIfNotNull (RenderBeforeTag ());
+ WriteBeginTag (TagName);
+ FilterAttributes ();
+
+ HtmlTextWriterTag key = (int) TagKey < tags.Length ? TagKey : HtmlTextWriterTag.Unknown;
+
+ switch (tags [(int) key].tag_type) {
+ case TagType.Inline:
+ Write (TagRightChar);
+ break;
+ case TagType.Block:
+ Write (TagRightChar);
+ WriteLine ();
+ Indent ++;
+ break;
+ case TagType.SelfClosing:
+ Write (SelfClosingTagEnd);
+ break;
+ }
+
+ // FIXME what do i do for self close here?
+ WriteIfNotNull (RenderBeforeContent ());
+ }
+
+
+ public virtual void RenderEndTag ()
+ {
+ // FIXME what do i do for self close here?
+ WriteIfNotNull (RenderAfterContent ());
+
+ HtmlTextWriterTag key = (int) TagKey < tags.Length ? TagKey : HtmlTextWriterTag.Unknown;
+
+ switch (tags [(int) key].tag_type) {
+ case TagType.Inline:
+ WriteEndTag (TagName);
+ break;
+ case TagType.Block:
+ Indent --;
+ WriteLineNoTabs ("");
+ WriteEndTag (TagName);
+
+ break;
+ case TagType.SelfClosing:
+ // NADA
+ break;
+ }
+ WriteIfNotNull (RenderAfterTag ());
+
+ PopEndTag ();
+ }
+
+
+ public virtual void WriteAttribute (string name, string value, bool fEncode)
+ {
+ Write (SpaceChar);
+ Write (name);
+ if (value != null) {
+ Write (EqualsDoubleQuoteString);
+ value = EncodeAttributeValue (value, fEncode);
+ Write (value);
+ Write (DoubleQuoteChar);
+ }
+ }
+
+
+ public virtual void WriteBeginTag (string tagName)
+ {
+ Write (TagLeftChar);
+ Write (tagName);
+ }
+
+ public virtual void WriteEndTag (string tagName)
+ {
+ Write (EndTagLeftChars);
+ Write (tagName);
+ Write (TagRightChar);
+ }
+
+ public virtual void WriteFullBeginTag (string tagName)
+ {
+ Write (TagLeftChar);
+ Write (tagName);
+ Write (TagRightChar);
+ }
+
+ public virtual void WriteStyleAttribute (string name, string value)
+ {
+ WriteStyleAttribute (name, value, true);
+ }
+
+ public virtual void WriteStyleAttribute (string name, string value, bool fEncode)
+ {
+ Write (name);
+ Write (StyleEqualsChar);
+ Write (EncodeAttributeValue (value, fEncode));
+ Write (SemicolonChar);
+ }
+
+ public override void Write (char [] buffer, int index, int count)
+ {
+ OutputTabs ();
+ b.Write (buffer, index, count);
+ }
+
+ public override void Write (double value)
+ {
+ OutputTabs ();
+ b.Write (value);
+ }
+
+ public override void Write (char value)
+ {
+ OutputTabs ();
+ b.Write (value);
+ }
+
+ public override void Write (char [] buffer)
+ {
+ OutputTabs ();
+ b.Write (buffer);
+ }
+
+ public override void Write (int value)
+ {
+ OutputTabs ();
+ b.Write (value);
+ }
+
+ public override void Write (string format, object arg0)
+ {
+ OutputTabs ();
+ b.Write (format, arg0);
+ }
+
+ public override void Write (string format, object arg0, object arg1)
+ {
+ OutputTabs ();
+ b.Write (format, arg0, arg1);
+ }
+
+ public override void Write (string format, params object [] args)
+ {
+ OutputTabs ();
+ b.Write (format, args);
+ }
+
+ public override void Write (string s)
+ {
+ OutputTabs ();
+ b.Write (s);
+ }
+
+ public override void Write (long value)
+ {
+ OutputTabs ();
+ b.Write (value);
+ }
+
+ public override void Write (object value)
+ {
+ OutputTabs ();
+ b.Write (value);
+ }
+
+ public override void Write (float value)
+ {
+ OutputTabs ();
+ b.Write (value);
+ }
+
+ public override void Write (bool value)
+ {
+ OutputTabs ();
+ b.Write (value);
+ }
+
+ public virtual void WriteAttribute (string name, string value)
+ {
+ WriteAttribute (name, value, true);
+ }
+
+ public override void WriteLine (char value)
+ {
+ OutputTabs ();
+ b.WriteLine (value);
+ newline = true;
+ }
+
+ public override void WriteLine (long value)
+ {
+ OutputTabs ();
+ b.WriteLine (value);
+ newline = true;
+ }
+
+ public override void WriteLine (object value)
+ {
+ OutputTabs ();
+ b.WriteLine (value);
+ newline = true;
+ }
+
+ public override void WriteLine (double value)
+ {
+ OutputTabs ();
+ b.WriteLine (value);
+ newline = true;
+ }
+
+ public override void WriteLine (char [] buffer, int index, int count)
+ {
+ OutputTabs ();
+ b.WriteLine (buffer, index, count);
+ newline = true;
+ }
+
+ public override void WriteLine (char [] buffer)
+ {
+ OutputTabs ();
+ b.WriteLine (buffer);
+ newline = true;
+ }
+
+ public override void WriteLine (bool value)
+ {
+ OutputTabs ();
+ b.WriteLine (value);
+ newline = true;
+ }
+
+ public override void WriteLine ()
+ {
+ OutputTabs ();
+ b.WriteLine ();
+ newline = true;
+ }
+
+ public override void WriteLine (int value)
+ {
+ OutputTabs ();
+ b.WriteLine (value);
+ newline = true;
+ }
+
+ public override void WriteLine (string format, object arg0, object arg1)
+ {
+ OutputTabs ();
+ b.WriteLine (format, arg0, arg1);
+ newline = true;
+ }
+
+ public override void WriteLine (string format, object arg0)
+ {
+ OutputTabs ();
+ b.WriteLine (format, arg0);
+ newline = true;
+ }
+
+ public override void WriteLine (string format, params object [] args)
+ {
+ OutputTabs ();
+ b.WriteLine (format, args);
+ newline = true;
+ }
+
+ [CLSCompliant (false)]
+ public override void WriteLine (uint value)
+ {
+ OutputTabs ();
+ b.WriteLine (value);
+ newline = true;
+ }
+
+ public override void WriteLine (string s)
+ {
+ OutputTabs ();
+ b.WriteLine (s);
+ newline = true;
+ }
+
+ public override void WriteLine (float value)
+ {
+ OutputTabs ();
+ b.WriteLine (value);
+ newline = true;
+ }
+
+ public void WriteLineNoTabs (string s)
+ {
+ b.WriteLine (s);
+ newline = true;
+ }
+
+ public override Encoding Encoding {
+ get {
+ return b.Encoding;
+ }
+ }
+
+ int indent;
+ public int Indent {
+ get {
+ return indent;
+ }
+ set {
+ indent = value;
+ }
+ }
+
+ public System.IO.TextWriter InnerWriter {
+ get {
+ return b;
+ }
+ set {
+ b = value;
+ }
+ }
+
+ public override string NewLine {
+ get {
+ return b.NewLine;
+ }
+ set {
+ b.NewLine = value;
+ }
+ }
+
+ protected HtmlTextWriterTag TagKey {
+ get {
+ if (cur_tag == null)
+ throw new InvalidOperationException ();
+
+ return cur_tag.key;
+ }
+ set {
+ cur_tag.key = value;
+ cur_tag.name = GetTagName (value);
+ }
+ }
+
+ protected string TagName {
+ get {
+ if (cur_tag == null)
+ throw new InvalidOperationException ();
+
+ return cur_tag.name;
+ }
+ set {
+ cur_tag.name = value;
+ cur_tag.key = GetTagKey (value);
+ if (cur_tag.key != HtmlTextWriterTag.Unknown)
+ cur_tag.name = GetTagName (cur_tag.key);
+ }
+ }
+
+
+ TextWriter b;
+ string tab_string;
+ bool newline;
+
+ public const string DefaultTabString = "\t";
+ public const char DoubleQuoteChar = '"';
+ public const string EndTagLeftChars = "</";
+ public const char EqualsChar = '=';
+ public const string EqualsDoubleQuoteString = "=\"";
+ public const string SelfClosingChars = " /";
+ public const string SelfClosingTagEnd = " />";
+ public const char SemicolonChar = ';';
+ public const char SingleQuoteChar = '\'';
+ public const char SlashChar = '/';
+ public const char SpaceChar = ' ' ;
+ public const char StyleEqualsChar = ':';
+ public const char TagLeftChar = '<';
+ public const char TagRightChar = '>';
+
+ enum TagType {
+ Block,
+ Inline,
+ SelfClosing,
+ }
+
+
+ struct HtmlTag {
+ public HtmlTextWriterTag key;
+ public string name;
+ public TagType tag_type;
+
+ public HtmlTag (HtmlTextWriterTag k, string n, TagType tt)
+ {
+ key = k;
+ name = n;
+ tag_type = tt;
+ }
+ }
+
+ struct HtmlStyle {
+ public HtmlTextWriterStyle key;
+ public string name;
+
+ public HtmlStyle (HtmlTextWriterStyle k, string n)
+ {
+ key = k;
+ name = n;
+ }
+ }
+
+
+ struct HtmlAttribute {
+ public HtmlTextWriterAttribute key;
+ public string name;
+
+ public HtmlAttribute (HtmlTextWriterAttribute k, string n)
+ {
+ key = k;
+ name = n;
+ }
+ }
+
+ static HtmlTag [] tags = {
+ new HtmlTag (HtmlTextWriterTag.Unknown, "", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.A, "a", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Acronym, "acronym", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Address, "address", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Area, "area", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.B, "b", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Base, "base", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Basefont, "basefont", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Bdo, "bdo", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Bgsound, "bgsound", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Big, "big", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Blockquote, "blockquote", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Body, "body", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Br, "br", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Button, "button", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Caption, "caption", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Center, "center", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Cite, "cite", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Code, "code", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Col, "col", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Colgroup, "colgroup", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Dd, "dd", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Del, "del", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Dfn, "dfn", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Dir, "dir", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Div, "div", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Dl, "dl", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Dt, "dt", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Em, "em", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Embed, "embed", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Fieldset, "fieldset", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Font, "font", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Form, "form", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Frame, "frame", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Frameset, "frameset", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.H1, "h1", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.H2, "h2", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.H3, "h3", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.H4, "h4", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.H5, "h5", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.H6, "h6", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Head, "head", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Hr, "hr", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Html, "html", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.I, "i", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Iframe, "iframe", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Img, "img", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Input, "input", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Ins, "ins", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Isindex, "isindex", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Kbd, "kbd", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Label, "label", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Legend, "legend", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Li, "li", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Link, "link", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Map, "map", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Marquee, "marquee", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Menu, "menu", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Meta, "meta", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Nobr, "nobr", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Noframes, "noframes", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Noscript, "noscript", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Object, "object", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Ol, "ol", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Option, "option", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.P, "p", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Param, "param", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Pre, "pre", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Q, "q", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Rt, "rt", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Ruby, "ruby", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.S, "s", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Samp, "samp", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Script, "script", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Select, "select", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Small, "small", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Span, "span", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Strike, "strike", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Strong, "strong", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Style, "style", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Sub, "sub", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Sup, "sup", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Table, "table", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Tbody, "tbody", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Td, "td", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Textarea, "textarea", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Tfoot, "tfoot", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Th, "th", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Thead, "thead", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Title, "title", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Tr, "tr", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Tt, "tt", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.U, "u", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Ul, "ul", TagType.Block),
+ new HtmlTag (HtmlTextWriterTag.Var, "var", TagType.Inline),
+ new HtmlTag (HtmlTextWriterTag.Wbr, "wbr", TagType.SelfClosing),
+ new HtmlTag (HtmlTextWriterTag.Xml, "xml", TagType.Block),
+ };
+
+ HtmlAttribute [] htmlattrs = {
+ new HtmlAttribute (HtmlTextWriterAttribute.Accesskey, "accesskey"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Align, "align"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Alt, "alt"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Background, "background"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Bgcolor, "bgcolor"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Border, "border"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Bordercolor, "bordercolor"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Cellpadding, "cellpadding"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Cellspacing, "cellspacing"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Checked, "checked"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Class, "class"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Cols, "cols"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Colspan, "colspan"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Disabled, "disabled"),
+ new HtmlAttribute (HtmlTextWriterAttribute.For, "for"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Height, "height"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Href, "href"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Id, "id"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Maxlength, "maxlength"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Multiple, "multiple"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Name, "name"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Nowrap, "nowrap"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Onchange, "onchange"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Onclick, "onclick"),
+ new HtmlAttribute (HtmlTextWriterAttribute.ReadOnly, "readonly"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Rows, "rows"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Rowspan, "rowspan"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Rules, "rules"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Selected, "selected"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Size, "size"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Src, "src"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Style, "style"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Tabindex, "tabindex"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Target, "target"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Title, "title"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Type, "type"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Valign, "valign"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Value, "value"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Width, "width"),
+ new HtmlAttribute (HtmlTextWriterAttribute.Wrap, "wrap"),
+ };
+
+ HtmlStyle [] htmlstyles = {
+ new HtmlStyle (HtmlTextWriterStyle.BackgroundColor, "background-color"),
+ new HtmlStyle (HtmlTextWriterStyle.BackgroundImage, "background-image"),
+ new HtmlStyle (HtmlTextWriterStyle.BorderCollapse, "border-collapse"),
+ new HtmlStyle (HtmlTextWriterStyle.BorderColor, "border-color"),
+ new HtmlStyle (HtmlTextWriterStyle.BorderStyle, "border-style"),
+ new HtmlStyle (HtmlTextWriterStyle.BorderWidth, "border-width"),
+ new HtmlStyle (HtmlTextWriterStyle.Color, "color"),
+ new HtmlStyle (HtmlTextWriterStyle.FontFamily, "font-family"),
+ new HtmlStyle (HtmlTextWriterStyle.FontSize, "font-size"),
+ new HtmlStyle (HtmlTextWriterStyle.FontStyle, "font-style"),
+ new HtmlStyle (HtmlTextWriterStyle.FontWeight, "font-weight"),
+ new HtmlStyle (HtmlTextWriterStyle.Height, "height"),
+ new HtmlStyle (HtmlTextWriterStyle.TextDecoration, "text-decoration"),
+ new HtmlStyle (HtmlTextWriterStyle.Width, "width"),
+ };
+ }
+}