Sfoglia il codice sorgente

2002-06-11 Gonzalo Paniagua Javier <[email protected]>

	* System.Web.Caching/CacheDependency.cs: fixed a couple of typos and
	don't throw NotImplementedException in constructors.

	* System.Web.UI/Control.cs:
	(MapPathSecure): until security is implemented, return the same path
	received as argument.
	(RenderControl): call OnPreRender before rendering the control. So
	AdRotator can read its configuration file.Is there any other place
	where this should be done?

	* System.Web.UI/HtmlTextWriter.cs:
	(AddAttribute): fixed. Now it really stores attributes.
	(RenderBeginTag): fixed a couple of bugs (little ones but hard to find).

	* System.Web.UI.WebControls/AdRotator.cs: GetData does not work as it
	should, but now it returns useful data (only the first ad in the file).
	Set the NavigateUrl property in the hyperlink if available.

	* System.Web.UI.WebControls/HyperLink.cs: fixed constructor and a
	couple of stack overflows.

	* System.Web.UI.WebControls/Image.cs: added an attribute and fixed
	stack overflow.

	* System.Web.UI.WebControls/WebControl.cs:
	(RenderBeginTag): fixed.
	(TagName): don't call Enum.IsDefined twice.

svn path=/trunk/mcs/; revision=5230
Gonzalo Paniagua Javier 23 anni fa
parent
commit
b79e2220a3

+ 2 - 4
mcs/class/System.Web/System.Web.Caching/CacheDependency.cs

@@ -23,19 +23,17 @@ namespace System.Web.Caching
 		/// <remarks>
 		/// Added by [email protected]
 		/// </remarks>
-		[MonoTODO("Constrcutor")]
+		[MonoTODO("Constructor")]
 		public CacheDependency(string filename)
 		{
-			throw new NotImplementedException();
 		}
 		
 		/// <remarks>
 		/// Added by [email protected]
 		/// </remarks>
-		[MonoTODO("Constrcutor")]
+		[MonoTODO("Constructor")]
 		public CacheDependency(string[] filenames, string[] cachekeys)
 		{
-			throw new NotImplementedException();
 		}
 
 		public delegate void CacheDependencyCallback(CacheDependency objDependency);

+ 5 - 0
mcs/class/System.Web/System.Web.Caching/ChangeLog

@@ -1,3 +1,8 @@
+2002-06-11  Gonzalo Paniagua Javier <[email protected]>
+
+	* CacheDependency.cs: fixed a couple of typos and don't throw
+	NotImplementedException in constructors.
+
 2001-12-21      Gaurav Vaish <[email protected]>
 
         * CacheDependency.cs:    Some unimplemented methods to make build

+ 10 - 6
mcs/class/System.Web/System.Web.UI.WebControls/AdRotator.cs

@@ -140,6 +140,7 @@ namespace System.Web.UI.WebControls
 			return adsArray;
 		}
 
+		[MonoTODO("CacheDependency does nothing")]
 		private AdRecord[] GetData(string file)
 		{
 			string physPath = MapPathSecure(file);
@@ -168,7 +169,7 @@ namespace System.Web.UI.WebControls
 				for(int i=0 ; i < records.Length; i++)
 				{
 					if(IsAdMatching(records[i]))
-						impressions += records[1].hits;
+						impressions += records[i].hits;
 				}
 				if(impressions!=0)
 				{
@@ -189,17 +190,18 @@ namespace System.Web.UI.WebControls
 					}
 					return records[index].adProps;
 				}
+				//FIXME: the line below added. Where should i init hits to make
+				//impressions not be 0?
+				return records [0].adProps;
 			}
 			return null;
 		}
 
 		private bool IsAdMatching(AdRecord currAd)
 		{
-			if(KeywordFilter!=String.Empty)
-			{
-				if(currAd.keyword.ToLower() == KeywordFilter.ToLower())
-					return false;
-			}
+			if (KeywordFilter != String.Empty)
+				return (0 == String.Compare (currAd.keyword, KeywordFilter, true));
+
 			return true;
 		}
 
@@ -342,6 +344,8 @@ namespace System.Web.UI.WebControls
 			hLink.AccessKey = AccessKey;
 			hLink.Enabled   = Enabled;
 			hLink.TabIndex  = TabIndex;
+			if (navigateUrl != null && navigateUrl.Length != 0)
+				hLink.NavigateUrl = ResolveAdUrl (navigateUrl);
 			hLink.RenderBeginTag(writer);
 			if(ControlStyleCreated)
 			{

+ 14 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,17 @@
+2002-06-11  Gonzalo Paniagua Javier <[email protected]>
+
+	* AdRotator.cs: GetData does not work as it should, but now it returns
+	useful data (only the first ad in the file).  Set the NavigateUrl
+	property in the hyperlink if available.
+
+	* HyperLink.cs: fixed constructor and a couple of stack overflows.
+
+	* Image.cs: added an attribute and fixed stack overflow.
+
+	* WebControl.cs:
+	(RenderBeginTag): fixed.
+	(TagName): don't call Enum.IsDefined twice.
+
 2002-06-03  Gonzalo Paniagua Javier <[email protected]>
 
 	* WebControl.cs: added attributes PersistChildrenAttribute and 

+ 3 - 3
mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs

@@ -26,7 +26,7 @@ namespace System.Web.UI.WebControls
 	[ToolboxData("<{0}:HyperLink runat=\"server\">HyperLink</{0}:HyperLink>")]
 	public class HyperLink: WebControl
 	{
-		public HyperLink(): base()
+		public HyperLink(): base(HtmlTextWriterTag.A)
 		{
 		}
 
@@ -92,7 +92,7 @@ namespace System.Web.UI.WebControls
 
 		protected override void AddAttributesToRender(HtmlTextWriter writer)
 		{
-			AddAttributesToRender(writer);
+			base.AddAttributesToRender(writer);
 			if(NavigateUrl.Length > 0)
 			{
 				writer.AddAttribute(HtmlTextWriterAttribute.Href, NavigateUrl);
@@ -120,7 +120,7 @@ namespace System.Web.UI.WebControls
 				base.AddParsedSubObject(Text);
 				Text = String.Empty;
 			}
-			AddParsedSubObject(obj);
+			base.AddParsedSubObject (obj);
 		}
 
 		protected override void LoadViewState(object savedState)

+ 2 - 1
mcs/class/System.Web/System.Web.UI.WebControls/Image.cs

@@ -19,6 +19,7 @@ using System.ComponentModel;
 namespace System.Web.UI.WebControls
 {
 	[DefaultProperty("ImageUrl")]
+	[ParseChildrenAttribute(false)]
 	public class Image : WebControl
 	{
 		public Image(): base(HtmlTextWriterTag.Img)
@@ -92,7 +93,7 @@ namespace System.Web.UI.WebControls
 
 		protected override void AddAttributesToRender(HtmlTextWriter writer)
 		{
-			AddAttributesToRender(writer);
+			base.AddAttributesToRender(writer);
 			if(ImageUrl.Length > 0)
 			{
 				writer.AddAttribute(HtmlTextWriterAttribute.Src, ResolveUrl(ImageUrl));

+ 4 - 9
mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs

@@ -60,7 +60,7 @@ namespace System.Web.UI.WebControls
 		{
 			controlStyle   = null;
 			enabled        = true;
-			tagName        = null;
+			tagName        = stringTag;
 			attributeState = null;
 		}
 
@@ -84,7 +84,6 @@ namespace System.Web.UI.WebControls
 		{
 			get
 			{
-				throw new NotImplementedException();
 				if(attributes==null)
 				{
 					//FIXME: From where to get StateBag and how? I think this method is OK!
@@ -357,12 +356,7 @@ namespace System.Web.UI.WebControls
 		public virtual void RenderBeginTag(HtmlTextWriter writer)
 		{
 			AddAttributesToRender(writer);
-			if(Enum.IsDefined(typeof(HtmlTextWriterTag), TagKey) )
-			{
-				writer.RenderBeginTag(TagKey);
-				return;
-			}
-			writer.RenderBeginTag(tagName);
+			writer.RenderBeginTag(TagName);
 		}
 
 		public virtual void RenderEndTag(HtmlTextWriter writer)
@@ -382,10 +376,11 @@ namespace System.Web.UI.WebControls
 		{
 			get
 			{
-				if(tagName==null && Enum.IsDefined(typeof(HtmlTextWriterTag), tagKey) )
+				if(tagName == null && tagKey != 0)
 				{
 					tagName = Enum.Format(typeof(HtmlTextWriterTag), tagKey, "G").ToString();
 				}
+				// What if tagName is null and tagKey 0?
 				return tagName;
 			}
 		}

+ 13 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,3 +1,16 @@
+2002-06-11  Gonzalo Paniagua Javier <[email protected]>
+
+	* Control.cs:
+	(MapPathSecure): until security is implemented, return the same path
+	received as argument.
+	(RenderControl): call OnPreRender before rendering the control. So
+	AdRotator can read its configuration file.Is there any other place
+	where this should be done?
+
+	* HtmlTextWriter.cs:
+	(AddAttribute): fixed. Now it really stores attributes.
+	(RenderBeginTag): fixed a couple of bugs (little ones but hard to find).
+
 2002-06-09  Gonzalo Paniagua Javier <[email protected]>
 
 	* ControlCollection.cs:

+ 4 - 1
mcs/class/System.Web/System.Web.UI/Control.cs

@@ -351,8 +351,9 @@ namespace System.Web.UI
 				[MonoTODO]
                 protected string MapPathSecure(string virtualPath)
                 {
-                        throw new NotImplementedException();
                         //TODO: Need to read up on security+web.
+			//Return the same path. So AdRotator can read its config file.
+			return virtualPath;
                 }
                 protected virtual bool OnBubbleEvent(object source, EventArgs args) //DIT
                 {
@@ -531,6 +532,8 @@ namespace System.Web.UI
                 {
                         if (_visible)
                         {
+				// By now, PreRender is fired here.
+				OnPreRender (EventArgs.Empty); //FIXME
                                 //TODO: Something about tracing here.
                                 Render(writer);
                         }

+ 4 - 5
mcs/class/System.Web/System.Web.UI/HtmlTextWriter.cs

@@ -232,7 +232,7 @@ private void AddAttribute(string name, string value, HtmlTextWriterAttribute key
 	rAttr.value = value;
 	rAttr.key = key;
 	rAttr.encode = encode;
-	_attrCount++;
+	_attrList [_attrCount++] = rAttr;
 }
 
 public virtual void AddStyleAttribute(HtmlTextWriterStyle key, string value){
@@ -489,6 +489,7 @@ protected virtual string RenderBeforeTag(){
 
 public virtual void RenderBeginTag(HtmlTextWriterTag tagKey){
 	TagKey = tagKey;
+	bool tagRendered = true;
 	bool tagRender = true;
 	if (_isDescendant) {
 		tagRender = OnTagRender(_tagName, _tagKey);
@@ -501,17 +502,15 @@ public virtual void RenderBeginTag(HtmlTextWriterTag tagKey){
 		}
 	}
 	TagInformation currentTag = HtmlTextWriter._tagNameLookupArray[_tagIndex];
-	bool tagRendered=true;
-	if (!tagRender)
-		tagRendered = false;
 	if (tagRender) {
+		tagRendered = false;
 		if (tabsPending)
 			OutputTabs();
 		writer.Write(TagLeftChar);
 		writer.Write(_tagName);
 		RenderAttribute rAttr;
 		string rAttrValue = null;
-		for (int i=0; i <= _attrCount; i++) {
+		for (int i=0; i < _attrCount; i++) {
 			rAttr = _attrList[i];
 			if (rAttr.key == HtmlTextWriterAttribute.Style)
 				rAttrValue = rAttr.value;