| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907 |
- //
- // System.Web.Compilation.AspElements
- //
- // Authors:
- // Gonzalo Paniagua Javier ([email protected])
- //
- // (C) 2002 Ximian, Inc (http://www.ximian.com)
- //
- using System;
- using System.Collections;
- using System.IO;
- using System.Reflection;
- using System.Text;
- using System.Web.UI;
- using System.Web.UI.HtmlControls;
- using System.Web.UI.WebControls;
- using System.Web.Util;
- namespace System.Web.Compilation
- {
-
- enum ElementType
- {
- TAG,
- PLAINTEXT
- }
- abstract class Element
- {
- private ElementType elementType;
- public Element (ElementType type)
- {
- elementType = type;
- }
-
- public ElementType GetElementType
- {
- get { return elementType; }
- }
- } // class Element
- class PlainText : Element
- {
- private StringBuilder text;
- public PlainText () : base (ElementType.PLAINTEXT)
- {
- text = new StringBuilder ();
- }
- public PlainText (StringBuilder text) : base (ElementType.PLAINTEXT)
- {
- this.text = text;
- }
- public PlainText (string text) : this ()
- {
- this.text.Append (text);
- }
- public void Append (string more)
- {
- text.Append (more);
- }
-
- public string Text
- {
- get { return text.ToString (); }
- }
- public override string ToString ()
- {
- return "PlainText: " + Text;
- }
- }
- enum TagType
- {
- DIRECTIVE,
- HTML,
- HTMLCONTROL,
- SERVERCONTROL,
- INLINEVAR,
- INLINECODE,
- CLOSING,
- SERVEROBJECT,
- PROPERTYTAG,
- CODERENDER,
- DATABINDING,
- SERVERCOMMENT,
- NOTYET
- }
- /*
- * Attributes and values are stored in a couple of ArrayList in Add ().
- * When MakeHash () is called, they are converted to a Hashtable. If there are any
- * attributes duplicated it throws an ArgumentException.
- *
- * The [] operator works with the Hashtable if the values are in it, otherwise
- * it uses the ArrayList's.
- *
- * Why? You can have a tag in HTML like <a att="value" att="xxx">, but not in tags
- * marked runat=server and Hashtable requires the key to be unique.
- *
- */
- class TagAttributes
- {
- private Hashtable atts_hash;
- private ArrayList keys;
- private ArrayList values;
- private bool got_hashed;
- public TagAttributes ()
- {
- got_hashed = false;
- keys = new ArrayList ();
- values = new ArrayList ();
- }
- private void MakeHash ()
- {
- atts_hash = new Hashtable (CaseInsensitiveHashCodeProvider.Default,
- CaseInsensitiveComparer.Default);
- for (int i = 0; i < keys.Count; i++)
- atts_hash.Add (keys [i], values [i]);
- got_hashed = true;
- keys = null;
- values = null;
- }
-
- public bool IsRunAtServer ()
- {
- return got_hashed;
- }
- public void Add (object key, object value)
- {
- if (key != null && value != null &&
- 0 == String.Compare ((string) key, "runat", true) &&
- 0 == String.Compare ((string) value, "server", true))
- MakeHash ();
- if (got_hashed)
- atts_hash.Add (key, value);
- else {
- keys.Add (key);
- values.Add (value);
- }
- }
-
- public ICollection Keys
- {
- get { return (got_hashed ? atts_hash.Keys : keys); }
- }
- private int CaseInsensitiveSearch (string key)
- {
- // Hope not to have many attributes when the tag is not a server tag...
- for (int i = 0; i < keys.Count; i++){
- if (0 == String.Compare ((string) keys [i], key, true))
- return i;
- }
- return -1;
- }
-
- public object this [object key]
- {
- get {
- if (got_hashed)
- return atts_hash [key];
- int idx = CaseInsensitiveSearch ((string) key);
- if (idx == -1)
- return null;
-
- return values [idx];
- }
- set {
- if (got_hashed)
- atts_hash [key] = value;
- else {
- int idx = CaseInsensitiveSearch ((string) key);
- keys [idx] = value;
- }
- }
- }
-
- public int Count
- {
- get { return (got_hashed ? atts_hash.Count : keys.Count);}
- }
- public bool IsDataBound (string att)
- {
- if (att == null || !got_hashed)
- return false;
- return (att.StartsWith ("<%#") && att.EndsWith ("%>"));
- }
-
- public override string ToString ()
- {
- StringBuilder result = new StringBuilder ();
- string value;
- foreach (string key in Keys){
- result.Append (key);
- value = this [key] as string;
- if (value != null)
- result.AppendFormat ("=\"{0}\"", value);
- result.Append (' ');
- }
- if (result.Length > 0 && result [result.Length - 1] == ' ')
- result.Length--;
-
- return result.ToString ();
- }
- }
- class Tag : Element
- {
- protected string tag;
- protected TagType tagType;
- protected TagAttributes attributes;
- protected bool self_closing;
- protected bool hasDefaultID;
- private static int ctrlNumber = 1;
- ArrayList elements;
- internal Tag (ElementType etype) : base (etype) { }
- internal Tag (Tag other) :
- this (other.tag, other.attributes, other.self_closing)
- {
- this.tagType = other.tagType;
- }
- public Tag (string tag, TagAttributes attributes, bool self_closing) :
- base (ElementType.TAG)
- {
- if (tag == null)
- throw new ArgumentNullException ();
- this.tag = tag;
- this.attributes = attributes;
- this.tagType = TagType.NOTYET;
- this.self_closing = self_closing;
- this.hasDefaultID = false;
- }
- void ParseError (string msg, int line, int col)
- {
- string exc = String.Format ("error parsing attributes: {0}", msg);
- throw new HttpException (exc);
- }
- void TagParsed (Tag tag, int line, int col)
- {
- elements.Add (tag);
- }
- void TextParsed (string msg, int line, int col)
- {
- elements.Add (new PlainText (msg));
- }
- public ArrayList GetElements ()
- {
- string text = this.PlainHtml;
- string inner = text.Substring (1, text.Length - 2);
- byte [] bytes = WebEncoding.Encoding.GetBytes (inner);
- AspTokenizer tok = new AspTokenizer ("@@inner_string", new MemoryStream (bytes));
- AspParser parser = new AspParser (tok);
- elements = new ArrayList ();
- parser.Error += new ParseErrorHandler (ParseError);
- parser.TagParsed += new TagParsedHandler (TagParsed);
- parser.TextParsed += new TextParsedHandler (TextParsed);
- parser.Parse ();
- elements.Insert (0, new PlainText ("<"));
- elements.Add (new PlainText (">"));
- return elements;
- }
- public string TagID
- {
- get { return tag; }
- }
- public TagType TagType
- {
- get { return tagType; }
- }
- public bool SelfClosing
- {
- get { return self_closing; }
- }
- public TagAttributes Attributes
- {
- get { return attributes; }
- }
- public string PlainHtml
- {
- get {
- StringBuilder plain = new StringBuilder ();
- plain.Append ('<');
- if (tagType == TagType.CLOSING)
- plain.Append ('/');
- plain.Append (tag);
- if (attributes != null){
- plain.Append (' ');
- plain.Append (attributes.ToString ());
- }
-
- if (self_closing)
- plain.Append ('/');
- plain.Append ('>');
- return plain.ToString ();
- }
- }
- public override string ToString ()
- {
- return TagID + " " + Attributes + " " + self_closing;
- }
- public bool HasDefaultID
- {
- get { return hasDefaultID; }
- }
-
- protected virtual void SetNewID ()
- {
- if (attributes == null)
- attributes = new TagAttributes ();
- attributes.Add ("ID", GetDefaultID ());
- hasDefaultID = true;
- }
- public static string GetDefaultID ()
- {
- return "_control" + ctrlNumber++;
- }
- }
- class CloseTag : Tag
- {
- public CloseTag (string tag) : base (tag, null, false)
- {
- tagType = TagType.CLOSING;
- }
- }
- class Directive : Tag
- {
- // 'codebehind' is just ignored for Page, Application and Control
- private static Hashtable directivesHash;
- private static string [] page_atts = { "AspCompat", "AutoEventWireup", "Buffer",
- "ClassName", "ClientTarget", "CodePage",
- "CompilerOptions", "ContentType", "Culture", "Debug",
- "Description", "EnableSessionState", "EnableViewState",
- "EnableViewStateMac", "ErrorPage", "Explicit",
- "Inherits", "Language", "LCID", "ResponseEncoding",
- "Src", "SmartNavigation", "Strict", "Trace",
- "TraceMode", "Transaction", "UICulture",
- "WarningLevel", "CodeBehind" };
- private static string [] control_atts = { "AutoEventWireup", "ClassName", "CompilerOptions",
- "Debug", "Description", "EnableViewState",
- "Explicit", "Inherits", "Language", "Strict", "Src",
- "WarningLevel", "CodeBehind" };
- private static string [] import_atts = { "namespace" };
- private static string [] implements_atts = { "interface" };
- private static string [] assembly_atts = { "name", "src" };
- private static string [] register_atts = { "tagprefix", "tagname", "Namespace",
- "Src", "Assembly" };
- private static string [] outputcache_atts = { "Duration", "Location", "VaryByControl",
- "VaryByCustom", "VaryByHeader", "VaryByParam" };
- private static string [] reference_atts = { "page", "control" };
- private static string [] webservice_atts = { "class", "codebehind", "debug", "language" };
- private static string [] application_atts = { "description", "inherits", "codebehind" };
- static Directive ()
- {
- InitHash ();
- }
-
- private static void InitHash ()
- {
- CaseInsensitiveHashCodeProvider provider = new CaseInsensitiveHashCodeProvider ();
- CaseInsensitiveComparer comparer = new CaseInsensitiveComparer ();
- directivesHash = new Hashtable (provider, comparer);
- // Use Hashtable 'cause is O(1) in Contains (ArrayList is O(n))
- Hashtable valid_attributes = new Hashtable (provider, comparer);
- foreach (string att in page_atts) valid_attributes.Add (att, null);
- directivesHash.Add ("PAGE", valid_attributes);
- valid_attributes = new Hashtable (provider, comparer);
- foreach (string att in control_atts) valid_attributes.Add (att, null);
- directivesHash.Add ("CONTROL", valid_attributes);
- valid_attributes = new Hashtable (provider, comparer);
- foreach (string att in import_atts) valid_attributes.Add (att, null);
- directivesHash.Add ("IMPORT", valid_attributes);
- valid_attributes = new Hashtable (provider, comparer);
- foreach (string att in implements_atts) valid_attributes.Add (att, null);
- directivesHash.Add ("IMPLEMENTS", valid_attributes);
- valid_attributes = new Hashtable (provider, comparer);
- foreach (string att in register_atts) valid_attributes.Add (att, null);
- directivesHash.Add ("REGISTER", valid_attributes);
- valid_attributes = new Hashtable (provider, comparer);
- foreach (string att in assembly_atts) valid_attributes.Add (att, null);
- directivesHash.Add ("ASSEMBLY", valid_attributes);
- valid_attributes = new Hashtable (provider, comparer);
- foreach (string att in outputcache_atts) valid_attributes.Add (att, null);
- directivesHash.Add ("OUTPUTCACHE", valid_attributes);
- valid_attributes = new Hashtable (provider, comparer);
- foreach (string att in reference_atts) valid_attributes.Add (att, null);
- directivesHash.Add ("REFERENCE", valid_attributes);
- valid_attributes = new Hashtable (provider, comparer);
- foreach (string att in webservice_atts) valid_attributes.Add (att, null);
- directivesHash.Add ("WEBSERVICE", valid_attributes);
- valid_attributes = new Hashtable (provider, comparer);
- foreach (string att in application_atts) valid_attributes.Add (att, null);
- directivesHash.Add ("APPLICATION", valid_attributes);
- }
-
- public Directive (string tag, TagAttributes attributes) :
- base (tag, attributes, true)
- {
- CheckAttributes ();
- tagType = TagType.DIRECTIVE;
- }
- private void CheckAttributes ()
- {
- Hashtable atts;
- if (!(directivesHash [tag] is Hashtable))
- throw new ApplicationException ("Unknown directive: " + tag);
- if (attributes == null || attributes.Count == 0)
- return;
- atts = (Hashtable) directivesHash [tag];
- foreach (string att in attributes.Keys){
- if (!atts.Contains (att))
- throw new ApplicationException ("Attribute " + att +
- " not valid for tag " + tag);
- }
- }
- public static bool IsDirectiveID (string id)
- {
- return directivesHash.Contains (id);
- }
-
- public override string ToString ()
- {
- return "Directive: " + tag;
- }
- }
- class ServerObjectTag : Tag
- {
- public ServerObjectTag (Tag tag) :
- base (tag.TagID, tag.Attributes, tag.SelfClosing)
- {
- tagType = TagType.SERVEROBJECT;
- if (!attributes.IsRunAtServer ())
- throw new ApplicationException ("<object> without runat=server");
-
- if (attributes.Count != 3 || !SelfClosing || ObjectID == null || ObjectClass == null)
- throw new ApplicationException ("Incorrect syntax: <object id=\"name\" " +
- "class=\"full.class.name\" runat=\"server\" />");
- }
- public string ObjectID
- {
- get { return (string) attributes ["id"]; }
- }
-
- public string ObjectClass
- {
- get { return (string) attributes ["class"]; }
- }
- }
- class HtmlControlTag : Tag
- {
- private Type control_type;
- private bool is_container;
- private string parse_children;
- private bool got_parse_children;
- private static Hashtable controls;
- private static Hashtable inputTypes;
- private static void InitHash ()
- {
- controls = new Hashtable (new CaseInsensitiveHashCodeProvider (),
- new CaseInsensitiveComparer ());
- controls.Add ("A", typeof (HtmlAnchor));
- controls.Add ("BUTTON", typeof (HtmlButton));
- controls.Add ("FORM", typeof (HtmlForm));
- controls.Add ("IMG", typeof (HtmlImage));
- controls.Add ("INPUT", "INPUT");
- controls.Add ("SELECT", typeof (HtmlSelect));
- controls.Add ("TABLE", typeof (HtmlTable));
- controls.Add ("TD", typeof (HtmlTableCell));
- controls.Add ("TH", typeof (HtmlTableCell));
- controls.Add ("TR", typeof (HtmlTableRow));
- controls.Add ("TEXTAREA", typeof (HtmlTextArea));
- inputTypes = new Hashtable (new CaseInsensitiveHashCodeProvider (),
- new CaseInsensitiveComparer ());
- inputTypes.Add ("BUTTON", typeof (HtmlInputButton));
- inputTypes.Add ("SUBMIT", typeof (HtmlInputButton));
- inputTypes.Add ("RESET", typeof (HtmlInputButton));
- inputTypes.Add ("CHECKBOX", typeof (HtmlInputCheckBox));
- inputTypes.Add ("FILE", typeof (HtmlInputFile));
- inputTypes.Add ("HIDDEN", typeof (HtmlInputHidden));
- inputTypes.Add ("IMAGE", typeof (HtmlInputImage));
- inputTypes.Add ("RADIO", typeof (HtmlInputRadioButton));
- inputTypes.Add ("TEXT", typeof (HtmlInputText));
- inputTypes.Add ("PASSWORD", typeof (HtmlInputText));
- }
-
- static HtmlControlTag ()
- {
- InitHash ();
- }
-
- public HtmlControlTag (string tag, TagAttributes attributes, bool self_closing) :
- base (tag, attributes, self_closing)
- {
- SetData ();
- if (attributes == null || attributes ["ID"] == null)
- SetNewID ();
- }
- public HtmlControlTag (Tag source_tag) :
- this (source_tag.TagID, source_tag.Attributes, source_tag.SelfClosing)
- {
- }
- private void SetData ()
- {
- tagType = TagType.HTMLCONTROL;
- if (!(controls [tag] is string)){
- control_type = (Type) controls [tag];
- if (control_type == null)
- control_type = typeof (HtmlGenericControl);
- is_container = (0 != String.Compare (tag, "img", true));
- } else {
- string type_value = (string) attributes ["TYPE"];
- if (type_value== null)
- throw new ArgumentException ("INPUT tag without TYPE attribute!!!");
- control_type = (Type) inputTypes [type_value];
- //TODO: what does MS with this one?
- if (control_type == null)
- throw new ArgumentException ("Unknown input type -> " + type_value);
- is_container = false;
- self_closing = true; // All <input ...> are self-closing
- }
- }
- public Type ControlType
- {
- get { return control_type; }
- }
- public string ControlID
- {
- get { return (string) attributes ["ID"]; }
- }
- public bool IsContainer
- {
- get { return is_container; }
- }
- public string ParseChildren {
- get {
- if (got_parse_children)
- return parse_children;
- got_parse_children = true;
- object [] custom_atts = control_type.GetCustomAttributes (true);
- foreach (object att in custom_atts) {
- if (!(att is ParseChildrenAttribute))
- continue;
- ParseChildrenAttribute pc = (ParseChildrenAttribute) att;
- if (pc.ChildrenAsProperties == true)
- parse_children = pc.DefaultProperty;
- return parse_children;
- }
- return parse_children;
- }
- }
-
- public override string ToString ()
- {
- string ret = "HtmlControlTag: " + tag + " Name: " + ControlID + "Type:" +
- control_type.ToString () + "\n\tAttributes:\n";
- foreach (string key in attributes.Keys){
- ret += "\t" + key + "=" + attributes [key];
- }
- return ret;
- }
- }
- enum ChildrenKind
- {
- NONE,
- /*
- * Children must be ASP.NET server controls. Literal text is passed as LiteralControl.
- * Child controls and text are added using AddParsedSubObject ().
- */
- CONTROLS,
- /*
- * Children must correspond to properties of the parent control. No literal text allowed.
- */
- PROPERTIES,
- /*
- * Special case used inside <columns>...</columns>
- * Only allow DataGridColumn and derived classes.
- */
- DBCOLUMNS,
- /*
- * Special case for list controls (ListBox, DropDownList...)
- */
- LISTITEM,
- /* For HtmlSelect children. They are <option> tags that must
- * be treated as ListItem
- */
- OPTION,
- /* Childs of HtmlTable */
- HTMLROW,
- /* Childs of HtmlTableRow */
- HTMLCELL
- }
- // TODO: support for ControlBuilderAttribute that may be used in custom controls
- class AspComponent : Tag
- {
- private Type type;
- private string alias;
- private string control_type;
- private bool is_close_tag;
- private bool allow_children;
- private ChildrenKind children_kind;
- private string defaultPropertyName;
- private Type defaultPropertyType;
- ChildrenKind ChildrenKindFromProperty (Type type, string propertyName)
- {
- PropertyInfo prop = type.GetProperty (propertyName);
- if (prop == null)
- return ChildrenKind.LISTITEM;
- defaultPropertyType = prop.PropertyType;
- if (typeof (TableRowCollection).IsAssignableFrom (defaultPropertyType))
- return ChildrenKind.HTMLROW;
- if (typeof (TableCellCollection).IsAssignableFrom (defaultPropertyType))
- return ChildrenKind.HTMLCELL;
- return ChildrenKind.LISTITEM;
- }
- private ChildrenKind GuessChildrenKind (Type type)
- {
- object [] custom_atts = type.GetCustomAttributes (true);
- foreach (object custom_att in custom_atts){
- if (custom_att is ParseChildrenAttribute){
- /* FIXME
- * When adding full support for custom controls, we gotta
- * bear in mind the pca.DefaultProperty value
- */
- ParseChildrenAttribute pca = custom_att as ParseChildrenAttribute;
- defaultPropertyName = pca.DefaultProperty;
- /* this property will be true for all controls derived from
- * WebControls. */
- if (pca.ChildrenAsProperties == false)
- return ChildrenKind.CONTROLS;
- else if (defaultPropertyName == "")
- return ChildrenKind.PROPERTIES;
- else
- return ChildrenKindFromProperty (type, defaultPropertyName);
- }
- }
- return ChildrenKind.NONE;
- }
- private static bool GuessAllowChildren (Type type)
- {
- PropertyInfo controls = type.GetProperty ("Controls");
- if (controls == null)
- return false;
- MethodInfo getm = controls.GetGetMethod ();
- object control_instance = Activator.CreateInstance (type);
- object control_collection = getm.Invoke (control_instance, null);
- return (!(control_collection is System.Web.UI.EmptyControlCollection));
- }
-
- public AspComponent (Tag input_tag, Type type) :
- base (input_tag)
- {
- tagType = TagType.SERVERCONTROL;
- this.is_close_tag = input_tag is CloseTag;
- this.type = type;
- this.defaultPropertyName = "";
- this.allow_children = GuessAllowChildren (type);
- if (input_tag.SelfClosing)
- this.children_kind = ChildrenKind.NONE;
- else if (type == typeof (System.Web.UI.WebControls.DataGridColumn) ||
- type.IsSubclassOf (typeof (System.Web.UI.WebControls.DataGridColumn)))
- this.children_kind = ChildrenKind.PROPERTIES;
- else if (type == typeof (System.Web.UI.WebControls.ListItem))
- this.children_kind = ChildrenKind.CONTROLS;
- else
- this.children_kind = GuessChildrenKind (type);
- int pos = input_tag.TagID.IndexOf (':');
- alias = tag.Substring (0, pos);
- control_type = tag.Substring (pos + 1);
- if (attributes == null || attributes ["ID"] == null)
- SetNewID ();
- }
- public Type ComponentType
- {
- get { return type; }
- }
-
- public string ControlID
- {
- get { return (string) attributes ["ID"]; }
- }
- public bool IsCloseTag
- {
- get { return is_close_tag; }
- }
- public bool AllowChildren
- {
- get { return allow_children; }
- }
- public ChildrenKind ChildrenKind
- {
- get { return children_kind; }
- }
- public string DefaultPropertyName
- {
- get { return defaultPropertyName; }
- }
-
- public Type DefaultPropertyType
- {
- get { return defaultPropertyType; }
- }
-
- public override string ToString ()
- {
- return type.ToString () + " Alias: " + alias + " ID: " + (string) attributes ["id"];
- }
- }
- class PropertyTag : Tag
- {
- private Type type;
- private string name;
- public PropertyTag (Tag tag, Type type, string name)
- : base (tag)
- {
- tagType = TagType.PROPERTYTAG;
- SetNewID ();
- this.name = name;
- this.type = type;
- }
- public Type PropertyType
- {
- get { return type; }
- }
- public string PropertyID
- {
- get { return (string) attributes ["ID"]; }
- }
- public string PropertyName
- {
- get { return name; }
- }
- }
- class CodeRenderTag : Tag
- {
- private string code;
- private bool isVarName;
- public CodeRenderTag (bool isVarName, string code) : base ("", null, false)
- {
- tagType = TagType.CODERENDER;
- this.isVarName = isVarName;
- this.code = code.Trim ();
- }
- public string Code
- {
- get { return code; }
- }
- public bool IsVarName
- {
- get { return isVarName; }
- }
- public string AsText
- {
- get { return "<%" + (IsVarName ? "=" : "") + Code + "%>"; }
- }
- }
- class DataBindingTag : Tag
- {
- private string data;
- public DataBindingTag (string data) : base ("", null, false)
- {
- tagType = TagType.DATABINDING;
- this.data = data.Trim ();
- }
- public string Data
- {
- get { return data; }
- }
- public string AsText
- {
- get { return "<%#" + Data + "%>"; }
- }
- }
-
- class ServerComment : Tag
- {
- public ServerComment (string tag)
- : base (ElementType.TAG)
- {
- if (tag == null)
- throw new ArgumentNullException ();
- this.tag = tag;
- this.attributes = null;
- this.tagType = TagType.SERVERCOMMENT;
- this.self_closing = true;
- this.hasDefaultID = false;
- }
-
- public override string ToString ()
- {
- return TagID;
- }
- protected override void SetNewID ()
- {
- throw new NotSupportedException ();
- }
- }
- }
|