{\r
_boolDisposed = false;\r
}\r
- \r
+\r
+ /// <remarks>\r
+ /// Added by gvaish@iitk.ac.in\r
+ /// </remarks>\r
+ public CacheDependency(string filename)\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ \r
+ /// <remarks>\r
+ /// Added by gvaish@iitk.ac.in\r
+ /// </remarks>\r
+ public CacheDependency(string[] filenames, string[] cachekeys)\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
public delegate void CacheDependencyCallback(CacheDependency objDependency);\r
\r
public event CacheDependencyCallback Changed;\r
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
XmlReader reader;\r
XmlDocument document;\r
XmlNode topNode, innerNode;\r
- IDictionary hybridDict;\r
+ IDictionary hybridDict = null;\r
AdRecord[] adsArray = null;\r
try\r
{\r
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
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
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
}\r
}\r
\r
- public AdRotator()\r
+ public AdRotator(): base()\r
{\r
- base();\r
advertisementFile = string.Empty;\r
fileDirectory = null;\r
}\r
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
writer.AddAttribute("digits", currInfo.CurrencyDecimalDigits.ToString(NumberFormatInfo.InvariantInfo));\r
return;\r
}\r
- if(Type == ValidationType.Date)\r
+ if(Type == ValidationDataType.Date)\r
{\r
- writer.AddAttribute("cutoffyear", CutoffYear);\r
+ writer.AddAttribute("cutoffyear", CutoffYear.ToString());\r
writer.AddAttribute("century", ( DateTime.Today.Year - (DateTime.Today.Year % 100) ).ToString());\r
return;\r
}\r
*/\r
\r
using System;\r
+using System.ComponentModel;\r
using System.Collections;\r
using System.Web;\r
using System.Web.UI;\r
get\r
{\r
if(!ControlStyleCreated)\r
- retrurn -1;\r
+ return -1;\r
return ((TableStyle)ControlStyle).CellPadding;\r
}\r
set\r
get\r
{\r
if(!ControlStyleCreated)\r
- retrurn -1;\r
+ return -1;\r
return ((TableStyle)ControlStyle).CellSpacing;\r
}\r
set\r
{\r
get\r
{\r
- if( !(dataKeys) )\r
+ if( dataKeys==null )\r
dataKeys = new DataKeyCollection(DataKeysArray);\r
return dataKeys;\r
\r
}\r
set\r
{\r
- if( (value) && ( value is IListSource || value is IEnumerable) )\r
+ if( (value!=null) && ( value is IListSource || value is IEnumerable) )\r
{\r
dataSource = value;\r
} else\r
protected string GetControlRenderID(string name)\r
{\r
// TODO: What value? What is it?\r
+ throw new NotImplementedException();\r
}\r
\r
protected string GetControlValidationValue(string name)\r
{\r
+ throw new NotImplementedException();\r
// TODO: What value? What is it?\r
}\r
\r
protected void RegisterValidatorCommonScript()\r
{\r
+ throw new NotImplementedException();\r
// TODO: Still wondering!\r
// Note: This method is primarily used by control developers\r
}\r
// TODO: Still wondering!\r
// Note: This method is primarily used by control developers\r
// The documentation in M$ refers to: Page_Validators array\r
+ throw new NotImplementedException();\r
}\r
}\r
}\r
{\r
// TODO: How to extract the value from the object?\r
// TODO: Then format the value. Here's a possible solution\r
- if(dataFormatString == null || dataFormatString.equals(String.Empty))\r
- return dataValue.toString();\r
+ if(dataFormatString == null || dataFormatString.Equals(String.Empty))\r
+ return dataValue.ToString();\r
if(dataValue is DateTime)\r
- return ((DateTime)dataValue).toString(dataFormatString);\r
+ return ((DateTime)dataValue).ToString(dataFormatString);\r
throw new NotImplementedException();\r
// and so on for int, String, double..\r
// something's wrong here. there must be some shorter method!\r
*/\r
\r
using System;\r
+using System.IO;\r
using System.Collections;\r
using System.Globalization;\r
using System.Text;\r
{\r
weekendDayStyle.TrackViewState();\r
}\r
- if(otherMonthStyle!=null)\r
+ if(otherMonthDayStyle!=null)\r
{\r
- otherMonthStyle.TrackViewState();\r
+ otherMonthDayStyle.TrackViewState();\r
}\r
if(selectedDayStyle!=null)\r
{\r
\r
private DateTime SetFirstCalendarDay(DateTime visibleDate)\r
{\r
- globCal = visibleDate;\r
throw new NotImplementedException();\r
//TODO: Implement me\r
}\r
dispVal.Append("\" style=\"color: ");\r
if(foreground.IsEmpty)\r
{\r
- dispVal.Append(ColorTranslater.ToHtml(defaultTextColor);\r
+ dispVal.Append(ColorTranslator.ToHtml(defaultTextColor));\r
} else\r
{\r
- dispVal.Append(ColorTranslater.ToHtml(foreground);\r
+ dispVal.Append(ColorTranslator.ToHtml(foreground));\r
}\r
dispVal.Append("\">");\r
dispVal.Append(text);\r
+2001-12-20 Gaurav Vaish <gvaish@iitk.ac.in>\r
+\r
+ FontInfo.cs - Completed revamp. Completed\r
+\r
2001-12-19 Gaurav Vaish <gvaish@iitk.ac.in>\r
\r
ListItemCollection.cs - Completed\r
\r
2001-12-02 Gaurav Vaish <gvaish@iitk.ac.in>\r
\r
- CheckBoxList.cs - Partial Implementation. All except "Render"\r
+ CheckBoxList.cs - Partial Implementation.\r
+ All except "Render"\r
\r
2001-12-01 Gaurav Vaish <gvaish@iitk.ac.in>\r
\r
\r
CheckBox.cs - Completed\r
ListControl.cs - Initial Implementation\r
- CheckBoxList.cs - Started with it, but first needed ListControl. Left it.\r
+ CheckBoxList.cs - Started with it, but first needed\r
+ ListControl. Left it.\r
\r
2001-11-29 Gaurav Vaish <gvaish@iitk.ac.in>\r
\r
- CalendarDay.cs - Making a note that this has been implemented\r
+ CalendarDay.cs - Making a note that this\r
+ has been implemented\r
Calendar.cs - Making a note that have made some changes.\r
- Unimplmented functions throw NotImplementedException\r
+ Unimplmented functions throw\r
+ NotImplementedException\r
CheckBox.cs - Can now "Render" and "LoadPostData"\r
\r
\r
{\r
private static readonly object CheckedChangedEvent = new object();\r
\r
- public CheckBox()\r
+ public CheckBox(): base(HtmlTextWriterTag.Input)\r
{\r
- base(HtmlTextWriterTag.Input);\r
}\r
\r
public virtual bool AutoPostBack\r
private string cmdName;\r
private object cmdArg;\r
\r
- public CommandEventArgs(CommandEventArgs e)\r
+ public CommandEventArgs(CommandEventArgs e) : this(e.CommandName, e.CommandArgument)\r
{\r
- CommandEventArgs(e.CommandName, e.CommandArgument);\r
}\r
\r
public CommandEventArgs(string commandName, object argument)\r
public DataGridCommandEventArgs(DataGridItem item, object commandSource, CommandEventArgs originalArgs): base(originalArgs)\r
{\r
dgItem = item;\r
- original = originalArgs;\r
+ cmdSrc = originalArgs;\r
}\r
\r
public object CommandSource\r
private TableItemStyle editItemStyle;\r
private TableItemStyle footerStyle;\r
private TableItemStyle headerStyle;\r
+ private TableItemStyle separatorStyle;\r
\r
private ITemplate alternatingItemTemplate;\r
private ITemplate editItemTemplate;\r
private ITemplate footerTemplate;\r
private ITemplate headerTemplate;\r
+ private ITemplate separatorTemplate;\r
\r
private int editItemIndex;\r
private bool extractTemplateRows;\r
alternatingItemStyle = new TableItemStyle();\r
editItemStyle = new TableItemStyle();\r
footerStyle = new TableItemStyle();\r
+ headerStyle = new TableItemStyle();\r
\r
alternatingItemTemplate = null;\r
editItemTemplate = null;\r
footerTemplate = null;\r
headerTemplate = null;\r
+ separatorTemplate = null;\r
\r
extractTemplateRows = false;\r
\r
{\r
if(GetItem(itemType, repeatIndex)!=null && ControlStyleCreated)\r
return ControlStyle;\r
+ return null;\r
}\r
}\r
}\r
*/\r
\r
using System;\r
+using System.Text;\r
using System.Reflection;\r
using System.Web;\r
using System.Web.UI;\r
infoOwner = owner;\r
}\r
\r
+ /// <summary>\r
+ /// Default constructor\r
+ /// <remarks>\r
+ /// The default constructor is made private to prevent any instances being made.\r
+ /// </remarks>\r
+ /// </summary>\r
+ private FontInfo()\r
+ {\r
+ }\r
+ \r
public bool Bold\r
{\r
get\r
}\r
}\r
\r
+ //TODO: How do I check if the value is negative. FontUnit is struct not enum\r
public FontUnit Size\r
{\r
get\r
}\r
set\r
{\r
- infoOwner.ViewState["FontInfoNames"] = value;\r
- infoOwner.Set(Style.FONT_NAMES);\r
+ if(value!=null)\r
+ {\r
+ infoOwner.ViewState["FontInfoNames"] = value;\r
+ infoOwner.Set(Style.FONT_NAMES);\r
+ }\r
}\r
}\r
\r
infoOwner.ViewState.Remove("FontInfoOverline");\r
if(infoOwner.IsSet(Style.FONT_ULINE))\r
infoOwner.ViewState.Remove("FontInfoUnderline");\r
- if(infoOwner.IsSet(Style.FONT_SIZE) && infoOwner.Size != FontUnit.Empty)\r
+ if(infoOwner.IsSet(Style.FONT_SIZE) && infoOwner.Font.Size != FontUnit.Empty)\r
infoOwner.ViewState.Remove("FontInfoSize");\r
}\r
\r
{\r
if(source!=null)\r
{\r
- if(source.IsSet(Style.FONT_NAMES))\r
+ if(source.Owner.IsSet(Style.FONT_NAMES))\r
Names = source.Names;\r
- if(source.IsSet(Style.FONT_BOLD))\r
+ if(source.Owner.IsSet(Style.FONT_BOLD))\r
Bold = source.Bold;\r
- if(source.IsSet(Style.FONT_ITALIC))\r
+ if(source.Owner.IsSet(Style.FONT_ITALIC))\r
Italic = source.Italic;\r
- if(source.IsSet(Style.FONT_STRIKE))\r
+ if(source.Owner.IsSet(Style.FONT_STRIKE))\r
Strikeout = source.Strikeout;\r
- if(source.IsSet(Style.FONT_OLINE))\r
+ if(source.Owner.IsSet(Style.FONT_OLINE))\r
Overline = source.Overline;\r
- if(source.IsSet(Style.FONT_ULINE))\r
+ if(source.Owner.IsSet(Style.FONT_ULINE))\r
Underline = source.Underline;\r
- if(source.IsSet(Style.FONT_SIZE) && source.Size != FontUnit.Empty)\r
+ if(source.Owner.IsSet(Style.FONT_SIZE) && source.Size != FontUnit.Empty)\r
Size = source.Size;\r
}\r
}\r
{\r
if(with!=null)\r
{\r
- if(source.IsSet(Style.FONT_NAMES) && !infoOwner.IsSet(Style.FONT_NAMES))\r
- Names = source.Names;\r
- if(source.IsSet(Style.FONT_BOLD && !infoOwner.IsSet(Style.FONT_BOLD)))\r
- Bold = source.Bold;\r
- if(source.IsSet(Style.FONT_ITALIC && !infoOwner.IsSet(Style.FONT_ITALIC)))\r
- Italic = source.Italic;\r
- if(source.IsSet(Style.FONT_STRIKE && !infoOwner.IsSet(Style.FONT_STRIKE)))\r
- Strikeout = source.Strikeout;\r
- if(source.IsSet(Style.FONT_OLINE && !infoOwner.IsSet(Style.FONT_OLINE)))\r
- Overline = source.Overline;\r
- if(source.IsSet(Style.FONT_ULINE && !infoOwner.IsSet(Style.FONT_ULINE)))\r
- Underline = source.Underline;\r
- if(source.IsSet(Style.FONT_SIZE) && source.Size != FontUnit.Empty && !infoOwner.IsSet(Style.FONT_SIZE))\r
- Size = source.Size;\r
+ if(with.Owner.IsSet(Style.FONT_NAMES) && !infoOwner.IsSet(Style.FONT_NAMES))\r
+ Names = with.Names;\r
+ if(with.Owner.IsSet(Style.FONT_BOLD) && !infoOwner.IsSet(Style.FONT_BOLD))\r
+ Bold = with.Bold;\r
+ if(with.Owner.IsSet(Style.FONT_ITALIC) && !infoOwner.IsSet(Style.FONT_ITALIC))\r
+ Italic = with.Italic;\r
+ if(with.Owner.IsSet(Style.FONT_STRIKE) && !infoOwner.IsSet(Style.FONT_STRIKE))\r
+ Strikeout = with.Strikeout;\r
+ if(with.Owner.IsSet(Style.FONT_OLINE) && !infoOwner.IsSet(Style.FONT_OLINE))\r
+ Overline = with.Overline;\r
+ if(with.Owner.IsSet(Style.FONT_ULINE) && !infoOwner.IsSet(Style.FONT_ULINE))\r
+ Underline = with.Underline;\r
+ if(with.Owner.IsSet(Style.FONT_SIZE) && with.Size != FontUnit.Empty && !infoOwner.IsSet(Style.FONT_SIZE))\r
+ Size = with.Size;\r
}\r
}\r
\r
return (Names.Length > 0);\r
}\r
\r
- protected override ToString()\r
+ public override string ToString()\r
{\r
return ( (Name.Length > 0) ? (Name.ToString() + ", " + Size.ToString()) : Size.ToString() );\r
}\r
for(int i=0; i < Items.Count; i++)\r
{\r
if(Items[i].Selected)\r
- ArrayList.Add(i);\r
+ si.Add(i);\r
}\r
return si;\r
}\r
internal void Select(ArrayList indices)\r
{\r
ClearSelection();\r
- foreach(int index in indices)\r
+ foreach(object intObj in indices)\r
{\r
+ int index = (int)intObj;\r
if(index >= 0 && index < Items.Count)\r
Items[index].Selected = true;\r
}\r
{\r
base.OnDataBinding(e);\r
IEnumerable resolvedDataSource = DataSourceHelper.GetResolvedDataSource(DataSource, DataMember);\r
- if(resolvedData != null)\r
+ if(resolvedDataSource != null)\r
{\r
string dataTextField = DataTextField;\r
string dataValueField = DataValueField;\r
* Maintainer: gvaish@iitk.ac.in\r
* Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
* Implementation: yes\r
- * Status: 10%\r
+ * Status: 100%\r
*\r
* (C) Gaurav Vaish (2001)\r
*/\r
\r
namespace System.Web.UI.WebControls\r
{\r
- public class ListItem : IStateManager, IParserAccessor, IAttributeAccessor\r
+ public sealed class ListItem : IStateManager, IParserAccessor, IAttributeAccessor\r
{\r
+ private static int MARKED = (0x01 << 0);\r
+ private static int SELECTED = (0x01 << 1);\r
+ private static int DIRTY_T = (0x01 << 2);\r
+ private static int DIRTY_V = (0x01 << 3);\r
\r
+ private static int selBits;\r
+ \r
+ private AttributeCollection attributes;\r
+ private string text;\r
+ private string val;\r
+ \r
+ public ListItem(string text, string value)\r
+ {\r
+ this.text = text;\r
+ this.val = value;\r
+ selBits = 0x00;\r
+ attributes = null;\r
+ }\r
+ \r
+ public ListItem(string text): this(text, null)\r
+ {\r
+ }\r
+ \r
+ public ListItem(): this(null, null)\r
+ {\r
+ }\r
+ \r
+ public static ListItem FromString(string text)\r
+ {\r
+ return new ListItem(text);\r
+ }\r
+ \r
+ public AttributeCollection Attributes\r
+ {\r
+ get\r
+ {\r
+ if(attributes == null)\r
+ attributes = new AttributeCollection(new StateBag(true));\r
+ return attributes;\r
+ }\r
+ }\r
+ \r
+ public bool Selected\r
+ {\r
+ get\r
+ {\r
+ return IsSet(SELECTED);\r
+ }\r
+ set\r
+ {\r
+ Set(SELECTED);\r
+ }\r
+ }\r
+ \r
+ internal bool Dirty\r
+ {\r
+ get\r
+ {\r
+ return (IsSet(DIRTY_T) && IsSet(DIRTY_V));\r
+ }\r
+ set\r
+ {\r
+ Set(DIRTY_T);\r
+ Set(DIRTY_V);\r
+ }\r
+ }\r
+ \r
+ private bool IsSet(int bit)\r
+ {\r
+ return ( (selBits & bit) != 0x00 );\r
+ }\r
+ \r
+ private void Set(int bit)\r
+ {\r
+ selBits |= bit;\r
+ }\r
+ \r
+ public string Text\r
+ {\r
+ get\r
+ {\r
+ if(text!=null)\r
+ {\r
+ return text;\r
+ }\r
+ if(val!=null)\r
+ {\r
+ return val;\r
+ }\r
+ return String.Empty;\r
+ }\r
+ set\r
+ {\r
+ text = value;\r
+ if(IsTrackingViewState)\r
+ {\r
+ Set(DIRTY_T);\r
+ }\r
+ }\r
+ }\r
+ \r
+ public string Value\r
+ {\r
+ get\r
+ {\r
+ if(val!=null)\r
+ {\r
+ return val;\r
+ }\r
+ if(text!=null)\r
+ {\r
+ return text;\r
+ }\r
+ return String.Empty;\r
+ }\r
+ set\r
+ {\r
+ val = value;\r
+ if(IsTrackingViewState)\r
+ {\r
+ Set(DIRTY_V);\r
+ }\r
+ }\r
+ }\r
+ \r
+ string IAttributeAccessor.GetAttribute(string key)\r
+ {\r
+ return attributes[key];\r
+ }\r
+ \r
+ void IAttributeAccessor.SetAttribute(string key, string value)\r
+ {\r
+ attributes[key] = value;\r
+ }\r
+ \r
+ /// <remarks>\r
+ /// The data is parsed - object must be of type LiteralControl or DataBoundLiteralControl.\r
+ /// In latter case, throw an exception telling that the data cannot be bind-ed.\r
+ /// </remarks>\r
+ void IParserAccessor.AddParsedSubObject(object obj)\r
+ {\r
+ if(obj is LiteralControl)\r
+ {\r
+ Text = ((LiteralControl)obj).Text;\r
+ return;\r
+ }\r
+ if(obj is DataBoundLiteralControl)\r
+ {\r
+ throw new HttpException(HttpRuntime.FormatResourceString("Control_Cannot_DataBind","ListItem"));\r
+ }\r
+ throw new HttpException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type", "ListItem", obj.GetType().ToString()));\r
+ }\r
+ \r
+ internal bool IsTrackingViewState\r
+ {\r
+ get\r
+ {\r
+ return IsSet(MARKED);\r
+ }\r
+ }\r
+ \r
+ internal void TrackViewState()\r
+ {\r
+ Set(MARKED);\r
+ }\r
+ \r
+ internal void LoadViewState(object state)\r
+ {\r
+ if(state is Pair)\r
+ {\r
+ Pair tv = (Pair)state;\r
+ if(tv.First!=null)\r
+ {\r
+ Text = (string)tv.First;\r
+ }\r
+ if(tv.Second!=null)\r
+ {\r
+ Value = (string)tv.Second;\r
+ }\r
+ }\r
+ if(state is string)\r
+ {\r
+ Text = (string)state;\r
+ }\r
+ }\r
+ \r
+ internal object SaveViewState()\r
+ {\r
+ if(IsSet(DIRTY_T) && IsSet(DIRTY_V))\r
+ {\r
+ return new Pair(Text, Value);\r
+ }\r
+ if(IsSet(DIRTY_T))\r
+ {\r
+ return Text;\r
+ }\r
+ if(IsSet(DIRTY_V))\r
+ {\r
+ return new Pair(null, Value);\r
+ }\r
+ return null;\r
+ }\r
+ \r
+ bool IStateManager.IsTrackingViewState\r
+ {\r
+ get\r
+ {\r
+ return IsTrackingViewState;\r
+ }\r
+ }\r
+ \r
+ void IStateManager.TrackViewState()\r
+ {\r
+ TrackViewState();\r
+ }\r
+ \r
+ object IStateManager.SaveViewState()\r
+ {\r
+ return SaveViewState();\r
+ }\r
+ \r
+ void IStateManager.LoadViewState(object state)\r
+ {\r
+ LoadViewState(state);\r
+ }\r
}\r
}\r
public ListItem FindByText(string text)\r
{\r
int i=-1;\r
- foreach(ListItem current in items)\r
+ foreach(object current in items)\r
{\r
i++;\r
- if(current.Text == text)\r
+ if(((ListItem)current).Text == text)\r
break;\r
}\r
- return (i==-1 ? null : items[i]);\r
+ return (i==-1 ? null : (ListItem)items[i]);\r
}\r
\r
public ListItem FindByValue(string value)\r
{\r
int i=-1;\r
- foreach(ListItem current in items)\r
+ foreach(object current in items)\r
{\r
i++;\r
- if(current.Value == value)\r
+ if(((ListItem)current).Value == value)\r
break;\r
}\r
- return (i==-1 ? null : items[i]);\r
+ return (i==-1 ? null : (ListItem)items[i]);\r
}\r
\r
public IEnumerator GetEnumerator()\r
\r
public void Remove(string item)\r
{\r
- RemoveAt(IndexOf(item));\r
+ RemoveAt(IndexOf(ListItem.FromString(item)));\r
}\r
\r
internal object SaveViewState()\r
}\r
set\r
{\r
- this[index] = value;\r
+ if(value is ListItem)\r
+ {\r
+ this[index] = (ListItem)value;\r
+ }\r
}\r
}\r
\r
{\r
int index = (item is ListItem ? items.Add((ListItem)item) : -1);\r
if(index!=-1 && marked)\r
- item.Dirty = true;\r
+ ((ListItem)item).Dirty = true;\r
return index;\r
}\r
\r
* Maintainer: gvaish@iitk.ac.in\r
* Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
* Implementation: yes\r
- * Status: 10%\r
+ * Status: 100%\r
*\r
* (C) Gaurav Vaish (2001)\r
*/\r
\r
using System;\r
+using System.Text;\r
using System.Collections;\r
using System.Drawing;\r
+using System.Globalization;\r
using System.ComponentModel;\r
using System.Web;\r
using System.Web.UI;\r
\r
namespace System.Web.UI.WebControls\r
{\r
- public class Style : Component, IStateManager\r
+ public class Style : Component , IStateManager\r
{\r
internal static int MARKED = (0x01 << 0);\r
internal static int BACKCOLOR = (0x01 << 1);\r
internal static int FONT_STRIKE = (0x01 << 13);\r
internal static int FONT_OLINE = (0x01 << 14);\r
internal static int FONT_ULINE = (0x01 << 15);\r
- \r
- internal static string selectionBitString = "_!SBS";\r
+\r
+ internal static string selectionBitString = "_SystemWebUIWebControlsStyle_SBS";\r
\r
private StateBag viewState;\r
- private bool marked;\r
private int selectionBits;\r
- private bool selfStateBag; \r
+ private bool selfStateBag;\r
\r
private FontInfo font;\r
\r
{\r
Initialize(null);\r
selfStateBag = true;\r
- \r
}\r
- \r
+\r
public Style(StateBag bag): base()\r
{\r
Initialize(bag);\r
selfStateBag = false;\r
}\r
- \r
+\r
private void Initialize(StateBag bag)\r
{\r
viewState = bag;\r
- marked = false;\r
- selectionBits = 0x00; \r
+ selectionBits = 0x00;\r
}\r
- \r
- StateBag ViewState\r
+\r
+ internal virtual StateBag ViewState\r
{\r
get\r
{\r
- if(stateBag == null)\r
+ if(viewState == null)\r
{\r
- stateBag = new stateBag(false);\r
+ viewState = new StateBag(false);\r
if(IsTrackingViewState)\r
- stateBag.TrackViewState();\r
+ viewState.TrackViewState();\r
}\r
- return stateBag;\r
+ return viewState;\r
}\r
}\r
\r
internal bool IsSet(int bit)\r
{\r
- return ( (selectionBits & bitIndex) != 0x00);\r
+ return ( (selectionBits & bit) != 0x00);\r
}\r
- \r
- virtual void Set(int bit)\r
+\r
+ internal virtual void Set(int bit)\r
{\r
selectionBits |= bit;\r
if(IsTrackingViewState)\r
selectionBits |= MARKED;\r
}\r
- \r
+\r
public Color BackColor\r
{\r
get\r
Set(BACKCOLOR);\r
}\r
}\r
- \r
+\r
public Color BorderColor\r
{\r
get\r
set\r
{\r
ViewState["BorderColor"] = value;\r
- Set(BORERCOLOR);\r
+ Set(BORDERCOLOR);\r
}\r
}\r
- \r
+\r
public BorderStyle BorderStyle\r
{\r
get\r
{\r
if(IsSet(BORDERSTYLE))\r
- return (Color)ViewState["BorderStyle"];\r
+ return (BorderStyle)ViewState["BorderStyle"];\r
return BorderStyle.NotSet;\r
}\r
set\r
Set(BORDERSTYLE);\r
}\r
}\r
- \r
+\r
public Unit BorderWidth\r
{\r
get\r
Set(BORDERWIDTH);\r
}\r
}\r
- \r
+\r
public string CssClass\r
{\r
get\r
{\r
- if(Set(CSSCLASS))\r
+ if(IsSet(CSSCLASS))\r
return (string)ViewState["CssClass"];\r
return string.Empty;\r
}\r
Set(CSSCLASS);\r
}\r
}\r
- \r
+\r
public Color ForeColor\r
{\r
get\r
Set(FORECOLOR);\r
}\r
}\r
- \r
+\r
public Unit Height\r
{\r
get\r
Set(HEIGHT);\r
}\r
}\r
- \r
+\r
public Unit Width\r
{\r
get\r
Set(HEIGHT);\r
}\r
}\r
- \r
+\r
public FontInfo Font\r
{\r
get\r
return font;\r
}\r
}\r
- \r
+\r
+ internal virtual bool IsEmpty\r
+ {\r
+ get\r
+ {\r
+ return (selectionBits != 0);\r
+ }\r
+ }\r
+\r
+ private void AddColor(HtmlTextWriter writer, HtmlTextWriterStyle style, Color color)\r
+ {\r
+ if(!color.IsEmpty)\r
+ writer.AddStyleAttribute(style, ColorTranslator.ToHtml(color));\r
+ }\r
+\r
+ private static string StringArrayToString(string[] array, char separator)\r
+ {\r
+ if(array.Length == 0)\r
+ return String.Empty;\r
+ StringBuilder sb = new StringBuilder();\r
+ for(int i=0; i < array.Length; i++)\r
+ {\r
+ if(i==0)\r
+ {\r
+ sb.Append(array[0]);\r
+ } else\r
+ {\r
+ sb.Append(separator);\r
+ sb.Append(array[i]);\r
+ }\r
+ }\r
+ return sb.ToString();\r
+ }\r
+\r
public void AddAttributesToRender(HtmlTextWriter writer)\r
{\r
AddAttributesToRender(writer, null);\r
}\r
- \r
+\r
public void AddAttributesToRender(HtmlTextWriter writer, WebControl owner)\r
{\r
- if(Set(CSSCLASS))\r
+ if(IsSet(BACKCOLOR))\r
+ {\r
+ AddColor(writer, HtmlTextWriterStyle.BackgroundColor, (Color)ViewState["BackColor"]);\r
+ }\r
+\r
+ if(IsSet(BORDERCOLOR))\r
+ {\r
+ AddColor(writer, HtmlTextWriterStyle.BorderColor, (Color)ViewState["BorderColor"]);\r
+ }\r
+\r
+ if(IsSet(FORECOLOR))\r
+ {\r
+ AddColor(writer, HtmlTextWriterStyle.Color, (Color)ViewState["ForeColor"]);\r
+ }\r
+\r
+ if(IsSet(CSSCLASS))\r
{\r
string cssClass = (string)ViewState["CssClass"];\r
- //if(cssClass.Length > 0)\r
- // writer.Add(HtmlTextWriterAttribute.\r
+ if(cssClass.Length > 0)\r
+ writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);\r
+ }\r
+\r
+ if(!BorderWidth.IsEmpty)\r
+ {\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, BorderWidth.ToString(CultureInfo.InvariantCulture));\r
+ if(BorderStyle!=BorderStyle.NotSet)\r
+ {\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, Enum.Format(typeof(BorderStyle), BorderStyle, "G"));\r
+ } else\r
+ {\r
+ if(BorderWidth.Value != 0.0)\r
+ {\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid");\r
+ }\r
+ }\r
+ } else\r
+ {\r
+ if(BorderStyle!=BorderStyle.NotSet)\r
+ {\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, Enum.Format(typeof(BorderStyle), BorderStyle, "G"));\r
+ }\r
+ }\r
+\r
+ if(Font.Names.Length > 0)\r
+ {\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, StringArrayToString(Font.Names,','));\r
+ }\r
+\r
+ if(!Font.Size.IsEmpty)\r
+ {\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, Font.Size.ToString(CultureInfo.InvariantCulture));\r
+ }\r
+\r
+ if(Font.Bold)\r
+ {\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold");\r
+ }\r
+\r
+ if(Font.Italic)\r
+ {\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.FontStyle, "italic");\r
+ }\r
+\r
+ string textDecoration = String.Empty;\r
+ if(Font.Strikeout)\r
+ {\r
+ textDecoration += " strikeout";\r
+ }\r
+ if(Font.Underline)\r
+ {\r
+ textDecoration += " underline";\r
+ }\r
+ if(Font.Overline)\r
+ {\r
+ textDecoration += " overline";\r
+ }\r
+ if(textDecoration.Length > 0)\r
+ {\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, textDecoration);\r
+ }\r
+\r
+ Unit u = Unit.Empty;\r
+ if(IsSet(HEIGHT))\r
+ {\r
+ u = (Unit)ViewState["Height"];\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.Height, u.ToString(CultureInfo.InvariantCulture));\r
+ }\r
+ if(IsSet(WIDTH))\r
+ {\r
+ u = (Unit)ViewState["Width"];\r
+ writer.AddStyleAttribute(HtmlTextWriterStyle.Width, u.ToString(CultureInfo.InvariantCulture));\r
+ }\r
+ }\r
+\r
+ public virtual void CopyFrom(Style source)\r
+ {\r
+ if(source!=null && !source.IsEmpty)\r
+ {\r
+ Font.CopyFrom(source.Font);\r
+ if(source.Height!=Unit.Empty)\r
+ {\r
+ Height = source.Height;\r
+ }\r
+ if(source.Width!=Unit.Empty)\r
+ {\r
+ Width = source.Width;\r
+ }\r
+ if(source.BorderColor!=Color.Empty)\r
+ {\r
+ BorderColor = source.BorderColor;\r
+ }\r
+ if(source.BorderWidth!=Unit.Empty)\r
+ {\r
+ BorderWidth = source.BorderWidth;\r
+ }\r
+ if(source.BorderStyle!=BorderStyle.NotSet)\r
+ {\r
+ BorderStyle = source.BorderStyle;\r
+ }\r
+ if(source.BackColor!=Color.Empty)\r
+ {\r
+ BackColor = source.BackColor;\r
+ }\r
+ if(source.CssClass!=String.Empty)\r
+ {\r
+ CssClass = source.CssClass;\r
+ }\r
+ if(source.ForeColor!=Color.Empty)\r
+ {\r
+ ForeColor = source.ForeColor;\r
+ }\r
+ }\r
+ }\r
+\r
+ public virtual void MergeWith(Style with)\r
+ {\r
+ if(with!=null && !with.IsEmpty)\r
+ {\r
+ if(IsEmpty)\r
+ {\r
+ CopyFrom(with);\r
+ return;\r
+ }\r
+\r
+ Font.MergeWith(with.Font);\r
+ if(!IsSet(HEIGHT) && with.Height!=Unit.Empty)\r
+ {\r
+ Height = with.Height;\r
+ }\r
+ if(!IsSet(WIDTH) && with.Width!=Unit.Empty)\r
+ {\r
+ Width = with.Width;\r
+ }\r
+ if(!IsSet(BORDERCOLOR) && with.BorderColor!=Color.Empty)\r
+ {\r
+ BorderColor = with.BorderColor;\r
+ }\r
+ if(!IsSet(BORDERWIDTH) && with.BorderWidth!=Unit.Empty)\r
+ {\r
+ BorderWidth = with.BorderWidth;\r
+ }\r
+ if(!IsSet(BORDERSTYLE) && with.BorderStyle!=BorderStyle.NotSet)\r
+ {\r
+ BorderStyle = with.BorderStyle;\r
+ }\r
+ if(!IsSet(BACKCOLOR) && with.BackColor!=Color.Empty)\r
+ {\r
+ BackColor = with.BackColor;\r
+ }\r
+ if(!IsSet(CSSCLASS) && with.CssClass!=String.Empty)\r
+ {\r
+ CssClass = with.CssClass;\r
+ }\r
+ if(!IsSet(FORECOLOR) && with.ForeColor!=Color.Empty)\r
+ {\r
+ ForeColor = with.ForeColor;\r
+ }\r
+ }\r
+ }\r
+ \r
+ public virtual void Reset()\r
+ {\r
+ if(IsSet(BACKCOLOR))\r
+ ViewState.Remove("BackColor");\r
+ if(IsSet(BORDERCOLOR))\r
+ ViewState.Remove("BorderColor");\r
+ if(IsSet(BORDERSTYLE))\r
+ ViewState.Remove("BorderStyle");\r
+ if(IsSet(BORDERWIDTH))\r
+ ViewState.Remove("BorderWidth");\r
+ if(IsSet(CSSCLASS))\r
+ ViewState.Remove("CssClass");\r
+ if(IsSet(FORECOLOR))\r
+ ViewState.Remove("ForeColor");\r
+ if(IsSet(HEIGHT))\r
+ ViewState.Remove("Height");\r
+ if(IsSet(WIDTH))\r
+ ViewState.Remove("Width");\r
+ if(font!=null)\r
+ font.Reset();\r
+ selectionBits = 0x00;\r
+ }\r
+\r
+ protected bool IsTrackingViewState\r
+ {\r
+ get\r
+ {\r
+ return ( (selectionBits & MARKED) != 0x00 );\r
+ }\r
+ }\r
+\r
+ protected internal virtual void TrackViewState()\r
+ {\r
+ if(viewState!=null)\r
+ ViewState.TrackViewState();\r
+ Set(MARKED);\r
+ }\r
+\r
+ protected internal object SaveViewState()\r
+ {\r
+ if(viewState != null)\r
+ {\r
+ if(IsSet(MARKED))\r
+ {\r
+ ViewState[selectionBitString] = selectionBits;\r
+ }\r
+ if(selfStateBag)\r
+ {\r
+ return ViewState.SaveViewState();\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+ \r
+ protected internal void LoadViewState(object state)\r
+ {\r
+ if(state!=null && selfStateBag)\r
+ {\r
+ ViewState.LoadViewState(state);\r
+ }\r
+ if(viewState!=null)\r
+ {\r
+ selectionBits = (int)ViewState[selectionBitString];\r
+ }\r
+ }\r
+ \r
+ void IStateManager.LoadViewState(object state)\r
+ {\r
+ LoadViewState(state);\r
+ }\r
+ \r
+ object IStateManager.SaveViewState()\r
+ {\r
+ return SaveViewState();\r
+ }\r
+ \r
+ void IStateManager.TrackViewState()\r
+ {\r
+ TrackViewState();\r
+ }\r
+ \r
+ bool IStateManager.IsTrackingViewState\r
+ {\r
+ get\r
+ {\r
+ return IsTrackingViewState;\r
}\r
}\r
}\r
}\r
-\r
{\r
this.ignoreCase = ignoreCase;\r
marked = false;\r
- bag = new HybridDictionary(false);\r
+ bag = new HybridDictionary(ignoreCase);\r
}\r
\r
public int Count\r
-//
-// System.Web.UI.StateItem.cs
-//
-// Author:
-// Bob Smith <bob@thestuff.net>
-//
-// (C) Bob Smith
-//
-
-using System;
-using System.Web;
-
-namespace System.Web.UI
-{
- public sealed class StateItem
- {
- private bool _isDirty = false;
- private object _value = null;
- public bool IsDirty
- {
- get
- {
- return _isDirty;
- }
- set
- {
- _isDirty = value;
- }
- }
- public object Value
- {
- get
- {
- return _value;
- }
- set
- {
- _value = value;
- }
- }
- public StateItem() {}
- public StateItem(Object value)
- {
- _value = value;
- }
- }
-}
+//\r
+// System.Web.UI.StateItem.cs\r
+//\r
+// Author:\r
+// Bob Smith <bob@thestuff.net>\r
+//\r
+// (C) Bob Smith\r
+//\r
+\r
+using System;\r
+using System.Web;\r
+\r
+namespace System.Web.UI\r
+{\r
+ public sealed class StateItem\r
+ {\r
+ private bool _isDirty = false;\r
+ private object _value = null;\r
+ public bool IsDirty\r
+ {\r
+ get\r
+ {\r
+ return _isDirty;\r
+ }\r
+ set\r
+ {\r
+ _isDirty = value;\r
+ }\r
+ }\r
+ public object Value\r
+ {\r
+ get\r
+ {\r
+ return _value;\r
+ }\r
+ set\r
+ {\r
+ _value = value;\r
+ }\r
+ }\r
+ private StateItem() {}\r
+ internal StateItem(Object value)\r
+ {\r
+ _value = value;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/**\r\r
+ * Namespace: System.Web.Utils\r
+ * Class: ApacheVersionInfo\r
+ * \r
+ * Author: Gaurav Vaish\r
+ * Maintainer: gvaish@iitk.ac.in\r
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
+ * Implementation: yes\r
+ * Status: ??%\r
+ * \r
+ * (C) Gaurav Vaish (2001)\r
+ */\r
+\r
+namespace System.Web.Utils\r
+{\r
+ /// <summary>\r
+ /// Versions of the modules related to Apache\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// At present I don't know what modules are to be loaded and how\r
+ /// </remarks>\r
+ /// <see>\r
+ /// System.Web.Utils.IISVersionInfo\r
+ /// </see>\r
+ internal class ApacheVersionInfo\r
+ {\r
+ public ApacheVersionInfo()\r
+ {\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * Namespace: System.Web.Utils\r
+ * Class: FileAction\r
+ *\r
+ * Author: Gaurav Vaish\r
+ * Maintainer: gvaish@iitk.ac.in\r
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
+ * Implementation: yes\r
+ * Status: ??%\r
+ *\r
+ * (C) Gaurav Vaish (2001)\r
+ */\r
+\r
+namespace System.Web.Utils\r
+{\r
+ public enum FileAction\r
+ {\r
+ Overwhleming,\r
+ Added,\r
+ Removed,\r
+ Modifiled,\r
+ RenamedOldName,\r
+ RenamedNewName,\r
+ Error = 0xFFFFFFFF\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * Namespace: System.Web.Utils\r
+ * Class: FileChangeEventHandler\r
+ *\r
+ * Author: Gaurav Vaish\r
+ * Maintainer: gvaish@iitk.ac.in\r
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
+ * Implementation: yes\r
+ * Status: 100%\r
+ *\r
+ * (C) Gaurav Vaish (2001)\r
+ */\r
+\r
+namespace System.Web.Utils\r
+{\r
+ public delegate FileChangeEventHandler(object sender, int method);\r
+}\r
--- /dev/null
+/**\r
+ * Namespace: System.Web.Utils\r
+ * Class: FileChangedEventArgs\r
+ *\r
+ * Author: Gaurav Vaish\r
+ * Maintainer: gvaish@iitk.ac.in\r
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
+ * Implementation: yes\r
+ * Status: ??%\r
+ *\r
+ * (C) Gaurav Vaish (2001)\r
+ */\r
+\r
+namespace System.Web.Utils\r
+{\r
+ internal class FileChangedEventArgs : EventArgs\r
+ {\r
+ private string filename;\r
+ private FileAction action;\r
+\r
+ public FileChangedEvent(FileAction action, string file)\r
+ {\r
+ this.action = action;\r
+ this.filename = file;\r
+ }\r
+\r
+ public string FileName\r
+ {\r
+ get\r
+ {\r
+ return filename;\r
+ }\r
+ }\r
+\r
+ public FileAction Action\r
+ {\r
+ get\r
+ {\r
+ return action;\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * \r
+ * Namespace: System.Web.Utils\r
+ * Class: FileChangesMonitor\r
+ * \r
+ * Author: Gaurav Vaish\r
+ * Maintainer: gvaish@iitk.ac.in\r
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
+ * Implementation: yes\r
+ * Status: ??%\r
+ *\r
+ * \r
+ * (C) Gaurav Vaish (2001)\r
+ */\r
+\r
+namespace System.Web.Utils\r
+{\r
+ internal class FileChangesMonitor\r
+ {\r
+ private static string BIN = "bin";\r
+ private static string BINDIR = "bin/";\r
+ private static string MAXLEN = 260;\r
+ \r
+ private FileChangeEventHandler rename;\r
+ private NativeFileChangeEventHandler subDir;\r
+ \r
+ private int \r
+ }\r
+}\r
--- /dev/null
+/**\r
+\r
+ * Namespace: System.Web.Utils\r
+ * Class: IISVersionInfo\r
+ * \r
+ * Author: Gaurav Vaish\r
+ * Maintainer: gvaish@iitk.ac.in\r
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
+ * Implementation: yes\r
+ * Status: ??%\r
+\r
+ *\r
+\r
+ * (C) Gaurav Vaish (2001)\r
+\r
+ */\r
+\r
+\r
+using System;\r
+using System.Diagnostics;\r
+using System.Web;\r
+using System.Web.Utils;\r
+\r
+namespace System.Web.Utils\r
+{\r
+ //FIXME: This is highly Windows/IIS specific code. What about Apache related stuff?\r
+ internal class IISVersionInfo\r
+ {\r
+ private static string isapiVersion;\r
+ private static string mscoreeVersion;\r
+ private static string systemWebVersion;\r
+\r
+ private static string lockStr = "lock";\r
+\r
+ public IISVersionInfo()\r
+ {\r
+ }\r
+ \r
+ internal static string IsapiVersion\r
+ {\r
+ get\r
+ {\r
+ if(isapiVersion==null)\r
+ {\r
+ lock(lockStr)\r
+ {\r
+ // Recheck - another thread may have set the value\r
+ // before entering lock / exiting previous lock\r
+ if(isapiVersion==null)\r
+ {\r
+ //FIXME: What about Apache? What dll/shared-object to be loaded?\r
+ isapiVersion = GetLoadedModuleVersion("aspnet_isapi.dll");\r
+ }\r
+ }\r
+ }\r
+ return isapiVersion;\r
+ }\r
+ }\r
+ \r
+ internal static string ClrVersion\r
+ {\r
+ get\r
+ {\r
+ if(mscoreeVersion==null)\r
+ {\r
+ lock(lockStr)\r
+ {\r
+ if(mscoreeVersion==null)\r
+ {\r
+ mscoreeVersion = GetLoadedModuleVersion("mscorlib.dll");\r
+ }\r
+ }\r
+ }\r
+ return mscoreeVersion;\r
+ }\r
+ }\r
+ \r
+ internal static string SystemWebVersion\r
+ {\r
+ get\r
+ {\r
+ if(systemWebVersion == null)\r
+ {\r
+ lock(lockStr)\r
+ {\r
+ if(systemWebVersion==null)\r
+ {\r
+ systemWebVersion = (FileVersionInfo.GetVersionInfo((typeof(HttpRuntime)).Module.FullyQualifiedName)).FileVersion;\r
+ }\r
+ }\r
+ }\r
+ return systemWebVersion;\r
+ }\r
+ }\r
+ \r
+ internal static string GetLoadedModuleVersion(string modulename)\r
+ {\r
+ //TODO: Load the version information from the module\r
+ // Needs native calls - which ones, since the module will not be .Net aware\r
+ throw new NotImplementedException();\r
+ }\r
+ \r
+ internal static string GetLoadedModuleFilename(string modulename)\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * Namespace: System.Web.Utils\r
+ * Class: NativeFileChangeEventHandler\r
+ *\r
+ * Author: Gaurav Vaish\r
+ * Maintainer: gvaish@iitk.ac.in\r
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
+ * Implementation: yes\r
+ * Status: 100%\r
+ *\r
+ * (C) Gaurav Vaish (2001)\r
+ */\r
+\r
+namespace System.Web.Utils\r
+{\r
+ public delegate NativeFileChangeEventHandler(object sender, int method);\r
+}\r
*/\r
\r
using System;\r
+using System.Security;\r
+using System.Security.Permissions;\r
+using System.Web.Caching;\r
using System.Web.UI;\r
+using System.Web.Utils;\r
\r
namespace System.Web\r
{\r
/// </summary>\r
private static bool isapiLoaded;\r
\r
+ private Cache cache;\r
+ \r
+ // Security permission helper objects\r
+ private static IStackWalk appPathDiscoveryStackWalk;\r
+ private static IStackWalk ctrlPrincipalStackWalk;\r
+ private static IStackWalk sensitiveInfoStackWalk;\r
+ private static IStackWalk unmgdCodeStackWalk;\r
+ private static IStackWalk unrestrictedStackWalk;\r
+ private static IStackWalk reflectionStackWalk;\r
+ \r
+ private string appDomainAppPath;\r
private string appDomainAppVirtualPath;\r
\r
+ private FileChangesMonitor fcm;\r
+ \r
+ private Exception initErrorExcetion;\r
+ \r
static HttpRuntime()\r
{\r
autogenKeys = new byte[88];\r
initialized = false;\r
isapiLoaded = false;\r
+ \r
+ appPathDiscoveryStackWalk = null;\r
+ ctrlPrincipalStackWalk = null;\r
+ sensitiveInfoStackWalk = null;\r
+ unmgdCodeStackWalk = null;\r
+ unrestrictedStackWalk = null;\r
+ \r
if(!DesignTimeParseData.InDesigner)\r
Initialize();\r
runtime = new HttpRuntime();\r
runtime.Init();\r
}\r
\r
+ //FIXME: IIS specific code. Need information on what to do for Apache?\r
internal static void Initialize()\r
{\r
- throw new NotImplementedException();\r
+ if(!initialized)\r
+ {\r
+ bool moduleObtained = false;\r
+ string file = IISVersionInfo.GetLoadedModuleFilename("aspnet_isapi.dll");\r
+ string dir = null;\r
+ string version = null;\r
+ if(file!=null)\r
+ {\r
+ dir = file.Substring(0, file.LastIndexOf('\\'));\r
+ moduleObtained = true;\r
+ }\r
+ if(dir!=null && dir.Length > 0)\r
+ {\r
+ try\r
+ {\r
+ version = IISVersionInfo.SystemWebVersion;\r
+ /* TODO: I need the code to read registry\r
+ * I need LOCAL_MACHINE\Software\Micorosoft\ASP.NET\<version>\r
+ */\r
+ } catch(Exception e)\r
+ {\r
+ dir = null;\r
+ }\r
+ }\r
+ if(dir==null || dir.Length == 0)\r
+ {\r
+ string modulefile = (typeof(HttpRuntime)).Module.FullyQualifiedName;\r
+ dir = modulefile.Substring(0, modulefile.LastIndexOf('\\'));\r
+ }\r
+ if(!moduleObtained)\r
+ {\r
+ //TODO: Now what? Module still not obtained\r
+ // Try loading using native calls. something like LoadLibrary(...) in java\r
+ }\r
+ if(moduleObtained)\r
+ {\r
+ // Initialize the library\r
+ }\r
+ installDir = dir;\r
+ isapiLoaded = moduleObtained;\r
+ initialized = true;\r
+ }\r
}\r
\r
private void Init()\r
+ {\r
+ initError = null;\r
+ try\r
+ {\r
+ //FIXME: OS Check?\r
+ if(false)\r
+ throw new PlatformNotSupportedException();\r
+ //I am here <gvaish>\r
+ } catch(Exception e)\r
+ {\r
+ initErrorExcetion = e;\r
+ }\r
+ }\r
+\r
+ internal static string FormatResourceString(string key, string arg0, string type)\r
{\r
throw new NotImplementedException();\r
}\r
throw new NotImplementedException();\r
}\r
\r
+ public static Cache Cache\r
+ {\r
+ get\r
+ {\r
+ return runtime.cache;\r
+ }\r
+ }\r
+ \r
+ public static string AppDomainAppId\r
+ {\r
+ get\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+ \r
+ public static string AppDomainAppPath\r
+ {\r
+ get\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+ \r
public static string AppDomainAppVirtualPath\r
{\r
get\r
{\r
- return runtime.appDomainAppVirtualPath;\r
+ throw new NotImplementedException();\r
}\r
}\r
+ \r
+ public static string AppDomainId\r
+ {\r
+ get\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+ \r
+ public static string AspInstallDirectory\r
+ {\r
+ get\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+ \r
+ public static string BinDirectory\r
+ {\r
+ get\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+ \r
+ public static string ClrInstallDirectory\r
+ {\r
+ get\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+ \r
+ public static string CodegenDir\r
+ {\r
+ get\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+ \r
+ public static bool IsOnUNCShare\r
+ {\r
+ get\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+ \r
+ public static string MachineConfigurationDirectory\r
+ {\r
+ get\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+ \r
+ public static void Close()\r
+ {\r
+ throw new NotImplementedException();\r
+ }\r
+ \r
+ internal static IStackWalk AppPathDiscovery\r
+ {\r
+ get\r
+ {\r
+ if(appPathDiscoveryStackWalk == null)\r
+ {\r
+ appPathDiscoveryStackWalk = new FileIOPermission(FileIOPermissionAccess.PathDiscovery, runtime.appDomainAppPath);\r
+ }\r
+ return appPathDiscoveryStackWalk;\r
+ }\r
+ }\r
+ \r
+ internal static IStackWalk ControlPrincipal\r
+ {\r
+ get\r
+ {\r
+ if(ctrlPrincipalStackWalk == null)\r
+ {\r
+ ctrlPrincipalStackWalk = new SecurityPermission(SecurityPermissionFlag.ControlPrincipal);\r
+ }\r
+ return ctrlPrincipalStackWalk;\r
+ }\r
+ }\r
+ \r
+ internal static IStackWalk Reflection\r
+ {\r
+ get\r
+ {\r
+ if(reflectionStackWalk == null)\r
+ {\r
+ reflectionStackWalk = new ReflectionPermission(ReflectionPermissionFlag.TypeInformation | ReflectionPermissionFlag.MemberAccess);\r
+ }\r
+ return reflectionStackWalk;\r
+ }\r
+ }\r
+ \r
+ internal static IStackWalk SensitiveInformation\r
+ {\r
+ get\r
+ {\r
+ if(sensitiveInfoStackWalk == null)\r
+ {\r
+ sensitiveInfoStackWalk = new EnvironmentPermission(PermissionState.Unrestricted);\r
+ }\r
+ return sensitiveInfoStackWalk;\r
+ }\r
+ }\r
+ \r
+ internal static IStackWalk UnmanagedCode\r
+ {\r
+ get\r
+ {\r
+ if(unmgdCodeStackWalk == null)\r
+ {\r
+ unmgdCodeStackWalk = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);\r
+ }\r
+ return unmgdCodeStackWalk;\r
+ }\r
+ }\r
+ \r
+ internal static IStackWalk Unrestricted\r
+ {\r
+ get\r
+ {\r
+ if(unrestrictedStackWalk == null)\r
+ {\r
+ unrestrictedStackWalk = new PermissionSet(PermissionState.Unrestricted);\r
+ }\r
+ return unrestrictedStackWalk;\r
+ }\r
+ }\r
+ \r
+ internal static IStackWalk FileReadAccess(string file)\r
+ {\r
+ return new FileIOPermission(FileIOPermissionAccess.Read, file);\r
+ }\r
+ \r
+ internal static IStackWalk PathDiscoveryAccess(string path)\r
+ {\r
+ return new FileIOPermission(FileIOPermissionAccess.PathDiscovery, path);\r
+ }\r
}\r
}\r