2002-02-21 Gaurav Vaish <gvaish@iitk.ac.in>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / AdRotator.cs
index 4e6e521640fb06e899acaf4912cc97412b618cdc..f93f710f37b096743a2371b2977cab487eea2019 100755 (executable)
@@ -42,13 +42,11 @@ namespace System.Web.UI.WebControls
                        public int         hits; // or impressions or clicks\r
                        public string      keyword;\r
 \r
-                       public AdRecord()\r
-                       {\r
-                       }\r
-                       \r
-                       public void Initialize(IDictionary adProps)\r
+                       public AdRecord(IDictionary adProps)\r
                        {\r
                                this.adProps = adProps;\r
+                               hits         = 0;\r
+                               keyword      = String.Empty;\r
                        }\r
                }\r
 \r
@@ -70,7 +68,7 @@ namespace System.Web.UI.WebControls
                        XmlReader   reader;\r
                        XmlDocument document;\r
                        XmlNode     topNode, innerNode;\r
-                       IDictionary hybridDict;\r
+                       IDictionary hybridDict = null;\r
                        AdRecord[]  adsArray = null;\r
                        try\r
                        {\r
@@ -97,11 +95,11 @@ namespace System.Web.UI.WebControls
                                                                innerNode = topNode.FirstChild;\r
                                                                while(innerNode!=null)\r
                                                                {\r
-                                                                       if(innerNode.NodeType==NodeType.Element)\r
+                                                                       if(innerNode.NodeType==XmlNodeType.Element)\r
                                                                        {\r
-                                                                               if(hybridDic==null)\r
+                                                                               if(hybridDict==null)\r
                                                                                {\r
-                                                                                       hybirdDict = new HybridDictionary();\r
+                                                                                       hybridDict = new HybridDictionary();\r
                                                                                }\r
                                                                                hybridDict.Add(innerNode.LocalName, innerNode.InnerText);\r
                                                                        }\r
@@ -141,23 +139,23 @@ namespace System.Web.UI.WebControls
                        string physPath = MapPathSecure(file);\r
                        string AdKey = "AdRotatorCache: " + physPath;\r
                        fileDirectory = UrlUtils.GetDirectory(UrlUtils.Combine(TemplateSourceDirectory, file));\r
-                       CacheInternal ci = HttpRuntime.CacheInternal;\r
-                       AdRecord[] records = (AdRecord[])ci[AdKey];\r
+                       Cache cache = HttpRuntime.Cache;\r
+                       AdRecord[] records = (AdRecord[])cache[AdKey];\r
                        if(records==null)\r
                        {\r
                                records = LoadAdFile(physPath);\r
-                               if(!(records))\r
+                               if(records==null)\r
                                {\r
                                        return null;\r
                                }\r
-                               ci.Insert(AdKey, records, new CacheDependency(physPath));\r
+                               cache.Insert(AdKey, records, new CacheDependency(physPath));\r
                        }\r
                        return records;\r
                }\r
                \r
                private IDictionary SelectAd()\r
                {\r
-                       AdRecord[] records = GetFileData(AdvertisementFile);\r
+                       AdRecord[] records = GetData(AdvertisementFile);\r
                        if(records!=null && records.Length!=0)\r
                        {\r
                                int impressions = 0;\r
@@ -173,7 +171,7 @@ namespace System.Web.UI.WebControls
                                        int index = 0;\r
                                        for(int i=0; i < records.Length; i++)\r
                                        {\r
-                                               if(IsAdMaching(records[i]))\r
+                                               if(IsAdMatching(records[i]))\r
                                                {\r
                                                        if(rnd <= (counter + records[i].hits))\r
                                                        {\r
@@ -225,9 +223,8 @@ namespace System.Web.UI.WebControls
                        }\r
                }\r
                \r
-               public AdRotator()\r
+               public AdRotator(): base()\r
                {\r
-                       base();\r
                        advertisementFile = string.Empty;\r
                        fileDirectory     = null;\r
                }\r
@@ -307,7 +304,7 @@ namespace System.Web.UI.WebControls
                        Image adImage = new Image();\r
                        foreach(IEnumerable current in Attributes.Keys)\r
                        {\r
-                               hLink[(string)current] = Attributes[(string)current];\r
+                               hLink.Attributes[(string)current] = Attributes[(string)current];\r
                        }\r
                        if(ID != null && ID.Length > 0)\r
                                hLink.ID = ID;\r