Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/System.Web')
-rw-r--r--mcs/class/System.Web/.cvsignore7
-rw-r--r--mcs/class/System.Web/ChangeLog193
-rw-r--r--mcs/class/System.Web/System.Web.Caching/Cache.cs533
-rw-r--r--mcs/class/System.Web/System.Web.Caching/CacheDefinitions.cs53
-rw-r--r--mcs/class/System.Web/System.Web.Caching/CacheDependency.cs95
-rw-r--r--mcs/class/System.Web/System.Web.Caching/CacheEntry.cs445
-rw-r--r--mcs/class/System.Web/System.Web.Caching/CacheExpires.cs147
-rw-r--r--mcs/class/System.Web/System.Web.Caching/ChangeLog45
-rw-r--r--mcs/class/System.Web/System.Web.Caching/ExpiresBuckets.cs787
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/AspComponentFoundry.cs216
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/AspElements.cs863
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs2021
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/AspParser.cs277
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/AspTokenizer.cs215
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs114
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/CachingCompiler.cs156
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/ChangeLog231
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/CompilationException.cs40
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/CompilationResult.cs71
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/GlobalAsaxCompiler.cs101
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs104
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/UserControlCompiler.cs118
-rw-r--r--mcs/class/System.Web/System.Web.Compilation/WebServiceCompiler.cs85
-rwxr-xr-xmcs/class/System.Web/System.Web.Configuration/AuthConfig.cs175
-rwxr-xr-xmcs/class/System.Web/System.Web.Configuration/AuthenticationConfigHandler.cs112
-rwxr-xr-xmcs/class/System.Web/System.Web.Configuration/AuthenticationMode.cs19
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/ChangeLog78
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/ClientTargetSectionHandler.cs44
-rwxr-xr-xmcs/class/System.Web/System.Web.Configuration/FormsAuthPasswordFormat.cs18
-rwxr-xr-xmcs/class/System.Web/System.Web.Configuration/FormsProtectionEnum.cs19
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/GlobalizationConfiguration.cs29
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/HandlerFactoryConfiguration.cs75
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/HandlerFactoryProxy.cs15
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/HandlerItem.cs120
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/HttpCapabilitiesBase.cs46
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/HttpConfigurationContext.cs29
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/HttpHandlersSectionHandler.cs131
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/HttpModulesConfigurationHandler.cs81
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/MachineKeyConfig.cs65
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/MachineKeyConfigHandler.cs116
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/ModuleItem.cs53
-rw-r--r--mcs/class/System.Web/System.Web.Configuration/ModulesConfiguration.cs75
-rw-r--r--mcs/class/System.Web/System.Web.Handlers/ChangeLog6
-rw-r--r--mcs/class/System.Web/System.Web.Handlers/TraceHandler.cs32
-rw-r--r--mcs/class/System.Web/System.Web.Hosting/AppDomainFactory.cs122
-rw-r--r--mcs/class/System.Web/System.Web.Hosting/ApplicationHost.cs87
-rw-r--r--mcs/class/System.Web/System.Web.Hosting/ChangeLog45
-rw-r--r--mcs/class/System.Web/System.Web.Hosting/IAppDomainFactory.cs24
-rw-r--r--mcs/class/System.Web/System.Web.Hosting/IISAPIRuntime.cs21
-rw-r--r--mcs/class/System.Web/System.Web.Hosting/ISAPIRuntime.cs48
-rw-r--r--mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs273
-rw-r--r--mcs/class/System.Web/System.Web.Mail/ChangeLog12
-rw-r--r--mcs/class/System.Web/System.Web.Mail/MailAttachment.cs44
-rw-r--r--mcs/class/System.Web/System.Web.Mail/MailEncoding.cs26
-rw-r--r--mcs/class/System.Web/System.Web.Mail/MailFormat.cs26
-rw-r--r--mcs/class/System.Web/System.Web.Mail/MailMessage.cs106
-rw-r--r--mcs/class/System.Web/System.Web.Mail/MailPriority.cs30
-rw-r--r--mcs/class/System.Web/System.Web.Mail/SmtpMail.cs77
-rw-r--r--mcs/class/System.Web/System.Web.Security/ChangeLog59
-rw-r--r--mcs/class/System.Web/System.Web.Security/DefaultAuthenticationEventArgs.cs32
-rw-r--r--mcs/class/System.Web/System.Web.Security/DefaultAuthenticationEventHandler.cs15
-rw-r--r--mcs/class/System.Web/System.Web.Security/DefaultAuthenticationModule.cs43
-rw-r--r--mcs/class/System.Web/System.Web.Security/FileAuthorizationModule.cs27
-rw-r--r--mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs300
-rw-r--r--mcs/class/System.Web/System.Web.Security/FormsAuthenticationEventArgs.cs45
-rw-r--r--mcs/class/System.Web/System.Web.Security/FormsAuthenticationEventHandler.cs14
-rw-r--r--mcs/class/System.Web/System.Web.Security/FormsAuthenticationModule.cs91
-rw-r--r--mcs/class/System.Web/System.Web.Security/FormsAuthenticationTicket.cs147
-rw-r--r--mcs/class/System.Web/System.Web.Security/FormsIdentity.cs54
-rw-r--r--mcs/class/System.Web/System.Web.Security/PassportAuthenticationEventArgs.cs54
-rw-r--r--mcs/class/System.Web/System.Web.Security/PassportAuthenticationEventHandler.cs15
-rw-r--r--mcs/class/System.Web/System.Web.Security/PassportAuthenticationModule.cs29
-rw-r--r--mcs/class/System.Web/System.Web.Security/PassportIdentity.cs438
-rw-r--r--mcs/class/System.Web/System.Web.Security/UrlAuthorizationModule.cs33
-rw-r--r--mcs/class/System.Web/System.Web.Security/WindowsAuthenticationEventArgs.cs54
-rw-r--r--mcs/class/System.Web/System.Web.Security/WindowsAuthenticationEventHandler.cs15
-rw-r--r--mcs/class/System.Web/System.Web.Security/WindowsAuthenticationModule.cs34
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/ChangeLog39
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/HttpSessionState.cs199
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/IReadOnlySessionState.cs15
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/IRequiresSessionState.cs15
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/SessionDictionary.cs93
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/SessionStateMode.cs20
-rw-r--r--mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs35
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog254
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs118
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs92
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlContainerControl.cs122
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlControl.cs133
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs176
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlGenericControl.cs46
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs121
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs99
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs85
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputControl.cs70
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs88
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs62
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs145
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs134
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs113
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs463
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs199
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs158
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCellCollection.cs84
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs156
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRowCollection.cs83
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs137
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/.cvsignore2
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/AdCreatedEventArgs.cs92
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/AdCreatedEventHandler.cs17
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/AdRotator.cs364
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/BaseCompareValidator.cs311
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs277
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs414
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/BorderStyle.cs29
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/BoundColumn.cs179
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/Button.cs172
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/ButtonColumn.cs186
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/ButtonColumnType.cs21
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs1161
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/CalendarDay.cs100
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/CalendarSelectionMode.cs23
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog977
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs215
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/CheckBoxList.cs252
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/CommandEventArgs.cs50
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/CommandEventHandler.cs17
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/CompareValidator.cs92
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/CustomValidator.cs113
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs1445
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs408
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs186
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridCommandEventArgs.cs46
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridCommandEventHandler.cs17
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridItem.cs86
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemCollection.cs83
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemEventArgs.cs37
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemEventHandler.cs17
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/DataGridLinkButton.cs54
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridPageChangedEventArgs.cs47
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridPageChangedEventHandler.cs16
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridPagerStyle.cs257
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridSortCommandEventArgs.cs47
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataGridSortCommandEventHandler.cs16
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/DataGridTableInternal.cs31
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataKeyCollection.cs83
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/DataList.cs876
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataListCommandEventArgs.cs46
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataListCommandEventHandler.cs16
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataListItem.cs112
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataListItemCollection.cs83
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataListItemEventArgs.cs37
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DataListItemEventHandler.cs16
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/DataSourceInternal.cs108
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/DayNameFormat.cs23
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DayRenderEventArgs.cs43
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DayRenderEventHandler.cs17
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs160
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/EditCommandColumn.cs109
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/FirstDayOfWeek.cs27
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/FontInfo.cs253
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/FontNamesConverter.cs63
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/FontSize.cs30
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/FontUnit.cs215
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/FontUnitConverter.cs92
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/GridLines.cs23
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/HorizontalAlign.cs27
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/HorizontalAlignConverter.cs51
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs176
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/HyperLinkColumn.cs213
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/HyperLinkControlBuilder.cs27
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/IRepeatInfoUser.cs29
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Image.cs118
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/ImageAlign.cs29
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs181
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Label.cs86
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/LabelControlBuilder.cs27
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs174
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/LinkButtonControlBuilder.cs31
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/LinkButtonInternal.cs55
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs177
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs343
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ListItem.cs241
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ListItemCollection.cs362
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ListItemControlBuilder.cs36
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/ListItemType.cs27
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/ListSelectionMode.cs21
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Literal.cs62
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/LiteralControlBuilder.cs36
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/MonthChangedEventArgs.cs47
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/MonthChangedEventHandler.cs16
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/NextPrevFormat.cs22
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs475
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/PagerMode.cs21
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/PagerPosition.cs22
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Panel.cs97
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/PlaceHolder.cs28
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/PlaceHolderControlBuilder.cs31
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs125
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs244
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RangeValidator.cs125
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RegularExpressionValidator.cs88
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/RepeatDirection.cs21
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RepeatInfo.cs372
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/RepeatLayout.cs21
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Repeater.cs377
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RepeaterCommandEventArgs.cs46
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RepeaterCommandEventHandler.cs16
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItem.cs72
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemCollection.cs83
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemEventArgs.cs37
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemEventHandler.cs16
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/RequiredFieldValidator.cs60
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/SelectedDatesCollection.cs125
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ServerValidateEventArgs.cs42
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ServerValidateEventHandler.cs16
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Style.cs539
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/TODO156
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Table.cs159
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TableCell.cs147
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TableCellCollection.cs181
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TableCellControlBuilder.cs31
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TableHeaderCell.cs26
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TableItemStyle.cs176
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TableRow.cs99
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TableRowCollection.cs179
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TableStyle.cs229
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TargetConverter.cs55
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TemplateColumn.cs109
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/TextAlign.cs21
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs236
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/TextBoxControlBuilder.cs36
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/TextBoxMode.cs22
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/TitleFormat.cs21
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Unit.cs257
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/UnitConverter.cs65
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/UnitType.cs28
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ValidatedControlConverter.cs76
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/ValidationCompareOperator.cs26
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/ValidationDataType.cs24
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs142
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/ValidationSummaryDisplayMode.cs22
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/ValidatorDisplay.cs22
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/VerticalAlign.cs26
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/VerticalAlignConverter.cs51
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/WebColorConverter.cs74
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs451
-rw-r--r--mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs224
-rw-r--r--mcs/class/System.Web/System.Web.UI/ApplicationFileParser.cs46
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/AttributeCollection.cs82
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/BaseParser.cs84
-rw-r--r--mcs/class/System.Web/System.Web.UI/BuildMethod.cs16
-rw-r--r--mcs/class/System.Web/System.Web.UI/BuildTemplateMethod.cs16
-rw-r--r--mcs/class/System.Web/System.Web.UI/ChangeLog673
-rw-r--r--mcs/class/System.Web/System.Web.UI/CompiledTemplateBuilder.cs29
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/ConstructorNeedsTagAttribute.cs31
-rw-r--r--mcs/class/System.Web/System.Web.UI/Control.cs867
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/ControlBuilder.cs167
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/ControlBuilderAttribute.cs47
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/ControlCollection.cs124
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/CssStyleCollection.cs106
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/DataBinder.cs158
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/DataBinding.cs60
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/DataBindingCollection.cs92
-rw-r--r--mcs/class/System.Web/System.Web.UI/DataBindingHandlerAttribute.cs49
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/DataBoundLiteralControl.cs80
-rw-r--r--mcs/class/System.Web/System.Web.UI/DesignTimeParseData.cs29
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/EmptyControlCollection.cs30
-rw-r--r--mcs/class/System.Web/System.Web.UI/HtmlTextWriter.cs1027
-rw-r--r--mcs/class/System.Web/System.Web.UI/HtmlTextWriterAttribute.cs54
-rw-r--r--mcs/class/System.Web/System.Web.UI/HtmlTextWriterStyle.cs28
-rw-r--r--mcs/class/System.Web/System.Web.UI/HtmlTextWriterTag.cs111
-rw-r--r--mcs/class/System.Web/System.Web.UI/IAttributeAccessor.cs20
-rw-r--r--mcs/class/System.Web/System.Web.UI/IDataBindingsAccessor.cs20
-rw-r--r--mcs/class/System.Web/System.Web.UI/INamingContainer.cs18
-rw-r--r--mcs/class/System.Web/System.Web.UI/IParserAccessor.cs19
-rw-r--r--mcs/class/System.Web/System.Web.UI/IPostBackDataHandler.cs21
-rw-r--r--mcs/class/System.Web/System.Web.UI/IPostBackEventHandler.cs19
-rw-r--r--mcs/class/System.Web/System.Web.UI/IStateManager.cs22
-rw-r--r--mcs/class/System.Web/System.Web.UI/ITagNameToTypeMapper.cs20
-rw-r--r--mcs/class/System.Web/System.Web.UI/ITemplate.cs19
-rw-r--r--mcs/class/System.Web/System.Web.UI/IValidator.cs21
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/ImageClickEventArgs.cs25
-rw-r--r--mcs/class/System.Web/System.Web.UI/ImageClickEventHandler.cs16
-rw-r--r--mcs/class/System.Web/System.Web.UI/LiteralControl.cs44
-rw-r--r--mcs/class/System.Web/System.Web.UI/LosFormatter.cs487
-rw-r--r--mcs/class/System.Web/System.Web.UI/OutputCacheLocation.cs23
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/Page.cs706
-rw-r--r--mcs/class/System.Web/System.Web.UI/PageHandlerFactory.cs27
-rw-r--r--mcs/class/System.Web/System.Web.UI/PageParser.cs46
-rw-r--r--mcs/class/System.Web/System.Web.UI/Pair.cs36
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/ParseChildrenAttribute.cs80
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/PartialCachingAttribute.cs51
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/PersistChildrenAttribute.cs50
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/PersistenceMode.cs22
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/PersistenceModeAttribute.cs52
-rw-r--r--mcs/class/System.Web/System.Web.UI/PropertyConverter.cs124
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/RenderMethod.cs13
-rw-r--r--mcs/class/System.Web/System.Web.UI/SimpleHandlerFactory.cs31
-rw-r--r--mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs186
-rw-r--r--mcs/class/System.Web/System.Web.UI/StateBag.cs249
-rw-r--r--mcs/class/System.Web/System.Web.UI/StateItem.cs47
-rw-r--r--mcs/class/System.Web/System.Web.UI/TODO42
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/TagPrefixAttribute.cs37
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/TemplateContainerAttribute.cs27
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/TemplateControl.cs217
-rw-r--r--mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs47
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/TemplateParser.cs55
-rw-r--r--mcs/class/System.Web/System.Web.UI/ToolboxDataAttribute.cs58
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/Triplet.cs36
-rw-r--r--mcs/class/System.Web/System.Web.UI/UserControl.cs189
-rw-r--r--mcs/class/System.Web/System.Web.UI/UserControlParser.cs50
-rw-r--r--mcs/class/System.Web/System.Web.UI/Utils.cs46
-rw-r--r--mcs/class/System.Web/System.Web.UI/ValidationPropertyAttribute.cs27
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/ValidatorCollection.cs69
-rw-r--r--mcs/class/System.Web/System.Web.UI/WebServiceParser.cs36
-rw-r--r--mcs/class/System.Web/System.Web.Util/.cvsignore1
-rw-r--r--mcs/class/System.Web/System.Web.Util/ApacheVersionInfo.cs31
-rw-r--r--mcs/class/System.Web/System.Web.Util/ChangeLog84
-rw-r--r--mcs/class/System.Web/System.Web.Util/DataSourceHelper.cs67
-rw-r--r--mcs/class/System.Web/System.Web.Util/FileAction.cs26
-rw-r--r--mcs/class/System.Web/System.Web.Util/FileChangeEventHandler.cs17
-rw-r--r--mcs/class/System.Web/System.Web.Util/FileChangedEventArgs.cs43
-rw-r--r--mcs/class/System.Web/System.Web.Util/FileChangesMonitor.cs62
-rw-r--r--mcs/class/System.Web/System.Web.Util/FilePathParser.cs82
-rw-r--r--mcs/class/System.Web/System.Web.Util/IISVersionInfo.cs109
-rw-r--r--mcs/class/System.Web/System.Web.Util/NativeFileChangeEventHandler.cs17
-rw-r--r--mcs/class/System.Web/System.Web.Util/UrlUtils.cs290
-rw-r--r--mcs/class/System.Web/System.Web.Util/WebEncoding.cs24
-rw-r--r--mcs/class/System.Web/System.Web.Util/WebEqualComparer.cs107
-rw-r--r--mcs/class/System.Web/System.Web.Util/WebHashCodeProvider.cs54
-rw-r--r--mcs/class/System.Web/System.Web.Util/WebTrace.cs98
-rw-r--r--mcs/class/System.Web/System.Web.build58
-rw-r--r--mcs/class/System.Web/System.Web/.cvsignore1
-rw-r--r--mcs/class/System.Web/System.Web/BeginEventHandler.cs16
-rw-r--r--mcs/class/System.Web/System.Web/ChangeLog536
-rw-r--r--mcs/class/System.Web/System.Web/EndEventHandler.cs13
-rw-r--r--mcs/class/System.Web/System.Web/HttpApplication.cs1037
-rw-r--r--mcs/class/System.Web/System.Web/HttpApplicationFactory.cs321
-rw-r--r--mcs/class/System.Web/System.Web/HttpApplicationState.cs232
-rw-r--r--mcs/class/System.Web/System.Web/HttpAsyncResult.cs73
-rwxr-xr-xmcs/class/System.Web/System.Web/HttpBrowserCapabilities.cs143
-rw-r--r--mcs/class/System.Web/System.Web/HttpCachePolicy.cs148
-rw-r--r--mcs/class/System.Web/System.Web/HttpCacheRevalidation.cs17
-rw-r--r--mcs/class/System.Web/System.Web/HttpCacheValidateHandler.cs16
-rw-r--r--mcs/class/System.Web/System.Web/HttpCacheVaryByHeaders.cs110
-rw-r--r--mcs/class/System.Web/System.Web/HttpCacheVaryByParams.cs81
-rw-r--r--mcs/class/System.Web/System.Web/HttpCacheability.cs18
-rw-r--r--mcs/class/System.Web/System.Web/HttpClientCertificate.cs147
-rw-r--r--mcs/class/System.Web/System.Web/HttpCompileException.cs45
-rw-r--r--mcs/class/System.Web/System.Web/HttpContext.cs299
-rw-r--r--mcs/class/System.Web/System.Web/HttpCookie.cs183
-rw-r--r--mcs/class/System.Web/System.Web/HttpCookieCollection.cs147
-rw-r--r--mcs/class/System.Web/System.Web/HttpException.cs86
-rw-r--r--mcs/class/System.Web/System.Web/HttpFileCollection.cs73
-rw-r--r--mcs/class/System.Web/System.Web/HttpForbiddenHandler.cs27
-rw-r--r--mcs/class/System.Web/System.Web/HttpHelper.cs48
-rw-r--r--mcs/class/System.Web/System.Web/HttpMethodNotAllowedHandler.cs28
-rw-r--r--mcs/class/System.Web/System.Web/HttpModuleCollection.cs73
-rw-r--r--mcs/class/System.Web/System.Web/HttpParseException.cs44
-rw-r--r--mcs/class/System.Web/System.Web/HttpPostedFile.cs56
-rw-r--r--mcs/class/System.Web/System.Web/HttpRequest.cs1010
-rw-r--r--mcs/class/System.Web/System.Web/HttpRequestStream.cs142
-rw-r--r--mcs/class/System.Web/System.Web/HttpResponse.cs901
-rw-r--r--mcs/class/System.Web/System.Web/HttpResponseHeader.cs49
-rw-r--r--mcs/class/System.Web/System.Web/HttpResponseStream.cs87
-rw-r--r--mcs/class/System.Web/System.Web/HttpResponseStreamProxy.cs48
-rw-r--r--mcs/class/System.Web/System.Web/HttpRuntime.cs463
-rw-r--r--mcs/class/System.Web/System.Web/HttpServerUtility.cs283
-rw-r--r--mcs/class/System.Web/System.Web/HttpStaticObjectsCollection.cs59
-rw-r--r--mcs/class/System.Web/System.Web/HttpUnhandledException.cs28
-rw-r--r--mcs/class/System.Web/System.Web/HttpUtility.cs777
-rw-r--r--mcs/class/System.Web/System.Web/HttpValidationStatus.cs17
-rw-r--r--mcs/class/System.Web/System.Web/HttpValueCollection.cs192
-rw-r--r--mcs/class/System.Web/System.Web/HttpWorkerRequest.cs529
-rw-r--r--mcs/class/System.Web/System.Web/HttpWriter.cs209
-rw-r--r--mcs/class/System.Web/System.Web/IHttpAsyncHandler.cs18
-rw-r--r--mcs/class/System.Web/System.Web/IHttpHandler.cs16
-rw-r--r--mcs/class/System.Web/System.Web/IHttpHandlerFactory.cs19
-rw-r--r--mcs/class/System.Web/System.Web/IHttpMapPath.cs19
-rw-r--r--mcs/class/System.Web/System.Web/IHttpModule.cs14
-rw-r--r--mcs/class/System.Web/System.Web/MimeTypes.cs471
-rw-r--r--mcs/class/System.Web/System.Web/NOTES21
-rw-r--r--mcs/class/System.Web/System.Web/ProcessInfo.cs90
-rw-r--r--mcs/class/System.Web/System.Web/ProcessModelInfo.cs52
-rw-r--r--mcs/class/System.Web/System.Web/ProcessShutdownReason.cs23
-rw-r--r--mcs/class/System.Web/System.Web/ProcessStatus.cs17
-rw-r--r--mcs/class/System.Web/System.Web/StaticFileHandler.cs48
-rw-r--r--mcs/class/System.Web/System.Web/TODO19
-rw-r--r--mcs/class/System.Web/System.Web/TODOAttribute.cs33
-rw-r--r--mcs/class/System.Web/System.Web/TraceContext.cs69
-rw-r--r--mcs/class/System.Web/System.Web/TraceMode.cs16
-rw-r--r--mcs/class/System.Web/System.Web/WebCategoryAttribute.cs38
-rw-r--r--mcs/class/System.Web/System.Web/WebSysDescriptionAttribute.cs44
-rw-r--r--mcs/class/System.Web/Test/DataBinderTests.cs181
-rw-r--r--mcs/class/System.Web/Test/TestMonoWeb/AsyncHandler.cs103
-rw-r--r--mcs/class/System.Web/Test/TestMonoWeb/AsyncModule.cs36
-rw-r--r--mcs/class/System.Web/Test/TestMonoWeb/AsyncOperation.cs42
-rw-r--r--mcs/class/System.Web/Test/TestMonoWeb/README5
-rw-r--r--mcs/class/System.Web/Test/TestMonoWeb/SyncHandler.cs16
-rw-r--r--mcs/class/System.Web/Test/TestMonoWeb/SyncModule.cs37
-rw-r--r--mcs/class/System.Web/Test/TestMonoWeb/Test1.cs46
-rw-r--r--mcs/class/System.Web/Test/TestMonoWeb/TestMonoWeb.build26
-rw-r--r--mcs/class/System.Web/Test/test.aspx29
-rw-r--r--mcs/class/System.Web/Test/test2.aspx101
-rw-r--r--mcs/class/System.Web/Test/test3.aspx23
-rw-r--r--mcs/class/System.Web/Test/test4.aspx119
-rw-r--r--mcs/class/System.Web/Test/test5.aspx121
-rw-r--r--mcs/class/System.Web/Test/test6.aspx83
-rwxr-xr-xmcs/class/System.Web/list369
-rw-r--r--mcs/class/System.Web/makefile.gnu13
-rw-r--r--mcs/class/System.Web/makefile.trace12
412 files changed, 53449 insertions, 0 deletions
diff --git a/mcs/class/System.Web/.cvsignore b/mcs/class/System.Web/.cvsignore
new file mode 100644
index 00000000000..9a1d05f6953
--- /dev/null
+++ b/mcs/class/System.Web/.cvsignore
@@ -0,0 +1,7 @@
+Temp.build
+*.dll
+lib
+makefile
+.makefrag
+.response
+library-deps.stamp
diff --git a/mcs/class/System.Web/ChangeLog b/mcs/class/System.Web/ChangeLog
new file mode 100644
index 00000000000..e36cf5f3244
--- /dev/null
+++ b/mcs/class/System.Web/ChangeLog
@@ -0,0 +1,193 @@
+2002-11-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added new file.
+
+2002-11-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added/removed files.
+
+2002-11-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * makefile.gnu: s/MONO_PATH_PREFIX/MONO_PATH/
+
+2002-10-28 Duncan Mak <duncan@ximian.com>
+
+ * list: added DataGridLinkButton.cs.
+
+2002-10-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added WebEncoding.cs
+
+2002-10-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * makefile.trace: used to build System.Web.dll with trace enabled.
+ * System.Web.build: added trace and clean targets.
+
+2002-10-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.build: added options (commented out) to activate tracing.
+
+2002-10-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added new file in System.Web.Handlers.
+
+2002-10-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added new files in System.Web.Configuration.
+
+2002-09-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added new files in System.Web.
+
+2002-09-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added PageHandlerFactory.
+
+2002-09-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added 2 new files (DataGrid*Internal.cs).
+
+2002-09-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added new files.
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added new files in System.Web.Security
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added HorizontalAlignConverter and VerticalAlignConverter.
+
+2002-08-05 Patrik Torstensson <ptorsten@hotmail.com>
+ * list:
+ Add System.Web/ApplicationFactory.cs
+ Add System.Web/HttpAsyncResult.cs
+ Add System.Web.Configuration/GlobalizationConfiguration.cs
+ Add System.Web.Configuration/HandlerFactoryConfiguration.cs
+ Add System.Web.Configuration/HandlerFactoryProxy.cs
+ Add System.Web.Configuration/HandlerItem.cs
+ Add System.Web.Configuration/ModuleItem.cs
+ Add System.Web.Configuration/ModulesConfiguration.cs
+
+2002-07-24 Tim Coleman <tim@timcoleman.com>
+ * list:
+ Add System.Web/ProcessInfo.cs
+ Add System.Web/HttpCompileException.cs
+ Add System.Web/HttpParseException.cs
+ Add System.Web/HttpUnhandledException.cs
+
+2002-07-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: added some more files from System.Web.Hosting.
+
+2002-07-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.build: removed some more excludes.
+
+2002-07-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: updated. Currently mcs cannot compile System.Web because it
+ cannot find NameObjectCollectionBase.KeysCollection.
+
+ * System.Web.build: don't display unused event nor always default value
+ warnings by now.
+
+2002-06-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list: updated and reformatted.
+
+2002-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.build: added /debug flag. I wanna see line numbers in
+ exceptions thrown.
+
+2002-06-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.Security:
+ * System.Web.SessionState: new directories.
+
+2002-05-17 Duncan Mak <duncan@ximian.com>
+
+ * System.Web.build: Added new arguments: "/noconfig",
+ "/r:System.Drawing.dll" and "/r:System.Xml.dll".
+
+2002-05-10 Duncan Mak <duncan@ximian.com>
+
+ * System.Web.build: Include the System.Web.UI.HtmlControls namespace.
+
+ * Page.cs:
+ * ValidatorCollection.cs: Stubs to make things compile for
+ now. Added one dummy method (RegisterClientScriptFile) that's used
+ in the existing codebase, but not in MS docs.
+
+2002-04-26 Lawrence Pit <loz@cable.a2000.nl>
+
+ * Added directory: System.Web.Mail
+
+2002-04-10 Patrik Torstensson <patrik.torstensson@labs2.com>
+
+ * System.Web -- Assembly build.
+
+ The basic runtime support is now working, we can now start working
+ on the runtime flow system (thread pool etc) and also start testing
+ the parser and control framework. (224 files are compiled)
+
+2002-03-26 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * System.Web.Security: Removed all files. Will do it later.
+ May be someone else like to do it for the time being.
+
+2002-03-17 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * System.Web -- Assembly build.
+ Another milestone reached. Compiled 195 classes successfully.
+ Build includes System.Web.UI.WebControls and all the dependencies
+ for the namespace.
+
+2002-03-05 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * System.Web.Security: Added directory.
+
+2002-03-04 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * System.Web.UI.WebContorls: Virtually complete. See
+ System.Web.UI.WebControls/ChangeLog for a comprehensensive
+ description of what's left and where. But, don't go for
+ a build at this stage. There are a few classes left in
+ System.Web namespace that need to be filled-up, though
+ I will try to fix up the current state to be able to make
+ a build.
+
+2001-12-20 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ Did first successful build of System.Web.dll that included
+ System.Web.UI.WebControls namespace. Though, not updating
+ the System.Web.build file, since with the changes that
+ followed, the build again fails :(
+
+2001-11-30 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * System.Web.WebUtils: Removed
+ * System.Web.Utils : Added --- replacement of WebUtils
+
+2001-11-08 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * System.Web.WebUtils: Added directory
+
+2001-08-22 Bob Smith <bob@thestuff.net>
+
+ * Added directory: System.Web.UI.HtmlControls
+ * Added directory: Test
+
+2001-08-17 Bob Smith <bob@thestuff.net>
+
+ * Added directory: System.Web.UI
+
+2001-08-09 Bob Smith <bob@thestuff.net>
+
+ * Added directory: System.Web
+
+2001-07-20 Patrik Torstensson (Patrik.Torstensson@labs2.com)
+
+ * Added directory: System.Web.Caching
diff --git a/mcs/class/System.Web/System.Web.Caching/Cache.cs b/mcs/class/System.Web/System.Web.Caching/Cache.cs
new file mode 100644
index 00000000000..4e13b80abab
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Caching/Cache.cs
@@ -0,0 +1,533 @@
+//
+// System.Web.Caching
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Changes:
+// Daniel Cazzulino [DHC] (dcazzulino@users.sf.net)
+//
+// (C) Copyright Patrik Torstensson, 2001
+//
+namespace System.Web.Caching
+{
+ /// <summary>
+ /// Implements a cache for Web applications and other. The difference from the MS.NET implementation is that we
+ /// support to use the Cache object as cache in our applications.
+ /// </summary>
+ /// <remarks>
+ /// The Singleton cache is created per application domain, and it remains valid as long as the application domain remains active.
+ /// </remarks>
+ /// <example>
+ /// Usage of the singleton cache:
+ ///
+ /// Cache objManager = Cache.SingletonCache;
+ ///
+ /// String obj = "tobecached";
+ /// objManager.Add("kalle", obj);
+ /// </example>
+ public class Cache : System.Collections.IEnumerable, System.IDisposable
+ {
+ // Declarations
+
+ // MS.NET Does only have the cache connected to the HttpRuntime and we don't have the HttpRuntime (yet)
+ // HACK: [DHC] Don't construct a new cache unless it's actually used.
+ //static Cache objSingletonCache = new Cache();
+ static Cache objSingletonCache;
+
+ private bool _boolDisposed;
+
+ // Helper objects
+ private CacheExpires _objExpires;
+
+ // The data storage
+ // Todo: Make a specialized storage for the cache entries?
+ // todo: allow system to replace the storage?
+ private System.Collections.Hashtable _arrEntries;
+ private System.Threading.ReaderWriterLock _lockEntries;
+
+ static private System.TimeSpan _datetimeOneYear = System.TimeSpan.FromDays(365);
+
+ // Number of items in the cache
+ private long _longItems;
+
+ // Constructor
+ public Cache()
+ {
+ _boolDisposed = false;
+ _longItems = 0;
+
+ _lockEntries = new System.Threading.ReaderWriterLock();
+ _arrEntries = new System.Collections.Hashtable();
+
+ _objExpires = new CacheExpires(this);
+ }
+
+ // Public methods and properties
+
+ //
+ /// <summary>
+ /// Returns a static version of the cache. In MS.NET the cache is stored in the System.Web.HttpRuntime
+ /// but we keep it here as a singleton (right now anyway).
+ /// </summary>
+ public static Cache SingletonCache
+ {
+ get
+ {
+ if (objSingletonCache == null)
+ {
+ // HACK: [DHC] Create the cache here instead of throwing.
+ //throw new System.InvalidOperationException();
+ objSingletonCache = new Cache();
+ }
+
+ return objSingletonCache;
+ }
+ }
+
+ /// <summary>
+ /// Used in the absoluteExpiration parameter in an Insert method call to indicate the item should never expire. This field is read-only.
+ /// </summary>
+ public static readonly System.DateTime NoAbsoluteExpiration = System.DateTime.MaxValue;
+
+ /// <summary>
+ /// Used as the slidingExpiration parameter in an Insert method call to disable sliding expirations. This field is read-only.
+ /// </summary>
+ public static readonly System.TimeSpan NoSlidingExpiration = System.TimeSpan.Zero;
+
+ /// <summary>
+ /// Internal method to create a enumerator and over all public items in the cache and is used by GetEnumerator method.
+ /// </summary>
+ /// <returns>Returns IDictionaryEnumerator that contains all public items in the cache</returns>
+ private System.Collections.IDictionaryEnumerator CreateEnumerator()
+ {
+ System.Collections.Hashtable objTable;
+
+ //Locking with 0 provides a non-expiring lock.
+ _lockEntries.AcquireReaderLock(0);
+ try
+ {
+ // Create a new hashtable to return as collection of public items
+ objTable = new System.Collections.Hashtable(_arrEntries.Count);
+
+ foreach(System.Collections.DictionaryEntry objEntry in _arrEntries)
+ {
+ if (objEntry.Key != null)
+ {
+ // Check if this is a public entry
+ if (((CacheEntry) objEntry.Value).TestFlag(CacheEntry.Flags.Public))
+ {
+ // Add to the collection
+ objTable.Add(objEntry.Key, ((CacheEntry) objEntry.Value).Item);
+ }
+ }
+ }
+ }
+ finally
+ {
+ _lockEntries.ReleaseReaderLock();
+ }
+
+ return objTable.GetEnumerator();
+ }
+
+ /// <summary>
+ /// Implementation of IEnumerable interface and calls the GetEnumerator that returns
+ /// IDictionaryEnumerator.
+ /// </summary>
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ /// <summary>
+ /// Virtual override of the IEnumerable.GetEnumerator() method, returns a specialized enumerator.
+ /// </summary>
+ public System.Collections.IDictionaryEnumerator GetEnumerator()
+ {
+ return CreateEnumerator();
+ }
+
+ /// <summary>
+ /// Touches a object in the cache. Used to update expire time and hit count.
+ /// </summary>
+ /// <param name="strKey">The identifier for the cache item to retrieve.</param>
+ public void Touch(string strKey)
+ {
+ // Just touch the object
+ Get(strKey);
+ }
+
+ /// <summary>
+ /// Adds the specified item to the Cache object with dependencies, expiration and priority policies, and a
+ /// delegate you can use to notify your application when the inserted item is removed from the Cache.
+ /// </summary>
+ /// <param name="strKey">The cache key used to reference the item.</param>
+ /// <param name="objItem">The item to be added to the cache.</param>
+ /// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
+ /// <param name="absolutExpiration">The time at which the added object expires and is removed from the cache. </param>
+ /// <param name="slidingExpiration">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
+ /// <param name="enumPriority">The relative cost of the object, as expressed by the CacheItemPriority enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.</param>
+ /// <param name="enumPriorityDecay">The rate at which an object in the cache decays in importance. Objects that decay quickly are more likely to be removed.</param>
+ /// <param name="eventRemoveCallback">A delegate that, if provided, is called when an object is removed from the cache. You can use this to notify applications when their objects are deleted from the cache.</param>
+ /// <returns>The Object item added to the Cache.</returns>
+ public object Add(string strKey, object objItem, CacheDependency objDependency, System.DateTime absolutExpiration, System.TimeSpan slidingExpiration, CacheItemPriority enumPriority, CacheItemPriorityDecay enumPriorityDecay, CacheItemRemovedCallback eventRemoveCallback)
+ {
+ if (_boolDisposed)
+ {
+ throw new System.ObjectDisposedException("System.Web.Cache");
+ }
+
+ if (strKey == null)
+ {
+ throw new System.ArgumentNullException("strKey");
+ }
+
+ if (objItem == null)
+ {
+ throw new System.ArgumentNullException("objItem");
+ }
+
+ if (slidingExpiration > _datetimeOneYear)
+ {
+ throw new System.ArgumentOutOfRangeException("slidingExpiration");
+ }
+
+ CacheEntry objEntry;
+ CacheEntry objNewEntry;
+
+ long longHitRange = 10000;
+
+ // todo: check decay and make up the minHit range
+
+ objEntry = new CacheEntry(this, strKey, objItem, objDependency, eventRemoveCallback, absolutExpiration, slidingExpiration, longHitRange, true, enumPriority);
+
+ System.Threading.Interlocked.Increment(ref _longItems);
+
+ // If we have any kind of expiration add into the CacheExpires class
+ if (objEntry.HasSlidingExpiration || objEntry.HasAbsoluteExpiration)
+ {
+ // Add it to CacheExpires
+ _objExpires.Add(objEntry);
+ }
+
+ // Check and get the new item..
+ objNewEntry = UpdateCache(strKey, objEntry, true, CacheItemRemovedReason.Removed);
+
+ if (objNewEntry != null)
+ {
+ // Return added item
+ return objEntry.Item;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// Inserts an item into the Cache object with a cache key to reference its location and using default values
+ /// provided by the CacheItemPriority and CacheItemPriorityDecay enumerations.
+ /// </summary>
+ /// <param name="strKey">The cache key used to reference the item.</param>
+ /// <param name="objItem">The item to be added to the cache.</param>
+ public void Insert(string strKey, object objItem)
+ {
+ //HACK: [DHC] Use constants defined in Cache.
+ //Add(strKey, objItem, null, System.DateTime.MaxValue, System.TimeSpan.Zero, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
+ Add(strKey, objItem, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
+ }
+
+ /// <summary>
+ /// Inserts an object into the Cache that has file or key dependencies.
+ /// </summary>
+ /// <param name="strKey">The cache key used to reference the item.</param>
+ /// <param name="objItem">The item to be added to the cache.</param>
+ /// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
+ public void Insert(string strKey, object objItem, CacheDependency objDependency)
+ {
+ //HACK: [DHC] Use constants defined in Cache.
+ //Add(strKey, objItem, objDependency, System.DateTime.MaxValue, System.TimeSpan.Zero, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
+ Add(strKey, objItem, objDependency, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
+ }
+
+ /// <summary>
+ /// Inserts an object into the Cache with dependencies and expiration policies.
+ /// </summary>
+ /// <param name="strKey">The cache key used to reference the item.</param>
+ /// <param name="objItem">The item to be added to the cache.</param>
+ /// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
+ /// <param name="absolutExpiration">The time at which the added object expires and is removed from the cache. </param>
+ /// <param name="slidingExpiration">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
+ public void Insert(string strKey, object objItem, CacheDependency objDependency, System.DateTime absolutExpiration, System.TimeSpan slidingExpiration)
+ {
+ Add(strKey, objItem, objDependency, absolutExpiration, slidingExpiration, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
+ }
+
+ /// <summary>
+ /// Inserts an object into the Cache object with dependencies, expiration and priority policies, and a delegate
+ /// you can use to notify your application when the inserted item is removed from the Cache.
+ /// </summary>
+ /// <param name="strKey">The cache key used to reference the item.</param>
+ /// <param name="objItem">The item to be added to the cache.</param>
+ /// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
+ /// <param name="absolutExpiration">The time at which the added object expires and is removed from the cache. </param>
+ /// <param name="slidingExpiration">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
+ /// <param name="enumPriority">The relative cost of the object, as expressed by the CacheItemPriority enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.</param>
+ /// <param name="enumPriorityDecay">The rate at which an object in the cache decays in importance. Objects that decay quickly are more likely to be removed.</param>
+ /// <param name="eventRemoveCallback">A delegate that, if provided, is called when an object is removed from the cache. You can use this to notify applications when their objects are deleted from the cache.</param>
+ public void Insert(string strKey, object objItem, CacheDependency objDependency, System.DateTime absolutExpiration, System.TimeSpan slidingExpiration, CacheItemPriority enumPriority, CacheItemPriorityDecay enumPriorityDecay, CacheItemRemovedCallback eventRemoveCallback)
+ {
+ Add(strKey, objItem, objDependency, absolutExpiration, slidingExpiration, enumPriority, enumPriorityDecay, eventRemoveCallback);
+ }
+
+ /// <summary>
+ /// Removes the specified item from the Cache object.
+ /// </summary>
+ /// <param name="strKey">The cache key for the cache item to remove.</param>
+ /// <returns>The item removed from the Cache. If the value in the key parameter is not found, returns a null reference.</returns>
+ public object Remove(string strKey)
+ {
+ return Remove(strKey, CacheItemRemovedReason.Removed);
+ }
+
+ /// <summary>
+ /// Internal method that updates the cache, decremenents the number of existing items and call close on the cache entry. This method
+ /// is also used from the ExpiresBuckets class to remove an item during GC flush.
+ /// </summary>
+ /// <param name="strKey">The cache key for the cache item to remove.</param>
+ /// <param name="enumReason">Reason why the item is removed.</param>
+ /// <returns>The item removed from the Cache. If the value in the key parameter is not found, returns a null reference.</returns>
+ internal object Remove(string strKey, CacheItemRemovedReason enumReason)
+ {
+ CacheEntry objEntry = UpdateCache(strKey, null, true, enumReason);
+
+ if (objEntry != null)
+ {
+ System.Threading.Interlocked.Decrement(ref _longItems);
+
+ // Close the cache entry (calls the remove delegate)
+ objEntry.Close(enumReason);
+
+ return objEntry.Item;
+ } else
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves the specified item from the Cache object.
+ /// </summary>
+ /// <param name="strKey">The identifier for the cache item to retrieve.</param>
+ /// <returns>The retrieved cache item, or a null reference.</returns>
+ public object Get(string strKey)
+ {
+ CacheEntry objEntry = UpdateCache(strKey, null, false, CacheItemRemovedReason.Expired);
+
+ if (objEntry == null)
+ {
+ return null;
+ } else
+ {
+ return objEntry.Item;
+ }
+ }
+
+ /// <summary>
+ /// Internal method used for removing, updating and adding CacheEntries into the cache.
+ /// </summary>
+ /// <param name="strKey">The identifier for the cache item to modify</param>
+ /// <param name="objEntry">CacheEntry to use for overwrite operation, if this parameter is null and overwrite true the item is going to be removed</param>
+ /// <param name="boolOverwrite">If true the objEntry parameter is used to overwrite the strKey entry</param>
+ /// <param name="enumReason">Reason why an item was removed</param>
+ /// <returns></returns>
+ private CacheEntry UpdateCache(string strKey, CacheEntry objEntry, bool boolOverwrite, CacheItemRemovedReason enumReason)
+ {
+ if (_boolDisposed)
+ {
+ throw new System.ObjectDisposedException("System.Web.Cache", "Can't update item(s) in a disposed cache");
+ }
+
+ if (strKey == null)
+ {
+ throw new System.ArgumentNullException("System.Web.Cache");
+ }
+
+ long ticksNow = System.DateTime.Now.Ticks;
+ long ticksExpires = long.MaxValue;
+
+ bool boolGetItem = false;
+ bool boolExpiried = false;
+ bool boolWrite = false;
+ bool boolRemoved = false;
+
+ // Are we getting the item from the hashtable
+ if (boolOverwrite == false && strKey.Length > 0 && objEntry == null)
+ {
+ boolGetItem = true;
+ }
+
+ // TODO: Optimize this method, move out functionality outside the lock
+ _lockEntries.AcquireReaderLock(0);
+ try
+ {
+ if (boolGetItem)
+ {
+ objEntry = (CacheEntry) _arrEntries[strKey];
+ if (objEntry == null)
+ {
+ return null;
+ }
+ }
+
+ if (objEntry != null)
+ {
+ // Check if we have expired
+ if (objEntry.HasSlidingExpiration || objEntry.HasAbsoluteExpiration)
+ {
+ if (objEntry.Expires < ticksNow)
+ {
+ // We have expired, remove the item from the cache
+ boolWrite = true;
+ boolExpiried = true;
+ }
+ }
+ }
+
+ // Check if we going to modify the hashtable
+ if (boolWrite || (boolOverwrite && !boolExpiried))
+ {
+ // Upgrade our lock to write
+ System.Threading.LockCookie objCookie = _lockEntries.UpgradeToWriterLock(0);
+ try
+ {
+ // Check if we going to just modify an existing entry (or add)
+ if (boolOverwrite && objEntry != null)
+ {
+ _arrEntries[strKey] = objEntry;
+ }
+ else
+ {
+ // We need to remove the item, fetch the item first
+ objEntry = (CacheEntry) _arrEntries[strKey];
+ if (objEntry != null)
+ {
+ _arrEntries.Remove(strKey);
+ }
+
+ boolRemoved = true;
+ }
+ }
+ finally
+ {
+ _lockEntries.DowngradeFromWriterLock(ref objCookie);
+ }
+ }
+
+ // If the entry haven't expired or been removed update the info
+ if (!boolExpiried && !boolRemoved)
+ {
+ // Update that we got a hit
+ objEntry.Hits++;
+ if (objEntry.HasSlidingExpiration)
+ {
+ ticksExpires = ticksNow + objEntry.SlidingExpiration;
+ }
+ }
+ }
+ finally
+ {
+ _lockEntries.ReleaseLock();
+
+ }
+
+ // If the item was removed we need to remove it from the CacheExpired class also
+ if (boolRemoved)
+ {
+ if (objEntry != null)
+ {
+ if (objEntry.HasAbsoluteExpiration || objEntry.HasSlidingExpiration)
+ {
+ _objExpires.Remove(objEntry);
+ }
+ }
+
+ // Return the entry, it's not up to the UpdateCache to call Close on the entry
+ return objEntry;
+ }
+
+ // If we have sliding expiration and we have a correct hit, update the expiration manager
+ if (objEntry.HasSlidingExpiration)
+ {
+ _objExpires.Update(objEntry, ticksExpires);
+ }
+
+ // Return the cache entry
+ return objEntry;
+ }
+
+ /// <summary>
+ /// Gets the number of items stored in the cache.
+ /// </summary>
+ public long Count
+ {
+ get
+ {
+ return _longItems;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the cache item at the specified key.
+ /// </summary>
+ public object this[string strKey]
+ {
+ get
+ {
+ return Get(strKey);
+ }
+
+ set
+ {
+ Insert(strKey, value);
+ }
+ }
+
+ /// <summary>
+ /// Called to close the cache when the AppDomain is closing down or the GC has decided it's time to destroy the object.
+ /// </summary>
+ public void Dispose()
+ {
+ _boolDisposed = true;
+
+ _lockEntries.AcquireReaderLock(0);
+ try
+ {
+ foreach(System.Collections.DictionaryEntry objEntry in _arrEntries)
+ {
+ if (objEntry.Key != null)
+ {
+ // Check if this is active
+ if ( ((CacheEntry) objEntry.Value).TestFlag(CacheEntry.Flags.Removed) )
+ {
+ try
+ {
+ ((CacheEntry) objEntry.Value).Close(CacheItemRemovedReason.Removed);
+ }
+ catch (System.Exception objException)
+ {
+ System.Diagnostics.Debug.Fail("System.Web.Cache.Dispose() Exception when closing cache entry", "Message: " + objException.Message + " Stack: " + objException.StackTrace + " Source:" + objException.Source);
+ }
+ }
+ }
+ }
+ //HACK: dispose the expiring helper.
+ _objExpires.Dispose();
+ }
+ finally
+ {
+ _lockEntries.ReleaseReaderLock();
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Caching/CacheDefinitions.cs b/mcs/class/System.Web/System.Web.Caching/CacheDefinitions.cs
new file mode 100644
index 00000000000..bde614987ae
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Caching/CacheDefinitions.cs
@@ -0,0 +1,53 @@
+//
+// System.Web.Caching
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+// (C) Copyright Patrik Torstensson, 2001
+//
+namespace System.Web.Caching
+{
+ /// <summary>
+ /// Specifies the relative priority of items stored in the Cache.
+ /// </summary>
+ public enum CacheItemPriority {
+ Low = 1,
+ BelowNormal = 2,
+ Normal = 3,
+ Default = 3,
+ AboveNormal = 4,
+ High = 5,
+ NotRemovable
+ }
+
+ /// <summary>
+ /// Specifies the rate at which the priority of items stored in the Cache are downgraded when not accessed frequently.
+ /// </summary>
+ public enum CacheItemPriorityDecay {
+ Default,
+ Fast,
+ Medium,
+ Never,
+ Slow
+ }
+
+ /// <summary>
+ /// Specifies the reason an item was removed from the Cache.
+ /// </summary>
+ public enum CacheItemRemovedReason {
+ Expired = 1,
+ Removed = 2,
+ Underused = 3,
+ DependencyChanged = 4
+ }
+
+ /// <summary>
+ /// Defines a callback method for notifying applications when a cached item is removed from the Cache.
+ /// </summary>
+ /// <param name="key">The index location for the item removed from the cache. </param>
+ /// <param name="value">The Object item removed from the cache. </param>
+ /// <param name="reason">The reason the item was removed from the cache, as specified by the CacheItemRemovedReason enumeration.</param>
+ public delegate void CacheItemRemovedCallback(string key, object value, CacheItemRemovedReason reason);
+
+ }
diff --git a/mcs/class/System.Web/System.Web.Caching/CacheDependency.cs b/mcs/class/System.Web/System.Web.Caching/CacheDependency.cs
new file mode 100644
index 00000000000..68c1a39e623
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Caching/CacheDependency.cs
@@ -0,0 +1,95 @@
+//
+// System.Web.Caching
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+// (C) Copyright Patrik Torstensson, 2001
+//
+namespace System.Web.Caching
+{
+ /// <summary>
+ /// Class to handle cache dependency, right now this class is only a mookup
+ /// </summary>
+ public sealed class CacheDependency : System.IDisposable
+ {
+ private bool _boolDisposed;
+
+ public CacheDependency()
+ {
+ _boolDisposed = false;
+ }
+
+ /// <remarks>
+ /// Added by gvaish@iitk.ac.in
+ /// </remarks>
+ [MonoTODO("Constructor")]
+ public CacheDependency(string filename)
+ {
+ }
+
+ /// <remarks>
+ /// Added by gvaish@iitk.ac.in
+ /// </remarks>
+ [MonoTODO("Constructor")]
+ public CacheDependency(string[] filenames, string[] cachekeys)
+ {
+ }
+
+ public delegate void CacheDependencyCallback(CacheDependency objDependency);
+
+ public event CacheDependencyCallback Changed;
+
+ public void OnChanged()
+ {
+ if (_boolDisposed)
+ {
+ throw new System.ObjectDisposedException("System.Web.CacheDependency");
+ }
+
+ if (Changed != null)
+ {
+ Changed(this);
+ }
+ }
+
+ public bool IsDisposed
+ {
+ get
+ {
+ return _boolDisposed;
+ }
+ }
+
+ public bool HasEvents
+ {
+ get
+ {
+ if (_boolDisposed)
+ {
+ throw new System.ObjectDisposedException("System.Web.CacheDependency");
+ }
+
+ if (Changed != null)
+ {
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ public void Dispose()
+ {
+ _boolDisposed = true;
+ }
+
+ /// <summary>
+ /// Used in testing.
+ /// </summary>
+ public void Signal()
+ {
+ OnChanged();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Caching/CacheEntry.cs b/mcs/class/System.Web/System.Web.Caching/CacheEntry.cs
new file mode 100644
index 00000000000..80d56c8ad74
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Caching/CacheEntry.cs
@@ -0,0 +1,445 @@
+//
+// System.Web.Caching
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Changes:
+// Daniel Cazzulino [DHC] (dcazzulino@users.sf.net)
+//
+// (C) Copyright Patrik Torstensson, 2001
+//
+namespace System.Web.Caching
+{
+ /// <summary>
+ /// Class responsible for representing a cache entry.
+ /// </summary>
+ public class CacheEntry
+ {
+ /// <summary>
+ /// Defines the status of the current cache entry
+ /// </summary>
+ public enum Flags
+ {
+ Removed = 0,
+ Public = 1
+ }
+
+ private CacheItemPriority _enumPriority;
+
+ private long _longHits;
+
+ private byte _byteExpiresBucket;
+ private int _intExpiresIndex;
+
+ private long _ticksExpires;
+ private long _ticksSlidingExpiration;
+
+ private string _strKey;
+ private object _objItem;
+
+ private long _longMinHits;
+
+ private Flags _enumFlags;
+
+ private CacheDependency _objDependency;
+ private Cache _objCache;
+
+ /// <summary>
+ /// The item is not placed in a bucket. [DHC]
+ /// </summary>
+ public static readonly byte NoBucketHash = byte.MaxValue;
+
+ /// <summary>
+ /// The item is not placed in a bucket. [DHC]
+ /// </summary>
+ public static readonly int NoIndexInBucket = int.MaxValue;
+
+ /// <summary>
+ /// Lock for syncronized operations. [DHC]
+ /// </summary>
+ System.Threading.ReaderWriterLock _lock = new System.Threading.ReaderWriterLock();
+
+ /// <summary>
+ /// Constructs a new cache entry
+ /// </summary>
+ /// <param name="strKey">The cache key used to reference the item.</param>
+ /// <param name="objItem">The item to be added to the cache.</param>
+ /// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
+ /// <param name="dtExpires">The time at which the added object expires and is removed from the cache. </param>
+ /// <param name="tsSpan">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
+ /// <param name="longMinHits">Used to detect and control if the item should be flushed due to under usage</param>
+ /// <param name="boolPublic">Defines if the item is public or not</param>
+ /// <param name="enumPriority">The relative cost of the object, as expressed by the CacheItemPriority enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.</param>
+ public CacheEntry( Cache objManager, string strKey, object objItem, CacheDependency objDependency, CacheItemRemovedCallback eventRemove,
+ System.DateTime dtExpires, System.TimeSpan tsSpan, long longMinHits, bool boolPublic, CacheItemPriority enumPriority )
+ {
+ if (boolPublic)
+ {
+ SetFlag(Flags.Public);
+ }
+
+ _strKey = strKey;
+ _objItem = objItem;
+ _objCache = objManager;
+
+ _onRemoved += eventRemove;
+
+ _enumPriority = enumPriority;
+
+ _ticksExpires = dtExpires.Ticks;
+
+ _ticksSlidingExpiration = tsSpan.Ticks;
+
+ // If we have a sliding expiration it overrides the absolute expiration (MS behavior)
+ // This is because sliding expiration causes the absolute expiration to be
+ // moved after each period, and the absolute expiration is the value used
+ // for all expiration calculations.
+ //HACK: [DHC] Use constants defined in Cache.
+ //if (tsSpan.Ticks != System.TimeSpan.Zero.Ticks)
+ if (tsSpan.Ticks != Cache.NoSlidingExpiration.Ticks)
+ {
+ _ticksExpires = System.DateTime.Now.AddTicks(_ticksSlidingExpiration).Ticks;
+ }
+
+ _objDependency = objDependency;
+ if (_objDependency != null)
+ {
+ if (_objDependency.IsDisposed)
+ {
+ throw new System.ObjectDisposedException("System.Web.CacheDependency");
+ }
+
+ // Add the entry to the cache dependency handler (we support multiple entries per handler)
+ _objDependency.Changed += new CacheDependency.CacheDependencyCallback(OnChanged);
+ }
+
+ _longMinHits = longMinHits;
+ }
+
+ private event CacheItemRemovedCallback _onRemoved;
+
+ public void OnChanged(CacheDependency objDependency)
+ {
+ _objCache.Remove(_strKey, CacheItemRemovedReason.DependencyChanged);
+ }
+
+ /// <summary>
+ /// Cleans up the cache entry, removes the cache dependency and calls the remove delegate.
+ /// </summary>
+ /// <param name="enumReason">The reason why the cache entry are going to be removed</param>
+ public void Close(CacheItemRemovedReason enumReason)
+ {
+ //HACK: optimized locks. [DHC]
+ _lock.AcquireWriterLock(0);
+ try
+ {
+ // Check if the item already is removed
+ if (TestFlag(Flags.Removed))
+ {
+ return;
+ }
+
+ SetFlag(Flags.Removed);
+
+ if (_onRemoved != null)
+ {
+ // Call the delegate to tell that we are now removing the entry
+ try
+ {
+ _onRemoved(_strKey, _objItem, enumReason);
+ }
+ catch (System.Exception objException)
+ {
+ System.Diagnostics.Debug.Fail("System.Web.CacheEntry.Close() Exception when calling remove delegate", "Message: " + objException.Message + " Stack: " + objException.StackTrace + " Source:" + objException.Source);
+ }
+ }
+
+ // If we have a dependency, remove the entry
+ if (_objDependency != null)
+ {
+ _objDependency.Changed -= new CacheDependency.CacheDependencyCallback(OnChanged);
+ if (!_objDependency.HasEvents)
+ {
+ _objDependency.Dispose();
+ }
+ }
+ }
+ finally
+ {
+ _lock.ReleaseWriterLock();
+ }
+ }
+
+ /// <summary>
+ /// Tests a specific flag is set or not.
+ /// </summary>
+ /// <param name="oFlag">Flag to test agains</param>
+ /// <returns>Returns true if the flag is set.</returns>
+ public bool TestFlag(Flags oFlag)
+ {
+ _lock.AcquireReaderLock(0);
+ try
+ {
+ if ((_enumFlags & oFlag) != 0)
+ {
+ return true;
+ }
+ }
+ finally
+ {
+ _lock.ReleaseReaderLock();
+ }
+
+ return false;
+ }
+
+ /// <summary>
+ /// Sets a specific flag.
+ /// </summary>
+ /// <param name="oFlag">Flag to set.</param>
+ public void SetFlag(Flags oFlag)
+ {
+ _lock.AcquireWriterLock(0);
+ try
+ {
+ _enumFlags |= oFlag;
+ }
+ finally
+ {
+ _lock.ReleaseWriterLock ();
+ }
+ }
+
+ /// <summary>
+ /// Returns true if the object has minimum hit usage flushing enabled.
+ /// </summary>
+ public bool HasUsage
+ {
+ get {
+ if (_longMinHits == System.Int64.MaxValue)
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ /// <summary>
+ /// Returns true if the entry has absolute expiration.
+ /// </summary>
+ public bool HasAbsoluteExpiration
+ {
+ get
+ {
+ //HACK: [DHC] Use constant defined in Cache.
+ //if (_ticksExpires == System.DateTime.MaxValue.Ticks)
+ if (_ticksExpires == Cache.NoAbsoluteExpiration.Ticks)
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ /// <summary>
+ /// Returns true if the entry has sliding expiration enabled.
+ /// </summary>
+ public bool HasSlidingExpiration
+ {
+ get
+ {
+ //HACK: [DHC] Use constants defined in Cache.
+ //if (_ticksSlidingExpiration == System.TimeSpan.Zero.Ticks)
+ if (_ticksSlidingExpiration == Cache.NoSlidingExpiration.Ticks)
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ /// <summary>
+ /// Gets and sets the current expires bucket the entry is active in.
+ /// </summary>
+ public byte ExpiresBucket
+ {
+ get
+ {
+ _lock.AcquireReaderLock(0);
+ try
+ {
+ return _byteExpiresBucket;
+ }
+ finally
+ {
+ _lock.ReleaseReaderLock();
+ }
+ }
+ set
+ {
+ _lock.AcquireWriterLock(0);
+ try
+ {
+ _byteExpiresBucket = value;
+ }
+ finally
+ {
+ _lock.ReleaseWriterLock ();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets and sets the current index in the expires bucket of the current cache entry.
+ /// </summary>
+ public int ExpiresIndex
+ {
+ get
+ {
+ _lock.AcquireReaderLock(0);
+ try
+ {
+ return _intExpiresIndex;
+ }
+ finally
+ {
+ _lock.ReleaseReaderLock();
+ }
+ }
+
+ set
+ {
+ _lock.AcquireWriterLock(0);
+ try
+ {
+ _intExpiresIndex = value;
+ }
+ finally
+ {
+ _lock.ReleaseWriterLock();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets and sets the expiration of the cache entry.
+ /// </summary>
+ public long Expires
+ {
+ get
+ {
+ _lock.AcquireReaderLock(0);
+ try
+ {
+ return _ticksExpires;
+ }
+ finally
+ {
+ _lock.ReleaseReaderLock();
+ }
+ }
+ set
+ {
+ _lock.AcquireWriterLock(0);
+ try
+ {
+ _ticksExpires = value;
+ }
+ finally
+ {
+ _lock.ReleaseWriterLock();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the sliding expiration value. The return value is in ticks (since 0/0-01 in 100nanosec)
+ /// </summary>
+ public long SlidingExpiration
+ {
+ get
+ {
+ return _ticksSlidingExpiration;
+ }
+ }
+
+ /// <summary>
+ /// Returns the current cached item.
+ /// </summary>
+ public object Item
+ {
+ get
+ {
+ return _objItem;
+ }
+ }
+
+ /// <summary>
+ /// Returns the current cache identifier.
+ /// </summary>
+ public string Key
+ {
+ get
+ {
+ return _strKey;
+ }
+ }
+
+ /// <summary>
+ /// Gets and sets the current number of hits on the cache entry.
+ /// </summary>
+ public long Hits
+ {
+ // todo: Could be optimized by using interlocked methods..
+ get
+ {
+ _lock.AcquireReaderLock(0);
+ try
+ {
+ return _longHits;
+ }
+ finally
+ {
+ _lock.ReleaseReaderLock();
+ }
+ }
+ set
+ {
+ _lock.AcquireWriterLock(0);
+ try
+ {
+ _longHits = value;
+ }
+ finally
+ {
+ _lock.ReleaseWriterLock();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Returns minimum hits for the usage flushing rutine.
+ /// </summary>
+ public long MinimumHits
+ {
+ get
+ {
+ return _longMinHits;
+ }
+ }
+
+ /// <summary>
+ /// Returns the priority of the cache entry.
+ /// </summary>
+ public CacheItemPriority Priority
+ {
+ get
+ {
+ return _enumPriority;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Caching/CacheExpires.cs b/mcs/class/System.Web/System.Web.Caching/CacheExpires.cs
new file mode 100644
index 00000000000..cad44c36af1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Caching/CacheExpires.cs
@@ -0,0 +1,147 @@
+//
+// System.Web.Caching
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Changes:
+// Daniel Cazzulino [DHC] (dcazzulino@users.sf.net)
+//
+// (C) Copyright Patrik Torstensson, 2001
+//
+namespace System.Web.Caching
+{
+ /// <summary>
+ /// Class responsible for handling time based flushing of entries in the cache. The class creates
+ /// and manages 60 buckets each holding every item that expires that minute. The bucket calculated
+ /// for an entry is one minute more than the timeout just to make sure that the item end up in the
+ /// bucket where it should be flushed.
+ /// </summary>
+ public class CacheExpires : System.IDisposable
+ {
+ static int _intFlush;
+ /// <summary>
+ /// 1 bucket == 1 minute == 10M ticks (1 second) * 60
+ /// </summary>
+ static long _ticksPerBucket = 600000000;
+ /// <summary>
+ /// 1 cycle == 1 hour
+ /// </summary>
+ static long _ticksPerCycle = _ticksPerBucket * 60;
+
+ private ExpiresBucket[] _arrBuckets;
+ private System.Threading.Timer _objTimer;
+ private Cache _objManager;
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="objManager">The cache manager, used when flushing items in a bucket.</param>
+ public CacheExpires(Cache objManager)
+ {
+ _objManager = objManager;
+ Initialize();
+ }
+
+ /// <summary>
+ /// Initializes the class.
+ /// </summary>
+ private void Initialize()
+ {
+ // Create one bucket per minute
+ _arrBuckets = new ExpiresBucket[60];
+
+ byte bytePos = 0;
+ do
+ {
+ _arrBuckets[bytePos] = new ExpiresBucket(bytePos, _objManager);
+ bytePos++;
+ } while (bytePos < 60);
+
+ // GC Bucket controller
+ _intFlush = System.DateTime.Now.Minute - 1;
+ _objTimer = new System.Threading.Timer(new System.Threading.TimerCallback(GarbageCleanup), null, 10000, 60000);
+ }
+
+ /// <summary>
+ /// Adds a Cache entry to the correct flush bucket.
+ /// </summary>
+ /// <param name="objEntry">Cache entry to add.</param>
+ public void Add(CacheEntry objEntry)
+ {
+ lock(this)
+ {
+ // If the entry doesn't have a expires time we assume that the entry is due to expire now.
+ if (objEntry.Expires == 0)
+ {
+ objEntry.Expires = System.DateTime.Now.Ticks;
+ }
+
+ _arrBuckets[GetHashBucket(objEntry.Expires)].Add(objEntry);
+ }
+ }
+
+ public void Remove(CacheEntry objEntry)
+ {
+ lock(this)
+ {
+ // If the entry doesn't have a expires time we assume that the entry is due to expire now.
+ if (objEntry.Expires == 0)
+ {
+ objEntry.Expires = System.DateTime.Now.Ticks;
+ }
+
+ _arrBuckets[GetHashBucket(objEntry.Expires)].Remove(objEntry);
+ }
+ }
+
+ public void Update(CacheEntry objEntry, long ticksExpires)
+ {
+ lock(this)
+ {
+ // If the entry doesn't have a expires time we assume that the entry is due to expire now.
+ if (objEntry.Expires == 0)
+ {
+ objEntry.Expires = System.DateTime.Now.Ticks;
+ }
+
+ _arrBuckets[GetHashBucket(objEntry.Expires)].Update(objEntry, ticksExpires);
+ }
+ }
+
+ public void GarbageCleanup(object State)
+ {
+ ExpiresBucket objBucket;
+
+ lock(this)
+ {
+ // Do cleanup of the bucket
+ objBucket = _arrBuckets[(++_intFlush) % 60];
+ }
+
+ // Flush expired items in the current bucket (defined by _intFlush)
+ objBucket.FlushExpiredItems();
+ }
+
+ private int GetHashBucket(long ticks)
+ {
+ // Get bucket to add expire item into, add one minute to the bucket just to make sure that we get it in the bucket gc
+ return (int) (((((ticks + 60000) % _ticksPerCycle) / _ticksPerBucket) + 1) % 60);
+ }
+
+ /// <summary>
+ /// Called by the cache for cleanup.
+ /// </summary>
+ public void Dispose()
+ {
+ lock(this)
+ {
+ // Cleanup the internal timer
+ if (_objTimer != null)
+ {
+ _objTimer.Dispose();
+ _objTimer = null;
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Caching/ChangeLog b/mcs/class/System.Web/System.Web.Caching/ChangeLog
new file mode 100644
index 00000000000..6e5b8f166e1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Caching/ChangeLog
@@ -0,0 +1,45 @@
+2002-12-27 Daniel Cazzulino <dcazzulino@users.sf.net>
+
+ * CacheEntry.cs: several changes. New constants, use of constants
+ defined in Cache.cs, modified locks to optimize perf. Fixed property
+ sets which weren't using the keyword value to set the new values
+ (don't know how this worked before!).
+
+ * Cache.cs: changed singleton implementation to only create the object
+ when actually used. Changed Insert overloads to use constants
+ defined instead of hard values.
+
+ * ExpiresBuchets: major changes. All locking now uses ReaderWriterLock
+ class. Bucket now efectively reuses free indexes from removed items
+ to avoid unnecessary expansions. Expansion now uses Array.CopyTo to
+ add elements to the new list. Added private Int32Collection to
+ handle int indexes efficiently (thanks Shawn Van Ness). See comments
+ there.
+
+2002-10-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Cache.cs: little fixes.
+
+2002-07-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * CacheDefinitions.cs: fixed a couple of enums.
+
+ * CacheDependency.cs: the class is sealed.
+
+2002-06-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * CacheDependency.cs: fixed a couple of typos and don't throw
+ NotImplementedException in constructors.
+
+2001-12-21 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * CacheDependency.cs: Some unimplemented methods to make build
+
+2001-07-20 Patrik Torstensson (Patrik.Torstensson@labs2.com)
+
+ * Cache.cs: Implemented. (90% ready)
+ * CacheDefinitions.cs: Implemented.
+ * CacheDependency.cs: Added. (20% ready)
+ * CacheExpires: Implemented.
+ * CacheEntry.cs: Implemented. (95% ready, going to be changed due to CacheDependecy support)
+ * ExpiresBuckets.cs: Implemented.
diff --git a/mcs/class/System.Web/System.Web.Caching/ExpiresBuckets.cs b/mcs/class/System.Web/System.Web.Caching/ExpiresBuckets.cs
new file mode 100644
index 00000000000..12d06ae8894
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Caching/ExpiresBuckets.cs
@@ -0,0 +1,787 @@
+//
+// System.Web.Caching
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Changes:
+// Daniel Cazzulino [DHC] (dcazzulino@users.sf.net)
+//
+// (C) Copyright Patrik Torstensson, 2001
+//
+namespace System.Web.Caching
+{
+ /// <summary>
+ /// Responsible for holding a cache entry in the linked list bucket.
+ /// </summary>
+ public struct ExpiresEntry
+ {
+ public CacheEntry _objEntry;
+ public long _ticksExpires;
+ public int _intNext;
+ }
+
+ /// <summary>
+ /// Holds cache entries that has a expiration in a bucket list.
+ /// </summary>
+ public class ExpiresBucket
+ {
+ private static int MIN_ENTRIES = 16;
+
+ private byte _byteID;
+ private int _intSize;
+ private int _intCount;
+ private int _intNext;
+
+ private Cache _objManager;
+
+ private ExpiresEntry [] _arrEntries;
+
+ /// <summary>
+ /// A lock to use for syncronized operations. [DHC]
+ /// </summary>
+ private System.Threading.ReaderWriterLock _lock = new System.Threading.ReaderWriterLock();
+
+ /// <summary>
+ /// Keeps a list of indexes in the list which are available to place new items. [DHC]
+ /// </summary>
+ Int32Collection _freeidx = new Int32Collection();
+
+ /// <summary>
+ /// Constructs a new bucket.
+ /// </summary>
+ /// <param name="bucket">Current bucket ID.</param>
+ /// <param name="objManager">Cache manager reponsible for the item(s) in the expires bucket.</param>
+ public ExpiresBucket(byte bucket, Cache objManager)
+ {
+ _objManager = objManager;
+ Initialize(bucket);
+ }
+
+ /// <summary>
+ /// Initializes the expires bucket, creates a linked list of MIN_ENTRIES.
+ /// </summary>
+ /// <param name="bucket">Bucket ID.</param>
+ private void Initialize(byte bucket)
+ {
+ _byteID = bucket;
+ _intNext = 0;
+ _intCount = 0;
+
+ _arrEntries = new ExpiresEntry[MIN_ENTRIES];
+ _intSize = MIN_ENTRIES;
+
+ int intPos = 0;
+ do
+ {
+ _arrEntries[intPos]._intNext = intPos + 1;
+ //HACK: [DHC] Use constant defined in Cache.
+ //_arrEntries[intPos]._ticksExpires = System.DateTime.MaxValue.Ticks;
+ _arrEntries[intPos]._ticksExpires = Cache.NoAbsoluteExpiration.Ticks;
+
+ intPos++;
+ } while (intPos < _intSize);
+
+ _arrEntries[_intSize - 1]._intNext = -1;
+ }
+
+ /// <summary>
+ /// Expands the bucket linked array list.
+ /// </summary>
+ private void Expand()
+ {
+ //HACK: [DHC] MAJOR performance improvement by using Array.CopyTo method. Better locking added.
+ _lock.AcquireReaderLock(0);
+ try
+ {
+ int oldsize = _intSize;
+ _intSize *= 2;
+
+ // Copy items to the new list.
+ ExpiresEntry[] newlist = new ExpiresEntry[_intSize];
+ _arrEntries.CopyTo(newlist, 0);
+
+ // Set last element to point to the next new empty element
+ newlist[oldsize - 1]._intNext = oldsize;
+
+ // Initialize positions for the rest of new elements.
+ for (int i = oldsize; i < _intSize; i++)
+ {
+ newlist[i]._intNext = i + 1;
+ newlist[i]._ticksExpires = Cache.NoAbsoluteExpiration.Ticks;
+ }
+
+ // Last item signals the expansion of the list.
+ newlist[_intSize - 1]._intNext = -1;
+
+ // Replace the existing list.
+ _lock.UpgradeToWriterLock(0);
+ _arrEntries = newlist;
+ }
+ finally
+ {
+ //Releases both reader & writer locks.
+ _lock.ReleaseReaderLock();
+ }
+
+ /* ORIGINAL CODE *
+ ExpiresEntry [] arrData;
+ int intPos = 0;
+ int intOldSize;
+
+ lock(this)
+ {
+ intOldSize = _intSize;
+ _intSize *= 2;
+
+ // Create a new array and copy the old data into the new array
+ arrData = new ExpiresEntry[_intSize];
+
+ do
+ {
+ arrData[intPos] = _arrEntries[intPos];
+ intPos++;
+ } while (intPos < intOldSize);
+
+ _intNext = intPos;
+
+ // Initialize the "new" positions.
+ do
+ {
+ arrData[intPos]._intNext = intPos + 1;
+ intPos++;
+ } while (intPos < _intSize);
+
+ arrData[_intSize - 1]._intNext = -1;
+
+ _arrEntries = arrData;
+ }
+ */
+ }
+
+ /// <summary>
+ /// Adds a cache entry into the expires bucket.
+ /// </summary>
+ /// <param name="objEntry">Cache Entry object to be added.</param>
+ public void Add(CacheEntry objEntry)
+ {
+ bool dogrow = false;
+
+ // Check the need for expansion or reuse free index.
+ if (_intNext == -1)
+ {
+ if (_freeidx.Count == 0)
+ {
+ dogrow = true;
+ }
+ else
+ {
+ _lock.AcquireReaderLock(0);
+ try
+ {
+ // Elements may have been removed before the lock statement.
+ if (_freeidx.Count == 0)
+ {
+ dogrow = true;
+ }
+ else
+ {
+ _intNext = _freeidx[0];
+ _freeidx.Remove(_intNext);
+ }
+ }
+ finally
+ {
+ _lock.ReleaseReaderLock();
+ }
+ }
+ }
+
+ if (dogrow) Expand();
+
+ _lock.AcquireWriterLock(0);
+ try
+ {
+ _arrEntries[_intNext]._ticksExpires = objEntry.Expires;
+ _arrEntries[_intNext]._objEntry = objEntry;
+ // If there are free indexes in the list, reuse them for the _next value.
+ if (_freeidx.Count != 0)
+ {
+ _intNext = _freeidx[0];
+ _freeidx.Remove(_intNext);
+ }
+ else
+ {
+ _intNext = _arrEntries[_intNext]._intNext;
+ }
+
+ _intCount++;
+ }
+ finally
+ {
+ _lock.ReleaseWriterLock();
+ }
+
+ /* ORIGINAL CODE *
+ if (_intNext == -1)
+ {
+ Expand();
+ }
+
+ lock(this)
+ {
+ _arrEntries[_intNext]._ticksExpires = objEntry.Expires;
+ _arrEntries[_intNext]._objEntry = objEntry;
+
+ _intNext = _arrEntries[_intNext]._intNext;
+
+ _intCount++;
+ }
+ */
+ }
+
+ /// <summary>
+ /// Removes a cache entry from the expires bucket.
+ /// </summary>
+ /// <param name="objEntry">Cache entry to be removed.</param>
+ public void Remove(CacheEntry objEntry)
+ {
+ //HACK: optimized locks. [DHC]
+ _lock.AcquireReaderLock(0);
+ try
+ {
+ // Check if this is our bucket
+ if (objEntry.ExpiresIndex != _byteID) return;
+ if (objEntry.ExpiresIndex == CacheEntry.NoIndexInBucket) return;
+ if (_arrEntries.Length < objEntry.ExpiresIndex) return;
+
+ // Proceed to removal.
+ _lock.UpgradeToWriterLock(0);
+ _intCount--;
+
+ // Push the index as a free one.
+ _freeidx.Add(objEntry.ExpiresIndex);
+
+ _arrEntries[objEntry.ExpiresIndex]._objEntry = null;
+ // Clear bucket-related values from the item.
+ objEntry.ExpiresBucket = CacheEntry.NoBucketHash;
+ objEntry.ExpiresIndex = CacheEntry.NoIndexInBucket;
+ }
+ finally
+ {
+ //Releases both reader & writer locks
+ _lock.ReleaseReaderLock();
+ }
+ }
+
+ /// <summary>
+ /// Updates a cache entry in the expires bucket, this is called during a hit of an item if the
+ /// cache item has a sliding expiration. The function is responsible for updating the cache
+ /// entry.
+ /// </summary>
+ /// <param name="objEntry">Cache entry to update.</param>
+ /// <param name="ticksExpires">New expiration value for the cache entry.</param>
+ public void Update(CacheEntry objEntry, long ticksExpires)
+ {
+ //HACK: optimized locks. [DHC]
+ _lock.AcquireReaderLock(0);
+ try
+ {
+ // Check if this is our bucket
+ if (objEntry.ExpiresIndex != _byteID) return;
+ if (objEntry.ExpiresIndex == CacheEntry.NoIndexInBucket) return;
+ if (_arrEntries.Length < objEntry.ExpiresIndex) return;
+
+ _arrEntries[objEntry.ExpiresIndex]._ticksExpires = ticksExpires;
+ _arrEntries[objEntry.ExpiresIndex]._objEntry.Expires = ticksExpires;
+
+ // Proceed to update.
+ _lock.UpgradeToWriterLock(0);
+ _arrEntries[objEntry.ExpiresIndex]._ticksExpires = ticksExpires;
+ _arrEntries[objEntry.ExpiresIndex]._objEntry.Expires = ticksExpires;
+ }
+ finally
+ {
+ //Releases both read & write locks
+ _lock.ReleaseReaderLock();
+ }
+ }
+
+ /// <summary>
+ /// Flushes all cache entries that has expired and removes them from the cache manager.
+ /// </summary>
+ public void FlushExpiredItems()
+ {
+ ExpiresEntry objEntry;
+ CacheEntry [] arrCacheEntries;
+
+ int intCachePos;
+ int intPos;
+ long ticksNow;
+
+ ticksNow = System.DateTime.Now.Ticks;
+
+ intCachePos = 0;
+
+ // Lookup all items that needs to be removed, this is done in a two part
+ // operation to minimize the locking time.
+ _lock.AcquireReaderLock(0);
+ try
+ {
+ arrCacheEntries = new CacheEntry[_intSize];
+
+ intPos = 0;
+ do
+ {
+ objEntry = _arrEntries[intPos];
+ if (objEntry._objEntry != null)
+ {
+ if (objEntry._ticksExpires < ticksNow)
+ {
+ System.Threading.LockCookie ck = _lock.UpgradeToWriterLock(0);
+ try
+ {
+ //push the index for reuse
+ _freeidx.Add(intPos);
+ arrCacheEntries[intCachePos++] = objEntry._objEntry;
+
+ objEntry._objEntry.ExpiresBucket = CacheEntry.NoBucketHash;
+ objEntry._objEntry.ExpiresIndex = CacheEntry.NoIndexInBucket;
+ objEntry._objEntry = null;
+ }
+ finally
+ {
+ _lock.DowngradeFromWriterLock(ref ck);
+ }
+ }
+ }
+
+ intPos++;
+ } while (intPos < _intSize);
+ }
+ finally
+ {
+ _lock.ReleaseReaderLock();
+ }
+
+ // If we have any entries to remove, go ahead and call the cache manager remove.
+ if (intCachePos > 0)
+ {
+ intPos = 0;
+ do
+ {
+ _objManager.Remove(arrCacheEntries[intPos].Key, CacheItemRemovedReason.Expired);
+
+ intPos++;
+ } while (intPos < intCachePos);
+ }
+ }
+
+ /// <summary>
+ /// Returns the current size of the expires bucket.
+ /// </summary>
+ public int Size
+ {
+ get
+ {
+ //HACK: reuse the _intSize field!!! [DHC]
+ return _intSize;
+ }
+ }
+
+ /// <summary>
+ /// Returns number of items in the bucket.
+ /// </summary>
+ public int Count
+ {
+ get
+ {
+ return _intCount;
+ }
+ }
+
+ #region Private Int32Collection
+ /* This file has been automatically generated by TextBox -- DO NOT EDIT! */
+ /*
+ Int32Collection
+ Int32Collection.Enumerator
+
+ These C# classes implement a strongly-typed collection of
+ Int32 objects.
+
+ The internal representation is an array of Int32, so the performance
+ characteristics will be more like a vector than a list, to use STL terminology.
+
+ The implementation is optimized for value-types, as it goes to great length to
+ avoid the overhead of boxing and unboxing. But it should also work well for
+ reference types.
+
+ Mad props to Nick Wienholt <sheyenne@bigpond.com> for assisting me in
+ this research, and the testing, the benchmarking, and of course, the
+ implementation!
+
+ Last but not least, a quick shout out to Kit George, for his generous
+ contribution to the dotnet mailing list -- a code-generator for
+ CollectionBase-derived classes:
+ http://discuss.develop.com/archives/wa.exe?A2=ind0107C&L=DOTNET&P=R35911
+ This was the original inspiration for the fine code you are now enjoying.
+
+ - Shawn Van Ness
+
+ Other folks who've contributed:
+ Ethan Smith <ethan.smith@pobox.com> (minor perf. improvements)
+ Joel Mueller <jmueller@swiftk.com> (major perf. improvements)
+ Chris Sells <csells@sellsbrothers.com> (generative programming guru)
+ Patrice Lafond <plafond@hemisphere.bm> (a bug fix -- yikes!)
+ */
+
+ /// <summary>
+ /// An optimized collection for holding <see cref="Int32"/> values.
+ /// </summary>
+ [System.Serializable]
+ private class Int32Collection : System.Collections.ICollection, System.Collections.IList, System.Collections.IEnumerable
+ {
+ #region Private vars & ctors
+ private const int DefaultMinimumCapacity = 16;
+
+ private System.Int32[] m_array = new System.Int32[DefaultMinimumCapacity];
+ private int m_count = 0;
+ private int m_version = 0;
+
+ /// <summary />
+ public Int32Collection()
+ { }
+
+ /// <summary />
+ public Int32Collection(Int32Collection collection)
+ { AddRange(collection); }
+
+ /// <summary />
+ public Int32Collection(System.Int32[] array)
+ { AddRange(array); }
+ #endregion
+
+ #region Public members
+
+ /// <summary />
+ public int Count
+ {
+ get
+ { return m_count; }
+ }
+
+ /// <summary />
+ public void CopyTo(System.Int32[] array)
+ {
+ this.CopyTo(array, 0);
+ }
+
+ /// <summary />
+ public void CopyTo(System.Int32[] array, int start)
+ {
+ if (m_count > array.GetUpperBound(0)+1-start)
+ throw new System.ArgumentException("Destination array was not long enough.");
+
+ // for (int i=0; i < m_count; ++i) array[start+i] = m_array[i];
+ System.Array.Copy(m_array, 0, array, start, m_count);
+ }
+
+ /// <summary />
+ public System.Int32 this[int index]
+ {
+ get
+ {
+ ValidateIndex(index); // throws
+ return m_array[index];
+ }
+ set
+ {
+ ValidateIndex(index); // throws
+
+ ++m_version;
+ m_array[index] = value;
+ }
+ }
+
+ /// <summary />
+ public int Add(System.Int32 item)
+ {
+ if (NeedsGrowth())
+ Grow();
+
+ ++m_version;
+ m_array[m_count] = item;
+
+ return m_count++;
+ }
+
+ /// <summary />
+ public void Clear()
+ {
+ ++m_version;
+ m_array = new System.Int32[DefaultMinimumCapacity];
+ m_count = 0;
+ }
+
+ /// <summary />
+ public bool Contains(System.Int32 item)
+ {
+ return ((IndexOf(item) == -1)?false:true);
+ }
+
+ /// <summary />
+ public int IndexOf(System.Int32 item)
+ {
+ for (int i=0; i < m_count; ++i)
+ if (m_array[i].Equals(item))
+ return i;
+ return -1;
+ }
+
+ /// <summary />
+ public void Insert(int position, System.Int32 item)
+ {
+ ValidateIndex(position,true); // throws
+
+ if (NeedsGrowth())
+ Grow();
+
+ ++m_version;
+ System.Array.Copy(m_array, position, m_array, position+1, m_count-position);
+
+ m_array[position] = item;
+ m_count++;
+ }
+
+ /// <summary />
+ public void Remove(System.Int32 item)
+ {
+ int index = IndexOf(item);
+ if (index < 0)
+ throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
+
+ RemoveAt(index);
+ }
+
+ /// <summary />
+ public void RemoveAt(int index)
+ {
+ ValidateIndex(index); // throws
+
+ ++m_version;
+ m_count--;
+ System.Array.Copy(m_array, index+1, m_array, index, m_count-index);
+
+ if (NeedsTrimming())
+ Trim();
+ }
+
+ // Public helpers (just to mimic some nice features of ArrayList)
+
+ /// <summary />
+ public int Capacity
+ {
+ get
+ { return m_array.Length; }
+ set
+ {
+ if (value < m_count) value = m_count;
+ if (value < DefaultMinimumCapacity) value = DefaultMinimumCapacity;
+
+ if (m_array.Length == value) return;
+
+ ++m_version;
+
+ System.Int32[] temp = new System.Int32[value];
+ System.Array.Copy(m_array, 0, temp, 0, m_count);
+ m_array = temp;
+ }
+ }
+
+ /// <summary />
+ public void AddRange(Int32Collection collection)
+ {
+ ++m_version;
+
+ Capacity += collection.Count;
+ System.Array.Copy(collection.m_array, 0, this.m_array, m_count, collection.m_count);
+ m_count += collection.Count;
+ }
+
+ /// <summary />
+ public void AddRange(System.Int32[] array)
+ {
+ ++m_version;
+
+ Capacity += array.Length;
+ System.Array.Copy(array, 0, this.m_array, m_count, array.Length);
+ m_count += array.Length;
+ }
+ #endregion
+
+ #region Private helper methods
+ private void ValidateIndex(int index)
+ {
+ ValidateIndex(index,false);
+ }
+
+ private void ValidateIndex(int index, bool allowEqualEnd)
+ {
+ int max = (allowEqualEnd)?(m_count):(m_count-1);
+ if (index < 0 || index > max)
+ throw new System.ArgumentOutOfRangeException("Index was out of range. Must be non-negative and less than the size of the collection.", (object)index, "Specified argument was out of the range of valid values.");
+ }
+
+ private bool NeedsGrowth()
+ {
+ return (m_count >= Capacity);
+ }
+
+ private void Grow()
+ {
+ if (NeedsGrowth())
+ Capacity = m_count*2;
+ }
+
+ private bool NeedsTrimming()
+ {
+ return (m_count <= Capacity/2);
+ }
+
+ private void Trim()
+ {
+ if (NeedsTrimming())
+ Capacity = m_count;
+ }
+ #endregion
+
+ #region System.Collections.ICollection implementation
+ bool System.Collections.ICollection.IsSynchronized
+ {
+ get
+ { return m_array.IsSynchronized; }
+ }
+
+ object System.Collections.ICollection.SyncRoot
+ {
+ get
+ { return m_array.SyncRoot; }
+ }
+
+ void System.Collections.ICollection.CopyTo(System.Array array, int start)
+ {
+ this.CopyTo((System.Int32[])array, start);
+ }
+ #endregion
+
+ #region System.Collections.IList implementation
+ bool System.Collections.IList.IsFixedSize
+ {
+ get
+ { return false; }
+ }
+
+ bool System.Collections.IList.IsReadOnly
+ {
+ get
+ { return false; }
+ }
+
+ object System.Collections.IList.this[int index]
+ {
+ get { return (object)this[index]; }
+ set { this[index] = (System.Int32)value; }
+ }
+
+ int System.Collections.IList.Add(object item)
+ {
+ return this.Add((System.Int32)item);
+ }
+
+ bool System.Collections.IList.Contains(object item)
+ {
+ return this.Contains((System.Int32)item);
+ }
+
+ int System.Collections.IList.IndexOf(object item)
+ {
+ return this.IndexOf((System.Int32)item);
+ }
+
+ void System.Collections.IList.Insert(int position, object item)
+ {
+ this.Insert(position, (System.Int32)item);
+ }
+
+ void System.Collections.IList.Remove(object item)
+ {
+ this.Remove((System.Int32)item);
+ }
+ #endregion
+
+ #region System.Collections.IEnumerable and enumerator implementation
+ /// <summary />
+ public Enumerator GetEnumerator()
+ {
+ return new Enumerator(this);
+ }
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ // Nested enumerator class
+ /// <summary />
+ public class Enumerator : System.Collections.IEnumerator
+ {
+ private Int32Collection m_collection;
+ private int m_index;
+ private int m_version;
+
+ // Construction
+
+ /// <summary />
+ public Enumerator(Int32Collection tc)
+ {
+ m_collection = tc;
+ m_index = -1;
+ m_version = tc.m_version;
+ }
+
+ /// <summary />
+ public System.Int32 Current
+ {
+ get
+ { return m_collection[m_index]; }
+ }
+
+ /// <summary />
+ public bool MoveNext()
+ {
+ if (m_version != m_collection.m_version)
+ throw new System.InvalidOperationException("Collection was modified; enumeration operation may not execute.");
+
+ ++m_index;
+ return (m_index < m_collection.Count)?true:false;
+ }
+
+ /// <summary />
+ public void Reset()
+ {
+ if (m_version != m_collection.m_version)
+ throw new System.InvalidOperationException("Collection was modified; enumeration operation may not execute.");
+
+ m_index = -1;
+ }
+
+ object System.Collections.IEnumerator.Current
+ {
+ get
+ { return (object)(this.Current); }
+ }
+ }
+ #endregion
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Compilation/AspComponentFoundry.cs b/mcs/class/System.Web/System.Web.Compilation/AspComponentFoundry.cs
new file mode 100644
index 00000000000..e8e394074b7
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/AspComponentFoundry.cs
@@ -0,0 +1,216 @@
+//
+// System.Web.Compilation.AspComponentFoundry
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+
+namespace System.Web.Compilation
+{
+ internal class AspComponentFoundry
+ {
+ private Hashtable foundries;
+
+ public AspComponentFoundry ()
+ {
+ foundries = new Hashtable (CaseInsensitiveHashCodeProvider.Default,
+ CaseInsensitiveComparer.Default);
+
+ RegisterFoundry ("asp", "System.Web", "System.Web.UI.WebControls");
+ }
+
+ public AspComponent MakeAspComponent (string foundryName, string componentName, Tag tag)
+ {
+ Foundry foundry = foundries [foundryName] as Foundry;
+ if (foundry == null)
+ throw new ApplicationException ("Foundry not found: " + foundryName);
+
+ return new AspComponent (tag, foundry.GetType (componentName));
+ }
+
+ public void RegisterFoundry (string foundryName,
+ string assemblyName,
+ string nameSpace)
+ {
+ AssemblyFoundry foundry = new AssemblyFoundry (assemblyName, nameSpace);
+ InternalRegister (foundryName, foundry);
+ }
+
+ public void RegisterFoundry (string foundryName,
+ string tagName,
+ string assemblyName,
+ string nameSpace,
+ string typeName)
+ {
+ TagNameFoundry foundry = new TagNameFoundry (assemblyName, tagName, nameSpace, typeName);
+ InternalRegister (foundryName, foundry);
+ }
+
+ void InternalRegister (string foundryName, Foundry foundry)
+ {
+ object f = foundries [foundryName];
+ if (f is CompoundFoundry) {
+ ((CompoundFoundry) f).Add (foundry);
+ } else if (f == null || (f is AssemblyFoundry && foundry is AssemblyFoundry)) {
+ // If more than 1 namespace/assembly specified, the last one is used.
+ foundries [foundryName] = foundry;
+ } else if (f != null) {
+ CompoundFoundry compound = new CompoundFoundry (foundryName);
+ compound.Add ((Foundry) f);
+ compound.Add (foundry);
+ foundries [foundryName] = compound;
+ }
+ }
+
+ public bool LookupFoundry (string foundryName)
+ {
+ return foundries.Contains (foundryName);
+ }
+
+ abstract class Foundry
+ {
+ public abstract Type GetType (string componentName);
+
+ public Assembly LoadAssembly (string assemblyName)
+ {
+ Assembly assembly = null;
+ try {
+ assembly = Assembly.LoadFrom (Path.GetFullPath (assemblyName));
+ } catch {
+ string partialName = assemblyName;
+ if (String.Compare (Path.GetExtension (partialName), ".dll", true) == 0)
+ partialName = Path.GetFileNameWithoutExtension (assemblyName);
+
+ assembly = Assembly.LoadWithPartialName (partialName);
+ }
+
+ if (assembly == null)
+ throw new ApplicationException ("Assembly not found:" + assemblyName);
+
+ return assembly;
+ }
+ }
+
+
+ class TagNameFoundry : Foundry
+ {
+ string assemblyName;
+ string tagName;
+ string nameSpace;
+ string typeName;
+ Type type;
+
+ public TagNameFoundry (string assemblyName, string tagName, string nameSpace, string typeName)
+ {
+ this.assemblyName = assemblyName;
+ this.tagName = tagName;
+ this.nameSpace = nameSpace;
+ this.typeName = typeName;
+ }
+
+ public override Type GetType (string componentName)
+ {
+ if (0 != String.Compare (componentName, tagName, true))
+ throw new ArgumentException (componentName + " != " + tagName);
+
+ if (type != null)
+ return type;
+
+ Assembly assembly = LoadAssembly (assemblyName);
+ type = assembly.GetType (nameSpace + "." + typeName, true, true);
+ return type;
+ }
+
+ public string TagName {
+ get { return tagName; }
+ }
+ }
+
+ class AssemblyFoundry : Foundry
+ {
+ string nameSpace;
+ string assemblyName;
+ Assembly assembly;
+
+ public AssemblyFoundry (string assemblyName, string nameSpace)
+ {
+ this.assemblyName = assemblyName;
+ this.nameSpace = nameSpace;
+ assembly = null;
+ }
+
+ public override Type GetType (string componentName)
+ {
+ Assembly ass = EnsureAssembly (componentName);
+
+ return ass.GetType (nameSpace + "." + componentName, true, true);
+ }
+
+ Assembly EnsureAssembly (string componentName)
+ {
+ if (assembly != null)
+ return assembly;
+
+ assembly = LoadAssembly (assemblyName);
+ return assembly;
+ }
+ }
+
+ class CompoundFoundry : Foundry
+ {
+ AssemblyFoundry assemblyFoundry;
+ Hashtable tagnames;
+ string tagPrefix;
+
+ public CompoundFoundry (string tagPrefix)
+ {
+ this.tagPrefix = tagPrefix;
+ tagnames = new Hashtable (CaseInsensitiveHashCodeProvider.Default,
+ CaseInsensitiveComparer.Default);
+ }
+
+ public void Add (Foundry foundry)
+ {
+ if (foundry is AssemblyFoundry) {
+ assemblyFoundry = (AssemblyFoundry) foundry;
+ return;
+ }
+
+ TagNameFoundry tn = (TagNameFoundry) foundry;
+ string tagName = tn.TagName;
+ if (tagnames.Contains (tagName)) {
+ string msg = String.Format ("{0}:{1} already registered.", tagPrefix, tagName);
+ throw new ApplicationException (msg);
+ }
+ tagnames.Add (tagName, foundry);
+ }
+
+ public override Type GetType (string componentName)
+ {
+ Type type = null;
+ if (assemblyFoundry != null) {
+ try {
+ type = assemblyFoundry.GetType (componentName);
+ return type;
+ } catch { }
+ }
+
+ Foundry foundry = tagnames [componentName] as Foundry;
+ if (foundry == null) {
+ string msg = String.Format ("Type {0} not registered for prefix {1}",
+ componentName, tagPrefix);
+ throw new ApplicationException (msg);
+ }
+
+ return foundry.GetType (componentName);
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/AspElements.cs b/mcs/class/System.Web/System.Web.Compilation/AspElements.cs
new file mode 100644
index 00000000000..0655c232959
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/AspElements.cs
@@ -0,0 +1,863 @@
+//
+// System.Web.Compilation.AspElements
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (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 (new CaseInsensitiveHashCodeProvider (),
+ new CaseInsensitiveComparer ());
+ 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;
+
+ 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;
+ }
+
+ 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);
+ parser.Parse ();
+ ArrayList elements = parser.Elements;
+ 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 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 ChildrenKind.LISTITEM;
+ }
+ }
+
+ 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 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 ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs b/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
new file mode 100644
index 00000000000..d094459b001
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
@@ -0,0 +1,2021 @@
+//
+// System.Web.Compilation.AspGenerator
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Web.UI;
+using System.Web.UI.HtmlControls;
+using System.Web.UI.WebControls;
+using System.Web.Util;
+
+namespace System.Web.Compilation
+{
+
+class ControlStack
+{
+ private Stack controls;
+ private ControlStackData top;
+ private bool space_between_tags;
+ private bool sbt_valid;
+
+ class ControlStackData
+ {
+ public Type controlType;
+ public string controlID;
+ public string tagID;
+ public ChildrenKind childKind;
+ public string defaultPropertyName;
+ public int childrenNumber;
+ public Type container;
+ public StringBuilder dataBindFunction;
+ public StringBuilder codeRenderFunction;
+ public bool useCodeRender;
+ public int codeRenderIndex;
+
+ public ControlStackData (Type controlType,
+ string controlID,
+ string tagID,
+ ChildrenKind childKind,
+ string defaultPropertyName,
+ Type container)
+ {
+ this.controlType = controlType;
+ this.controlID = controlID;
+ this.tagID = tagID;
+ this.childKind = childKind;
+ this.defaultPropertyName = defaultPropertyName;
+ this.container = container;
+ childrenNumber = 0;
+ }
+
+ public override string ToString ()
+ {
+ return controlType + " " + controlID + " " + tagID + " " + childKind + " " + childrenNumber;
+ }
+ }
+
+ public ControlStack ()
+ {
+ controls = new Stack ();
+ }
+
+ private Type GetContainerType (Type type)
+ {
+ if (type != typeof (System.Web.UI.Control) &&
+ !type.IsSubclassOf (typeof (System.Web.UI.Control)))
+ return null;
+
+ Type container_type;
+ if (type == typeof (System.Web.UI.WebControls.DataList))
+ container_type = typeof (System.Web.UI.WebControls.DataListItem);
+ else if (type == typeof (System.Web.UI.WebControls.DataGrid))
+ container_type = typeof (System.Web.UI.WebControls.DataGridItem);
+ else if (type == typeof (System.Web.UI.WebControls.Repeater))
+ container_type = typeof (System.Web.UI.WebControls.RepeaterItem);
+ else if (type == typeof (ListControl) || type.IsSubclassOf (typeof (ListControl)))
+ container_type = type;
+ else
+ container_type = Container;
+
+ return container_type;
+ }
+
+ public void Push (object o)
+ {
+ if (!(o is ControlStackData))
+ return;
+
+ controls.Push (o);
+ top = (ControlStackData) o;
+ sbt_valid = false;
+ }
+
+ public void Push (Type controlType,
+ string controlID,
+ string tagID,
+ ChildrenKind childKind,
+ string defaultPropertyName)
+ {
+ Type container_type = null;
+ if (controlType != null){
+ AddChild ();
+ container_type = GetContainerType (controlType);
+ if (container_type == null)
+ container_type = this.Container;
+ }
+
+ top = new ControlStackData (controlType,
+ controlID,
+ tagID,
+ childKind,
+ defaultPropertyName,
+ container_type);
+ sbt_valid = false;
+ controls.Push (top);
+ }
+
+ public object Pop ()
+ {
+ object item = controls.Pop ();
+ if (controls.Count != 0)
+ top = (ControlStackData) controls.Peek ();
+ sbt_valid = false;
+ return item;
+ }
+
+ public Type PeekType ()
+ {
+ return top.controlType;
+ }
+
+ public string PeekControlID ()
+ {
+ return top.controlID;
+ }
+
+ public string PeekTagID ()
+ {
+ return top.tagID;
+ }
+
+ public ChildrenKind PeekChildKind ()
+ {
+ return top.childKind;
+ }
+
+ public string PeekDefaultPropertyName ()
+ {
+ return top.defaultPropertyName;
+ }
+
+ public void AddChild ()
+ {
+ if (top != null)
+ top.childrenNumber++;
+ }
+
+ public bool HasDataBindFunction ()
+ {
+ if (top.dataBindFunction == null || top.dataBindFunction.Length == 0)
+ return false;
+ return true;
+ }
+
+ public bool UseCodeRender
+ {
+ get {
+ if (top.codeRenderFunction == null || top.codeRenderFunction.Length == 0)
+ return false;
+ return top.useCodeRender;
+ }
+
+ set { top.useCodeRender= value; }
+ }
+
+ public bool SpaceBetweenTags
+ {
+ get {
+ if (!sbt_valid){
+ sbt_valid = true;
+ Type type = top.controlType;
+ if (type.Namespace == "System.Web.UI.WebControls")
+ space_between_tags = true;
+ else if (type.IsSubclassOf (typeof (System.Web.UI.WebControls.WebControl)))
+ space_between_tags = true;
+ else if (type == typeof (System.Web.UI.HtmlControls.HtmlSelect))
+ space_between_tags = true;
+ else if (type == typeof (System.Web.UI.HtmlControls.HtmlTable))
+ space_between_tags = true;
+ else if (type == typeof (System.Web.UI.HtmlControls.HtmlTableRow))
+ space_between_tags = true;
+ else if (type == typeof (System.Web.UI.HtmlControls.HtmlTableCell))
+ space_between_tags = true;
+ else
+ space_between_tags = false;
+ }
+ return space_between_tags;
+ }
+ }
+
+ public Type Container {
+ get {
+ if (top == null)
+ return null;
+
+ return top.container;
+ }
+ }
+
+ public StringBuilder DataBindFunction
+ {
+ get {
+ if (top.dataBindFunction == null)
+ top.dataBindFunction = new StringBuilder ();
+ return top.dataBindFunction;
+ }
+ }
+
+ public int CodeRenderIndex {
+ get {
+ return top.codeRenderIndex++;
+ }
+ }
+
+ public StringBuilder CodeRenderFunction
+ {
+ get {
+ if (top.codeRenderFunction == null)
+ top.codeRenderFunction = new StringBuilder ();
+ return top.codeRenderFunction;
+ }
+ }
+
+ public int ChildIndex
+ {
+ get { return top.childrenNumber - 1; }
+ }
+
+ public int Count
+ {
+ get { return controls.Count; }
+ }
+
+ public override string ToString ()
+ {
+ return top.ToString () + " " + top.useCodeRender;
+ }
+
+}
+
+class ArrayListWrapper
+{
+ private ArrayList list;
+ private int index;
+
+ public ArrayListWrapper (ArrayList list)
+ {
+ this.list = list;
+ index = -1;
+ }
+
+ private void CheckIndex ()
+ {
+ if (index == -1 || index == list.Count)
+ throw new InvalidOperationException ();
+ }
+
+ public object Current
+ {
+ get {
+ CheckIndex ();
+ return list [index];
+ }
+
+ set {
+ CheckIndex ();
+ list [index] = value;
+ }
+ }
+
+ public bool MoveNext ()
+ {
+ if (index < list.Count)
+ index++;
+
+ return index < list.Count;
+ }
+}
+
+class AspGenerator
+{
+ private object [] parts;
+ private ArrayListWrapper elements;
+ private StringBuilder prolog;
+ private StringBuilder declarations;
+ private StringBuilder script;
+ private StringBuilder constructor;
+ private StringBuilder init_funcs;
+ private StringBuilder epilog;
+ private StringBuilder current_function;
+ private Stack functions;
+ private ControlStack controls;
+ private bool parse_ok;
+ private bool has_form_tag;
+ private AspComponentFoundry aspFoundry;
+
+ private string classDecl;
+ private string className;
+ private string interfaces;
+ private string basetype;
+ private string parent;
+ private Type parentType;
+ private string fullPath;
+
+ Hashtable options;
+ string privateBinPath;
+ string main_directive;
+ static string app_file_wrong = "The content in the application file is not valid.";
+
+ bool isPage;
+ bool isUserControl;
+ bool isApplication;
+
+ HttpContext context;
+
+ SessionState sessionState = SessionState.Enabled;
+
+ static Type styleType = typeof (System.Web.UI.WebControls.Style);
+ static Type fontinfoType = typeof (System.Web.UI.WebControls.FontInfo);
+
+ enum UserControlResult
+ {
+ OK = 0,
+ FileNotFound = 1,
+ CompilationFailed = 2
+ }
+
+ enum SessionState
+ {
+ Enabled,
+ ReadOnly,
+ Disabled
+ }
+
+ public AspGenerator (string pathToFile, ArrayList elements)
+ {
+ if (elements == null)
+ throw new ArgumentNullException ();
+
+ this.elements = new ArrayListWrapper (elements);
+ string filename = Path.GetFileName (pathToFile);
+ this.className = filename.Replace ('.', '_'); // Overridden by @ Page classname
+ this.className = className.Replace ('-', '_');
+ this.className = className.Replace (' ', '_');
+ Options ["ClassName"] = this.className;
+ this.fullPath = Path.GetFullPath (pathToFile);
+
+ this.has_form_tag = false;
+ AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
+ privateBinPath = setup.PrivateBinPath;
+ // This is a hack until we can run stuff in different domains
+ if (privateBinPath == null || privateBinPath.Length == 0)
+ privateBinPath = "bin";
+
+ if (!Path.IsPathRooted (privateBinPath))
+ privateBinPath = Path.Combine (setup.ApplicationBase, privateBinPath);
+
+ Init ();
+ }
+
+ public string BaseType {
+ get { return basetype; }
+
+ set {
+ if (parent == null)
+ parent = value;
+
+ basetype = value;
+ isUserControl = (basetype == "System.Web.UI.UserControl");
+ isPage = (basetype == "System.Web.UI.Page");
+ isApplication = (basetype == "System.Web.HttpApplication");
+ }
+ }
+
+ public bool IsUserControl {
+ get { return isUserControl; }
+ }
+
+ public bool IsPage {
+ get { return isPage; }
+ }
+
+ public bool IsApplication {
+ get { return isApplication; }
+ }
+
+ public string Interfaces {
+ get { return interfaces; }
+ }
+
+ public Hashtable Options {
+ get {
+ if (options == null)
+ options = new Hashtable ();
+
+ return options;
+ }
+ }
+
+ internal HttpContext Context {
+ get { return context; }
+ set { context = value; }
+ }
+
+ bool AddUsing (string nspace)
+ {
+ string _using = "using " + nspace + ";";
+ if (prolog.ToString ().IndexOf (_using) == -1) {
+ prolog.AppendFormat ("\t{0}\n", _using);
+ return true;
+ }
+
+ return false;
+ }
+
+ void AddInterface (Type type)
+ {
+ AddInterface (type.ToString ());
+ }
+
+ public void AddInterface (string iface)
+ {
+ if (interfaces == null) {
+ interfaces = ", " + iface;
+ } else {
+ string s = ", " + iface;
+ if (interfaces.IndexOf (s) == -1)
+ interfaces += s;
+ }
+ }
+
+ private AspComponentFoundry Foundry
+ {
+ get {
+ if (aspFoundry == null)
+ aspFoundry = new AspComponentFoundry ();
+
+ return aspFoundry;
+ }
+ }
+
+ private void Init ()
+ {
+ controls = new ControlStack ();
+ controls.Push (typeof (System.Web.UI.Control), "Root", null, ChildrenKind.CONTROLS, null);
+ prolog = new StringBuilder ();
+ declarations = new StringBuilder ();
+ script = new StringBuilder ();
+ constructor = new StringBuilder ();
+ init_funcs = new StringBuilder ();
+ epilog = new StringBuilder ();
+
+ current_function = new StringBuilder ();
+ functions = new Stack ();
+ functions.Push (current_function);
+
+ parts = new Object [6];
+ parts [0] = prolog;
+ parts [1] = declarations;
+ parts [2] = script;
+ parts [3] = constructor;
+ parts [4] = init_funcs;
+ parts [5] = epilog;
+
+ prolog.Append ("namespace ASP {\n" +
+ "\tusing System;\n" +
+ "\tusing System.Collections;\n" +
+ "\tusing System.Collections.Specialized;\n" +
+ "\tusing System.Configuration;\n" +
+ "\tusing System.IO;\n" +
+ "\tusing System.Text;\n" +
+ "\tusing System.Text.RegularExpressions;\n" +
+ "\tusing System.Web;\n" +
+ "\tusing System.Web.Caching;\n" +
+ "\tusing System.Web.Security;\n" +
+ "\tusing System.Web.SessionState;\n" +
+ "\tusing System.Web.UI;\n" +
+ "\tusing System.Web.UI.WebControls;\n" +
+ "\tusing System.Web.UI.HtmlControls;\n");
+
+ declarations.Append ("\t\tprivate static int __autoHandlers;\n");
+
+ current_function.Append ("\t\tprivate void __BuildControlTree (System.Web.UI.Control __ctrl)\n\t\t{\n");
+ if (!IsUserControl)
+ current_function.Append ("\t\t\tSystem.Web.UI.IParserAccessor __parser = " +
+ "(System.Web.UI.IParserAccessor) __ctrl;\n\n");
+ else
+ controls.UseCodeRender = true;
+ }
+
+ public StringReader GetCode ()
+ {
+ if (!parse_ok)
+ throw new ApplicationException ("You gotta call ProcessElements () first!");
+
+ StringBuilder code = new StringBuilder ();
+ for (int i = 0; i < parts.Length; i++)
+ code.Append ((StringBuilder) parts [i]);
+
+ return new StringReader (code.ToString ());
+ }
+
+ public void Print ()
+ {
+ if (!parse_ok){
+ Console.WriteLine ("//Warning!!!: Elements not correctly parsed.");
+ }
+
+ Console.Write (GetCode ().ReadToEnd ());
+ }
+
+ // Regex.Escape () make some illegal escape sequences for a C# source.
+ private string Escape (string input)
+ {
+ if (input == null)
+ return String.Empty;
+
+ string output = input.Replace ("\\", "\\\\");
+ output = output.Replace ("\"", "\\\"");
+ output = output.Replace ("\t", "\\t");
+ output = output.Replace ("\r", "\\r");
+ output = output.Replace ("\n", "\\n");
+ output = output.Replace ("\n", "\\n");
+ return output;
+ }
+
+ bool AddProtectedField (Type type, string fieldName)
+ {
+ if (parentType == null) {
+ declarations.AppendFormat ("\t\tprotected {0} {1};\n", type.ToString (), fieldName);
+ return true;
+ }
+
+ FieldInfo field = parentType.GetField (fieldName, BindingFlags.Public |
+ BindingFlags.NonPublic |
+ BindingFlags.Instance |
+ BindingFlags.Static);
+
+ if (field == null || (!field.IsPublic && !field.IsFamily)) {
+ declarations.AppendFormat ("\t\tprotected {0} {1};\n", type.ToString (), fieldName);
+ return true;
+ }
+
+ if (!field.FieldType.IsAssignableFrom (type)) {
+ string message = String.Format ("The base class includes the field '{0}', but its " +
+ "type '{1}' is not compatible with {2}",
+ fieldName, field.FieldType, type);
+
+ throw new ApplicationException (message);
+ }
+
+ return false;
+ }
+
+ private Type LoadParentType (string typeName)
+ {
+ // First try loaded assemblies, then try assemblies in Bin directory.
+ // By now i do this 'by hand' but may be this is a runtime/gac task.
+ Type type = null;
+ Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies ();
+ foreach (Assembly ass in assemblies) {
+ type = ass.GetType (typeName);
+ if (type != null)
+ return type;
+ }
+
+ Assembly assembly;
+ string [] binDlls = Directory.GetFiles (privateBinPath, "*.dll");
+ foreach (string dll in binDlls) {
+ string dllPath = Path.Combine (privateBinPath, dll);
+ assembly = null;
+ try {
+ assembly = Assembly.LoadFrom (dllPath);
+ type = assembly.GetType (typeName);
+ } catch (Exception e) {
+ if (assembly != null) {
+ Console.WriteLine ("ASP.NET Warning: assembly {0} loaded", dllPath);
+ Console.WriteLine ("ASP.NET Warning: but type {0} not found", typeName);
+ } else {
+ Console.WriteLine ("ASP.NET Warning: unable to load type {0} from {1}",
+ typeName, dllPath);
+ }
+ Console.WriteLine ("ASP.NET Warning: error was: {0}", e.Message);
+ }
+
+ if (type != null)
+ return type;
+ }
+
+ return null;
+ }
+
+ private void PageDirective (TagAttributes att)
+ {
+ if (att ["ClassName"] != null){
+ this.className = (string) att ["ClassName"];
+ Options ["ClassName"] = className;
+ }
+
+ if (att ["EnableSessionState"] != null){
+ if (!IsPage)
+ throw new ApplicationException ("EnableSessionState not allowed here.");
+
+ string est = (string) att ["EnableSessionState"];
+ if (0 == String.Compare (est, "false", true))
+ sessionState = SessionState.Disabled;
+ else if (0 == String.Compare (est, "true", true))
+ sessionState = SessionState.Enabled;
+ else if (0 == String.Compare (est, "readonly", true))
+ sessionState = SessionState.ReadOnly;
+ else
+ throw new ApplicationException ("EnableSessionState in Page directive not set to " +
+ "a correct value: " + est);
+ }
+
+ if (att ["Inherits"] != null) {
+ parent = (string) att ["Inherits"];
+ parentType = LoadParentType (parent);
+ if (parentType == null)
+ throw new ApplicationException ("The class " + parent + " cannot be found.");
+ }
+
+ if (att ["CompilerOptions"] != null)
+ Options ["CompilerOptions"] = (string) att ["CompilerOptions"];
+
+ if (att ["AutoEventWireup"] != null) {
+ if (options ["AutoEventWireup"] != null)
+ throw new ApplicationException ("Already have an AutoEventWireup attribute");
+
+ bool autoevent = true;
+ string v = att ["AutoEventWireup"] as string;
+ try {
+ autoevent = Convert.ToBoolean (v);
+ } catch (Exception) {
+ throw new ApplicationException ("'" + v + "' is not a valid value for AutoEventWireup");
+ }
+ options ["AutoEventWireup"] = autoevent;
+ }
+
+ //FIXME: add support for more attributes.
+ }
+
+ void AddReference (string dll)
+ {
+ string references = Options ["References"] as string;
+ if (references == null)
+ references = dll;
+ else
+ references = references + " " + dll;
+
+ Options ["References"] = references;
+ }
+
+ private void RegisterDirective (TagAttributes att)
+ {
+ string tag_prefix = (string) (att ["tagprefix"] == null ? "" : att ["tagprefix"]);
+ string name_space = (string) (att ["namespace"] == null ? "" : att ["namespace"]);
+ string assembly_name = (string) (att ["assembly"] == null ? "" : att ["assembly"]);
+ string tag_name = (string) (att ["tagname"] == null ? "" : att ["tagname"]);
+ string src = (string) (att ["src"] == null ? "" : att ["src"]);
+
+ if (tag_prefix != "" && name_space != "" && assembly_name != ""){
+ if (tag_name != "" || src != "")
+ throw new ApplicationException ("Invalid attributes for @ Register: " +
+ att.ToString ());
+
+ AddUsing (name_space);
+ string dll = privateBinPath + Path.DirectorySeparatorChar + assembly_name + ".dll";
+ // Hack: it should use assembly.load semantics...
+ // may be when we don't run mcs as a external program...
+ if (!File.Exists (dll))
+ dll = assembly_name;
+
+ Foundry.RegisterFoundry (tag_prefix, dll, name_space);
+ AddReference (dll);
+ return;
+ }
+
+ if (tag_prefix != "" && tag_name != "" && src != ""){
+ if (name_space != "" && assembly_name != "")
+ throw new ApplicationException ("Invalid attributes for @ Register: " +
+ att.ToString ());
+
+ if (!src.EndsWith (".ascx"))
+ throw new ApplicationException ("Source file extension for controls " +
+ "must be .ascx");
+
+ UserControlData data = GenerateUserControl (src, Context);
+ switch (data.result) {
+ case UserControlResult.OK:
+ AddUsing ("ASP");
+ string dll = "output" + Path.DirectorySeparatorChar + data.assemblyName + ".dll";
+ Foundry.RegisterFoundry (tag_prefix, tag_name, data.assemblyName, "ASP", data.className);
+ AddReference (data.assemblyName);
+ break;
+ case UserControlResult.FileNotFound:
+ throw new ApplicationException ("File '" + src + "' not found.");
+ case UserControlResult.CompilationFailed:
+ //TODO: should say where the generated .cs file is for the server to
+ //show the source and the compiler error
+ throw new NotImplementedException ();
+ }
+ return;
+ }
+
+ throw new ApplicationException ("Invalid combination of attributes in " +
+ "@ Register: " + att.ToString ());
+ }
+
+ private void ProcessDirective ()
+ {
+ Directive directive = (Directive) elements.Current;
+ TagAttributes att = directive.Attributes;
+ if (att == null)
+ return;
+
+ string value;
+ string id = directive.TagID.ToUpper ();
+ switch (id){
+ case "APPLICATION":
+ if (main_directive != null)
+ throw new ApplicationException (id + " not allowed after " + main_directive);
+
+ if (!IsApplication)
+ throw new ApplicationException ("@Application not allowed.");
+
+ string inherits = att ["inherits"] as string;
+ if (inherits != null)
+ Options ["Inherits"] = inherits;
+
+ main_directive = directive.TagID;
+ break;
+ case "PAGE":
+ case "CONTROL":
+ if (main_directive != null)
+ throw new ApplicationException (id + " not allowed after " + main_directive);
+
+ if (IsUserControl && id != "CONTROL")
+ throw new ApplicationException ("@Page not allowed for user controls.");
+ else if (IsPage && id != "PAGE")
+ throw new ApplicationException ("@Control not allowed here. This is a page!");
+
+ PageDirective (att);
+ main_directive = directive.TagID;
+ break;
+ case "IMPORT":
+ value = att ["namespace"] as string;
+ if (value == null || att.Count > 1)
+ throw new ApplicationException ("Wrong syntax in Import directive.");
+
+ string _using = "using " + value + ";";
+ if (AddUsing (value) == true) {
+ string imports = Options ["Import"] as string;
+ if (imports == null) {
+ imports = value;
+ } else {
+ imports += "," + value;
+ }
+
+ Options ["Import"] = imports;
+ }
+ break;
+ case "IMPLEMENTS":
+ if (IsApplication)
+ throw new ApplicationException ("@ Implements not allowed in an application file.");
+
+ string iface = (string) att ["interface"];
+ AddInterface (iface);
+ break;
+ case "REGISTER":
+ if (IsApplication)
+ throw new ApplicationException ("@ Register not allowed in an application file.");
+
+ RegisterDirective (att);
+ break;
+ case "ASSEMBLY":
+ if (att.Count > 1)
+ throw new ApplicationException ("Wrong syntax in Assembly directive.");
+
+ string name = att ["name"] as string;
+ string src = att ["src"] as string;
+
+ if (name == null && src == null)
+ throw new ApplicationException ("Wrong syntax in Assembly directive.");
+
+ if (IsApplication && src != null)
+ throw new ApplicationException ("'name' attribute expected.");
+
+ value = (name == null) ? src : name;
+ string assemblies = Options ["Assembly"] as string;
+ if (assemblies == null) {
+ assemblies = value;
+ } else {
+ assemblies += "," + value;
+ }
+
+ Options ["Assembly"] = assemblies;
+ break;
+ }
+ }
+
+ private void ProcessPlainText ()
+ {
+ PlainText asis = (PlainText) elements.Current;
+ string trimmed = asis.Text.Trim ();
+ if (trimmed == String.Empty && controls.SpaceBetweenTags == true)
+ return;
+
+ if (IsApplication) {
+ if (trimmed != String.Empty)
+ throw new ApplicationException (app_file_wrong);
+ return;
+ }
+
+ if (trimmed != String.Empty && controls.PeekChildKind () != ChildrenKind.CONTROLS){
+ string tag_id = controls.PeekTagID ();
+ throw new ApplicationException ("Literal content not allowed for " + tag_id);
+ }
+
+ string escaped_text = Escape (asis.Text);
+ current_function.AppendFormat ("\t\t\t__parser.AddParsedSubObject (" +
+ "new System.Web.UI.LiteralControl (\"{0}\"));\n",
+ escaped_text);
+ StringBuilder codeRenderFunction = controls.CodeRenderFunction;
+ codeRenderFunction.AppendFormat ("\t\t\t__output.Write (\"{0}\");\n", escaped_text);
+ }
+
+ private string EnumValueNameToString (Type enum_type, string value_name)
+ {
+ if (value_name.EndsWith ("*"))
+ throw new ApplicationException ("Invalid property value: '" + value_name +
+ ". It must be a valid " + enum_type.ToString () + " value.");
+
+ MemberInfo [] nested_types = enum_type.FindMembers (MemberTypes.Field,
+ BindingFlags.Public | BindingFlags.Static,
+ Type.FilterNameIgnoreCase,
+ value_name);
+
+ if (nested_types.Length == 0)
+ throw new ApplicationException ("Value " + value_name + " not found in enumeration " +
+ enum_type.ToString ());
+ if (nested_types.Length > 1)
+ throw new ApplicationException ("Value " + value_name + " found " +
+ nested_types.Length + " in enumeration " +
+ enum_type.ToString ());
+
+ return enum_type.ToString () + "." + nested_types [0].Name;
+ }
+
+ private void NewControlFunction (string tag_id,
+ string control_id,
+ Type control_type,
+ ChildrenKind children_kind,
+ string defaultPropertyName)
+ {
+ ChildrenKind prev_children_kind = controls.PeekChildKind ();
+ if (prev_children_kind == ChildrenKind.NONE ||
+ prev_children_kind == ChildrenKind.PROPERTIES){
+ string prev_tag_id = controls.PeekTagID ();
+ throw new ApplicationException ("Child controls not allowed for " + prev_tag_id);
+ }
+
+ if (prev_children_kind == ChildrenKind.DBCOLUMNS &&
+ control_type != typeof (System.Web.UI.WebControls.DataGridColumn) &&
+ !control_type.IsSubclassOf (typeof (System.Web.UI.WebControls.DataGridColumn)))
+ throw new ApplicationException ("Inside " + controls.PeekTagID () + " only " +
+ "System.Web.UI.WebControls.DataGridColum " +
+ "objects are allowed");
+ else if (prev_children_kind == ChildrenKind.LISTITEM &&
+ control_type != typeof (System.Web.UI.WebControls.ListItem))
+ throw new ApplicationException ("Inside " + controls.PeekTagID () + " only " +
+ "System.Web.UI.WebControls.ListItem " +
+ "objects are allowed");
+ else if (prev_children_kind == ChildrenKind.HTMLROW &&
+ control_type != typeof (System.Web.UI.HtmlControls.HtmlTableRow))
+ throw new ApplicationException ("Inside " + controls.PeekTagID () + " only " +
+ "System.Web.UI.HtmlControls.HtmlTableRow " +
+ "objects are allowed");
+ else if (prev_children_kind == ChildrenKind.HTMLCELL &&
+ control_type != typeof (System.Web.UI.HtmlControls.HtmlTableCell))
+ throw new ApplicationException ("Inside " + controls.PeekTagID () + " only " +
+ "System.Web.UI.HtmlControls.HtmlTableCell " +
+ "objects are allowed");
+
+
+ StringBuilder func_code = new StringBuilder ();
+ current_function = func_code;
+ if (0 == String.Compare (tag_id, "form", true)){
+ if (has_form_tag)
+ throw new ApplicationException ("Only one form server tag allowed.");
+ has_form_tag = true;
+ }
+
+ controls.Push (control_type, control_id, tag_id, children_kind, defaultPropertyName);
+ bool is_generic = control_type == typeof (System.Web.UI.HtmlControls.HtmlGenericControl);
+ functions.Push (current_function);
+ if (control_type != typeof (System.Web.UI.WebControls.ListItem) &&
+ prev_children_kind != ChildrenKind.DBCOLUMNS) {
+ current_function.AppendFormat ("\t\tprivate System.Web.UI.Control __BuildControl_" +
+ "{0} ()\n\t\t{{\n\t\t\t{1} __ctrl;\n\n\t\t\t__ctrl" +
+ " = new {1} ({2});\n\t\t\tthis.{0} = __ctrl;\n",
+ control_id, control_type,
+ (is_generic? "\"" + tag_id + "\"" : ""));
+ } else {
+ current_function.AppendFormat ("\t\tprivate void __BuildControl_{0} ()\n\t\t{{" +
+ "\n\t\t\t{1} __ctrl;\n\t\t\t__ctrl = new {1} ();" +
+ "\n\t\t\tthis.{0} = __ctrl;\n",
+ control_id, control_type);
+ }
+
+ if (children_kind == ChildrenKind.CONTROLS || children_kind == ChildrenKind.OPTION)
+ current_function.Append ("\t\t\tSystem.Web.UI.IParserAccessor __parser = " +
+ "(System.Web.UI.IParserAccessor) __ctrl;\n");
+ }
+
+ private void DataBoundProperty (Type target, string varName, string value)
+ {
+ if (value == "")
+ throw new ApplicationException ("Empty data binding tag.");
+
+ string control_id = controls.PeekControlID ();
+ string control_type_string = controls.PeekType ().ToString ();
+ StringBuilder db_function = controls.DataBindFunction;
+ string container;
+ if (controls.Container == null || !typeof (INamingContainer).IsAssignableFrom (controls.Container))
+ container = "System.Web.UI.Control";
+ else {
+ container = controls.Container.ToString ();
+ }
+
+ if (db_function.Length == 0)
+ db_function.AppendFormat ("\t\tpublic void __DataBind_{0} (object sender, " +
+ "System.EventArgs e) {{\n" +
+ "\t\t\t{1} Container;\n" +
+ "\t\t\t{2} target;\n" +
+ "\t\t\ttarget = ({2}) sender;\n" +
+ "\t\t\tContainer = ({1}) target.BindingContainer;\n",
+ control_id, container, control_type_string);
+
+ /* Removes '<%#' and '%>' */
+ string real_value = value.Remove (0,3);
+ real_value = real_value.Remove (real_value.Length - 2, 2);
+ real_value = real_value.Trim ();
+
+ if (target == typeof (string))
+ db_function.AppendFormat ("\t\t\ttarget.{0} = System.Convert.ToString ({1});\n",
+ varName, real_value);
+ else
+ db_function.AppendFormat ("\t\t\ttarget.{0} = ({1}) ({2});\n",
+ varName, target, real_value);
+ }
+
+ /*
+ * Returns true if it generates some code for the specified property
+ */
+ private void AddCodeForPropertyOrField (Type type, string var_name, string att, bool isDataBound)
+ {
+ /* FIXME: should i check for this or let the compiler fail?
+ * if (!prop.CanWrite)
+ * ....
+ */
+ if (isDataBound) {
+ DataBoundProperty (type, var_name, att);
+ }
+ else if (type == typeof (string)){
+ if (att == null)
+ throw new ApplicationException ("null value for attribute " + var_name );
+
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = \"{1}\";\n", var_name,
+ Escape (att)); // FIXME: really Escape this?
+ }
+ else if (type.IsEnum){
+ if (att == null)
+ throw new ApplicationException ("null value for attribute " + var_name );
+
+ string enum_value = EnumValueNameToString (type, att);
+
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = {1};\n", var_name, enum_value);
+ }
+ else if (type == typeof (bool)){
+ string value;
+ if (att == null)
+ value = "true"; //FIXME: is this ok for non Style properties?
+ else if (0 == String.Compare (att, "true", true))
+ value = "true";
+ else if (0 == String.Compare (att, "false", true))
+ value = "false";
+ else
+ throw new ApplicationException ("Value '" + att + "' is not a valid boolean.");
+
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = {1};\n", var_name, value);
+ }
+ else if (type == typeof (System.Web.UI.WebControls.Unit)){
+ //FIXME: should use the culture specified in Page
+ try {
+ Unit value = Unit.Parse (att, System.Globalization.CultureInfo.InvariantCulture);
+ } catch (Exception) {
+ throw new ApplicationException ("'" + att + "' cannot be parsed as a unit.");
+ }
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = " +
+ "System.Web.UI.WebControls.Unit.Parse (\"{1}\", " +
+ "System.Globalization.CultureInfo.InvariantCulture);\n",
+ var_name, att);
+ }
+ else if (type == typeof (System.Web.UI.WebControls.FontUnit)){
+ //FIXME: should use the culture specified in Page
+ try {
+ FontUnit value = FontUnit.Parse (att, System.Globalization.CultureInfo.InvariantCulture);
+ } catch (Exception) {
+ throw new ApplicationException ("'" + att + "' cannot be parsed as a unit.");
+ }
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = " +
+ "System.Web.UI.WebControls.FontUnit.Parse (\"{1}\", " +
+ "System.Globalization.CultureInfo.InvariantCulture);\n",
+ var_name, att);
+ }
+ else if (type == typeof (Int16) || type == typeof (Int32) || type == typeof (Int64)) {
+ long value;
+ try {
+ value = Int64.Parse (att); //FIXME: should use the culture specified in Page
+ } catch (Exception){
+ throw new ApplicationException (att + " is not a valid signed number " +
+ "or is out of range.");
+ }
+
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = {1};\n", var_name, value);
+ }
+ else if (type == typeof (UInt16) || type == typeof (UInt32) || type == typeof (UInt64)) {
+ ulong value;
+ try {
+ value = UInt64.Parse (att); //FIXME: should use the culture specified in Page
+ } catch (Exception){
+ throw new ApplicationException (att + " is not a valid unsigned number " +
+ "or is out of range.");
+ }
+
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = {1};\n", var_name, value);
+ }
+ else if (type == typeof (float)) {
+ float value;
+ try {
+ value = Single.Parse (att);
+ } catch (Exception){
+ throw new ApplicationException (att + " is not avalid float number or " +
+ "is out of range.");
+ }
+
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = {1};\n", var_name, value);
+ }
+ else if (type == typeof (double)){
+ double value;
+ try {
+ value = Double.Parse (att);
+ } catch (Exception){
+ throw new ApplicationException (att + " is not avalid double number or " +
+ "is out of range.");
+ }
+
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = {1};\n", var_name, value);
+ }
+ else if (type == typeof (System.Drawing.Color)){
+ Color c;
+ try {
+ c = (Color) TypeDescriptor.GetConverter (typeof (Color)).ConvertFromString (att);
+ } catch (Exception e){
+ throw new ApplicationException ("Color " + att + " is not a valid color.", e);
+ }
+
+ // Should i also test for IsSystemColor?
+ // Are KnownColor members in System.Drawing.Color?
+ if (c.IsKnownColor){
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = System.Drawing.Color." +
+ "{1};\n", var_name, c.Name);
+ }
+ else {
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = System.Drawing.Color." +
+ "FromArgb ({1}, {2}, {3}, {4});\n",
+ var_name, c.A, c.R, c.G, c.B);
+ }
+ }
+ else {
+ throw new ApplicationException ("Unsupported type in property: " +
+ type.ToString ());
+ }
+ }
+
+ private bool ProcessPropertiesAndFields (MemberInfo member, string id, TagAttributes att)
+ {
+ int hyphen = id.IndexOf ('-');
+
+ bool isPropertyInfo = (member is PropertyInfo);
+
+ bool is_processed = false;
+ bool isDataBound = att.IsDataBound ((string) att [id]);
+ Type type;
+ if (isPropertyInfo) {
+ type = ((PropertyInfo) member).PropertyType;
+ if (hyphen == -1 && ((PropertyInfo) member).CanWrite == false)
+ return false;
+ } else {
+ type = ((FieldInfo) member).FieldType;
+ }
+
+ if (0 == String.Compare (member.Name, id, true)){
+ AddCodeForPropertyOrField (type, member.Name, (string) att [id], isDataBound);
+ is_processed = true;
+ } else if (hyphen != -1 && (type == fontinfoType || type == styleType || type.IsSubclassOf (styleType))){
+ string prop_field = id.Replace ("-", ".");
+ string [] parts = prop_field.Split (new char [] {'.'});
+ if (parts.Length != 2 || 0 != String.Compare (member.Name, parts [0], true))
+ return false;
+
+ PropertyInfo [] subprops = type.GetProperties ();
+ foreach (PropertyInfo subprop in subprops){
+ if (0 != String.Compare (subprop.Name, parts [1], true))
+ continue;
+
+ if (subprop.CanWrite == false)
+ return false;
+
+ bool is_bool = subprop.PropertyType == typeof (bool);
+ if (!is_bool && att [id] == null){
+ att [id] = ""; // Font-Size -> Font-Size="" as html
+ return false;
+ }
+
+ string value;
+ if (att [id] == null && is_bool)
+ value = "true"; // Font-Bold <=> Font-Bold="true"
+ else
+ value = (string) att [id];
+
+ AddCodeForPropertyOrField (subprop.PropertyType,
+ member.Name + "." + subprop.Name,
+ value, isDataBound);
+ is_processed = true;
+ }
+ }
+
+ return is_processed;
+ }
+
+ private void AddCodeForAttributes (Type type, TagAttributes att)
+ {
+ EventInfo [] ev_info = type.GetEvents ();
+ PropertyInfo [] prop_info = type.GetProperties ();
+ FieldInfo [] field_info = type.GetFields ();
+ bool is_processed = false;
+ ArrayList processed = new ArrayList ();
+
+ foreach (string id in att.Keys){
+ if (0 == String.Compare (id, "runat", true) || 0 == String.Compare (id, "id", true))
+ continue;
+
+ if (id.Length > 2 && id.Substring (0, 2).ToUpper () == "ON"){
+ string id_as_event = id.Substring (2);
+ foreach (EventInfo ev in ev_info){
+ if (0 == String.Compare (ev.Name, id_as_event, true)){
+ current_function.AppendFormat (
+ "\t\t\t__ctrl.{0} += " +
+ "new {1} (this.{2});\n",
+ ev.Name, ev.EventHandlerType, att [id]);
+ is_processed = true;
+ break;
+ }
+ }
+ if (is_processed){
+ is_processed = false;
+ continue;
+ }
+ }
+
+ foreach (PropertyInfo prop in prop_info){
+ is_processed = ProcessPropertiesAndFields (prop, id, att);
+ if (is_processed)
+ break;
+ }
+
+ if (!is_processed) {
+ foreach (FieldInfo field in field_info){
+ is_processed = ProcessPropertiesAndFields (field, id, att);
+ if (is_processed)
+ break;
+ }
+ }
+
+ if (is_processed){
+ is_processed = false;
+ continue;
+ }
+
+ current_function.AppendFormat ("\t\t\t((System.Web.UI.IAttributeAccessor) __ctrl)." +
+ "SetAttribute (\"{0}\", \"{1}\");\n",
+ id, Escape ((string) att [id]));
+ }
+ }
+
+ private void AddCodeRenderControl (StringBuilder function)
+ {
+ AddCodeRenderControl (function, controls.CodeRenderIndex);
+ }
+
+ private void AddCodeRenderControl (StringBuilder function, int index)
+ {
+ function.AppendFormat ("\t\t\tparameterContainer.Controls [{0}]." +
+ "RenderControl (__output);\n", index);
+ }
+
+ private void AddRenderMethodDelegate (StringBuilder function, string control_id)
+ {
+ function.AppendFormat ("\t\t\t__ctrl.SetRenderMethodDelegate (new System.Web." +
+ "UI.RenderMethod (this.__Render_{0}));\n", control_id);
+ }
+
+ private void AddCodeRenderFunction (string codeRender, string control_id)
+ {
+ StringBuilder codeRenderFunction = new StringBuilder ();
+ codeRenderFunction.AppendFormat ("\t\tprivate void __Render_{0} " +
+ "(System.Web.UI.HtmlTextWriter __output, " +
+ "System.Web.UI.Control parameterContainer)\n" +
+ "\t\t{{\n", control_id);
+ codeRenderFunction.Append (codeRender);
+ codeRenderFunction.Append ("\t\t}\n\n");
+ init_funcs.Append (codeRenderFunction);
+ }
+
+ private void RemoveLiterals (StringBuilder function)
+ {
+ string no_literals = Regex.Replace (function.ToString (),
+ @"\t\t\t__parser.AddParsedSubObject \(" +
+ @"new System.Web.UI.LiteralControl \(.+\);\n", "");
+ function.Length = 0;
+ function.Append (no_literals);
+ }
+
+ private bool FinishControlFunction (string tag_id)
+ {
+ if (functions.Count == 0)
+ throw new ApplicationException ("Unbalanced open/close tags");
+
+ if (controls.Count == 0)
+ return false;
+
+ string saved_id = controls.PeekTagID ();
+ if (0 != String.Compare (saved_id, tag_id, true))
+ return false;
+
+ StringBuilder old_function = (StringBuilder) functions.Pop ();
+ current_function = (StringBuilder) functions.Peek ();
+
+ string control_id = controls.PeekControlID ();
+ Type control_type = controls.PeekType ();
+ ChildrenKind child_kind = controls.PeekChildKind ();
+
+ bool hasDataBindFunction = controls.HasDataBindFunction ();
+ if (hasDataBindFunction)
+ old_function.AppendFormat ("\t\t\t__ctrl.DataBinding += new System.EventHandler " +
+ "(this.__DataBind_{0});\n", control_id);
+
+ bool useCodeRender = controls.UseCodeRender;
+ if (useCodeRender)
+ AddRenderMethodDelegate (old_function, control_id);
+
+ if (control_type == typeof (System.Web.UI.ITemplate)){
+ old_function.Append ("\n\t\t}\n\n");
+ current_function.AppendFormat ("\t\t\t__ctrl.{0} = new System.Web.UI." +
+ "CompiledTemplateBuilder (new System.Web.UI." +
+ "BuildTemplateMethod (this.__BuildControl_{1}));\n",
+ saved_id, control_id);
+ }
+ else if (control_type == typeof (System.Web.UI.WebControls.DataGridColumnCollection)){
+ old_function.Append ("\n\t\t}\n\n");
+ current_function.AppendFormat ("\t\t\tthis.__BuildControl_{0} (__ctrl.{1});\n",
+ control_id, saved_id);
+ }
+ else if (control_type == typeof (System.Web.UI.WebControls.DataGridColumn) ||
+ control_type.IsSubclassOf (typeof (System.Web.UI.WebControls.DataGridColumn)) ||
+ control_type == typeof (System.Web.UI.WebControls.ListItem)){
+ old_function.Append ("\n\t\t}\n\n");
+ string parsed = "";
+ string ctrl_name = "ctrl";
+ Type cont = controls.Container;
+ if (cont == null || cont == typeof (System.Web.UI.HtmlControls.HtmlSelect)){
+ parsed = "ParsedSubObject";
+ ctrl_name = "parser";
+ }
+
+ current_function.AppendFormat ("\t\t\tthis.__BuildControl_{0} ();\n" +
+ "\t\t\t__{1}.Add{2} (this.{0});\n\n",
+ control_id, ctrl_name, parsed);
+ }
+ else if (child_kind == ChildrenKind.LISTITEM){
+ old_function.Append ("\n\t\t}\n\n");
+ init_funcs.Append (old_function); // Closes the BuildList function
+ old_function = (StringBuilder) functions.Pop ();
+ current_function = (StringBuilder) functions.Peek ();
+ old_function.AppendFormat ("\n\t\t\tthis.__BuildControl_{0} (__ctrl.{1});\n\t\t\t" +
+ "return __ctrl;\n\t\t}}\n\n",
+ control_id, controls.PeekDefaultPropertyName ());
+
+ controls.Pop ();
+ control_id = controls.PeekControlID ();
+ current_function.AppendFormat ("\t\t\tthis.__BuildControl_{0} ();\n\t\t\t__parser." +
+ "AddParsedSubObject (this.{0});\n\n", control_id);
+ } else if (control_type == typeof (HtmlTableCell)) {
+ old_function.Append ("\n\t\t\treturn __ctrl;\n\t\t}\n\n");
+ object top = controls.Pop ();
+ Type t = controls.PeekType ();
+ controls.Push (top);
+ string parsed = "";
+ string ctrl_name = "ctrl";
+ if (t != typeof (HtmlTableRow)) {
+ parsed = "ParsedSubObject";
+ ctrl_name = "parser";
+ }
+
+ current_function.AppendFormat ("\t\t\tthis.__BuildControl_{0} ();\n" +
+ "\t\t\t__{1}.Add{2} (this.{0});\n\n",
+ control_id, ctrl_name, parsed);
+ } else if (child_kind == ChildrenKind.HTMLROW || child_kind == ChildrenKind.HTMLCELL) {
+ old_function.Append ("\n\t\t}\n\n");
+ init_funcs.Append (old_function);
+ old_function = (StringBuilder) functions.Pop ();
+ current_function = (StringBuilder) functions.Peek ();
+ old_function.AppendFormat ("\n\t\t\tthis.__BuildControl_{0} (__ctrl.{1});\n\t\t\t" +
+ "return __ctrl;\n\t\t}}\n\n",
+ control_id, controls.PeekDefaultPropertyName ());
+
+ controls.Pop ();
+ control_id = controls.PeekControlID ();
+ current_function.AppendFormat ("\t\t\tthis.__BuildControl_{0} ();\n", control_id);
+ if (child_kind == ChildrenKind.HTMLROW) {
+ current_function.AppendFormat ("\t\t\t__parser.AddParsedSubObject ({0});\n",
+ control_id);
+ } else {
+ current_function.AppendFormat ("\t\t\t__ctrl.Add (this.{0});\n", control_id);
+ }
+ } else {
+ old_function.Append ("\n\t\t\treturn __ctrl;\n\t\t}\n\n");
+ current_function.AppendFormat ("\t\t\tthis.__BuildControl_{0} ();\n\t\t\t__parser." +
+ "AddParsedSubObject (this.{0});\n\n", control_id);
+ }
+
+ if (useCodeRender)
+ RemoveLiterals (old_function);
+
+ init_funcs.Append (old_function);
+ if (useCodeRender)
+ AddCodeRenderFunction (controls.CodeRenderFunction.ToString (), control_id);
+
+ if (hasDataBindFunction){
+ StringBuilder db_function = controls.DataBindFunction;
+ db_function.Append ("\t\t}\n\n");
+ init_funcs.Append (db_function);
+ }
+
+ // Avoid getting empty stacks for unbalanced open/close tags
+ if (controls.Count > 1){
+ controls.Pop ();
+ AddCodeRenderControl (controls.CodeRenderFunction, controls.ChildIndex);
+ }
+
+ return true;
+ }
+
+ private void NewTableElementFunction (HtmlControlTag ctrl)
+ {
+ string control_id = Tag.GetDefaultID ();
+ ChildrenKind child_kind;
+
+ Type t;
+ if (ctrl.ControlType == typeof (HtmlTable)) {
+ t = typeof (HtmlTableRowCollection);
+ child_kind = ChildrenKind.HTMLROW;
+ } else {
+ t = typeof (HtmlTableCellCollection);
+ child_kind = ChildrenKind.HTMLCELL;
+ }
+
+ controls.Push (ctrl.ControlType,
+ control_id,
+ ctrl.TagID,
+ child_kind,
+ ctrl.ParseChildren);
+
+
+ current_function = new StringBuilder ();
+ functions.Push (current_function);
+ current_function.AppendFormat ("\t\tprivate void __BuildControl_{0} ({1} __ctrl)\n" +
+ "\t\t{{\n", control_id, t);
+ }
+
+ private void ProcessHtmlControlTag ()
+ {
+ HtmlControlTag html_ctrl = (HtmlControlTag) elements.Current;
+ if (html_ctrl.TagID.ToUpper () == "SCRIPT"){
+ //FIXME: if the is script is to be read from disk, do it!
+ if (html_ctrl.SelfClosing)
+ throw new ApplicationException ("Read script from file not supported yet.");
+
+ if (elements.MoveNext () == false)
+ throw new ApplicationException ("Error after " + html_ctrl.ToString ());
+
+ if (elements.Current is PlainText){
+ script.Append (((PlainText) elements.Current).Text);
+ if (!elements.MoveNext ())
+ throw new ApplicationException ("Error after " +
+ elements.Current.ToString ());
+ }
+
+ if (elements.Current is CloseTag)
+ elements.MoveNext ();
+ return;
+ } else if (IsApplication) {
+ throw new ApplicationException (app_file_wrong);
+ }
+
+ Type controlType = html_ctrl.ControlType;
+ AddProtectedField (controlType, html_ctrl.ControlID);
+
+ ChildrenKind children_kind;
+ if (0 == String.Compare (html_ctrl.TagID, "table", true))
+ children_kind = ChildrenKind.HTMLROW;
+ else if (0 == String.Compare (html_ctrl.TagID, "tr", true))
+ children_kind = ChildrenKind.HTMLCELL;
+ else if (0 != String.Compare (html_ctrl.TagID, "select", true))
+ children_kind = html_ctrl.IsContainer ? ChildrenKind.CONTROLS :
+ ChildrenKind.NONE;
+ else
+ children_kind = ChildrenKind.OPTION;
+
+ NewControlFunction (html_ctrl.TagID, html_ctrl.ControlID, controlType, children_kind, html_ctrl.ParseChildren);
+
+ current_function.AppendFormat ("\t\t\t__ctrl.ID = \"{0}\";\n", html_ctrl.ControlID);
+ AddCodeForAttributes (html_ctrl.ControlType, html_ctrl.Attributes);
+
+ if (children_kind == ChildrenKind.HTMLROW || children_kind == ChildrenKind.HTMLCELL)
+ NewTableElementFunction (html_ctrl);
+
+ if (!html_ctrl.SelfClosing)
+ JustDoIt ();
+ else
+ FinishControlFunction (html_ctrl.TagID);
+ }
+
+ // Closing is performed in FinishControlFunction ()
+ private void NewBuildListFunction (AspComponent component)
+ {
+ string control_id = Tag.GetDefaultID ();
+
+ controls.Push (component.ComponentType,
+ control_id,
+ component.TagID,
+ ChildrenKind.LISTITEM,
+ component.DefaultPropertyName);
+
+ current_function = new StringBuilder ();
+ functions.Push (current_function);
+ current_function.AppendFormat ("\t\tprivate void __BuildControl_{0} " +
+ "(System.Web.UI.WebControls.ListItemCollection __ctrl)\n" +
+ "\t\t{{\n", control_id);
+ }
+
+ private void ProcessComponent ()
+ {
+ AspComponent component = (AspComponent) elements.Current;
+ Type component_type = component.ComponentType;
+ AddProtectedField (component_type, component.ControlID);
+
+ NewControlFunction (component.TagID, component.ControlID, component_type,
+ component.ChildrenKind, component.DefaultPropertyName);
+
+ if (component_type == typeof (UserControl) ||
+ component_type.IsSubclassOf (typeof (System.Web.UI.UserControl)))
+ current_function.Append ("\t\t\t__ctrl.InitializeAsUserControl (Page);\n");
+
+ if (component_type == typeof (Control) ||
+ component_type.IsSubclassOf (typeof (System.Web.UI.Control)))
+ current_function.AppendFormat ("\t\t\t__ctrl.ID = \"{0}\";\n", component.ControlID);
+
+ AddCodeForAttributes (component.ComponentType, component.Attributes);
+ if (component.ChildrenKind == ChildrenKind.LISTITEM)
+ NewBuildListFunction (component);
+
+ if (!component.SelfClosing)
+ JustDoIt ();
+ else
+ FinishControlFunction (component.TagID);
+ }
+
+ private void ProcessServerObjectTag ()
+ {
+ ServerObjectTag obj = (ServerObjectTag) elements.Current;
+ declarations.AppendFormat ("\t\tprivate {0} cached{1};\n", obj.ObjectClass, obj.ObjectID);
+ constructor.AppendFormat ("\n\t\tprivate {0} {1}\n\t\t{{\n\t\t\tget {{\n\t\t\t\t" +
+ "if (this.cached{1} == null)\n\t\t\t\t\tthis.cached{1} = " +
+ "new {0} ();\n\t\t\t\treturn cached{1};\n\t\t\t}}\n\t\t}}\n\n",
+ obj.ObjectClass, obj.ObjectID);
+ }
+
+ // Creates a new function that sets the values of subproperties.
+ private void NewStyleFunction (PropertyTag tag)
+ {
+ current_function = new StringBuilder ();
+
+ string prop_id = tag.PropertyID;
+ Type prop_type = tag.PropertyType;
+ // begin function
+ current_function.AppendFormat ("\t\tprivate void __BuildControl_{0} ({1} __ctrl)\n" +
+ "\t\t{{\n", prop_id, prop_type);
+
+ // Add property initialization code
+ PropertyInfo [] subprop_info = prop_type.GetProperties ();
+ TagAttributes att = tag.Attributes;
+
+ string subprop_name = null;
+ foreach (string id in att.Keys){
+ if (0 == String.Compare (id, "runat", true) || 0 == String.Compare (id, "id", true))
+ continue;
+
+ bool is_processed = false;
+ foreach (PropertyInfo subprop in subprop_info){
+ is_processed = ProcessPropertiesAndFields (subprop, id, att);
+ if (is_processed){
+ subprop_name = subprop.Name;
+ break;
+ }
+ }
+
+ if (subprop_name == null)
+ throw new ApplicationException ("Property " + tag.TagID + " does not have " +
+ "a " + id + " subproperty.");
+ }
+
+ // Finish function
+ current_function.Append ("\n\t\t}\n\n");
+ init_funcs.Append (current_function);
+ current_function = (StringBuilder) functions.Peek ();
+ current_function.AppendFormat ("\t\t\tthis.__BuildControl_{0} (__ctrl.{1});\n",
+ prop_id, tag.PropertyName);
+
+ if (!tag.SelfClosing){
+ // Next tag should be the closing tag
+ controls.Push (null, null, null, ChildrenKind.NONE, null);
+ bool closing_tag_found = false;
+ Element elem;
+ while (!closing_tag_found && elements.MoveNext ()){
+ elem = (Element) elements.Current;
+ if (elem is PlainText)
+ ProcessPlainText ();
+ else if (!(elem is CloseTag))
+ throw new ApplicationException ("Tag " + tag.TagID +
+ " not properly closed.");
+ else
+ closing_tag_found = true;
+ }
+
+ if (!closing_tag_found)
+ throw new ApplicationException ("Tag " + tag.TagID + " not properly closed.");
+
+ controls.Pop ();
+ }
+ }
+
+ // This one just opens the function. Closing is performed in FinishControlFunction ()
+ private void NewTemplateFunction (PropertyTag tag)
+ {
+ /*
+ * FIXME
+ * This function does almost the same as NewControlFunction.
+ * Consider merging.
+ */
+ string prop_id = tag.PropertyID;
+ Type prop_type = tag.PropertyType;
+ string tag_id = tag.PropertyName; // Real property name used in FinishControlFunction
+
+ controls.Push (prop_type, prop_id, tag_id, ChildrenKind.CONTROLS, null);
+ current_function = new StringBuilder ();
+ functions.Push (current_function);
+ current_function.AppendFormat ("\t\tprivate void __BuildControl_{0} " +
+ "(System.Web.UI.Control __ctrl)\n" +
+ "\t\t{{\n" +
+ "\t\t\tSystem.Web.UI.IParserAccessor __parser " +
+ "= (System.Web.UI.IParserAccessor) __ctrl;\n" , prop_id);
+ }
+
+ // Closing is performed in FinishControlFunction ()
+ private void NewDBColumnFunction (PropertyTag tag)
+ {
+ /*
+ * FIXME
+ * This function also does almost the same as NewControlFunction.
+ * Consider merging.
+ */
+ string prop_id = tag.PropertyID;
+ Type prop_type = tag.PropertyType;
+ string tag_id = tag.PropertyName; // Real property name used in FinishControlFunction
+
+ controls.Push (prop_type, prop_id, tag_id, ChildrenKind.DBCOLUMNS, null);
+ current_function = new StringBuilder ();
+ functions.Push (current_function);
+ current_function.AppendFormat ("\t\tprivate void __BuildControl_{0} " +
+ "(System.Web.UI.WebControls.DataGridColumnCollection __ctrl)\n" +
+ "\t\t{{\n", prop_id);
+ }
+
+ private void NewPropertyFunction (PropertyTag tag)
+ {
+ if (tag.PropertyType == typeof (System.Web.UI.WebControls.Style) ||
+ tag.PropertyType.IsSubclassOf (typeof (System.Web.UI.WebControls.Style)))
+ NewStyleFunction (tag);
+ else if (tag.PropertyType == typeof (System.Web.UI.ITemplate))
+ NewTemplateFunction (tag);
+ else if (tag.PropertyType == typeof (System.Web.UI.WebControls.DataGridColumnCollection))
+ NewDBColumnFunction (tag);
+ else
+ throw new ApplicationException ("Other than Style and ITemplate not supported yet. " +
+ tag.PropertyType);
+ }
+
+ private void ProcessHtmlTag ()
+ {
+ Tag tag = (Tag) elements.Current;
+ ChildrenKind child_kind = controls.PeekChildKind ();
+ if (child_kind == ChildrenKind.NONE){
+ string tag_id = controls.PeekTagID ();
+ throw new ApplicationException (tag + " not allowed inside " + tag_id);
+ }
+
+ if (child_kind == ChildrenKind.OPTION){
+ if (0 != String.Compare (tag.TagID, "option", true))
+ throw new ApplicationException ("Only <option> tags allowed inside <select>.");
+
+ string default_id = Tag.GetDefaultID ();
+ Type type = typeof (System.Web.UI.WebControls.ListItem);
+ AddProtectedField (type, default_id);
+ NewControlFunction (tag.TagID, default_id, type, ChildrenKind.CONTROLS, null);
+ return;
+ }
+
+ if (child_kind == ChildrenKind.CONTROLS) {
+ ArrayList tag_elements = tag.GetElements ();
+ foreach (Element e in tag_elements) {
+ if (e is PlainText) {
+ elements.Current = e;
+ ProcessPlainText ();
+ } else if (e is CodeRenderTag) {
+ elements.Current = e;
+ ProcessCodeRenderTag ();
+ } else if (e is DataBindingTag) {
+ elements.Current = e;
+ ProcessDataBindingLiteral ();
+ } else {
+ throw new ApplicationException (fullPath + ": unexpected tag type " + e.GetType ());
+ }
+ }
+ return;
+ }
+
+ if (child_kind == ChildrenKind.HTMLROW) {
+ if (0 == String.Compare (tag.TagID, "tr", true)) {
+ elements.Current = new HtmlControlTag (tag);
+ ProcessHtmlControlTag ();
+ return;
+ }
+ }
+
+ if (child_kind == ChildrenKind.HTMLCELL) {
+ if (0 == String.Compare (tag.TagID, "td", true)) {
+ elements.Current = new HtmlControlTag (tag);
+ ProcessHtmlControlTag ();
+ return;
+ }
+ }
+
+ // Now child_kind should be PROPERTIES, so only allow tag_id == property
+ Type control_type = controls.PeekType ();
+ PropertyInfo [] prop_info = control_type.GetProperties ();
+ bool is_processed = false;
+ foreach (PropertyInfo prop in prop_info){
+ if (0 == String.Compare (prop.Name, tag.TagID, true)){
+ PropertyTag prop_tag = new PropertyTag (tag, prop.PropertyType, prop.Name);
+ NewPropertyFunction (prop_tag);
+ is_processed = true;
+ break;
+ }
+ }
+
+ if (!is_processed){
+ string tag_id = controls.PeekTagID ();
+ throw new ApplicationException (tag.TagID + " is not a property of " + control_type);
+ }
+ }
+
+ private Tag Map (Tag tag)
+ {
+ int pos = tag.TagID.IndexOf (":");
+ if (pos == -1) {
+ ChildrenKind child_kind = controls.PeekChildKind ();
+ if (child_kind == ChildrenKind.HTMLROW && 0 == String.Compare (tag.TagID, "tr", true)) {
+ tag.Attributes.Add ("runat", "server");
+ return new HtmlControlTag (tag);
+ } else if (child_kind == ChildrenKind.HTMLROW && 0 == String.Compare (tag.TagID, "tr", true)) {
+ tag.Attributes.Add ("runat", "server");
+ return new HtmlControlTag (tag);
+ }
+ }
+
+ if (tag is CloseTag ||
+ ((tag.Attributes == null ||
+ !tag.Attributes.IsRunAtServer ()) && pos == -1))
+ return tag;
+
+ if (pos == -1){
+ if (0 == String.Compare (tag.TagID, "object", true))
+ return new ServerObjectTag (tag);
+
+ return new HtmlControlTag (tag);
+ }
+
+ string foundry_name = tag.TagID.Substring (0, pos);
+ string component_name = tag.TagID.Substring (pos + 1);
+
+ if (Foundry.LookupFoundry (foundry_name) == false)
+ throw new ApplicationException ("Cannot find foundry for alias'" + foundry_name + "'");
+
+ AspComponent component = Foundry.MakeAspComponent (foundry_name, component_name, tag);
+ if (component == null)
+ throw new ApplicationException ("Cannot find component '" + component_name +
+ "' for alias '" + foundry_name + "'");
+
+ return component;
+ }
+
+ private void ProcessCloseTag ()
+ {
+ CloseTag close_tag = (CloseTag) elements.Current;
+ if (FinishControlFunction (close_tag.TagID))
+ return;
+
+ elements.Current = new PlainText (close_tag.PlainHtml);
+ ProcessPlainText ();
+ }
+
+ private void ProcessDataBindingLiteral ()
+ {
+ DataBindingTag dataBinding = (DataBindingTag) elements.Current;
+ string actual_value = dataBinding.Data;
+ if (actual_value == "")
+ throw new ApplicationException ("Empty data binding tag.");
+
+ if (controls.PeekChildKind () != ChildrenKind.CONTROLS)
+ throw new ApplicationException ("Data bound content not allowed for " +
+ controls.PeekTagID ());
+
+ StringBuilder db_function = new StringBuilder ();
+ string control_id = Tag.GetDefaultID ();
+ string control_type_string = "System.Web.UI.DataBoundLiteralControl";
+ AddProtectedField (typeof (System.Web.UI.DataBoundLiteralControl), control_id);
+ // Build the control
+ db_function.AppendFormat ("\t\tprivate System.Web.UI.Control __BuildControl_{0} ()\n" +
+ "\t\t{{\n\t\t\t{1} __ctrl;\n\n" +
+ "\t\t\t__ctrl = new {1} (0, 1);\n" +
+ "\t\t\tthis.{0} = __ctrl;\n" +
+ "\t\t\t__ctrl.DataBinding += new System.EventHandler " +
+ "(this.__DataBind_{0});\n" +
+ "\t\t\treturn __ctrl;\n"+
+ "\t\t}}\n\n",
+ control_id, control_type_string);
+ // DataBinding handler
+ db_function.AppendFormat ("\t\tpublic void __DataBind_{0} (object sender, " +
+ "System.EventArgs e) {{\n" +
+ "\t\t\t{1} Container;\n" +
+ "\t\t\t{2} target;\n" +
+ "\t\t\ttarget = ({2}) sender;\n" +
+ "\t\t\tContainer = ({1}) target.BindingContainer;\n" +
+ "\t\t\ttarget.SetDataBoundString (0, System.Convert." +
+ "ToString ({3}));\n" +
+ "\t\t}}\n\n",
+ control_id, controls.Container, control_type_string,
+ actual_value);
+
+ init_funcs.Append (db_function);
+ current_function.AppendFormat ("\t\t\tthis.__BuildControl_{0} ();\n\t\t\t__parser." +
+ "AddParsedSubObject (this.{0});\n\n", control_id);
+
+ AddCodeRenderControl (controls.CodeRenderFunction);
+ }
+
+ private void ProcessCodeRenderTag ()
+ {
+ CodeRenderTag code_tag = (CodeRenderTag) elements.Current;
+
+ controls.UseCodeRender = true;
+ if (code_tag.IsVarName)
+ controls.CodeRenderFunction.AppendFormat ("\t\t\t__output.Write ({0});\n",
+ code_tag.Code);
+ else
+ controls.CodeRenderFunction.AppendFormat ("\t\t\t{0}\n", code_tag.Code);
+ }
+
+ public void ProcessElements ()
+ {
+ JustDoIt ();
+ End ();
+ parse_ok = true;
+ }
+
+ private void JustDoIt ()
+ {
+ Element element;
+
+ while (elements.MoveNext ()){
+ element = (Element) elements.Current;
+ if (element is Directive){
+ ProcessDirective ();
+ } else if (element is PlainText){
+ ProcessPlainText ();
+ } else if (element is DataBindingTag){
+ if (IsApplication)
+ throw new ApplicationException (app_file_wrong);
+ ProcessDataBindingLiteral ();
+ } else if (element is CodeRenderTag){
+ if (IsApplication)
+ throw new ApplicationException (app_file_wrong);
+ ProcessCodeRenderTag ();
+ } else {
+ elements.Current = Map ((Tag) element);
+ if (elements.Current is ServerObjectTag) {
+ ProcessServerObjectTag ();
+ continue;
+ }
+
+ if (elements.Current is HtmlControlTag) {
+ ProcessHtmlControlTag ();
+ continue;
+ }
+
+ if (IsApplication)
+ throw new ApplicationException (app_file_wrong);
+
+ else if (elements.Current is AspComponent)
+ ProcessComponent ();
+ else if (elements.Current is CloseTag)
+ ProcessCloseTag ();
+ else if (elements.Current is Tag)
+ ProcessHtmlTag ();
+ else
+ throw new ApplicationException ("This place should not be reached.");
+ }
+ }
+ }
+
+ private string GetTemplateDirectory ()
+ {
+ string templatePath = Path.GetDirectoryName (fullPath);
+ string appPath = Path.GetDirectoryName (HttpRuntime.AppDomainAppPath);
+
+ if (templatePath == appPath)
+ return "/";
+
+ templatePath = templatePath.Substring (appPath.Length);
+ if (Path.DirectorySeparatorChar != '/')
+ templatePath = templatePath.Replace (Path.DirectorySeparatorChar, '/');
+
+ return templatePath;
+ }
+
+ private void End ()
+ {
+ if (isPage) {
+ if (sessionState == SessionState.Enabled || sessionState == SessionState.ReadOnly)
+ AddInterface (typeof (System.Web.SessionState.IRequiresSessionState));
+
+ if (sessionState == SessionState.ReadOnly)
+ AddInterface (typeof (System.Web.SessionState.IReadOnlySessionState));
+ }
+
+ classDecl = "\tpublic class " + className + " : " + parent + interfaces + " {\n";
+ prolog.Append ("\n" + classDecl);
+ declarations.Append ("\t\tprivate static bool __intialized = false;\n\n");
+ if (IsPage)
+ declarations.Append ("\t\tprivate static ArrayList __fileDependencies;\n\n");
+
+ // adds the constructor
+ constructor.AppendFormat ("\t\tpublic {0} ()\n\t\t{{\n", className);
+ if (!IsApplication)
+ constructor.Append ("\t\t\tSystem.Collections.ArrayList dependencies;\n\n");
+
+ constructor.AppendFormat ("\t\t\tif (ASP.{0}.__intialized == false){{\n", className);
+
+ if (IsPage) {
+ constructor.AppendFormat ("\t\t\t\tdependencies = new System.Collections.ArrayList ();\n" +
+ "\t\t\t\tdependencies.Add (@\"{1}\");\n" +
+ "\t\t\t\tASP.{0}.__fileDependencies = dependencies;\n",
+ className, fullPath);
+ }
+
+ constructor.AppendFormat ("\t\t\t\tASP.{0}.__intialized = true;\n\t\t\t}}\n\t\t}}\n\n",
+ className);
+
+ if (!IsApplication) {
+ //FIXME: add AutoHandlers: don't know what for...yet!
+ constructor.AppendFormat (
+ "\t\tprotected override int AutoHandlers\n\t\t{{\n" +
+ "\t\t\tget {{ return ASP.{0}.__autoHandlers; }}\n" +
+ "\t\t\tset {{ ASP.{0}.__autoHandlers = value; }}\n" +
+ "\t\t}}\n\n", className);
+
+ constructor.Append (
+ "\t\tprotected System.Web.HttpApplication ApplicationInstance\n\t\t{\n" +
+ "\t\t\tget { return (System.Web.HttpApplication) this.Context.ApplicationInstance; }\n" +
+ "\t\t}\n\n");
+
+ constructor.AppendFormat (
+ "\t\tpublic override string TemplateSourceDirectory\n\t\t{{\n" +
+ "\t\t\tget {{ return \"{0}\"; }}\n" +
+ "\t\t}}\n\n", GetTemplateDirectory ());
+
+ epilog.Append ("\n\t\tprotected override void FrameworkInitialize ()\n\t\t{\n" +
+ "\t\t\tthis.__BuildControlTree (this);\n");
+
+ if (IsPage) {
+ epilog.AppendFormat ("\t\t\tthis.FileDependencies = ASP.{0}.__fileDependencies;\n" +
+ "\t\t\tthis.EnableViewStateMac = true;\n", className);
+ }
+
+ epilog.Append ("\t\t}\n\n");
+ }
+
+ if (IsPage) {
+ Random rnd = new Random ();
+ epilog.AppendFormat ("\t\tpublic override int GetTypeHashCode ()\n\t\t{{\n" +
+ "\t\t\treturn {0};\n" +
+ "\t\t}}\n", rnd.Next ());
+ }
+
+ epilog.Append ("\t}\n}\n");
+
+ // Closes the currently opened tags
+ StringBuilder old_function = current_function;
+ string control_id;
+ while (functions.Count > 1){
+ old_function.Append ("\n\t\t\treturn __ctrl;\n\t\t}\n\n");
+ init_funcs.Append (old_function);
+ control_id = controls.PeekControlID ();
+ FinishControlFunction (control_id);
+ controls.AddChild ();
+ old_function = (StringBuilder) functions.Pop ();
+ current_function = (StringBuilder) functions.Peek ();
+ controls.Pop ();
+ }
+
+ bool useCodeRender = controls.UseCodeRender;
+ if (useCodeRender){
+ RemoveLiterals (current_function);
+ AddRenderMethodDelegate (current_function, controls.PeekControlID ());
+ }
+
+ current_function.Append ("\t\t}\n\n");
+ init_funcs.Append (current_function);
+ if (useCodeRender)
+ AddCodeRenderFunction (controls.CodeRenderFunction.ToString (), controls.PeekControlID ());
+
+ functions.Pop ();
+ }
+
+ //
+ // Functions related to compilation of user controls
+ //
+
+ private static char dirSeparator = Path.DirectorySeparatorChar;
+ struct UserControlData
+ {
+ public UserControlResult result;
+ public string className;
+ public string assemblyName;
+ }
+
+ private static UserControlData GenerateUserControl (string src, HttpContext context)
+ {
+ UserControlData data = new UserControlData ();
+ data.result = UserControlResult.OK;
+
+ UserControlCompiler compiler = new UserControlCompiler (new UserControlParser (src, context));
+ Type t = compiler.GetCompiledType ();
+ if (t == null) {
+ data.result = UserControlResult.CompilationFailed;
+ return data;
+ }
+
+ data.className = t.Name;
+ data.assemblyName = compiler.TargetFile;
+
+ return data;
+ }
+}
+
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/AspParser.cs b/mcs/class/System.Web/System.Web.Compilation/AspParser.cs
new file mode 100644
index 00000000000..f35ddfc52c9
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/AspParser.cs
@@ -0,0 +1,277 @@
+//
+// System.Web.Compilation.AspParser
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+
+namespace System.Web.Compilation
+{
+ class AspParser {
+ private AspTokenizer tokenizer;
+ private ArrayList elements; // List of processed elements in the HTML page.
+
+ private void error ()
+ {
+ throw new HttpException ("Error parsing: " + tokenizer.location);
+ }
+
+ private void error (string msg)
+ {
+ throw new Exception ("Error: "+ msg + "\n" + tokenizer.location);
+ }
+
+ public AspParser (AspTokenizer tokenizer)
+ {
+ this.tokenizer = tokenizer;
+ elements = new ArrayList ();
+ }
+
+ public AspParser (string filename, Stream input) :
+ this (new AspTokenizer (filename, input))
+ {
+ }
+
+ public ArrayList Elements
+ {
+ get { return elements; }
+ }
+
+ private bool Eat (int expected_token)
+ {
+ if (tokenizer.get_token () != expected_token) {
+ tokenizer.put_back ();
+ return false;
+ }
+ return true;
+ }
+
+ private void AddPlainText (string newText)
+ {
+ if (elements.Count > 0){
+ Element element = (Element) elements [elements.Count - 1];
+ if (element is PlainText){
+ ((PlainText) element).Append (newText);
+ return;
+ }
+ }
+ elements.Add (new PlainText (newText));
+ }
+
+ public void Parse ()
+ {
+ int token;
+ Element element;
+ Tag tag_element;
+ string tag = "";
+
+ while ((token = tokenizer.get_token ()) != Token.EOF){
+ if (tokenizer.Verbatim){
+ string end_verbatim = "</" + tag + ">";
+ string verbatim_text = GetVerbatim (token, end_verbatim);
+
+ if (verbatim_text == null)
+ error ("Unexpected EOF processing " + tag);
+
+ AddPlainText (verbatim_text);
+ elements.Add (new CloseTag (tag));
+ tokenizer.Verbatim = false;
+ }
+ else if (token == '<') {
+ element = GetTag ();
+ if (element == null)
+ error ();
+
+ if (element is ServerComment)
+ continue;
+
+ if (!(element is Tag)){
+ AddPlainText (((PlainText) element).Text);
+ continue;
+ }
+
+ elements.Add (element);
+
+ tag_element = element as Tag;
+ tag = tag_element.TagID.ToUpper ();
+ if (!tag_element.SelfClosing && (tag == "SCRIPT" || tag == "PRE"))
+ tokenizer.Verbatim = true;
+ }
+ else {
+ StringBuilder text = new StringBuilder ();
+ do {
+ text.Append (tokenizer.value);
+ token = tokenizer.get_token ();
+ } while (token != '<' && token != Token.EOF);
+ tokenizer.put_back ();
+ AddPlainText (text.ToString ());
+ }
+ }
+ }
+
+ private Element GetTag ()
+ {
+ int token = tokenizer.get_token ();
+ string id;
+
+ switch (token){
+ case '%':
+ return GetServerTag ();
+ case '/':
+ if (!Eat (Token.IDENTIFIER))
+ error ("expecting TAGNAME");
+ id = tokenizer.value;
+ if (!Eat ('>'))
+ error ("expecting '>'");
+ return new CloseTag (id);
+ case '!':
+ bool double_dash = Eat (Token.DOUBLEDASH);
+ if (double_dash)
+ tokenizer.put_back ();
+
+ tokenizer.Verbatim = true;
+ string end = double_dash ? "-->" : ">";
+ string comment = GetVerbatim (tokenizer.get_token (), end);
+ tokenizer.Verbatim = false;
+ if (comment == null)
+ error ("Unfinished HTML comment/DTD");
+
+ return new PlainText ("<!" + comment + end);
+ case Token.IDENTIFIER:
+ id = tokenizer.value;
+ Tag tag = new Tag (id, GetAttributes (), Eat ('/'));
+ if (!Eat ('>'))
+ error ("expecting '>'");
+ return tag;
+ default:
+ return null;
+ }
+ }
+
+ private TagAttributes GetAttributes ()
+ {
+ int token;
+ TagAttributes attributes;
+ string id;
+
+ attributes = new TagAttributes ();
+ while ((token = tokenizer.get_token ()) != Token.EOF){
+ if (token != Token.IDENTIFIER)
+ break;
+ id = tokenizer.value;
+ if (Eat ('=')){
+ if (Eat (Token.ATTVALUE)){
+ attributes.Add (id, tokenizer.value);
+ } else {
+ //TODO: support data binding syntax without quotes
+ error ("expected ATTVALUE");
+ return null;
+ }
+
+ } else {
+ attributes.Add (id, null);
+ }
+ }
+
+ tokenizer.put_back ();
+ if (attributes.Count == 0)
+ return null;
+
+ return attributes;
+ }
+
+ private string GetVerbatim (int token, string end)
+ {
+ StringBuilder vb_text = new StringBuilder ();
+ int i = 0;
+
+ if (tokenizer.value.Length > 1){
+ // May be we have a put_back token that is not a single character
+ vb_text.Append (tokenizer.value);
+ token = tokenizer.get_token ();
+ }
+
+ while (token != Token.EOF){
+ if (Char.ToUpper ((char) token) == end [i]){
+ if (++i >= end.Length)
+ break;
+ token = tokenizer.get_token ();
+ continue;
+ }
+ else {
+ for (int j = 0; j < i; j++)
+ vb_text.Append (end [j]);
+ }
+
+ i = 0;
+ vb_text.Append ((char) token);
+ token = tokenizer.get_token ();
+ }
+
+ if (token == Token.EOF)
+ return null;
+
+ return RemoveComments (vb_text.ToString ());
+ }
+
+ private string RemoveComments (string text)
+ {
+ int end;
+ int start = text.IndexOf ("<%--");
+
+ while (start != -1) {
+ end = text.IndexOf ("--%>");
+ if (end == -1 || end <= start + 1)
+ break;
+
+ text = text.Remove (start, end - start + 4);
+ start = text.IndexOf ("<%--");
+ }
+
+ return text;
+ }
+
+ private Element GetServerTag ()
+ {
+ string id;
+ string inside_tags;
+ TagAttributes attributes;
+
+ if (Eat ('@')){
+ id = (Eat (Token.DIRECTIVE) ? tokenizer.value : "Page");
+ attributes = GetAttributes ();
+ if (!Eat ('%') || !Eat ('>'))
+ error ("expecting '%>'");
+
+ return new Directive (id, attributes);
+ } else if (Eat (Token.DOUBLEDASH)) {
+ tokenizer.Verbatim = true;
+ inside_tags = GetVerbatim (tokenizer.get_token (), "--%>");
+ tokenizer.Verbatim = false;
+ return new ServerComment ("<%--" + inside_tags + "--%>");
+ }
+
+ bool varname;
+ bool databinding;
+ varname = Eat ('=');
+ databinding = !varname && Eat ('#');
+
+ tokenizer.Verbatim = true;
+ inside_tags = GetVerbatim (tokenizer.get_token (), "%>");
+ tokenizer.Verbatim = false;
+ if (databinding)
+ return new DataBindingTag (inside_tags);
+
+ return new CodeRenderTag (varname, inside_tags);
+ }
+
+ }
+
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/AspTokenizer.cs b/mcs/class/System.Web/System.Web.Compilation/AspTokenizer.cs
new file mode 100644
index 00000000000..0b72bef93dd
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/AspTokenizer.cs
@@ -0,0 +1,215 @@
+//
+// System.Web.Compilation.AspTokenizer
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+
+namespace System.Web.Compilation {
+
+ class Token
+ {
+ public const int EOF = 0;
+ public const int IDENTIFIER = 1000;
+ public const int DIRECTIVE = 1001;
+ public const int ATTVALUE = 1002;
+ public const int TEXT = 1003;
+ public const int DOUBLEDASH = 1004;
+ public const int CLOSING = 1005;
+ }
+
+ class AspTokenizer {
+ private StreamReader sr;
+ private int current_token;
+ private StringBuilder sb;
+ private int col, line;
+ private bool inTag;
+ private bool hasPutBack;
+ private bool verbatim;
+ private string filename;
+
+ public AspTokenizer (string filename, Stream stream)
+ {
+ if (filename == null || stream == null)
+ throw new ArgumentNullException ();
+
+ this.sr = new StreamReader (stream);
+ this.filename = filename;
+ sb = new StringBuilder ();
+ col = line = 1;
+ hasPutBack = inTag = false;
+ }
+
+ public bool Verbatim
+ {
+ get { return verbatim; }
+ set { verbatim = value; }
+ }
+
+ public void put_back ()
+ {
+ if (hasPutBack)
+ throw new ApplicationException ("put_back called twice!");
+
+ hasPutBack = true;
+ }
+
+ public int get_token ()
+ {
+ if (hasPutBack){
+ hasPutBack = false;
+ return current_token;
+ }
+
+ current_token = NextToken ();
+ return current_token;
+ }
+
+ bool is_identifier_start_character (char c)
+ {
+ return (Char.IsLetter (c) || c == '_' );
+ }
+
+ bool is_identifier_part_character (char c)
+ {
+ return (Char.IsLetterOrDigit (c) || c == '_' || c == '-');
+ }
+
+ private int read_char ()
+ {
+ int c = sr.Read ();
+
+ if (c == '\r' && sr.Peek () == '\n')
+ c = sr.Read ();
+
+ if (c == '\n'){
+ col = 0;
+ line++;
+ }
+ else if (c != -1)
+ col++;
+
+ return c;
+ }
+
+ private int NextToken ()
+ {
+ int c;
+
+ sb.Length = 0;
+ while ((c = read_char ()) != -1){
+ if (verbatim){
+ inTag = false;
+ sb.Append ((char) c);
+ return c;
+ }
+
+ if (inTag && (c == '"' || c == '\'')){
+ int previous;
+ int start = c;
+
+ previous = 0;
+ while ((c = sr.Peek ()) != -1) {
+ if (c == start && previous != '\\'){
+ read_char ();
+ break;
+ }
+ sb.Append ((char) read_char ());
+ previous = c;
+ }
+
+ return Token.ATTVALUE;
+ }
+
+ if (c == '<'){
+ inTag = true;
+ sb.Append ((char) c);
+ return c;
+ }
+
+ if (c == '>'){
+ inTag = false;
+ sb.Append ((char) c);
+ return c;
+ }
+
+ if (current_token == '<' && "%/!".IndexOf ((char) c) != -1){
+ sb.Append ((char) c);
+ return c;
+ }
+
+ if (inTag && current_token == '%' && "@#=".IndexOf ((char) c) != -1){
+ sb.Append ((char) c);
+ return c;
+ }
+
+ if (inTag && c == '-' && sr.Peek () == '-'){
+ sb.Append ("--");
+ read_char ();
+ return Token.DOUBLEDASH;
+ }
+
+ if (!inTag){
+ sb.Append ((char) c);
+ while ((c = sr.Peek ()) != -1 && c != '<')
+ sb.Append ((char) read_char ());
+
+ return (c != -1 || sb.Length > 0) ? Token.TEXT : Token.EOF;
+ }
+
+ if (inTag && current_token == '=' && !Char.IsWhiteSpace ((char) c)){
+ sb.Append ((char) c);
+ while ((c = sr.Peek ()) != -1) {
+ if (Char.IsWhiteSpace ((char) c) || c == '/' || c == '>')
+ break;
+ sb.Append ((char) read_char ());
+ }
+
+ return Token.ATTVALUE;
+ }
+
+ if (inTag && is_identifier_start_character ((char) c)){
+ sb.Append ((char) c);
+ while ((c = sr.Peek ()) != -1) {
+ if (!is_identifier_part_character ((char) c) && c != ':')
+ break;
+ sb.Append ((char) read_char ());
+ }
+
+ if (current_token == '@' && Directive.IsDirectiveID (sb.ToString ()))
+ return Token.DIRECTIVE;
+
+ return Token.IDENTIFIER;
+ }
+
+ if (!Char.IsWhiteSpace ((char) c))
+ return c;
+ }
+
+ return Token.EOF;
+ }
+
+ public string value
+ {
+ get { return sb.ToString (); }
+ }
+
+ public string location
+ {
+ get {
+ string msg = filename;
+ msg += " (" + line + ", " + col + "): " + sb.ToString ();
+ return msg;
+ }
+ }
+
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs
new file mode 100644
index 00000000000..81535529e51
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs
@@ -0,0 +1,114 @@
+//
+// System.Web.Compilation.BaseCompiler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+
+namespace System.Web.Compilation
+{
+ abstract class BaseCompiler
+ {
+ //FIXME: configurable?
+ static string default_assemblies = "System.Web.dll, System.Data.dll, System.Drawing.dll";
+ static Random rnd = new Random ((int) DateTime.Now.Ticks);
+ string randomName;
+ protected Hashtable options;
+
+ protected BaseCompiler ()
+ {
+ }
+
+ public virtual Type GetCompiledType ()
+ {
+ return null;
+ }
+
+ public virtual string Key {
+ get {
+ return null;
+ }
+ }
+
+ public virtual string SourceFile {
+ get {
+ return null;
+ }
+ }
+
+ public virtual string [] Dependencies {
+ get {
+ return null;
+ }
+ }
+
+ public virtual string CompilerOptions {
+ get {
+ string assemblies = default_assemblies;
+ string privatePath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;
+ //FIXME: remove the next line once multiple appdomains can work together
+ if (privatePath == null) privatePath = "bin";
+ //
+ if (privatePath != null && Directory.Exists (privatePath)) {
+ StringBuilder sb = new StringBuilder (assemblies);
+ foreach (string fileName in Directory.GetFiles (privatePath, "*.dll"))
+ sb.AppendFormat (", {0}", fileName);
+ assemblies = sb.ToString ();
+ sb = null;
+ }
+
+ string [] split = assemblies.Split (',');
+ StringBuilder result = new StringBuilder ();
+ foreach (string assembly in split)
+ result.AppendFormat ("/r:{0} ", assembly.TrimStart ());
+
+ if (options == null)
+ return result.ToString ();
+
+ string compilerOptions = options ["CompilerOptions"] as string;
+ if (compilerOptions != null) {
+ result.Append (' ');
+ result.Append (compilerOptions);
+ }
+
+ string references = options ["References"] as string;
+ if (references == null)
+ return result.ToString ();
+
+ split = references.Split (' ');
+ foreach (string s in split)
+ result.AppendFormat (" /r:{0}", s);
+
+ return result.ToString ();
+ }
+ }
+
+ static string GetRandomFileName ()
+ {
+ string output;
+
+ do {
+ output = "tmp" + rnd.Next () + ".dll";
+ } while (File.Exists (output));
+
+ return output;
+ }
+
+ public virtual string TargetFile {
+ get {
+ if (randomName == null)
+ randomName = GetRandomFileName ();
+
+ return randomName;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/CachingCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/CachingCompiler.cs
new file mode 100644
index 00000000000..14708e4d469
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/CachingCompiler.cs
@@ -0,0 +1,156 @@
+//
+// System.Web.Compilation.CachingCompiler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using System.Web.UI;
+using System.Web.Util;
+
+namespace System.Web.Compilation
+{
+ //TODO: caching should be done using System.Web.Caching, but that namespace still need some work.
+ internal class CompilationCacheItem
+ {
+ CompilationResult result;
+ DateTime time;
+
+ public CompilationCacheItem (CompilationResult result, DateTime time)
+ {
+ this.result = result;
+ this.time = time;
+ }
+
+ public bool CheckDependencies (string [] newDependencies, DateTime time)
+ {
+ // FIXME
+ return true;
+ }
+
+ public CompilationResult Result
+ {
+ get { return result; }
+ }
+ }
+
+ internal class CompilationCache
+ {
+ static Hashtable cache;
+ static CompilationCache instance = new CompilationCache ();
+
+ private CompilationCache ()
+ {
+ }
+
+ static CompilationCache ()
+ {
+ cache = new Hashtable ();
+ }
+
+ public static CompilationCache GetInstance ()
+ {
+ return instance;
+ }
+
+ public CompilationCacheItem this [string key]
+ {
+ get {
+ return cache [key] as CompilationCacheItem;
+ }
+
+ set {
+ cache [key] = value;
+ }
+ }
+ }
+
+ internal class CachingCompiler
+ {
+ static CompilationCache cache = CompilationCache.GetInstance ();
+ string key;
+ BaseCompiler compiler;
+
+ public CachingCompiler (BaseCompiler compiler)
+ {
+ this.compiler = compiler;
+ this.key = compiler.Key;
+ }
+
+ public static CompilationCacheItem GetCached (string key)
+ {
+ if (key == null)
+ throw new ArgumentNullException ("key");
+
+ CompilationCacheItem item = cache [key];
+ return item;
+ }
+
+ static object compilationLock = new object ();
+ public bool Compile (CompilationResult result)
+ {
+ if (compiler.SourceFile == null)
+ throw new ArgumentException ("No source to compile!");
+
+ result.Reset ();
+ CompilationCacheItem item;
+
+ item = GetCached (key);
+ if (item != null) {
+ if (item.CheckDependencies (compiler.Dependencies, DateTime.Now) == true) {
+ result.CopyFrom (item.Result);
+ return true;
+ }
+ }
+
+ lock (compilationLock) {
+ item = GetCached (key);
+ if (item != null) {
+ if (item.CheckDependencies (compiler.Dependencies, DateTime.Now) == true) {
+ result.CopyFrom (item.Result);
+ return true;
+ }
+ }
+
+ RealCompile (result);
+ cache [key] = new CompilationCacheItem (result, DateTime.Now);
+ }
+
+ return (result.ExitCode == 0);
+ }
+
+ void RealCompile (CompilationResult result)
+ {
+ StringBuilder options = new StringBuilder ("/target:library ");
+ if (compiler.CompilerOptions != null)
+ options.Append (compiler.CompilerOptions + ' ');
+
+ options.AppendFormat ("/out:{0} ", compiler.TargetFile);
+ options.Append (compiler.SourceFile);
+
+ Process proc = new Process ();
+ proc.StartInfo.FileName = "mcs";
+ proc.StartInfo.Arguments = options.ToString ();
+ proc.StartInfo.UseShellExecute = false;
+ proc.StartInfo.RedirectStandardOutput = true;
+
+ WebTrace.WriteLine ("{0} {1}", proc.StartInfo.FileName, options.ToString ());
+ proc.Start ();
+ string poutput = proc.StandardOutput.ReadToEnd();
+ proc.WaitForExit ();
+ result.ExitCode = proc.ExitCode;
+ proc.Close ();
+ proc = null;
+
+ result.CompilerOutput = poutput;
+ result.OutputFile = compiler.TargetFile;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/ChangeLog b/mcs/class/System.Web/System.Web.Compilation/ChangeLog
new file mode 100644
index 00000000000..47cad3355a4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/ChangeLog
@@ -0,0 +1,231 @@
+
+2003-01-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: modified loading of the parent type now that
+ Type.GetType is fixed.
+
+2003-01-10 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: cast to Control if the container does not implement
+ INamingContainer.
+
+2003-01-10 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: fixed a couple of thinkos related to IsSubclassOf.
+
+2003-01-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspElements.cs: attributes without value lacked a space afterwards.
+
+2003-01-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: functions for columns don't return anything. Fixed
+ typo.
+
+2003-01-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: add data bound controls to code render function.
+
+2003-01-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspComponentFoundry.cs: reworked to allow same prefix for multiple
+ controls. You can register 1 assembly plus any number of user controls
+ under the same prefix.
+
+ * AspGenerator.cs: don't add duplicate 'using' for the same namespace.
+ Hack to allow @Register access to assemblies in other places than bin
+ directory.
+
+2003-01-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspElements.cs: added 'codebehind' attribute for page, control and
+ application. It's ignored by MS, but allowed. Fixed typo.
+
+2003-01-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: fixed EnableSesssionState handling.
+
+2003-01-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: don't generate instance fields for pages/controls
+ when the base class specified in the Inherits attribute already has
+ them. Closes bug #36262.
+
+2002-12-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: generate code like 'control.XXX = value' also for
+ public fields (properties were being handled in that way too).
+
+2002-12-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: now it uses the current HttpContext when creating
+ user controls. TemplateSourceDirectory is no longer a dummy value.
+
+ * GlobalAsaxCompiler.cs:
+ * PageCompiler.cs:
+ * UserControlCompiler.cs: set the context which will be used to locate
+ the files.
+
+2002-12-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: added support for AutoEventWireup attribute in
+ @Page and @Control.
+
+ * CompilationResult.cs:
+ * GlobalAsaxCompiler.cs:
+ * PageCompiler.cs:
+ * UserControlCompiler.cs: store the options.
+
+2002-12-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspElements.cs: new method Tag.GetElements
+ used to parse the inner contents of a tag looking for data binding or
+ code render tags.
+
+ New property HtmlControlTag.ParseChildren allows
+ differentiation of a couple of HtmlControls that has children as
+ properties (namely HtmlTable and HtmlTableRow).
+
+ * AspGenerator.cs: fixed container semantics to
+ match BindingContainer one. Implemented Inherits attribute for page and
+ control.
+
+ Support HtmlControls that has ChildrenAsProperties.
+
+ Generate code for data binding functions that matches the semantic of
+ Container.
+
+ Handle data bound and code render attribute values.
+
+ Set proper value return for TemplateSourceDirectory. Should be relative
+ to appPath.
+
+ * BaseCompiler.cs: moved CompilerOptions and
+ References handling here.
+
+ * CachingCompiler.cs: copy result of compilation.
+
+ * CompilationException.cs: simple ToString () implementation.
+
+ * CompilationResult.cs: implemented CopyFrom and ToString.
+
+ * GlobalAsaxCompiler.cs:
+ * PageCompiler.cs:
+ * UserControlCompiler.cs: removed CompilerOptions as it's now handled
+ in the base class. Get all the types in the generated assembly and
+ look for one that derives from the correct Type.
+
+2002-11-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspElements.cs: added @Application directive.
+
+ * AspGenerator.cs: make it work also with application files. We
+ currently generate an extra private function.
+
+2002-11-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * GlobalAsaxCompiler.cs: compiler for global.asax file. If the file
+ exists, it will be compiled into an HttpApplication derived class
+ (directly or through a user-provided class).
+
+2002-11-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: fixed target file name and generated class name.
+ * BaseCompiler.cs: reference assemblies in PrivateBinPath.
+
+2002-11-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: reworked user control
+ compilation. Provide the options as a Hashtable for use in compilation.
+ Create the user controls in the private bin path of the domain.
+
+ * BaseCompiler.cs: base class for the various compiler types.
+
+ * CachingCompiler.cs: actually executes mcs and do some poor caching
+ (it will use Cache when finished).
+
+ * CompilationException.cs: this exception has enough information to
+ generate a nice error page.
+ * CompilationResult.cs: used in caching.
+
+ * PageCompiler.cs: now derives from BaseCompiler
+
+ * TemplateFactory.cs: no longer needed.
+
+ * UserControlCompiler.cs: new class used when compiling user controls.
+ * WebServiceCompiler.cs: derives from BaseCompiler.
+
+2002-11-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspElements.cs: added ServerComment class.
+ * AspParser.cs: ignore ServerComments tags. Remove server comments when
+ in verbatim mode.
+
+ Fixes #33482.
+
+ * PageCompiler.cs: check if the type is already cached before generating
+ the C# file.
+ * TemplateFactory.cs: if csFile parameter is null, only checks if we
+ already have the page compiled.
+
+2002-11-02 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: undo one-liner change.
+
+2002-10-31 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspGenerator.cs: removed a few hacks no longer needed.
+
+2002-10-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * PageCompiler.cs: tracing.
+ * TemplateFactory.cs: cache compiled types and tracing.
+ * WebServiceCompiler.cs: new parameter in GetTypeFromsource,
+
+2002-10-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspComponentFoundry.cs: fixed typo.
+ * TemplateFactory.cs: use csc style options.
+ * AspGenerator.cs: don't use FileDependencies property of base class.
+
+2002-09-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.Compilation/AspElements.cs:
+ * System.Web.Compilation/AspGenerator.cs:
+ * System.Web.Compilation/AspParser.cs:
+ * System.Web.Compilation/PageCompiler.cs:
+ * System.Web.Compilation/TemplateFactory.cs: we are now able to compile
+ pages and use HttpApplication, HttpRuntime and SimpleWorkerRequest.
+
+2002-09-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspElements.cs: added WebService directive.
+ * WebServiceCompiler.cs: New file.
+
+2002-08-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * PageCompiler.cs: fixed compilation.
+
+2002-08-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * PageCompiler.cs: generate C# file using AspGenerator.
+
+2002-08-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspComponentFoundry.cs: LookupFoundry now returns bool.
+ * AspGenerator.cs: New file.
+
+2002-08-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspComponentFoundry.cs: New file.
+ * AspElements.cs: renamed Component to Aspcomponent.
+
+2002-08-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AspElements.cs:
+ * AspParser.cs:
+ * AspTokenizer.cs:
+ * ChangeLog:
+ * PageCompiler.cs:
+ * TemplateFactory.cs: first steps to move xsp into System.Web.
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/CompilationException.cs b/mcs/class/System.Web/System.Web.Compilation/CompilationException.cs
new file mode 100644
index 00000000000..8a4caf8177e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/CompilationException.cs
@@ -0,0 +1,40 @@
+//
+// System.Web.Compilation.CompilationException
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+
+namespace System.Web.Compilation
+{
+ internal class CompilationException : Exception
+ {
+ CompilationResult result;
+
+ public CompilationException (CompilationResult result)
+ {
+ this.result = result;
+ }
+
+ public CompilationException (string msg, CompilationResult result)
+ {
+ this.result = result;
+ }
+
+ public CompilationException (CompilationCacheItem item)
+ {
+ this.result = item.Result;
+ }
+
+ public override string Message {
+ get {
+ return result.ToString ();
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/CompilationResult.cs b/mcs/class/System.Web/System.Web.Compilation/CompilationResult.cs
new file mode 100644
index 00000000000..df04ecba110
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/CompilationResult.cs
@@ -0,0 +1,71 @@
+//
+// System.Web.Compilation.CompilationResult
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+
+namespace System.Web.Compilation
+{
+ internal class CompilationResult
+ {
+ int exitCode;
+ string output;
+ string outputFile;
+ object data;
+ Hashtable options;
+
+ public CompilationResult ()
+ {
+ }
+
+ public void Reset ()
+ {
+ exitCode = 0;
+ output = null;
+ }
+
+ public void CopyFrom (CompilationResult other)
+ {
+ exitCode = other.ExitCode;
+ output = other.output;
+ outputFile = other.outputFile;
+ data = other.data;
+ }
+
+ public int ExitCode {
+ get { return exitCode; }
+ set { exitCode = exitCode; }
+ }
+
+ public string CompilerOutput {
+ get { return output; }
+ set { output = value; }
+ }
+
+ public string OutputFile {
+ get { return outputFile; }
+ set { outputFile = value; }
+ }
+
+ public object Data {
+ get { return data; }
+ set { data = value; }
+ }
+
+ public Hashtable Options {
+ get { return options; }
+ set { options = value; }
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("CompilationResult: {0} {1} {2} {3}", exitCode, output, outputFile, data);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/GlobalAsaxCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/GlobalAsaxCompiler.cs
new file mode 100644
index 00000000000..718f679ee61
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/GlobalAsaxCompiler.cs
@@ -0,0 +1,101 @@
+//
+// System.Web.Compilation.GlobalAsaxCompiler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.IO;
+using System.Reflection;
+using System.Text;
+using System.Web;
+using System.Web.Util;
+
+namespace System.Web.Compilation
+{
+ class GlobalAsaxCompiler : BaseCompiler
+ {
+ string filename;
+ string sourceFile;
+ HttpContext context;
+
+ private GlobalAsaxCompiler (string filename)
+ {
+ this.filename = filename;
+ }
+
+ public override Type GetCompiledType ()
+ {
+ sourceFile = GenerateSourceFile ();
+
+ CachingCompiler compiler = new CachingCompiler (this);
+ CompilationResult result = new CompilationResult ();
+ result.Options = options;
+ if (compiler.Compile (result) == false)
+ throw new CompilationException (result);
+
+ Assembly assembly = Assembly.LoadFrom (result.OutputFile);
+ Type [] types = assembly.GetTypes ();
+ foreach (Type t in types) {
+ if (t.IsSubclassOf (typeof (HttpApplication))) {
+ if (result.Data != null)
+ throw new CompilationException ("More that 1 app!!!", result);
+ result.Data = t;
+ }
+ }
+
+ return result.Data as Type;
+ }
+
+ public override string Key {
+ get {
+ return filename;
+ }
+ }
+
+ public override string SourceFile {
+ get {
+ return sourceFile;
+ }
+ }
+
+ public static Type CompileApplicationType (string filename, HttpContext context)
+ {
+ CompilationCacheItem item = CachingCompiler.GetCached (filename);
+ if (item != null && item.Result != null) {
+ if (item.Result != null)
+ return item.Result.Data as Type;
+
+ throw new CompilationException (item.Result);
+ }
+
+ GlobalAsaxCompiler gac = new GlobalAsaxCompiler (filename);
+ gac.context = context;
+ return gac.GetCompiledType ();
+ }
+
+ string GenerateSourceFile ()
+ {
+ Stream input = File.OpenRead (filename);
+ AspParser parser = new AspParser (filename, input);
+ parser.Parse ();
+ AspGenerator generator = new AspGenerator (filename, parser.Elements);
+ generator.Context = context;
+ generator.BaseType = typeof (HttpApplication).ToString ();
+ generator.ProcessElements ();
+ string generated = generator.GetCode ().ReadToEnd ();
+ options = generator.Options;
+
+ //FIXME: should get Tmp dir for this application
+ string csName = Path.GetTempFileName () + ".cs";
+ WebTrace.WriteLine ("Writing {0}", csName);
+ StreamWriter output = new StreamWriter (File.OpenWrite (csName));
+ output.Write (generated);
+ output.Close ();
+ return csName;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs
new file mode 100644
index 00000000000..2fe1261e948
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/PageCompiler.cs
@@ -0,0 +1,104 @@
+//
+// System.Web.Compilation.PageCompiler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.IO;
+using System.Reflection;
+using System.Text;
+using System.Web.UI;
+using System.Web.Util;
+
+namespace System.Web.Compilation
+{
+ class PageCompiler : BaseCompiler
+ {
+ PageParser pageParser;
+ string sourceFile;
+
+ private PageCompiler (PageParser pageParser)
+ {
+ this.pageParser = pageParser;
+ }
+
+ public override Type GetCompiledType ()
+ {
+ string inputFile = pageParser.InputFile;
+ sourceFile = GenerateSourceFile ();
+
+ CachingCompiler compiler = new CachingCompiler (this);
+ CompilationResult result = new CompilationResult ();
+ result.Options = options;
+ if (compiler.Compile (result) == false)
+ throw new CompilationException (result);
+
+ Assembly assembly = Assembly.LoadFrom (result.OutputFile);
+ Type [] types = assembly.GetTypes ();
+ foreach (Type t in types) {
+ if (t.IsSubclassOf (typeof (Page))) {
+ if (result.Data != null)
+ throw new CompilationException ("More that 1 page!!!", result);
+ result.Data = t;
+ }
+ }
+
+ return result.Data as Type;
+ }
+
+ public override string Key {
+ get {
+ return pageParser.InputFile;
+ }
+ }
+
+ public override string SourceFile {
+ get {
+ return sourceFile;
+ }
+ }
+
+ public static Type CompilePageType (PageParser pageParser)
+ {
+ CompilationCacheItem item = CachingCompiler.GetCached (pageParser.InputFile);
+ if (item != null && item.Result != null) {
+ if (item.Result != null) {
+ pageParser.Options = item.Result.Options;
+ return item.Result.Data as Type;
+ }
+
+ throw new CompilationException (item.Result);
+ }
+
+ PageCompiler pc = new PageCompiler (pageParser);
+ return pc.GetCompiledType ();
+ }
+
+ string GenerateSourceFile ()
+ {
+ string inputFile = pageParser.InputFile;
+
+ Stream input = File.OpenRead (inputFile);
+ AspParser parser = new AspParser (inputFile, input);
+ parser.Parse ();
+ AspGenerator generator = new AspGenerator (inputFile, parser.Elements);
+ generator.Context = pageParser.Context;
+ generator.BaseType = pageParser.BaseType.ToString ();
+ generator.ProcessElements ();
+ pageParser.Text = generator.GetCode ().ReadToEnd ();
+ options = generator.Options;
+
+ //FIXME: should get Tmp dir for this application
+ string csName = Path.GetTempFileName () + ".cs";
+ WebTrace.WriteLine ("Writing {0}", csName);
+ StreamWriter output = new StreamWriter (File.OpenWrite (csName));
+ output.Write (pageParser.Text);
+ output.Close ();
+ return csName;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/UserControlCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/UserControlCompiler.cs
new file mode 100644
index 00000000000..c31d9fdf768
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/UserControlCompiler.cs
@@ -0,0 +1,118 @@
+//
+// System.Web.Compilation.UserControlCompiler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.IO;
+using System.Reflection;
+using System.Web.UI;
+using System.Web.Util;
+
+namespace System.Web.Compilation
+{
+ class UserControlCompiler : BaseCompiler
+ {
+ UserControlParser userControlParser;
+ string sourceFile;
+ string targetFile;
+
+ internal UserControlCompiler (UserControlParser userControlParser)
+ {
+ this.userControlParser = userControlParser;
+ }
+
+ public override Type GetCompiledType ()
+ {
+ string inputFile = userControlParser.InputFile;
+ sourceFile = GenerateSourceFile (userControlParser);
+
+ CachingCompiler compiler = new CachingCompiler (this);
+ CompilationResult result = new CompilationResult ();
+ result.Options = options;
+ if (compiler.Compile (result) == false)
+ throw new CompilationException (result);
+
+ if (result.Data is Type) {
+ targetFile = result.OutputFile;
+ return (Type) result.Data;
+ }
+
+ Assembly assembly = Assembly.LoadFrom (result.OutputFile);
+ Type [] types = assembly.GetTypes ();
+ foreach (Type t in types) {
+ if (t.IsSubclassOf (typeof (UserControl))) {
+ if (result.Data != null)
+ throw new CompilationException ("More that 1 user control!!!", result);
+ result.Data = t;
+ }
+ }
+
+ return result.Data as Type;
+ }
+
+ public override string Key {
+ get {
+ return userControlParser.InputFile;
+ }
+ }
+
+ public override string SourceFile {
+ get {
+ return sourceFile;
+ }
+ }
+
+ public override string TargetFile {
+ get {
+ if (targetFile == null)
+ targetFile = Path.ChangeExtension (sourceFile, ".dll");
+
+ return targetFile;
+ }
+ }
+
+ public static Type CompileUserControlType (UserControlParser userControlParser)
+ {
+ CompilationCacheItem item = CachingCompiler.GetCached (userControlParser.InputFile);
+ if (item != null && item.Result != null) {
+ if (item.Result != null) {
+ userControlParser.Options = item.Result.Options;
+ return item.Result.Data as Type;
+ }
+
+ throw new CompilationException (item.Result);
+ }
+
+ UserControlCompiler pc = new UserControlCompiler (userControlParser);
+ return pc.GetCompiledType ();
+ }
+
+ string GenerateSourceFile (UserControlParser userControlParser)
+ {
+ string inputFile = userControlParser.InputFile;
+
+ Stream input = File.OpenRead (inputFile);
+ AspParser parser = new AspParser (inputFile, input);
+ parser.Parse ();
+ AspGenerator generator = new AspGenerator (inputFile, parser.Elements);
+ generator.Context = userControlParser.Context;
+ generator.BaseType = userControlParser.BaseType.ToString ();
+ generator.ProcessElements ();
+ userControlParser.Text = generator.GetCode ().ReadToEnd ();
+ options = generator.Options;
+
+ //FIXME: should get Tmp dir for this application
+ string csName = Path.GetTempFileName () + ".cs";
+ WebTrace.WriteLine ("Writing {0}", csName);
+ StreamWriter output = new StreamWriter (File.OpenWrite (csName));
+ output.Write (userControlParser.Text);
+ output.Close ();
+ return csName;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Compilation/WebServiceCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/WebServiceCompiler.cs
new file mode 100644
index 00000000000..50e9962fb2f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Compilation/WebServiceCompiler.cs
@@ -0,0 +1,85 @@
+//
+// System.Web.Compilation.WebServiceCompiler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.IO;
+using System.Reflection;
+using System.Web.UI;
+
+namespace System.Web.Compilation
+{
+ class WebServiceCompiler : BaseCompiler
+ {
+ SimpleWebHandlerParser wService;
+ string sourceFile;
+
+ private WebServiceCompiler (SimpleWebHandlerParser wService)
+ {
+ this.wService = wService;
+ }
+
+ public static Type CompileIntoType (SimpleWebHandlerParser wService)
+ {
+ CompilationCacheItem item = CachingCompiler.GetCached (wService.PhysicalPath);
+ if (item != null && item.Result != null) {
+ if (item.Result != null)
+ return item.Result.Data as Type;
+
+ throw new CompilationException (item.Result);
+ }
+
+ WebServiceCompiler wsc = new WebServiceCompiler (wService);
+ return wsc.GetCompiledType ();
+ }
+
+ static string GenerateSourceFile (SimpleWebHandlerParser wService)
+ {
+ //FIXME: should get Tmp dir for this application
+ string csName = Path.GetTempFileName ();
+ StreamWriter output = new StreamWriter (File.OpenWrite (csName));
+ output.Write (wService.Program);
+ output.Close ();
+ return csName;
+ }
+
+ public override Type GetCompiledType ()
+ {
+ sourceFile = GenerateSourceFile (wService);
+
+ CachingCompiler compiler = new CachingCompiler (this);
+ CompilationResult result = new CompilationResult ();
+ if (compiler.Compile (result) == false)
+ throw new CompilationException (result);
+
+ Assembly assembly = Assembly.LoadFrom (result.OutputFile);
+ Type [] types = assembly.GetTypes ();
+ Type type = types [0];
+ if (type.FullName != wService.ClassName)
+ throw new ApplicationException (String.Format (
+ "Class={0}, but the class compiled is {1}",
+ wService.ClassName,
+ type.FullName));
+
+ result.Data = type;
+ return type;
+ }
+
+ public override string Key {
+ get {
+ return wService.PhysicalPath;
+ }
+ }
+
+ public override string SourceFile {
+ get {
+ return sourceFile;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/AuthConfig.cs b/mcs/class/System.Web/System.Web.Configuration/AuthConfig.cs
new file mode 100755
index 00000000000..f8b8f13ccf4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/AuthConfig.cs
@@ -0,0 +1,175 @@
+//
+// System.Web.Configuration.AuthConfig
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.Configuration;
+using System.Xml;
+
+namespace System.Web.Configuration
+{
+ class AuthConfig
+ {
+ AuthenticationMode mode;
+ string cookieName;
+ string cookiePath;
+ string loginUrl;
+ FormsProtectionEnum protection;
+ int timeout;
+ FormsAuthPasswordFormat pwdFormat;
+ Hashtable credentialUsers;
+ bool has_parent;
+
+ internal AuthConfig (object parent)
+ {
+ if (parent is AuthConfig) {
+ has_parent = true;
+ AuthConfig p = (AuthConfig) parent;
+ mode = p.mode;
+ cookieName = p.cookieName;
+ cookiePath = p.cookiePath;
+ loginUrl = p.loginUrl;
+ protection = p.protection;
+ timeout = p.timeout;
+ pwdFormat = p.pwdFormat;
+ credentialUsers = new Hashtable (p.CredentialUsers);
+ }
+ }
+
+ internal void SetMode (string m)
+ {
+ if (m == null) {
+ // we default to Forms authentication mode, MS defaults to Windows
+ if (!has_parent)
+ Mode = AuthenticationMode.Forms;
+ return;
+ }
+
+ Mode = (AuthenticationMode) Enum.Parse (typeof (AuthenticationMode), m, true);
+ }
+
+ internal void SetProtection (string prot)
+ {
+ if (prot == null) {
+ if (!has_parent)
+ Protection = FormsProtectionEnum.All;
+ return;
+ }
+
+ Protection = (FormsProtectionEnum) Enum.Parse (typeof (FormsProtectionEnum),
+ prot,
+ true);
+ }
+
+ internal void SetTimeout (string minutes)
+ {
+ if (minutes != null) {
+ Timeout = Int32.Parse (minutes);
+ return;
+ }
+
+ if (!has_parent)
+ Timeout = 30;
+ }
+
+ internal void SetPasswordFormat (string pwdFormat)
+ {
+ if (pwdFormat == null) {
+ if (!has_parent)
+ PasswordFormat = FormsAuthPasswordFormat.Clear;
+ return;
+ }
+
+ PasswordFormat =
+ (FormsAuthPasswordFormat) Enum.Parse (typeof (FormsAuthPasswordFormat),
+ pwdFormat,
+ true);
+ }
+
+ internal AuthenticationMode Mode {
+ get { return mode; }
+ set { mode = value; }
+ }
+
+ internal string CookieName {
+ get {
+ if (cookieName == null)
+ cookieName = ".ASPXAUTH";
+
+ return cookieName;
+ }
+ set {
+ if (value == null)
+ return;
+
+ cookieName = value;
+ }
+ }
+
+ internal string CookiePath {
+ get {
+ if (cookiePath == null)
+ cookiePath = "/";
+
+ return cookiePath;
+ }
+ set {
+ if (value == null)
+ return;
+
+ cookiePath = value;
+ }
+ }
+
+ internal string LoginUrl {
+ get {
+ if (loginUrl == null)
+ loginUrl = "login.aspx";
+
+ return loginUrl;
+ }
+ set {
+ if (value == null)
+ return;
+
+ loginUrl = value;
+ }
+ }
+
+ internal FormsProtectionEnum Protection {
+ get { return protection; }
+ set { protection = value; }
+ }
+
+ internal int Timeout {
+ get { return timeout; }
+ set {
+ if (value <= 0)
+ throw new ArgumentException ("Timeout must be > 0", "value");
+
+ timeout = value;
+ }
+ }
+
+ internal FormsAuthPasswordFormat PasswordFormat {
+ get { return pwdFormat; }
+ set { pwdFormat = value; }
+ }
+
+ internal Hashtable CredentialUsers {
+ get {
+ if (credentialUsers == null)
+ credentialUsers = new Hashtable ();
+
+ return credentialUsers;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/AuthenticationConfigHandler.cs b/mcs/class/System.Web/System.Web.Configuration/AuthenticationConfigHandler.cs
new file mode 100755
index 00000000000..7abb573b01c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/AuthenticationConfigHandler.cs
@@ -0,0 +1,112 @@
+//
+// System.Web.Configuration.AuthenticationSectionHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.Configuration;
+using System.Xml;
+
+namespace System.Web.Configuration
+{
+ class AuthenticationConfigHandler : IConfigurationSectionHandler
+ {
+ public object Create (object parent, object context, XmlNode section)
+ {
+ //TODO: context?
+ AuthConfig config = new AuthConfig (parent);
+
+ string mode = AttValue ("mode", section);
+ if (mode != null)
+ config.SetMode (mode);
+
+ if (section.Attributes != null && section.Attributes.Count != 0)
+ ThrowException ("Unrecognized attribute", section);
+
+ XmlNodeList authNodes = section.ChildNodes;
+ foreach (XmlNode child in authNodes) {
+ XmlNodeType ntype = child.NodeType;
+ if (ntype != XmlNodeType.Element)
+ continue;
+
+ if (child.Name == "forms") {
+ config.CookieName = AttValue ("name", child, false);
+ config.CookiePath = AttValue ("path", child);
+ config.LoginUrl = AttValue ("loginUrl", child);
+ config.SetProtection (AttValue ("protection", child));
+ config.SetTimeout (AttValue ("timeout", child));
+ ReadCredentials (child.ChildNodes, config);
+ continue;
+ }
+
+ if (child.Name == "passport") {
+ Console.WriteLine ("**WARNING**: Passport not supported! Ignoring section.");
+ continue;
+ }
+
+ HandlersUtil.ThrowException ("Unexpected element", child);
+ }
+
+ return config;
+ }
+
+ static void ReadCredentials (XmlNodeList nodes, AuthConfig config)
+ {
+ foreach (XmlNode child in nodes) {
+ XmlNodeType ntype = child.NodeType;
+ if (ntype != XmlNodeType.Element)
+ continue;
+
+ if (child.Name != "credentials")
+ HandlersUtil.ThrowException ("Unexpected element", child);
+
+ config.SetPasswordFormat (AttValue ("passwordFormat", child));
+ ReadUsers (child.ChildNodes, config.CredentialUsers);
+ }
+ }
+
+ static void ReadUsers (XmlNodeList nodes, Hashtable users)
+ {
+ foreach (XmlNode child in nodes) {
+ XmlNodeType ntype = child.NodeType;
+ if (ntype != XmlNodeType.Element)
+ continue;
+
+ if (child.Name != "user")
+ HandlersUtil.ThrowException ("Unexpected element", child);
+
+ string name = AttValue ("name", child, false);
+ string password = AttValue ("password", child);
+ if (users.ContainsKey (name))
+ ThrowException ("User '" + name + "' already added.", child);
+
+ users [name] = password;
+ if (child.HasChildNodes)
+ ThrowException ("Child nodes not allowed here", child.FirstChild);
+ }
+ }
+ // A few methods to save some typing
+ static string AttValue (string name, XmlNode node, bool optional)
+ {
+ return HandlersUtil.ExtractAttributeValue (name, node, optional);
+ }
+
+ static string AttValue (string name, XmlNode node)
+ {
+ return HandlersUtil.ExtractAttributeValue (name, node, true);
+ }
+
+ static void ThrowException (string message, XmlNode node)
+ {
+ HandlersUtil.ThrowException (message, node);
+ }
+ //
+
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/AuthenticationMode.cs b/mcs/class/System.Web/System.Web.Configuration/AuthenticationMode.cs
new file mode 100755
index 00000000000..6618e02ddc6
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/AuthenticationMode.cs
@@ -0,0 +1,19 @@
+/* System.Web.Configuration
+ * Authors:
+ * Leen Toelen (toelen@hotmail.com)
+ * Copyright (C) 2001 Leen Toelen
+*/
+
+namespace System.Web.Configuration {
+
+ /// <summary>
+ /// Defines the AuthenticationMode for a Web Application.
+ /// </summary>
+ public enum AuthenticationMode{
+ None,
+ Windows,
+ Passport,
+ Forms
+ }
+
+} //namespace System.Web.Configuration
diff --git a/mcs/class/System.Web/System.Web.Configuration/ChangeLog b/mcs/class/System.Web/System.Web.Configuration/ChangeLog
new file mode 100644
index 00000000000..0e59da70f83
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/ChangeLog
@@ -0,0 +1,78 @@
+2003-01-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpModulesConfigurationHandler.cs: add a default authentication
+ module at the end of the list.
+
+ * ModuleItem.cs: new constructor.
+
+2002-12-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AuthConfig.cs: LoginUrl defaults to login.aspx.
+
+2002-12-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AuthConfig.cs:
+ * AuthenticationConfigHandler.cs: handler and helper class for
+ system.web/authentication configuration section.
+
+ * HttpHandlersSectionHandler.cs: check for null in attributes.
+
+ * MachineKeyConfig.cs:
+ * MachineKeyConfigHandler.cs: handler and helper class for
+ system.web/machineKey tag.
+
+2002-10-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpHandlersSectionHandler.cs: more null checks.
+
+2002-10-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpHandlersSectionHandler.cs: made a couple of static methods be
+ part of a class used in other handlers.
+ * HttpModulesConfigurationHandler.cs: handler for modules.
+ * ModuleItem.cs: added IsMatch method.
+ * ModulesConfiguration.cs: made it similar to the handlers class: added Clear, Remove.
+
+2002-10-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpHandlerTypeMapper.cs: removed.
+ * HandlerFactoryConfiguration.cs: readded. I removed it by mistake.
+ * HandlerItem.cs: only load the type if we gotta validate it.
+ Implemented initial IsMatch.
+ * HttpConfigurationContext.cs: New file.
+ * HttpHandlersSectionHandler.cs: validate is optional (default true).
+ Use HttpHandlerTypeMapper.
+
+2002-10-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.Configuration/HandlerFactoryConfiguration.cs: removed.
+
+ * System.Web.Configuration/HandlerItem.cs: added validation field.
+
+ * System.Web.Configuration/HttpHandlerTypeMapper.cs: holds mappings
+ between verbs and wilcards and their associated HandlerItem.
+
+ * System.Web.Configuration/HttpHandlersSectionHandler.cs: this one
+ processes system.web/httpHandlers section of machine.config file.
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AuthenticationMode.cs:
+ * ClientTargetSectionHandler.cs:
+ * FormsAuthPasswordFormat.cs:
+ * FormsProtectionEnum.cs:
+ * HttpCapabilitiesBase.cs: fixes base on class status page.
+
+2002-08-05 Patrik Torstensson <ptorsten@hotmail.com>
+
+ * HandlerFactoryConfiguration.cs,
+ HandlerFactoryProxy.cs,
+ HandlerItem.cs : New files to emulate HttpHandler configuration
+
+ * ModuleItem.cs,
+ ModulesConfiguration.cs : New files to emulate HttpModule configuration
+
+2002-06-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.Configuration/HttpCapabilitiesBase.cs: New file.
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/ClientTargetSectionHandler.cs b/mcs/class/System.Web/System.Web.Configuration/ClientTargetSectionHandler.cs
new file mode 100644
index 00000000000..7f779a2e7df
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/ClientTargetSectionHandler.cs
@@ -0,0 +1,44 @@
+/* System.Web.Configuration
+ * Authors:
+ * Leen Toelen (toelen@hotmail.com)
+ * Copyright (C) 2001 Leen Toelen
+*/
+using System;
+using System.Configuration;
+
+namespace System.Web.Configuration
+{
+ /// <summary>
+ /// Summary description for ClientTargetSectionHandler.
+ /// </summary>
+ class ClientTargetSectionHandler: NameValueSectionHandler
+ {
+ /// <summary>
+ /// ClientTargetSectionHandler Constructor
+ /// </summary>
+ public ClientTargetSectionHandler(){}
+
+ /// <summary>
+ /// Gets the name of the key in the key-value pair.
+ /// </summary>
+ protected override string KeyAttributeName
+ {
+ get
+ {
+ return "alias";
+ }
+ }
+
+ /// <summary>
+ /// Gets the value for the key in the key-value pair.
+ /// </summary>
+ protected override string ValueAttributeName
+ {
+ get
+ {
+ return "userAgent";
+ }
+ }
+
+ }
+} //namespace System.Web.Configuration
diff --git a/mcs/class/System.Web/System.Web.Configuration/FormsAuthPasswordFormat.cs b/mcs/class/System.Web/System.Web.Configuration/FormsAuthPasswordFormat.cs
new file mode 100755
index 00000000000..9cc5e7e7087
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/FormsAuthPasswordFormat.cs
@@ -0,0 +1,18 @@
+/* System.Web.Configuration
+ * Authors:
+ * Leen Toelen (toelen@hotmail.com)
+ * Copyright (C) 2001 Leen Toelen
+*/
+
+namespace System.Web.Configuration {
+
+ /// <summary>
+ /// Defines the password encryption format.
+ /// </summary>
+ public enum FormsAuthPasswordFormat{
+ Clear,
+ SHA1,
+ MD5
+ }
+
+} //namespace System.Web.Configuration
diff --git a/mcs/class/System.Web/System.Web.Configuration/FormsProtectionEnum.cs b/mcs/class/System.Web/System.Web.Configuration/FormsProtectionEnum.cs
new file mode 100755
index 00000000000..db74e2d421d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/FormsProtectionEnum.cs
@@ -0,0 +1,19 @@
+/* System.Web.Configuration
+ * Authors:
+ * Leen Toelen (toelen@hotmail.com)
+ * Copyright (C) 2001 Leen Toelen
+*/
+
+namespace System.Web.Configuration {
+
+ /// <summary>
+ /// Defines the method used for securing web forms.
+ /// </summary>
+ public enum FormsProtectionEnum{
+ All,
+ None,
+ Encryption,
+ Validation
+ }
+
+} //namespace System.Web.Configuration
diff --git a/mcs/class/System.Web/System.Web.Configuration/GlobalizationConfiguration.cs b/mcs/class/System.Web/System.Web.Configuration/GlobalizationConfiguration.cs
new file mode 100644
index 00000000000..f60e6c65b60
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/GlobalizationConfiguration.cs
@@ -0,0 +1,29 @@
+//
+// System.Web.Configuration.GlobalizationConfiguration
+//
+// Author:
+// Patrik Torstensson (ptorsten@hotmail.com)
+//
+using System.Globalization;
+
+namespace System.Web.Configuration {
+ [MonoTODO]
+ public class GlobalizationConfiguration {
+ public GlobalizationConfiguration() {
+ }
+
+ [MonoTODO("")]
+ public CultureInfo Culture {
+ get {
+ return null;
+ }
+ }
+
+ [MonoTODO("")]
+ public CultureInfo UICulture {
+ get {
+ return null;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Configuration/HandlerFactoryConfiguration.cs b/mcs/class/System.Web/System.Web.Configuration/HandlerFactoryConfiguration.cs
new file mode 100644
index 00000000000..c80ac692670
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/HandlerFactoryConfiguration.cs
@@ -0,0 +1,75 @@
+//
+// System.Web.Configuration.HandlerFactoryConfiguration
+//
+// Authors:
+// Patrik Torstensson (ptorsten@hotmail.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Collections;
+
+namespace System.Web.Configuration
+{
+ class HandlerFactoryConfiguration
+ {
+ ArrayList mappings;
+
+ public HandlerFactoryConfiguration () : this (null)
+ {
+ }
+
+ public HandlerFactoryConfiguration (HandlerFactoryConfiguration parent)
+ {
+ if (parent != null)
+ mappings = new ArrayList (parent.mappings);
+ else
+ mappings = new ArrayList ();
+ }
+
+ public void Add (HandlerItem mapping)
+ {
+ mappings.Add (mapping);
+ }
+
+ public HandlerItem Remove (string verb, string path)
+ {
+ int i = GetIndex (verb, path);
+ if (i == -1)
+ return null;
+
+ HandlerItem item = (HandlerItem) mappings [i];
+ mappings.RemoveAt (i);
+ return item;
+ }
+
+ public void Clear ()
+ {
+ mappings.Clear ();
+ }
+
+ public HandlerItem FindHandler (string verb, string path)
+ {
+ int i = GetIndex (verb, path);
+ if (i == -1)
+ return null;
+
+ return (HandlerItem) mappings [i];
+ }
+
+ int GetIndex (string verb, string path)
+ {
+ int end = mappings.Count;
+
+ for (int i = 0; i < end; i++) {
+ HandlerItem item = (HandlerItem) mappings [i];
+ if (item.IsMatch (verb, path))
+ return i;
+ }
+
+ return -1;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/HandlerFactoryProxy.cs b/mcs/class/System.Web/System.Web.Configuration/HandlerFactoryProxy.cs
new file mode 100644
index 00000000000..e152a35041c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/HandlerFactoryProxy.cs
@@ -0,0 +1,15 @@
+//
+// System.Web.Configuration.HandlerFactoryProxy
+//
+// Author:
+// Patrik Torstensson (ptorsten@hotmail.com)
+//
+using System;
+
+namespace System.Web.Configuration {
+ [MonoTODO]
+ public class HandlerFactoryProxy {
+ public HandlerFactoryProxy() {
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Configuration/HandlerItem.cs b/mcs/class/System.Web/System.Web.Configuration/HandlerItem.cs
new file mode 100644
index 00000000000..ae134b3883f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/HandlerItem.cs
@@ -0,0 +1,120 @@
+//
+// System.Web.Configuration.HandlerItem
+//
+// Authors:
+// Patrik Torstensson (ptorsten@hotmail.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace System.Web.Configuration
+{
+ public class HandlerItem
+ {
+ private Type _type;
+ private string _typeName;
+ private string _path;
+ private string _requestType;
+ private Regex requestRegex;
+ private Regex pathRegex;
+ static Hashtable regexCache;
+
+ public HandlerItem (string requestType, string path, string type, bool validate)
+ {
+ _typeName = type;
+ _path = path;
+ _requestType = requestType.Replace (" ", "");
+ requestRegex = GetRegex (_requestType);
+ pathRegex = GetRegex (_path);
+ if (validate)
+ DoValidation ();
+ }
+
+ public object Create ()
+ {
+ if (_type == null)
+ DoValidation ();
+
+ return HttpRuntime.CreateInternalObject (_type);
+ }
+
+ public Type Type
+ {
+ get {
+ if (_type == null)
+ DoValidation ();
+ return _type;
+ }
+ }
+
+ public bool IsMatch (string type, string path)
+ {
+ return (MatchVerb (type) && MatchPath (path));
+ }
+
+ bool MatchVerb (string verb)
+ {
+ return requestRegex.IsMatch (verb);
+ }
+
+ bool MatchPath (string path)
+ {
+ return pathRegex.IsMatch (path);
+ }
+
+ void DoValidation ()
+ {
+ _type = Type.GetType (_typeName, true);
+ if (typeof (IHttpHandler).IsAssignableFrom (_type))
+ return;
+
+ if (typeof (IHttpHandlerFactory).IsAssignableFrom (_type))
+ return;
+
+ throw new HttpException (HttpRuntime.FormatResourceString ("type_not_factory_or_handler"));
+ }
+
+ static string ToRegexPattern (string dosPattern)
+ {
+ string result = dosPattern.Replace (".", "\\.");
+ result = result.Replace ("*", ".*");
+ result = result.Replace ('?', '.');
+ return result;
+ }
+
+ static Regex GetRegex (string verb)
+ {
+ EnsureCache ();
+ if (regexCache.ContainsKey (verb))
+ return (Regex) regexCache [verb];
+
+ StringBuilder result = new StringBuilder ("\\A");
+ string [] expressions = verb.Split (',');
+ int end = expressions.Length;
+ for (int i = 0; i < end; i++) {
+ string regex = ToRegexPattern (expressions [i]);
+ if (i + 1 < end) {
+ result.AppendFormat ("{0}\\z|\\A", regex);
+ } else {
+ result.AppendFormat ("({0})\\z", regex);
+ }
+ }
+
+ Regex r = new Regex (result.ToString ());
+ regexCache [verb] = r;
+ return r;
+ }
+
+ static void EnsureCache ()
+ {
+ if (regexCache == null)
+ regexCache = new Hashtable ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/HttpCapabilitiesBase.cs b/mcs/class/System.Web/System.Web.Configuration/HttpCapabilitiesBase.cs
new file mode 100644
index 00000000000..3143893c351
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/HttpCapabilitiesBase.cs
@@ -0,0 +1,46 @@
+//
+// System.Web.Configuration.HttpCapabilitiesBase
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web.Configuration {
+ using System;
+ using System.Collections;
+ using System.Web;
+
+public class HttpCapabilitiesBase
+{
+ Hashtable capabilities;
+
+ public HttpCapabilitiesBase ()
+ {
+ capabilities = new Hashtable ();
+ }
+
+ public virtual string this [string key]
+ {
+ get { return capabilities [key] as string; }
+ }
+
+ public static HttpCapabilitiesBase GetConfigCapabilities (string configKey, HttpRequest request)
+ {
+ throw new NotImplementedException ();
+ }
+
+ internal void SetCapabilities (Hashtable tbl)
+ {
+ capabilities = tbl;
+ Init ();
+ }
+
+ protected virtual void Init ()
+ {
+ }
+
+}
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/HttpConfigurationContext.cs b/mcs/class/System.Web/System.Web.Configuration/HttpConfigurationContext.cs
new file mode 100644
index 00000000000..192b3ad4e24
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/HttpConfigurationContext.cs
@@ -0,0 +1,29 @@
+//
+// System.Web.Configuration.HttpConfigurationContext
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web.Configuration
+{
+ public class HttpConfigurationContext
+ {
+ private string virtualPath;
+
+ internal HttpConfigurationContext (string virtualPath)
+ {
+ this.virtualPath = virtualPath;
+ }
+
+ public string VirtualPath
+ {
+ get {
+ return virtualPath;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/HttpHandlersSectionHandler.cs b/mcs/class/System.Web/System.Web.Configuration/HttpHandlersSectionHandler.cs
new file mode 100644
index 00000000000..85f573f47ee
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/HttpHandlersSectionHandler.cs
@@ -0,0 +1,131 @@
+//
+// System.Web.Configuration.HttpHandlersSectionHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Collections;
+using System.Configuration;
+using System.Xml;
+
+namespace System.Web.Configuration
+{
+ class HttpHandlersSectionHandler : IConfigurationSectionHandler
+ {
+ public virtual object Create (object parent, object configContext, XmlNode section)
+ {
+ HandlerFactoryConfiguration mapper;
+
+ if (parent is HandlerFactoryConfiguration)
+ mapper = new HandlerFactoryConfiguration ((HandlerFactoryConfiguration) parent);
+ else
+ mapper = new HandlerFactoryConfiguration ();
+
+ if (section.Attributes != null && section.Attributes.Count != 0)
+ HandlersUtil.ThrowException ("Unrecognized attribute", section);
+
+ XmlNodeList httpHandlers = section.ChildNodes;
+ foreach (XmlNode child in httpHandlers) {
+ XmlNodeType ntype = child.NodeType;
+ if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment)
+ continue;
+
+ if (ntype != XmlNodeType.Element)
+ HandlersUtil.ThrowException ("Only elements allowed", child);
+
+ string name = child.Name;
+ if (name == "clear") {
+ if (child.Attributes != null && child.Attributes.Count != 0)
+ HandlersUtil.ThrowException ("Unrecognized attribute", child);
+
+ mapper.Clear ();
+ continue;
+ }
+
+ string verb = HandlersUtil.ExtractAttributeValue ("verb", child);
+ string path = HandlersUtil.ExtractAttributeValue ("path", child);
+ string validateStr = HandlersUtil.ExtractAttributeValue ("validate", child, true);
+ bool validate;
+ if (validateStr == null) {
+ validate = true;
+ } else {
+ validate = validateStr == "true";
+ if (!validate && validateStr != "false")
+ HandlersUtil.ThrowException (
+ "Invalid value for validate attribute.", child);
+ }
+
+ if (name == "add") {
+ string type = HandlersUtil.ExtractAttributeValue ("type", child);
+ if (child.Attributes != null && child.Attributes.Count != 0)
+ HandlersUtil.ThrowException ("Unrecognized attribute", child);
+
+ HandlerItem item = new HandlerItem (verb, path, type, validate);
+ mapper.Add (item);
+ continue;
+ }
+
+ if (name == "remove") {
+ if (child.Attributes != null && child.Attributes.Count != 0)
+ HandlersUtil.ThrowException ("Unrecognized attribute", child);
+
+ if (validate && mapper.Remove (verb, path) == null)
+ HandlersUtil.ThrowException ("There's no mapping to remove", child);
+
+ continue;
+ }
+ HandlersUtil.ThrowException ("Unexpected element", child);
+ }
+
+ return mapper;
+ }
+ }
+
+ internal class HandlersUtil
+ {
+ private HandlersUtil ()
+ {
+ }
+
+ static internal string ExtractAttributeValue (string attKey, XmlNode node)
+ {
+ return ExtractAttributeValue (attKey, node, false);
+ }
+
+ static internal string ExtractAttributeValue (string attKey, XmlNode node, bool optional)
+ {
+ if (node.Attributes == null) {
+ if (optional)
+ return null;
+
+ ThrowException ("Required attribute not found: " + attKey, node);
+ }
+
+ XmlNode att = node.Attributes.RemoveNamedItem (attKey);
+ if (att == null) {
+ if (optional)
+ return null;
+ ThrowException ("Required attribute not found: " + attKey, node);
+ }
+
+ string value = att.Value;
+ if (value == String.Empty) {
+ string opt = optional ? "Optional" : "Required";
+ ThrowException (opt + " attribute is empty: " + attKey, node);
+ }
+
+ return value;
+ }
+
+ static internal void ThrowException (string msg, XmlNode node)
+ {
+ if (node != null && node.Name != String.Empty)
+ msg = msg + " (node name: " + node.Name + ") ";
+ throw new ConfigurationException (msg, node);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/HttpModulesConfigurationHandler.cs b/mcs/class/System.Web/System.Web.Configuration/HttpModulesConfigurationHandler.cs
new file mode 100644
index 00000000000..44776eb3a44
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/HttpModulesConfigurationHandler.cs
@@ -0,0 +1,81 @@
+//
+// System.Web.Configuration.HttpModulesConfigurationHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Configuration;
+using System.Xml;
+using System.Web.Security;
+
+namespace System.Web.Configuration
+{
+ class HttpModulesConfigurationHandler : IConfigurationSectionHandler
+ {
+ public virtual object Create (object parent, object configContext, XmlNode section)
+ {
+ ModulesConfiguration mapper;
+
+ if (parent is ModulesConfiguration)
+ mapper = new ModulesConfiguration ((ModulesConfiguration) parent);
+ else
+ mapper = new ModulesConfiguration ();
+
+ if (section.Attributes != null && section.Attributes.Count != 0)
+ HandlersUtil.ThrowException ("Unrecognized attribute", section);
+
+ XmlNodeList httpModules = section.ChildNodes;
+
+ foreach (XmlNode child in httpModules) {
+ XmlNodeType ntype = child.NodeType;
+ if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment)
+ continue;
+
+ if (ntype != XmlNodeType.Element)
+ HandlersUtil.ThrowException ("Only elements allowed", child);
+
+ string name = child.Name;
+ if (name == "clear") {
+ if (child.Attributes.Count != 0)
+ HandlersUtil.ThrowException ("Unrecognized attribute", child);
+
+ mapper.Clear ();
+ continue;
+ }
+
+ string nameAtt = HandlersUtil.ExtractAttributeValue ("name", child);
+ if (name == "add") {
+ string type = HandlersUtil.ExtractAttributeValue ("type", child);
+ if (child.Attributes.Count != 0)
+ HandlersUtil.ThrowException ("Unrecognized attribute", child);
+
+ // FIXME: gotta remove this. Just here to make it work with my local config
+ if (type.StartsWith ("System.Web.Mobile"))
+ continue;
+
+ ModuleItem item = new ModuleItem (nameAtt, type);
+ mapper.Add (item);
+ continue;
+ }
+
+ if (name == "remove") {
+ if (child.Attributes.Count != 0)
+ HandlersUtil.ThrowException ("Unrecognized attribute", child);
+
+ if (mapper.Remove (nameAtt) == null)
+ HandlersUtil.ThrowException ("Module not loaded", child);
+ continue;
+ }
+
+ HandlersUtil.ThrowException ("Unrecognized element", child);
+ }
+
+ mapper.Add (new ModuleItem ("DefaultAuthentication", typeof (DefaultAuthenticationModule)));
+ return mapper;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/MachineKeyConfig.cs b/mcs/class/System.Web/System.Web.Configuration/MachineKeyConfig.cs
new file mode 100644
index 00000000000..56f1ec80832
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/MachineKeyConfig.cs
@@ -0,0 +1,65 @@
+//
+// System.Web.Configuration.MachineKeyConfig
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.Configuration;
+using System.Xml;
+
+namespace System.Web.Configuration
+{
+ class MachineKeyConfig
+ {
+ static MachineKeyConfig machineKey;
+ byte [] validationKey;
+ byte [] decryptionKey;
+ string validationType;
+
+ internal MachineKeyConfig (object parent)
+ {
+ if (parent is MachineKeyConfig) {
+ MachineKeyConfig p = (MachineKeyConfig) parent;
+ validationKey = p.validationKey;
+ decryptionKey = p.decryptionKey;
+ validationType = p.validationType;
+ }
+ }
+
+ internal byte [] ValidationKey {
+ get { return validationKey; }
+ set { validationKey = value; }
+ }
+
+ internal byte [] DecryptionKey {
+ get { return decryptionKey; }
+ set { decryptionKey = value; }
+ }
+
+ internal string ValidationType {
+ get {
+ if (validationType == null)
+ validationType = "SHA1";
+
+ return validationType;
+ }
+ set {
+ if (value == null)
+ return;
+
+ validationType = value;
+ }
+ }
+
+ internal static MachineKeyConfig MachineKey {
+ get { return machineKey; }
+ set { machineKey = value; }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/MachineKeyConfigHandler.cs b/mcs/class/System.Web/System.Web.Configuration/MachineKeyConfigHandler.cs
new file mode 100644
index 00000000000..23971e93e89
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/MachineKeyConfigHandler.cs
@@ -0,0 +1,116 @@
+//
+// System.Web.Configuration.MachineKeyConfigHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.Configuration;
+using System.Security.Cryptography;
+using System.Xml;
+
+namespace System.Web.Configuration
+{
+ class MachineKeyConfigHandler : IConfigurationSectionHandler
+ {
+ static byte [] autogenerated;
+ static MachineKeyConfigHandler ()
+ {
+ autogenerated = new byte [64];
+ RNGCryptoServiceProvider cp = new RNGCryptoServiceProvider ();
+ cp.GetBytes (autogenerated);
+ }
+
+ static byte ToHexValue (char c, bool high)
+ {
+ byte v;
+ if (c >= '0' && c <= '9')
+ v = (byte) (c - '0');
+ else if (c >= 'a' && c <= 'f')
+ v = (byte) (c - 'a' + 10);
+ else if (c >= 'A' && c <= 'F')
+ v = (byte) (c - 'A' + 10);
+ else
+ throw new ArgumentException ("Invalid hex character");
+
+ if (high)
+ v <<= 4;
+
+ return v;
+ }
+
+ internal static byte [] GetBytes (string key, int len)
+ {
+ byte [] result = new byte [len / 2];
+ for (int i = 0; i < len; i += 2)
+ result [i / 2] = (byte) (ToHexValue (key [i], true) + ToHexValue (key [i + 1], false));
+
+ return result;
+ }
+
+ static byte [] MakeKey (string key)
+ {
+ if (key == null || key == "AutoGenerated")
+ return autogenerated;
+
+ int len = key.Length;
+ if (len < 40 || len > 128 || (len % 2) == 1)
+ throw new ArgumentException ("Invalid key length");
+
+ return GetBytes (key, len);
+ }
+
+ public object Create (object parent, object context, XmlNode section)
+ {
+ if (section.HasChildNodes)
+ ThrowException ("Child nodes not allowed here", section.FirstChild);
+
+ //TODO: context?
+ MachineKeyConfig config = new MachineKeyConfig (parent);
+
+ string validationKey = AttValue ("validationKey", section);
+ try {
+ config.ValidationKey = MakeKey (validationKey);
+ } catch (ArgumentException e) {
+ ThrowException (e.Message, section);
+ }
+
+ string decryptionKey = AttValue ("decryptionKey", section);
+ try {
+ config.DecryptionKey = MakeKey (decryptionKey);
+ } catch (ArgumentException e) {
+ ThrowException (e.Message, section);
+ }
+
+ string validation = AttValue ("validation", section);
+ if (validation != "SHA1" && validation != "MD5" && validation != "3DES")
+ ThrowException ("Invalid 'validation' value", section);
+
+ config.ValidationType = validation;
+
+ if (section.Attributes != null && section.Attributes.Count != 0)
+ ThrowException ("Unrecognized attribute", section);
+
+ MachineKeyConfig.MachineKey = config;
+ return config;
+ }
+
+ // A few methods to save some typing
+ static string AttValue (string name, XmlNode node)
+ {
+ return HandlersUtil.ExtractAttributeValue (name, node, true);
+ }
+
+ static void ThrowException (string message, XmlNode node)
+ {
+ HandlersUtil.ThrowException (message, node);
+ }
+ //
+
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Configuration/ModuleItem.cs b/mcs/class/System.Web/System.Web.Configuration/ModuleItem.cs
new file mode 100644
index 00000000000..3db4bce3eda
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/ModuleItem.cs
@@ -0,0 +1,53 @@
+//
+// System.Web.Configuration.ModuleItem
+//
+// Author:
+// Patrik Torstensson (ptorsten@hotmail.com)
+//
+using System;
+
+namespace System.Web.Configuration {
+ public class ModuleItem {
+ private Type _type;
+ private string _typeName;
+ private string _name;
+
+ public ModuleItem(string name, string type) {
+ _typeName = type;
+ _name = name;
+
+ _type = Type.GetType (type, true);
+ if (!typeof(IHttpModule).IsAssignableFrom(_type))
+ throw new HttpException(HttpRuntime.FormatResourceString("type_not_module"));
+ }
+
+ public ModuleItem(string name, Type type) {
+ _typeName = type.ToString ();
+ _name = name;
+ _type = type;
+ if (!typeof(IHttpModule).IsAssignableFrom(_type))
+ throw new HttpException(HttpRuntime.FormatResourceString("type_not_module"));
+ }
+
+ public IHttpModule Create() {
+ return (IHttpModule) HttpRuntime.CreateInternalObject(_type);
+ }
+
+ public Type Type {
+ get {
+ return _type;
+ }
+ }
+
+ public bool IsMatch (string name)
+ {
+ return (_type.Name == name || _type.FullName == name);
+ }
+
+ public string ModuleName {
+ get {
+ return _name;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Configuration/ModulesConfiguration.cs b/mcs/class/System.Web/System.Web.Configuration/ModulesConfiguration.cs
new file mode 100644
index 00000000000..d0b4ab1fda8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Configuration/ModulesConfiguration.cs
@@ -0,0 +1,75 @@
+//
+// System.Web.Configuration.ModulesConfiguration
+//
+// Authors:
+// Patrik Torstensson (ptorsten@hotmail.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+
+namespace System.Web.Configuration
+{
+ public class ModulesConfiguration
+ {
+ ArrayList modules;
+
+ public ModulesConfiguration () : this (null)
+ {
+ }
+
+ public ModulesConfiguration (ModulesConfiguration parent)
+ {
+ if (parent != null)
+ modules = new ArrayList (parent.modules);
+ else
+ modules = new ArrayList ();
+ }
+
+ public void Add (ModuleItem item)
+ {
+ modules.Add (item);
+ }
+
+ public ModuleItem Remove (string name)
+ {
+ int i = GetIndex (name);
+ if (i == -1)
+ return null;
+
+ ModuleItem item = (ModuleItem) modules [i];
+ modules.RemoveAt (i);
+ return item;
+ }
+
+ public void Clear ()
+ {
+ modules.Clear ();
+ }
+
+ public HttpModuleCollection CreateCollection ()
+ {
+ HttpModuleCollection items = new HttpModuleCollection ();
+ foreach (ModuleItem item in modules)
+ items.AddModule (item.ModuleName, item.Create ());
+
+ return items;
+ }
+
+ int GetIndex (string name)
+ {
+ int end = modules.Count;
+
+ for (int i = 0; i < end; i++) {
+ ModuleItem item = (ModuleItem) modules [i];
+ if (item.IsMatch (name))
+ return i;
+ }
+
+ return -1;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Handlers/ChangeLog b/mcs/class/System.Web/System.Web.Handlers/ChangeLog
new file mode 100644
index 00000000000..63df449a29c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Handlers/ChangeLog
@@ -0,0 +1,6 @@
+2002-10-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ChangeLog: New file.
+ * TraceHandler.cs: stubbed out. This should generate the trace page
+ when tracing is enabled.
+
diff --git a/mcs/class/System.Web/System.Web.Handlers/TraceHandler.cs b/mcs/class/System.Web/System.Web.Handlers/TraceHandler.cs
new file mode 100644
index 00000000000..1ee16a6c9e5
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Handlers/TraceHandler.cs
@@ -0,0 +1,32 @@
+//
+// System.Web.Handlers.TraceHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.Handlers
+{
+ public class TraceHandler : IHttpHandler
+ {
+ [MonoTODO]
+ void IHttpHandler.ProcessRequest (HttpContext context)
+ {
+ //TODO: This should generate the trace page.
+ throw new NotImplementedException ();
+ }
+
+ bool IHttpHandler.IsReusable
+ {
+ get {
+ return false;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Hosting/AppDomainFactory.cs b/mcs/class/System.Web/System.Web.Hosting/AppDomainFactory.cs
new file mode 100644
index 00000000000..b46e7812906
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Hosting/AppDomainFactory.cs
@@ -0,0 +1,122 @@
+//
+// System.Web.Hosting.AppDomainFactory.cs
+//
+// Authors:
+// Bob Smith <bob@thestuff.net>
+// Gonzalo Paniagua (gonzalo@ximian.com)
+//
+// (C) Bob Smith
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.IO;
+using System.Security;
+using System.Security.Policy;
+using System.Text;
+
+namespace System.Web.Hosting
+{
+ public sealed class AppDomainFactory : IAppDomainFactory
+ {
+ static int nDomain = 0;
+ static string [] domainData = { ".appDomain",
+ ".appId",
+ ".appPath",
+ ".appVPath",
+ ".appName",
+ ".domainId"
+ };
+
+ public object Create (string module,
+ string typeName,
+ string appId,
+ string appPath,
+ string strUrlOfAppOrigin,
+ int iZone)
+ {
+ appPath = Path.GetFullPath (appPath);
+ if (appPath [appPath.Length - 1] == '\\')
+ appPath += '\\';
+
+ StringBuilder sb = new StringBuilder (appId);
+ sb.Append ('-');
+ lock (domainData){
+ sb.Append (nDomain.ToString ());
+ nDomain++;
+ }
+
+ sb.Append ('-' + DateTime.Now.ToString ());
+ string domainId = sb.ToString ();
+ sb = null;
+
+ int slash = appId.IndexOf ('/');
+ string vPath;
+ if (slash == -1)
+ vPath = "/";
+ else
+ vPath = appId.Substring (slash + 1);
+
+ string appName = (appId.GetHashCode () + appPath.GetHashCode ()).ToString ("x");
+ AppDomainSetup domainSetup = new AppDomainSetup ();
+
+ PopulateDomainBindings (domainId,
+ appId,
+ appName,
+ appPath,
+ vPath,
+ domainSetup,
+ null);
+
+ // May be adding more assemblies and such to Evidence?
+ AppDomain domain = AppDomain.CreateDomain (domainId,
+ AppDomain.CurrentDomain.Evidence,
+ domainSetup);
+
+ string [] settings = new string [6];
+ settings [0] = "*";
+ settings [1] = appId;
+ settings [2] = appPath;
+ settings [3] = vPath;
+ settings [4] = appName;
+ settings [5] = domainId;
+ for (int i = 0; i < 6; i++)
+ domain.SetData (domainData [i], settings [i]);
+
+ object o = null;
+ try {
+ o = domain.CreateInstance (module, typeName);
+ } catch {
+ AppDomain.Unload (domain);
+ o = null;
+ }
+
+ return o;
+ }
+
+ internal static void PopulateDomainBindings (string domainId,
+ string appId,
+ string appName,
+ string appPath,
+ string appVPath,
+ AppDomainSetup setup,
+ IDictionary dict)
+ {
+ setup.PrivateBinPath = "bin";
+ setup.PrivateBinPathProbe = "*";
+ setup.ShadowCopyFiles = "true";
+ setup.ApplicationBase = new Uri (appPath, true).ToString ();
+ setup.ApplicationName = appName;
+ setup.ConfigurationFile = "web.config";
+ if (dict != null) {
+ dict.Add (domainData [0], "*");
+ dict.Add (domainData [1], appId);
+ dict.Add (domainData [2], appPath);
+ dict.Add (domainData [3], appVPath);
+ dict.Add (domainData [4], appName);
+ dict.Add (domainData [5], domainId);
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Hosting/ApplicationHost.cs b/mcs/class/System.Web/System.Web.Hosting/ApplicationHost.cs
new file mode 100644
index 00000000000..86eea5703fe
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Hosting/ApplicationHost.cs
@@ -0,0 +1,87 @@
+//
+// System.Web.Hosting.ApplicationHost
+//
+// Authors:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// (class signature from Bob Smith <bob@thestuff.net> (C) )
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+using System;
+using System.Collections;
+using System.IO;
+using System.Runtime.Remoting;
+
+namespace System.Web.Hosting
+{
+ public sealed class ApplicationHost
+ {
+ internal class ConfigInitHelper : MarshalByRefObject
+ {
+ internal void InitConfig ()
+ {
+ }
+ }
+
+ private ApplicationHost ()
+ {
+ }
+
+ public static object CreateApplicationHost (Type hostType,
+ string virtualDir,
+ string physicalDir)
+ {
+ if (hostType == null)
+ throw new ArgumentException ("hostType");
+
+ if (virtualDir == null || virtualDir.Length == 0)
+ throw new ArgumentException ("virtualDir");
+
+ if (physicalDir == null || physicalDir.Length == 0)
+ throw new ArgumentException ("physicalDir");
+
+ if (physicalDir [physicalDir.Length - 1] != Path.DirectorySeparatorChar)
+ physicalDir += Path.DirectorySeparatorChar;
+
+ int nowInt = DateTime.Now.ToString ().GetHashCode ();
+ string nowHash = nowInt.ToString ("x");
+ nowInt += physicalDir.GetHashCode ();
+ string sum = nowInt.ToString ("x");
+ Hashtable hTable = new Hashtable ();
+ AppDomainSetup domainSetup = new AppDomainSetup();
+
+ AppDomainFactory.PopulateDomainBindings (nowHash,
+ sum,
+ sum,
+ physicalDir,
+ virtualDir,
+ domainSetup,
+ hTable);
+
+ AppDomain domain = AppDomain.CreateDomain (nowHash, null, domainSetup);
+ foreach (string key in hTable.Keys) {
+ domain.SetData (key, (string) hTable [key]);
+ // [1] REMOVE THIS once bug #31245 is fixed
+ AppDomain.CurrentDomain.SetData (key, (string) hTable [key]);
+ }
+
+ domain.SetData (".hostingVirtualPath", virtualDir);
+ AppDomain.CurrentDomain.SetData (".hostingVirtualPath", virtualDir); // [1]
+ //FIXME: this should be the directory where dlls reside.
+ domain.SetData(".hostingInstallDir", "FIXME hostingInstallDir");
+ AppDomain.CurrentDomain.SetData (".hostingInstallDir", "FIXME hostingInstallDir"); // [1]
+ InitConfigInNewAppDomain (domain);
+ ObjectHandle o = domain.CreateInstance (hostType.Assembly.FullName,
+ hostType.FullName);
+ return o.Unwrap();
+ }
+
+ private static void InitConfigInNewAppDomain (AppDomain appDomain)
+ {
+ Type t = typeof (ConfigInitHelper);
+ ObjectHandle o = appDomain.CreateInstance (t.Assembly.FullName, t.FullName);
+ ConfigInitHelper helper = (ConfigInitHelper) o.Unwrap();
+ helper.InitConfig ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Hosting/ChangeLog b/mcs/class/System.Web/System.Web.Hosting/ChangeLog
new file mode 100644
index 00000000000..802ae221c22
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Hosting/ChangeLog
@@ -0,0 +1,45 @@
+2002-09-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.Hosting/SimpleWorkerRequest.cs: we are now able to compile
+ pages and use HttpApplication, HttpRuntime and SimpleWorkerRequest.
+
+2002-09-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ApplicationHost.cs:
+ * SimpleWorkerRequest.cs: workaround for bug #31245.
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ApplicationHost.cs: little fixes.
+
+2002-08-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ApplicationHost.cs: use Assembly instead of Module.
+
+2002-08-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AppDomainFactory.cs: implemented.
+ * ApplicationHost.cs: implemented.
+ * SimpleWorkerRequest.cs: a few little fixes and reformatted. It's now
+ fully implemented.
+
+2002-07-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AppDomainFactory.cs:
+ * IAppDomainFactory.cs:
+ * IISAPIRuntime.cs:
+ * ISAPIRuntime.cs: make them compile.
+
+2002-04-10 Patrik Torstensson <patrik.torstensson@labs2.com>
+
+ * ApplicationHost.cs: Test implementation to support testing.
+ * SimpleWorkerRequest.cs: Rewrite and a almost full implementation.
+
+2001-08-30 Bob Smith <bob@thestuff.net>
+
+ * AppDomainFactory.cs: Stubbed.
+ * ApplicationHost.cs: Stubbed.
+ * IAppDomainFactory.cs: Stubbed.
+ * IISAPIRuntime.cs: Stubbed.
+ * ISAPIRuntime.cs: Implemented.
+ * SimpleWorkerRequest.cs: Implemented.
diff --git a/mcs/class/System.Web/System.Web.Hosting/IAppDomainFactory.cs b/mcs/class/System.Web/System.Web.Hosting/IAppDomainFactory.cs
new file mode 100644
index 00000000000..2067260c4f4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Hosting/IAppDomainFactory.cs
@@ -0,0 +1,24 @@
+//
+// System.Web.Hosting.IAppDomainFactory.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+
+namespace System.Web.Hosting
+{
+ public interface IAppDomainFactory
+ {
+ object Create (string module,
+ string typeName,
+ string appId,
+ string appPath,
+ string strUrlOfAppOrigin,
+ int iZone);
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Hosting/IISAPIRuntime.cs b/mcs/class/System.Web/System.Web.Hosting/IISAPIRuntime.cs
new file mode 100644
index 00000000000..cf4d7bf6937
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Hosting/IISAPIRuntime.cs
@@ -0,0 +1,21 @@
+//
+// System.Web.Hosting.IISAPIRuntime.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+
+namespace System.Web.Hosting
+{
+ public interface IISAPIRuntime
+ {
+ void DoGCCollect ();
+ int ProcessRequest (IntPtr ecb, int useProcessModel);
+ void StartProcessing ();
+ void StopProcessing ();
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Hosting/ISAPIRuntime.cs b/mcs/class/System.Web/System.Web.Hosting/ISAPIRuntime.cs
new file mode 100644
index 00000000000..ac43100c95c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Hosting/ISAPIRuntime.cs
@@ -0,0 +1,48 @@
+//
+// System.Web.Hosting.ISAPIRuntime.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+// Gonzalo Paniagua (gonzalo@ximian.com)
+//
+// (C) Bob Smith
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+
+namespace System.Web.Hosting
+{
+ public sealed class ISAPIRuntime : IISAPIRuntime
+ {
+ [MonoTODO]
+ public ISAPIRuntime ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void DoGCCollect ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public int ProcessRequest (IntPtr ecb, int iWRType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void StartProcessing ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void StopProcessing ()
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs b/mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs
new file mode 100644
index 00000000000..764aa417a18
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Hosting/SimpleWorkerRequest.cs
@@ -0,0 +1,273 @@
+//
+// System.Web.Hosting
+//
+// Authors:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// (class signature from Bob Smith <bob@thestuff.net> (C) )
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+using System;
+using System.IO;
+using System.Text;
+
+namespace System.Web.Hosting
+{
+ [MonoTODO("Implement security demands on the path usage functions (and review)")]
+ public class SimpleWorkerRequest : HttpWorkerRequest
+ {
+ private string _Page;
+ private string _Query;
+ private string _PathInfo;
+ private string _AppVirtualPath;
+ private string _AppPhysicalPath;
+ private string _AppInstallPath;
+ private TextWriter _Output;
+ private bool _HasInstallInfo;
+
+ private SimpleWorkerRequest ()
+ {
+ }
+
+ public SimpleWorkerRequest (string Page, string Query, TextWriter Output)
+ {
+ _Page = Page;
+ ParsePathInfo ();
+
+ _Query = Query;
+ AppDomain current = AppDomain.CurrentDomain;
+ object o = current.GetData (".appPath");
+ if (o == null)
+ throw new HttpException ("Cannot get .appPath");
+ _AppPhysicalPath = o.ToString ();
+
+ o = current.GetData (".hostingVirtualPath");
+ if (o == null)
+ throw new HttpException ("Cannot get .hostingVirtualPath");
+ _AppInstallPath = o.ToString ();
+
+ o = current.GetData (".hostingInstallDir");
+ if (o == null)
+ throw new HttpException ("Cannot get .hostingInstallDir");
+ _AppVirtualPath = CheckAndAddSlash (o.ToString ());
+ _Output = Output;
+
+ if (_AppPhysicalPath == null)
+ throw new HttpException ("Invalid app domain");
+
+ _HasInstallInfo = true;
+ }
+
+ public SimpleWorkerRequest (string AppVirtualPath,
+ string AppPhysicalPath,
+ string Page,
+ string Query,
+ TextWriter Output)
+ {
+ if (AppDomain.CurrentDomain.GetData (".appPath") == null)
+ throw new HttpException ("Invalid app domain");
+
+ _Page = Page;
+ ParsePathInfo ();
+ _Query = Query;
+ _AppVirtualPath = AppVirtualPath;
+ _AppPhysicalPath = CheckAndAddSlash (AppPhysicalPath);
+ _Output = Output;
+ _HasInstallInfo = false;
+ }
+
+ [MonoTODO("Implement security")]
+ public override string MachineInstallDirectory
+ {
+ get {
+ if (_HasInstallInfo)
+ return _AppInstallPath;
+
+ return null;
+ }
+ }
+
+ [MonoTODO("Get config path from Web.Config class")]
+ public override string MachineConfigPath
+ {
+ get {
+ return "MachineConfigPath"; //FIXME
+ }
+ }
+
+ public override void EndOfRequest ()
+ {
+ }
+
+ public override void FlushResponse (bool finalFlush)
+ {
+ }
+
+ public override string GetAppPath ()
+ {
+ return _AppVirtualPath;
+ }
+
+ public override string GetAppPathTranslated ()
+ {
+ return _AppPhysicalPath;
+ }
+
+ public override string GetFilePath ()
+ {
+ return CreatePath (false);
+ }
+
+ public override string GetFilePathTranslated ()
+ {
+ if (Path.DirectorySeparatorChar != '/')
+ return _AppPhysicalPath + _Page.Replace ('/', Path.DirectorySeparatorChar);
+
+ return _AppPhysicalPath + _Page;
+ }
+
+ public override string GetHttpVerbName ()
+ {
+ return "GET";
+ }
+
+ public override string GetHttpVersion ()
+ {
+ return "HTTP/1.0";
+ }
+
+ public override string GetLocalAddress ()
+ {
+ return "127.0.0.1";
+ }
+
+ public override int GetLocalPort ()
+ {
+ return 80;
+ }
+
+ public override string GetPathInfo ()
+ {
+ return (null != _PathInfo) ? _PathInfo : String.Empty;
+ }
+
+ public override string GetQueryString ()
+ {
+ return _Query;
+ }
+
+ public override string GetRawUrl ()
+ {
+ string path = CreatePath (true);
+ if (null != _Query && _Query.Length > 0)
+ return path + "?" + _Query;
+
+ return path;
+ }
+
+ public override string GetRemoteAddress()
+ {
+ return "127.0.0.1";
+ }
+
+ public override int GetRemotePort()
+ {
+ return 0;
+ }
+
+ public override string GetServerVariable(string name)
+ {
+ return String.Empty;
+ }
+
+ public override string GetUriPath()
+ {
+ return CreatePath (true);
+ }
+
+ public override IntPtr GetUserToken()
+ {
+ return IntPtr.Zero;
+ }
+
+ public override string MapPath (string path)
+ {
+ string sPath = _AppPhysicalPath.Substring (0, _AppPhysicalPath.Length - 1);
+ if (path != null && path.Length > 0 && path [0] != '/')
+ return sPath;
+
+ char sep = Path.DirectorySeparatorChar;
+ if (path.StartsWith(_AppVirtualPath)) {
+ if (sep == '/')
+ return sPath + path.Substring (_AppVirtualPath.Length);
+ else
+ return sPath + path.Substring (_AppVirtualPath.Length).Replace ('/', '\\');
+ }
+
+ return null;
+ }
+
+ public override void SendKnownResponseHeader (int index, string value)
+ {
+ }
+
+ public override void SendResponseFromFile (IntPtr handle, long offset, long length)
+ {
+ }
+
+ public override void SendResponseFromFile (string filename, long offset, long length)
+ {
+ }
+
+ public override void SendResponseFromMemory (byte [] data, int length)
+ {
+ _Output.Write (Encoding.Default.GetChars (data, 0, length));
+ }
+
+ public override void SendStatus(int statusCode, string statusDescription)
+ {
+ }
+
+ public override void SendUnknownResponseHeader(string name, string value)
+ {
+ }
+
+ // Create's a path string
+ private string CheckAndAddSlash(string sPath)
+ {
+ if (null == sPath)
+ return null;
+
+ if (!sPath.EndsWith ("" + Path.DirectorySeparatorChar))
+ return sPath + Path.DirectorySeparatorChar;
+
+ return sPath;
+ }
+
+ // Create's a path string
+ private string CreatePath (bool bIncludePathInfo)
+ {
+ string sPath;
+
+ if ("/" != _AppVirtualPath)
+ sPath = "/" + _Page;
+ else
+ sPath = String.Empty;
+
+ if (bIncludePathInfo && null != _PathInfo)
+ return sPath + _PathInfo;
+
+ return sPath;
+ }
+
+ // Parses out the string after / known as the "path info"
+ private void ParsePathInfo ()
+ {
+ /* int iPos = _Page.LastIndexOf("/");
+ if (iPos >= 0) {
+ _PathInfo = _Page.Substring (iPos);
+ _Page = _Page.Substring (0, iPos);
+ }*/
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Mail/ChangeLog b/mcs/class/System.Web/System.Web.Mail/ChangeLog
new file mode 100644
index 00000000000..b2e226261e1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Mail/ChangeLog
@@ -0,0 +1,12 @@
+2002-11-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * SmtpMail.cs: i don't wanna see that warning :-).
+
+2002-04-26 Lawrence Pit <loz@cable.a2000.nl>
+
+ * MailAttachment.cs: Implemented
+ * MailEncoding.cs: Implemented
+ * MailFormat.cs: Implemented
+ * MailMessage.cs: Implemented
+ * MailPriority.cs: Implemented
+ * SmtpMail.cs: Stubbed
diff --git a/mcs/class/System.Web/System.Web.Mail/MailAttachment.cs b/mcs/class/System.Web/System.Web.Mail/MailAttachment.cs
new file mode 100644
index 00000000000..b0f5dfcc3a7
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Mail/MailAttachment.cs
@@ -0,0 +1,44 @@
+//
+// System.Web.Mail.MailAttachment.cs
+//
+// Author:
+// Lawrence Pit (loz@cable.a2000.nl)
+//
+
+namespace System.Web.Mail
+{
+ public class MailAttachment
+ {
+ private string filename;
+ private MailEncoding encoding;
+
+ public MailAttachment (string filename) :
+ this (filename, MailEncoding.Base64)
+ {
+ }
+
+ public MailAttachment (string filename, MailEncoding encoding)
+ {
+ this.filename = filename;
+ this.encoding = encoding;
+ try {
+ System.IO.File.OpenRead (filename).Close ();
+ } catch (Exception) {
+ throw new System.Web.HttpException ("Cannot find file: " + filename);
+ }
+ }
+
+ // Properties
+ public string Filename
+ {
+ get { return filename; }
+ }
+
+ public MailEncoding Encoding
+ {
+ get { return encoding; }
+ }
+
+ }
+
+} //namespace System.Web.Mail
diff --git a/mcs/class/System.Web/System.Web.Mail/MailEncoding.cs b/mcs/class/System.Web/System.Web.Mail/MailEncoding.cs
new file mode 100644
index 00000000000..16b1b341a91
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Mail/MailEncoding.cs
@@ -0,0 +1,26 @@
+//
+// System.Web.Mail.MailEncoding.cs
+//
+// Author:
+// Lawrence Pit (loz@cable.a2000.nl)
+//
+
+namespace System.Web.Mail
+{
+
+ /// <summary>
+ /// </summary>
+ public enum MailEncoding
+ {
+
+ /// <summary>
+ /// </summary>
+ UUEncode = 0,
+
+ /// <summary>
+ /// </summary>
+ Base64 = 1
+
+ }
+
+} //namespace System.Web.Mail
diff --git a/mcs/class/System.Web/System.Web.Mail/MailFormat.cs b/mcs/class/System.Web/System.Web.Mail/MailFormat.cs
new file mode 100644
index 00000000000..e1050d78549
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Mail/MailFormat.cs
@@ -0,0 +1,26 @@
+//
+// System.Web.Mail.MailFormat.cs
+//
+// Author:
+// Lawrence Pit (loz@cable.a2000.nl)
+//
+
+namespace System.Web.Mail
+{
+
+ /// <summary>
+ /// </summary>
+ public enum MailFormat
+ {
+
+ /// <summary>
+ /// </summary>
+ Text = 0,
+
+ /// <summary>
+ /// </summary>
+ Html = 1
+
+ }
+
+} //namespace System.Web.Mail
diff --git a/mcs/class/System.Web/System.Web.Mail/MailMessage.cs b/mcs/class/System.Web/System.Web.Mail/MailMessage.cs
new file mode 100644
index 00000000000..11d85b9c04c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Mail/MailMessage.cs
@@ -0,0 +1,106 @@
+//
+// System.Web.Mail.MailMessage.cs
+//
+// Author:
+// Lawrence Pit (loz@cable.a2000.nl)
+//
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace System.Web.Mail
+{
+ /// <remarks>
+ /// </remarks>
+ public class MailMessage
+ {
+ private ArrayList attachments;
+ private string bcc;
+ private string body;
+ private Encoding bodyEncoding;
+ private MailFormat bodyFormat;
+ private string cc;
+ private string from;
+ private ListDictionary headers;
+ private MailPriority priority;
+ private string subject;
+ private string to;
+ private string urlContentBase;
+ private string urlContentLocation;
+
+ // Constructor
+ public MailMessage ()
+ {
+ attachments = new ArrayList (8);
+ headers = new ListDictionary ();
+ }
+
+ // Properties
+ public IList Attachments {
+ get { return (IList) attachments; }
+ }
+
+ public string Bcc {
+ get { return bcc; }
+ set { bcc = value; }
+ }
+
+ public string Body {
+ get { return body; }
+ set { body = value; }
+ }
+
+ public Encoding BodyEncoding {
+ get { return bodyEncoding; }
+ set { bodyEncoding = value; }
+ }
+
+ public MailFormat BodyFormat {
+ get { return bodyFormat; }
+ set { bodyFormat = value; }
+ }
+
+ public string Cc {
+ get { return cc; }
+ set { cc = value; }
+ }
+
+ public string From {
+ get { return from; }
+ set { from = value; }
+ }
+
+ public IDictionary Headers {
+ get { return (IDictionary) headers; }
+ }
+
+ public MailPriority Priority {
+ get { return priority; }
+ set { priority = value; }
+ }
+
+ public string Subject {
+ get { return subject; }
+ set { subject = value; }
+ }
+
+ public string To {
+ get { return to; }
+ set { to = value; }
+ }
+
+ public string UrlContentBase {
+ get { return urlContentBase; }
+ set { urlContentBase = value; }
+ }
+
+ public string UrlContentLocation {
+ get { return urlContentLocation; }
+ set { urlContentLocation = value; }
+ }
+
+ }
+
+} //namespace System.Web.Mail
diff --git a/mcs/class/System.Web/System.Web.Mail/MailPriority.cs b/mcs/class/System.Web/System.Web.Mail/MailPriority.cs
new file mode 100644
index 00000000000..6b6c638edf2
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Mail/MailPriority.cs
@@ -0,0 +1,30 @@
+//
+// System.Web.Mail.MailPriority.cs
+//
+// Author:
+// Lawrence Pit (loz@cable.a2000.nl)
+//
+
+namespace System.Web.Mail
+{
+
+ /// <summary>
+ /// </summary>
+ public enum MailPriority
+ {
+
+ /// <summary>
+ /// </summary>
+ Normal = 0,
+
+ /// <summary>
+ /// </summary>
+ Low = 1,
+
+ /// <summary>
+ /// </summary>
+ High = 2
+
+ }
+
+} //namespace System.Web.Mail
diff --git a/mcs/class/System.Web/System.Web.Mail/SmtpMail.cs b/mcs/class/System.Web/System.Web.Mail/SmtpMail.cs
new file mode 100644
index 00000000000..3fb1d2d8135
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Mail/SmtpMail.cs
@@ -0,0 +1,77 @@
+//
+// System.Web.Mail.SmtpMail.cs
+//
+// Author:
+// Lawrence Pit (loz@cable.a2000.nl)
+//
+//
+
+using System;
+using System.Net;
+using System.Reflection;
+
+namespace System.Web.Mail
+{
+ /// <remarks>
+ /// </remarks>
+ public class SmtpMail
+ {
+ private static string smtpServer;
+
+ // Constructor
+ private SmtpMail ()
+ {
+ /* empty */
+ }
+
+ // Properties
+ public static string SmtpServer {
+ get { return smtpServer; }
+ set { smtpServer = value; }
+ }
+
+ [MonoTODO]
+ public static void Send (MailMessage message)
+ {
+ // delegate work to loosly coupled component Mono.Mail
+
+ // Mono.Mail.Smtp.SmtpSender.Send (smtpServer, message);
+
+ // NOTE: Mono.Mail is work in progress, and could be replaced by
+ // another component. For now:
+
+ throw new NotImplementedException("Mono.Mail component is work in progress");
+
+ /*
+ try {
+ // TODO: possibly cache ctor info object..
+ Type stype = Type.GetType ("Mono.Mail.Smtp.SmtpSender");
+ if (stype == null) {
+ throw new Exception ("You must have Mono.Mail installed to send mail.");
+ }
+ Type[] types = new Type[2];
+ types[0] = typeof (string);
+ types[1] = message.GetType ();
+ ConstructorInfo cinfo =
+ stype.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null,
+ CallingConventions.HasThis, types, null);
+ cinfo.Invoke (new object[] {smtpServer, message});
+ } catch (Exception) {
+ throw new Exception ("Unable to call Mono.Mail.Smtp.SmtpSender");
+ }
+ */
+ }
+
+ public static void Send (string from, string to, string subject, string messageText)
+ {
+ MailMessage message = new MailMessage ();
+ message.From = from;
+ message.To = to;
+ message.Subject = subject;
+ message.Body = messageText;
+ Send (message);
+ }
+
+ }
+
+} //namespace System.Web.Mail
diff --git a/mcs/class/System.Web/System.Web.Security/ChangeLog b/mcs/class/System.Web/System.Web.Security/ChangeLog
new file mode 100644
index 00000000000..68177fddc55
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/ChangeLog
@@ -0,0 +1,59 @@
+2003-01-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DefaultAuthenticationModule.cs: implemented. It just create a default
+ unauthenticated user when no one else provided one.
+
+ * FormsAuthenticationModule.cs: removed debug output.
+
+2002-12-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * FormsAuthenticationModule.cs: remove debug lines.
+
+2002-12-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * FormsAuthentication.cs: return a null ticket when an exception is
+ thrown creating it. Implemented RenewTicketIfOld.
+
+ * FormsAuthenticationModule.cs: implemented event handlers for
+ AuthenticateRequest and EndRequest.
+
+ * FormsAuthenticationTicket.cs: implemented SetDates and Clone methods.
+
+2002-12-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * FormsAuthentication.cs: implemented GetAuthCookie, SetAuthCookie,
+ SignOut, FormsCookieName and FormsCookiePath.
+
+2002-12-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * FormsAuthentication.cs: implemented Authenticate, unencrypted Encrypt
+ and Decrypt, HashPasswordForStoringInConfigFile and Initialize.
+
+ * FormsAuthenticationTicket.cs: set cookiePath to the default when no
+ other provided.
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DefaultAuthenticationEventHandler.cs:
+ * DefaultAuthenticationModule.cs:
+ * FileAuthorizationModule.cs:
+ * FormsAuthentication.cs:
+ * FormsAuthenticationEventArgs.cs:
+ * FormsAuthenticationEventHandler.cs:
+ * FormsAuthenticationModule.cs:
+ * FormsAuthenticationTicket.cs:
+ * FormsIdentity.cs:
+ * PassportAuthenticationEventArgs.cs:
+ * PassportAuthenticationEventHandler.cs:
+ * PassportAuthenticationModule.cs:
+ * PassportIdentity.cs:
+ * UrlAuthorizationModule.cs:
+ * WindowsAuthenticationEventArgs.cs:
+ * WindowsAuthenticationEventHandler.cs:
+ * WindowsAuthenticationModule.cs: new files. Some of them implemented,
+ some others stubbed out.
+
+2002-06-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DefaultAuthenticationEventArgs.cs: added file.
+
diff --git a/mcs/class/System.Web/System.Web.Security/DefaultAuthenticationEventArgs.cs b/mcs/class/System.Web/System.Web.Security/DefaultAuthenticationEventArgs.cs
new file mode 100644
index 00000000000..2031b829d9d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/DefaultAuthenticationEventArgs.cs
@@ -0,0 +1,32 @@
+//
+// System.Web.Security.DefaultAuthenticationEventArgs
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web.Security {
+ using System;
+ using System.Web;
+
+public sealed class DefaultAuthenticationEventArgs : EventArgs
+{
+ private HttpContext _context;
+
+ public DefaultAuthenticationEventArgs (HttpContext context)
+ {
+ if (context == null)
+ throw new ArgumentNullException ("context");
+
+ _context = context;
+ }
+
+ public HttpContext Context
+ {
+ get { return _context; }
+ }
+}
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/DefaultAuthenticationEventHandler.cs b/mcs/class/System.Web/System.Web.Security/DefaultAuthenticationEventHandler.cs
new file mode 100644
index 00000000000..1b9ab56cd79
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/DefaultAuthenticationEventHandler.cs
@@ -0,0 +1,15 @@
+//
+// System.Web.Security.DefaultAuthenticationEventHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web.Security
+{
+ public delegate void DefaultAuthenticationEventHandler (object sender,
+ DefaultAuthenticationEventArgs e);
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/DefaultAuthenticationModule.cs b/mcs/class/System.Web/System.Web.Security/DefaultAuthenticationModule.cs
new file mode 100644
index 00000000000..d9b56142143
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/DefaultAuthenticationModule.cs
@@ -0,0 +1,43 @@
+//
+// System.Web.Security.DefaultAuthenticationModule
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Web;
+using System.Security.Principal;
+
+namespace System.Web.Security
+{
+ public sealed class DefaultAuthenticationModule : IHttpModule
+ {
+ static GenericIdentity defaultIdentity = new GenericIdentity ("", "");
+
+ public event DefaultAuthenticationEventHandler Authenticate;
+
+ public void Dispose ()
+ {
+ }
+
+ public void Init (HttpApplication app)
+ {
+ app.DefaultAuthentication += new EventHandler (OnDefaultAuthentication);
+ }
+
+ void OnDefaultAuthentication (object sender, EventArgs args)
+ {
+ HttpApplication app = (HttpApplication) sender;
+ HttpContext context = app.Context;
+
+ if (context.User == null && Authenticate != null)
+ Authenticate (this, new DefaultAuthenticationEventArgs (context));
+
+ if (context.User == null)
+ context.User = new GenericPrincipal (defaultIdentity, new string [0]);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/FileAuthorizationModule.cs b/mcs/class/System.Web/System.Web.Security/FileAuthorizationModule.cs
new file mode 100644
index 00000000000..af70f6f4248
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/FileAuthorizationModule.cs
@@ -0,0 +1,27 @@
+//
+// System.Web.Security.FileAuthorizationModule
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Web;
+
+namespace System.Web.Security
+{
+ public sealed class FileAuthorizationModule : IHttpModule
+ {
+ public void Dispose ()
+ {
+ }
+
+ [MonoTODO]
+ public void Init (HttpApplication app)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs b/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs
new file mode 100644
index 00000000000..4bba86d5c1b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs
@@ -0,0 +1,300 @@
+//
+// System.Web.Security.FormsAuthentication
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.Security.Cryptography;
+using System.Text;
+using System.Web;
+using System.Web.Configuration;
+using System.Web.Util;
+
+namespace System.Web.Security
+{
+ public sealed class FormsAuthentication
+ {
+ static string authConfigPath = "system.web/authentication";
+ static bool initialized;
+ static string cookieName;
+ static string cookiePath;
+ static int timeout;
+ static FormsProtectionEnum protection;
+
+ public static bool Authenticate (string name, string password)
+ {
+ if (name == null || password == null)
+ return false;
+
+ Initialize ();
+ HttpContext context = HttpContext.Current;
+ if (context == null)
+ throw new HttpException ("Context is null!");
+
+ AuthConfig config = context.GetConfig (authConfigPath) as AuthConfig;
+ Hashtable users = config.CredentialUsers;
+ string stored = users [name] as string;
+ if (stored == null)
+ return false;
+
+ switch (config.PasswordFormat) {
+ case FormsAuthPasswordFormat.Clear:
+ /* Do nothing */
+ break;
+ case FormsAuthPasswordFormat.MD5:
+ stored = HashPasswordForStoringInConfigFile (stored, "MD5");
+ break;
+ case FormsAuthPasswordFormat.SHA1:
+ stored = HashPasswordForStoringInConfigFile (stored, "SHA1");
+ break;
+ }
+
+ return (password == stored);
+ }
+
+ public static FormsAuthenticationTicket Decrypt (string encryptedTicket)
+ {
+ if (encryptedTicket == null || encryptedTicket == String.Empty)
+ throw new ArgumentException ("Invalid encrypted ticket", "encryptedTicket");
+
+ Initialize ();
+ byte [] bytes = MachineKeyConfigHandler.GetBytes (encryptedTicket, encryptedTicket.Length);
+ //TODO: decrypt
+ string decrypted = WebEncoding.Encoding.GetString (bytes);
+ FormsAuthenticationTicket ticket = null;
+ try {
+ string [] values = decrypted.Split ((char) 1, (char) 2, (char) 3, (char) 4, (char) 5, (char) 6, (char) 7);
+ if (values.Length != 8)
+ throw new Exception (values.Length + " " + encryptedTicket);
+
+
+ ticket = new FormsAuthenticationTicket (Int32.Parse (values [0]),
+ values [1],
+ new DateTime (Int64.Parse (values [2])),
+ new DateTime (Int64.Parse (values [3])),
+ (values [4] == "1"),
+ values [5],
+ values [6]);
+ } catch (Exception e) {
+ ticket = null;
+ }
+
+ return ticket;
+ }
+
+ public static string Encrypt (FormsAuthenticationTicket ticket)
+ {
+ if (ticket == null)
+ throw new ArgumentNullException ("ticket");
+
+ Initialize ();
+ StringBuilder allTicket = new StringBuilder ();
+ allTicket.Append (ticket.Version);
+ allTicket.Append ('\u0001');
+ allTicket.Append (ticket.Name);
+ allTicket.Append ('\u0002');
+ allTicket.Append (ticket.IssueDate.Ticks);
+ allTicket.Append ('\u0003');
+ allTicket.Append (ticket.Expiration.Ticks);
+ allTicket.Append ('\u0004');
+ allTicket.Append (ticket.IsPersistent ? '1' : '0');
+ allTicket.Append ('\u0005');
+ allTicket.Append (ticket.UserData);
+ allTicket.Append ('\u0006');
+ allTicket.Append (ticket.CookiePath);
+ allTicket.Append ('\u0007');
+ //if (protection == FormsProtectionEnum.None)
+ return GetHexString (allTicket.ToString ());
+ //TODO: encrypt and validate
+ }
+
+ public static HttpCookie GetAuthCookie (string userName, bool createPersistentCookie)
+ {
+ return GetAuthCookie (userName, createPersistentCookie, cookiePath);
+ }
+
+ public static HttpCookie GetAuthCookie (string userName, bool createPersistentCookie, string strCookiePath)
+ {
+ Initialize ();
+
+ if (userName == null)
+ userName = String.Empty;
+
+ if (strCookiePath == null || strCookiePath.Length == 0)
+ strCookiePath = cookiePath;
+
+ DateTime now = DateTime.Now;
+ DateTime then;
+ if (createPersistentCookie)
+ then = now.AddYears (50);
+ else
+ then = now.AddMinutes (timeout);
+
+ FormsAuthenticationTicket ticket = new FormsAuthenticationTicket (1,
+ userName,
+ now,
+ then,
+ createPersistentCookie,
+ String.Empty,
+ cookiePath);
+
+ if (!createPersistentCookie)
+ then = DateTime.MinValue;
+
+ return new HttpCookie (cookieName, Encrypt (ticket), strCookiePath, then);
+ }
+
+ [MonoTODO]
+ public static string GetRedirectUrl (string userName, bool createPersistentCookie)
+ {
+ throw new NotImplementedException ();
+ }
+
+ static string GetHexString (string str)
+ {
+ return GetHexString (WebEncoding.Encoding.GetBytes (str));
+ }
+
+ static string GetHexString (byte [] bytes)
+ {
+ StringBuilder result = new StringBuilder (bytes.Length * 2);
+ foreach (byte b in bytes)
+ result.AppendFormat ("{0:x2}", (int) b);
+
+ return result.ToString ();
+ }
+
+ public static string HashPasswordForStoringInConfigFile (string password, string passwordFormat)
+ {
+ if (password == null)
+ throw new ArgumentNullException ("password");
+
+ if (passwordFormat == null)
+ throw new ArgumentNullException ("passwordFormat");
+
+ byte [] bytes;
+ if (String.Compare (passwordFormat, "MD5", true) == 0) {
+ bytes = MD5.Create ().ComputeHash (WebEncoding.Encoding.GetBytes (password));
+ } else if (String.Compare (passwordFormat, "SHA1", true) == 0) {
+ bytes = SHA1.Create ().ComputeHash (WebEncoding.Encoding.GetBytes (password));
+ } else {
+ throw new ArgumentException ("The format must be either MD5 or SHA1", "passwordFormat");
+ }
+
+ return GetHexString (bytes);
+ }
+
+ public static void Initialize ()
+ {
+ if (initialized)
+ return;
+
+ lock (typeof (FormsAuthentication)) {
+ if (initialized)
+ return;
+
+ HttpContext context = HttpContext.Current;
+ if (context == null)
+ throw new HttpException ("Context is null!");
+
+ AuthConfig authConfig = context.GetConfig (authConfigPath) as AuthConfig;
+ if (authConfig != null) {
+ cookieName = authConfig.CookieName;
+ timeout = authConfig.Timeout;
+ cookiePath = authConfig.CookiePath;
+ protection = authConfig.Protection;
+ } else {
+ cookieName = ".MONOAUTH";
+ timeout = 30;
+ cookiePath = "/";
+ protection = FormsProtectionEnum.All;
+ }
+
+ initialized = true;
+ }
+ }
+
+ [MonoTODO]
+ public static void RedirectFromLoginPage (string userName, bool createPersistentCookie)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void RedirectFromLoginPage (string userName, bool createPersistentCookie, string strCookiePath)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public static FormsAuthenticationTicket RenewTicketIfOld (FormsAuthenticationTicket tOld)
+ {
+ if (tOld == null)
+ return null;
+
+ DateTime now = DateTime.Now;
+ TimeSpan toIssue = now - tOld.IssueDate;
+ TimeSpan toExpiration = tOld.Expiration - now;
+ if (toExpiration > toIssue)
+ return tOld;
+
+ FormsAuthenticationTicket tNew = tOld.Clone ();
+ tNew.SetDates (now, now - toExpiration + toIssue);
+ return tNew;
+ }
+
+ public static void SetAuthCookie (string userName, bool createPersistentCookie)
+ {
+ SetAuthCookie (userName, createPersistentCookie, cookiePath);
+ }
+
+ public static void SetAuthCookie (string userName, bool createPersistentCookie, string strCookiePath)
+ {
+ HttpContext context = HttpContext.Current;
+ if (context == null)
+ throw new HttpException ("Context is null!");
+
+ HttpResponse response = context.Response;
+ if (response == null)
+ throw new HttpException ("Response is null!");
+
+ response.Cookies.Add (GetAuthCookie (userName, createPersistentCookie, strCookiePath));
+ }
+
+ public static void SignOut ()
+ {
+ Initialize ();
+
+ HttpContext context = HttpContext.Current;
+ if (context == null)
+ throw new HttpException ("Context is null!");
+
+ HttpResponse response = context.Response;
+ if (response == null)
+ throw new HttpException ("Response is null!");
+
+ response.Cookies.MakeCookieExpire (cookieName, cookiePath);
+ }
+
+ public static string FormsCookieName
+ {
+ get {
+ Initialize ();
+ return cookieName;
+ }
+ }
+
+ public static string FormsCookiePath
+ {
+ get {
+ Initialize ();
+ return cookiePath;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/FormsAuthenticationEventArgs.cs b/mcs/class/System.Web/System.Web.Security/FormsAuthenticationEventArgs.cs
new file mode 100644
index 00000000000..bbc61068513
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/FormsAuthenticationEventArgs.cs
@@ -0,0 +1,45 @@
+//
+// System.Web.Security.FormsAuthenticationEventArgs
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Security.Principal;
+using System.Web;
+
+namespace System.Web.Security
+{
+ public sealed class FormsAuthenticationEventArgs : EventArgs
+ {
+ IPrincipal user;
+ HttpContext context;
+
+ public FormsAuthenticationEventArgs (HttpContext context)
+ {
+ this.context = context;
+ }
+
+ public HttpContext Context
+ {
+ get {
+ return context;
+ }
+ }
+
+ public IPrincipal User
+ {
+ get {
+ return user;
+ }
+
+ set {
+ user = value;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/FormsAuthenticationEventHandler.cs b/mcs/class/System.Web/System.Web.Security/FormsAuthenticationEventHandler.cs
new file mode 100644
index 00000000000..ae47ed31206
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/FormsAuthenticationEventHandler.cs
@@ -0,0 +1,14 @@
+//
+// System.Web.Security.FormsAuthenticationEventHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web.Security
+{
+ public delegate void FormsAuthenticationEventHandler (object sender, FormsAuthenticationEventArgs e);
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/FormsAuthenticationModule.cs b/mcs/class/System.Web/System.Web.Security/FormsAuthenticationModule.cs
new file mode 100644
index 00000000000..21fc124de0d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/FormsAuthenticationModule.cs
@@ -0,0 +1,91 @@
+//
+// System.Web.Security.FormsAuthenticationModule
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Security.Principal;
+using System.Web;
+using System.Web.Configuration;
+
+namespace System.Web.Security
+{
+ public sealed class FormsAuthenticationModule : IHttpModule
+ {
+ bool noForms;
+
+ public void Dispose ()
+ {
+ }
+
+ public void Init (HttpApplication app)
+ {
+ app.AuthenticateRequest += new EventHandler (OnAuthenticateRequest);
+ app.EndRequest += new EventHandler (OnEndRequest);
+ }
+
+ void OnAuthenticateRequest (object sender, EventArgs args)
+ {
+ HttpApplication app = (HttpApplication) sender;
+ HttpContext context = app.Context;
+ AuthConfig config = (AuthConfig) context.GetConfig ("system.web/authentication");
+ if (config.Mode != AuthenticationMode.Forms) {
+ noForms = true;
+ return;
+ }
+
+ string cookieName = config.CookieName;
+ string cookiePath = config.CookiePath;
+ string loginPage = config.LoginUrl;
+
+ FormsAuthenticationEventArgs formArgs = new FormsAuthenticationEventArgs (context);
+ if (Authenticate != null)
+ Authenticate (this, formArgs);
+
+ bool contextUserNull = (context.User == null);
+ if (formArgs.User != null || !contextUserNull) {
+ if (contextUserNull)
+ context.User = formArgs.User;
+ return;
+ }
+
+ HttpCookie cookie = context.Request.Cookies [cookieName];
+ if (cookie == null || (cookie.Expires != DateTime.MinValue && cookie.Expires < DateTime.Now)) {
+ return;
+ }
+
+ FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt (cookie.Value);
+ FormsAuthentication.RenewTicketIfOld (ticket);
+ context.User = new GenericPrincipal (new FormsIdentity (ticket), new string [0]);
+
+ cookie.Value = FormsAuthentication.Encrypt (ticket);
+ cookie.Path = cookiePath;
+ if (ticket.IsPersistent)
+ cookie.Expires = ticket.Expiration;
+
+ context.Response.Cookies.Add (cookie);
+ context.SkipAuthorization = (context.Request.Path == loginPage);
+ }
+
+ void OnEndRequest (object sender, EventArgs args)
+ {
+ if (noForms)
+ return;
+
+ HttpApplication app = (HttpApplication) sender;
+ HttpContext context = app.Context;
+ if (context.Response.StatusCode != 401)
+ return;
+
+ AuthConfig config = (AuthConfig) context.GetConfig ("system.web/authentication");
+ context.Response.Redirect (config.LoginUrl);
+ }
+
+ public event FormsAuthenticationEventHandler Authenticate;
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/FormsAuthenticationTicket.cs b/mcs/class/System.Web/System.Web.Security/FormsAuthenticationTicket.cs
new file mode 100644
index 00000000000..d867c7783fc
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/FormsAuthenticationTicket.cs
@@ -0,0 +1,147 @@
+//
+// System.Web.Security.FormsAuthenticationTicket
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+
+namespace System.Web.Security
+{
+ [Serializable]
+ public sealed class FormsAuthenticationTicket
+ {
+ int version;
+ string name;
+ DateTime issueDate;
+ DateTime expiration;
+ bool isPersistent;
+ string userData;
+ string cookiePath;
+
+ public FormsAuthenticationTicket (int version,
+ string name,
+ DateTime issueDate,
+ DateTime expiration,
+ bool isPersistent,
+ string userData)
+ {
+ this.version = version;
+ this.name = name;
+ this.issueDate = issueDate;
+ this.expiration = expiration;
+ this.isPersistent = isPersistent;
+ this.userData = userData;
+ this.cookiePath = "/";
+ }
+
+ public FormsAuthenticationTicket (int version,
+ string name,
+ DateTime issueDate,
+ DateTime expiration,
+ bool isPersistent,
+ string userData,
+ string cookiePath)
+ {
+ this.version = version;
+ this.name = name;
+ this.issueDate = issueDate;
+ this.expiration = expiration;
+ this.isPersistent = isPersistent;
+ this.userData = userData;
+ this.cookiePath = cookiePath;
+ }
+
+ public FormsAuthenticationTicket (string name, bool isPersistent, int timeout)
+ {
+ this.version = 1;
+ this.name = name;
+ this.issueDate = DateTime.Now;
+ this.isPersistent = isPersistent;
+ if (isPersistent)
+ expiration = issueDate.AddYears (50);
+ else
+ expiration = issueDate.AddMinutes ((double) timeout);
+
+ this.userData = String.Empty;
+ this.cookiePath = "/";
+ }
+
+ internal void SetDates (DateTime issueDate, DateTime expiration)
+ {
+ this.issueDate = issueDate;
+ this.expiration = expiration;
+ }
+
+ internal FormsAuthenticationTicket Clone ()
+ {
+ return new FormsAuthenticationTicket (version,
+ name,
+ issueDate,
+ expiration,
+ isPersistent,
+ userData,
+ cookiePath);
+ }
+
+ public string CookiePath
+ {
+ get {
+ return cookiePath;
+ }
+ }
+
+ public DateTime Expiration
+ {
+ get {
+ return expiration;
+ }
+ }
+
+ public bool Expired
+ {
+ get {
+ return DateTime.Now > expiration;
+ }
+ }
+
+ public bool IsPersistent
+ {
+ get {
+ return isPersistent;
+ }
+ }
+
+ public DateTime IssueDate
+ {
+ get {
+ return issueDate;
+ }
+ }
+
+ public string Name
+ {
+ get {
+ return name;
+ }
+ }
+
+ public string UserData
+ {
+ get {
+ return userData;
+ }
+ }
+
+ public int Version
+ {
+ get {
+ return version;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/FormsIdentity.cs b/mcs/class/System.Web/System.Web.Security/FormsIdentity.cs
new file mode 100644
index 00000000000..98fedabdcae
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/FormsIdentity.cs
@@ -0,0 +1,54 @@
+//
+// System.Web.Security.FormsIdentity
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Security.Principal;
+
+namespace System.Web.Security
+{
+ [Serializable]
+ public sealed class FormsIdentity : IIdentity
+ {
+ FormsAuthenticationTicket ticket;
+
+ public FormsIdentity (FormsAuthenticationTicket ticket)
+ {
+ this.ticket = ticket;
+ }
+
+ public string AuthenticationType
+ {
+ get {
+ return "Forms";
+ }
+ }
+
+ public bool IsAuthenticated
+ {
+ get {
+ return true;
+ }
+ }
+
+ public string Name
+ {
+ get {
+ return ticket.Name;
+ }
+ }
+
+ public FormsAuthenticationTicket Ticket
+ {
+ get {
+ return ticket;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/PassportAuthenticationEventArgs.cs b/mcs/class/System.Web/System.Web.Security/PassportAuthenticationEventArgs.cs
new file mode 100644
index 00000000000..589b81fbf93
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/PassportAuthenticationEventArgs.cs
@@ -0,0 +1,54 @@
+//
+// System.Web.Security.PassportAuthenticationEventArgs
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Security.Principal;
+using System.Web;
+
+namespace System.Web.Security
+{
+ public sealed class PassportAuthenticationEventArgs : EventArgs
+ {
+ PassportIdentity identity;
+ HttpContext context;
+ IPrincipal user;
+
+ public PassportAuthenticationEventArgs (PassportIdentity identity, HttpContext context)
+ {
+ this.identity = identity;
+ this.context = context;
+ }
+
+ public HttpContext Context
+ {
+ get {
+ return context;
+ }
+ }
+
+ public PassportIdentity Identity
+ {
+ get {
+ return identity;
+ }
+ }
+
+ public IPrincipal User
+ {
+ get {
+ return user;
+ }
+
+ set {
+ user = value;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/PassportAuthenticationEventHandler.cs b/mcs/class/System.Web/System.Web.Security/PassportAuthenticationEventHandler.cs
new file mode 100644
index 00000000000..20181ae7098
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/PassportAuthenticationEventHandler.cs
@@ -0,0 +1,15 @@
+//
+// System.Web.Security.PassportAuthenticationEventHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web.Security
+{
+ public delegate void PassportAuthenticationEventHandler (object sender,
+ PassportAuthenticationEventArgs e);
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/PassportAuthenticationModule.cs b/mcs/class/System.Web/System.Web.Security/PassportAuthenticationModule.cs
new file mode 100644
index 00000000000..e5f1c422f8f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/PassportAuthenticationModule.cs
@@ -0,0 +1,29 @@
+//
+// System.Web.Security.PassportAuthenticationModule
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Web;
+
+namespace System.Web.Security
+{
+ public sealed class PassportAuthenticationModule : IHttpModule
+ {
+ public event PassportAuthenticationEventHandler Authenticate;
+
+ public void Dispose ()
+ {
+ }
+
+ [MonoTODO("Will we ever implement this? :-)")]
+ public void Init (HttpApplication app)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/PassportIdentity.cs b/mcs/class/System.Web/System.Web.Security/PassportIdentity.cs
new file mode 100644
index 00000000000..937e825eecc
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/PassportIdentity.cs
@@ -0,0 +1,438 @@
+//
+// System.Web.Security.PassportIdentity
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Security.Principal;
+
+namespace System.Web.Security
+{
+ public sealed class PassportIdentity : IIdentity
+ {
+ [MonoTODO]
+ public PassportIdentity ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ ~PassportIdentity ()
+ {
+ }
+
+ [MonoTODO]
+ public string AuthUrl ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string AuthUrl (string strReturnUrl,
+ int iTimeWindow,
+ bool fForceLogin,
+ string strCoBrandedArgs,
+ int iLangID,
+ string strNameSpace,
+ int iKPP,
+ bool bUseSecureAuth)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string AuthUrl (string strReturnUrl,
+ int iTimeWindow,
+ int iForceLogin,
+ string strCoBrandedArgs,
+ int iLangID,
+ string strNameSpace,
+ int iKPP,
+ int iUseSecureAuth)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string AuthUrl2 ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string AuthUrl2 (string strReturnUrl,
+ int iTimeWindow,
+ bool fForceLogin,
+ string strCoBrandedArgs,
+ int iLangID,
+ string strNameSpace,
+ int iKPP,
+ bool bUseSecureAuth)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string AuthUrl2 (string strReturnUrl,
+ int iTimeWindow,
+ int iForceLogin,
+ string strCoBrandedArgs,
+ int iLangID,
+ string strNameSpace,
+ int iKPP,
+ int iUseSecureAuth)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string Compress (string strData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static bool CryptIsValid ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static int CryptPutHost (string strHost)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static int CryptPutSite (string strSite)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string Decompress (string strData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string Decrypt (string strData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static string Encrypt (string strData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public object GetCurrentConfig (string strAttribute)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string GetDomainAttribute (string strAttribute, int iLCID, string strDomain)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string GetDomainFromMemberName (string strMemberName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool GetIsAuthenticated (int iTimeWindow, bool bForceLogin, bool bCheckSecure)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool GetIsAuthenticated (int iTimeWindow, int iForceLogin, int iCheckSecure)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string GetLoginChallenge ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string GetLoginChallenge (string szRetURL,
+ int iTimeWindow,
+ int fForceLogin,
+ string szCOBrandArgs,
+ int iLangID,
+ string strNameSpace,
+ int iKPP,
+ int iUseSecureAuth,
+ object oExtraParams)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public object GetOption (string strOpt)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public object GetProfileObject (string strProfileName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool HasFlag (int iFlagMask)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool HasProfile (string strProfile)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool HaveConsent (bool bNeedFullConsent, bool bNeedBirthdate)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public int LoginUser ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public int LoginUser (string szRetURL,
+ int iTimeWindow,
+ bool fForceLogin,
+ string szCOBrandArgs,
+ int iLangID,
+ string strNameSpace,
+ int iKPP,
+ bool fUseSecureAuth,
+ object oExtraParams)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public int LoginUser (string szRetURL,
+ int iTimeWindow,
+ int fForceLogin,
+ string szCOBrandArgs,
+ int iLangID,
+ string strNameSpace,
+ int iKPP,
+ int iUseSecureAuth,
+ object oExtraParams)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string LogoTag ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string LogoTag (string strReturnUrl,
+ int iTimeWindow,
+ bool fForceLogin,
+ string strCoBrandedArgs,
+ int iLangID,
+ bool fSecure,
+ string strNameSpace,
+ int iKPP,
+ bool bUseSecureAuth)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string LogoTag (string strReturnUrl,
+ int iTimeWindow,
+ int iForceLogin,
+ string strCoBrandedArgs,
+ int iLangID,
+ int iSecure,
+ string strNameSpace,
+ int iKPP,
+ int iUseSecureAuth)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string LogoTag2 ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string LogoTag2 (string strReturnUrl,
+ int iTimeWindow,
+ bool fForceLogin,
+ string strCoBrandedArgs,
+ int iLangID,
+ bool fSecure,
+ string strNameSpace,
+ int iKPP,
+ bool bUseSecureAuth)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string LogoTag2 (string strReturnUrl,
+ int iTimeWindow,
+ int iForceLogin,
+ string strCoBrandedArgs,
+ int iLangID,
+ int iSecure,
+ string strNameSpace,
+ int iKPP,
+ int iUseSecureAuth)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string LogoutURL ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string LogoutURL (string szReturnURL,
+ string szCOBrandArgs,
+ int iLangID,
+ string strDomain,
+ int iUseSecureAuth)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetOption (string strOpt, object vOpt)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static void SignOut (string strSignOutDotGifFileName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public object Ticket (string strAttribute)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public string AuthenticationType
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public int Error
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public bool GetFromNetworkServer
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public bool HasSavedPassword
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public bool HasTicket
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public string HexPUID
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public bool IsAuthenticated
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public string this [string strProfileName]
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public string Name
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public int TicketAge
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public int TimeSinceSignIn
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/UrlAuthorizationModule.cs b/mcs/class/System.Web/System.Web.Security/UrlAuthorizationModule.cs
new file mode 100644
index 00000000000..d648b3331cd
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/UrlAuthorizationModule.cs
@@ -0,0 +1,33 @@
+//
+// System.Web.Security.UrlAuthorizationModule
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Web;
+using System.Security.Principal;
+
+namespace System.Web.Security
+{
+ public sealed class UrlAuthorizationModule : IHttpModule
+ {
+ public UrlAuthorizationModule ()
+ {
+ }
+
+ public void Dispose ()
+ {
+ }
+
+ [MonoTODO]
+ public void Init (HttpApplication app)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/WindowsAuthenticationEventArgs.cs b/mcs/class/System.Web/System.Web.Security/WindowsAuthenticationEventArgs.cs
new file mode 100644
index 00000000000..b09de1c5d60
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/WindowsAuthenticationEventArgs.cs
@@ -0,0 +1,54 @@
+//
+// System.Web.Security.WindowsAuthenticationEventArgs
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Security.Principal;
+using System.Web;
+
+namespace System.Web.Security
+{
+ public sealed class WindowsAuthenticationEventArgs : EventArgs
+ {
+ WindowsIdentity identity;
+ HttpContext context;
+ IPrincipal user;
+
+ public WindowsAuthenticationEventArgs (WindowsIdentity identity, HttpContext context)
+ {
+ this.identity = identity;
+ this.context = context;
+ }
+
+ public System.Web.HttpContext Context
+ {
+ get {
+ return context;
+ }
+ }
+
+ public WindowsIdentity Identity
+ {
+ get {
+ return identity;
+ }
+ }
+
+ public IPrincipal User
+ {
+ get {
+ return user;
+ }
+
+ set {
+ user = value;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/WindowsAuthenticationEventHandler.cs b/mcs/class/System.Web/System.Web.Security/WindowsAuthenticationEventHandler.cs
new file mode 100644
index 00000000000..f1c0b47313e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/WindowsAuthenticationEventHandler.cs
@@ -0,0 +1,15 @@
+//
+// System.Web.Security.WindowsAuthenticationEventHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web.Security
+{
+ public delegate void WindowsAuthenticationEventHandler (object sender,
+ WindowsAuthenticationEventArgs e);
+}
+
diff --git a/mcs/class/System.Web/System.Web.Security/WindowsAuthenticationModule.cs b/mcs/class/System.Web/System.Web.Security/WindowsAuthenticationModule.cs
new file mode 100644
index 00000000000..419040e40a9
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Security/WindowsAuthenticationModule.cs
@@ -0,0 +1,34 @@
+//
+// System.Web.Security.WindowsAuthenticationModule
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.Security
+{
+ public sealed class WindowsAuthenticationModule : IHttpModule
+ {
+ public event WindowsAuthenticationEventHandler Authenticate;
+
+ public WindowsAuthenticationModule ()
+ {
+ }
+
+ public void Dispose ()
+ {
+ }
+
+ [MonoTODO]
+ public void Init (HttpApplication app)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.SessionState/ChangeLog b/mcs/class/System.Web/System.Web.SessionState/ChangeLog
new file mode 100644
index 00000000000..354c91f51d9
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.SessionState/ChangeLog
@@ -0,0 +1,39 @@
+2002-10-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * SessionStateModule.cs: don't throw exception. Just for testing the
+ configuration stuff until we implement this.
+
+2002-08-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpSessionState.cs: IsAbandoned is internal.
+ * SessionDictionary.cs: scope fixes.
+ * SessionStateModule.cs: added events.
+
+2002-06-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.SessionState/HttpSessionState.cs:
+ Fixes based on class status page:
+
+ - Add attributes (DefaultEvent, ParseChildren).
+ - Fix declarations.
+ - Explicitly implement some interfaces (IPostBackDataHandler
+ and IPostBackEventHandler).
+ - Implemented some missing methods.
+
+2002-06-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpSessionState.cs: implemented more methods/properties.
+ * SessionDictionary.cs: New file.
+
+2002-06-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.SessionState/HttpSessionState.cs:
+ * System.Web.SessionState/SessionStateModule.cs: new files with some
+ implementation and the rest stubbed.
+
+2002-06-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * IReadOnlySessionState.cs:
+ * IRequiresSessionState.cs:
+ * SessionStateMode.cs: new files.
+
diff --git a/mcs/class/System.Web/System.Web.SessionState/HttpSessionState.cs b/mcs/class/System.Web/System.Web.SessionState/HttpSessionState.cs
new file mode 100644
index 00000000000..324470a97cc
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.SessionState/HttpSessionState.cs
@@ -0,0 +1,199 @@
+//
+// System.Web.SessionState.HttpSessionState
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Globalization;
+using System.Threading;
+
+namespace System.Web.SessionState {
+public sealed class HttpSessionState : ICollection, IEnumerable
+{
+ private NameValueCollection _state; //FIXME: it should be a ManagementNamedValueCollection
+ private string _id;
+ private SessionDictionary _dict;
+ private HttpStaticObjectsCollection _staticObjects;
+ private int _timeout;
+ private bool _newSession;
+ private bool _isCookieless;
+ private SessionStateMode _mode;
+ private bool _isReadonly;
+ private bool _abandoned;
+
+ internal HttpSessionState (string id,
+ SessionDictionary dict,
+ HttpStaticObjectsCollection staticObjects,
+ int timeout,
+ bool newSession,
+ bool isCookieless,
+ SessionStateMode mode,
+ bool isReadonly)
+ {
+ _id = id;
+ _dict = dict;
+ _staticObjects = staticObjects;
+ _timeout = timeout;
+ _newSession = newSession;
+ _isCookieless = isCookieless;
+ _mode = mode;
+ _isReadonly = isReadonly;
+ }
+
+ // Compatibility with ASP
+ public int CodePage
+ {
+ get { return 0; }
+ set { }
+ }
+
+ public HttpSessionState Contents
+ {
+ get { return this; }
+ }
+
+ public int Count
+ {
+ get { return _state.Count; }
+ }
+
+ internal bool IsAbandoned
+ {
+ get { return _abandoned; }
+ }
+
+ public bool IsCookieless
+ {
+ get { return _isCookieless; }
+ }
+
+ public bool IsNewSession
+ {
+ get { return _newSession; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return _isReadonly; }
+ }
+
+ public bool IsSynchronized
+ {
+ get { return false; }
+ }
+
+ public object this [string key]
+ {
+ get { return _state [key]; }
+ set { _state [key] = (string) value; }
+ }
+
+ public object this [int index]
+ {
+ get { return _state [index]; }
+ set {
+ string key = _state.Keys [index];
+ _state [key] = (string) value;
+ }
+ }
+
+ public NameObjectCollectionBase.KeysCollection Keys
+ {
+ get { return _state.Keys; }
+ }
+
+ public int LCID
+ {
+ get { return Thread.CurrentThread.CurrentCulture.LCID; }
+ set { Thread.CurrentThread.CurrentCulture = new CultureInfo(value); }
+ }
+
+ public SessionStateMode Mode
+ {
+ get { return _mode; }
+ }
+
+ public string SessionID
+ {
+ get { return _id; }
+ }
+
+ public HttpStaticObjectsCollection StaticObjects
+ {
+ get { return _staticObjects; }
+ }
+
+ public object SyncRoot
+ {
+ get { return this; }
+ }
+
+ public int Timeout
+ {
+ get { return _timeout; }
+ set { _timeout = value; }
+ }
+
+ public void Abandon ()
+ {
+ _abandoned = true;
+ }
+
+ public void Add (string name, object value)
+ {
+ if (_state == null)
+ _state = new NameValueCollection ();
+
+ _state.Add (name, (string) value);
+ }
+
+ public void Clear ()
+ {
+ if (_state != null)
+ _state.Clear ();
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ if (_state == null)
+ _state = new NameValueCollection ();
+
+ _state.CopyTo (array, index);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ if (_state == null)
+ _state = new NameValueCollection ();
+
+ return _state.GetEnumerator ();
+ }
+
+ public void Remove (string name)
+ {
+ if (_state != null)
+ _state.Remove (name);
+ }
+
+ public void RemoveAll ()
+ {
+ if (_state != null)
+ foreach (string key in _state.AllKeys)
+ _state.Remove (key);
+ }
+
+ [MonoTODO("Implement ManagementNameValueCollection")]
+ public void RemoveAt (int index)
+ {
+ throw new NotImplementedException ();
+ //if (_state != null)
+ // _state.RemoveAt (index);
+ }
+}
+}
+
diff --git a/mcs/class/System.Web/System.Web.SessionState/IReadOnlySessionState.cs b/mcs/class/System.Web/System.Web.SessionState/IReadOnlySessionState.cs
new file mode 100644
index 00000000000..d9eb664a484
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.SessionState/IReadOnlySessionState.cs
@@ -0,0 +1,15 @@
+//
+// System.Web.SessionState.IReadOnlySessionState
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web.SessionState {
+public interface IReadOnlySessionState : IRequiresSessionState
+{
+}
+}
+
diff --git a/mcs/class/System.Web/System.Web.SessionState/IRequiresSessionState.cs b/mcs/class/System.Web/System.Web.SessionState/IRequiresSessionState.cs
new file mode 100644
index 00000000000..dd9a40b732b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.SessionState/IRequiresSessionState.cs
@@ -0,0 +1,15 @@
+//
+// System.Web.SessionState.IRequiresSessionState
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web.SessionState {
+public interface IRequiresSessionState
+{
+}
+}
+
diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionDictionary.cs b/mcs/class/System.Web/System.Web.SessionState/SessionDictionary.cs
new file mode 100644
index 00000000000..a389125e1dd
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.SessionState/SessionDictionary.cs
@@ -0,0 +1,93 @@
+//
+// System.Web.SessionState.SessionDictionary
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.IO;
+using System.Collections.Specialized;
+
+namespace System.Web.SessionState {
+internal class SessionDictionary : NameObjectCollectionBase
+{
+ private bool _dirty;
+
+ static SessionDictionary ()
+ {
+ }
+
+ public SessionDictionary ()
+ {
+ }
+
+ void Clear ()
+ {
+ _dirty = true;
+ BaseClear ();
+ }
+
+ [MonoTODO]
+ static SessionDictionary Deserialize (BinaryReader r)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public string GetKey (int index)
+ {
+ return BaseGetKey (index);
+ }
+
+ [MonoTODO]
+ static bool IsInmutable (object o)
+ {
+ throw new NotImplementedException ();
+ }
+
+ void Remove (string s)
+ {
+ BaseRemove (s);
+ _dirty = true;
+ }
+
+ void RemoveAt (int index)
+ {
+ BaseRemoveAt (index);
+ _dirty = true;
+ }
+
+ [MonoTODO]
+ void Serialize(BinaryWriter w)
+ {
+ throw new NotImplementedException ();
+ }
+
+ bool Dirty
+ {
+ get { return _dirty; }
+ set { _dirty = value; }
+ }
+
+ internal object this [string s]
+ {
+ get { return BaseGet (s); }
+ set {
+ BaseSet (s, value);
+ _dirty = true;
+ }
+ }
+
+ public object this [int index]
+ {
+ get { return BaseGet (index); }
+ set {
+ BaseSet (index, value);
+ _dirty = true;
+ }
+ }
+}
+
+}
+
diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionStateMode.cs b/mcs/class/System.Web/System.Web.SessionState/SessionStateMode.cs
new file mode 100644
index 00000000000..1a5fcc290c3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.SessionState/SessionStateMode.cs
@@ -0,0 +1,20 @@
+//
+// System.Web.SessionState.SessionStateMode
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web.SessionState {
+public enum SessionStateMode
+{
+ Off = 0,
+ InProc = 1,
+ StateServer = 2,
+ SQLServer = 3
+}
+
+}
+
diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs b/mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs
new file mode 100644
index 00000000000..c3bf13d8baf
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs
@@ -0,0 +1,35 @@
+//
+// System.Web.SessionState.SesionStateModule
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System.Web;
+
+namespace System.Web.SessionState
+{
+ public sealed class SessionStateModule : IHttpModule
+ {
+ public SessionStateModule ()
+ {
+ }
+
+ [MonoTODO()]
+ public void Dispose ()
+ {
+ //throw new NotImplementedException ();
+ }
+
+ [MonoTODO()]
+ public void Init (HttpApplication app)
+ {
+ //throw new NotImplementedException ();
+ }
+
+ public event EventHandler Start;
+ public event EventHandler End;
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
new file mode 100644
index 00000000000..0c3d8e41974
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
@@ -0,0 +1,254 @@
+2003-01-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.UI.HtmlControls/HtmlForm.cs: render 'action' attribute.
+
+2003-01-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlInputButton.cs: fixed bug #35677.
+
+2003-01-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlInputControl.cs: fixed bug #35673.
+
+2003-01-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlInputText.cs: fixed bug #35670.
+
+2002-11-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlSelect.cs: fixed LoadViewstate.
+
+2002-11-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlButton.cs: make it do a POST if the button has any ServerClick
+ events.
+
+2002-09-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlAnchor.cs:
+ * HtmlButton.cs:
+ * HtmlContainerControl.cs:
+ * HtmlControl.cs:
+ * HtmlForm.cs:
+ * HtmlGenericControl.cs:
+ * HtmlImage.cs:
+ * HtmlInputButton.cs:
+ * HtmlInputCheckBox.cs:
+ * HtmlInputControl.cs:
+ * HtmlInputFile.cs:
+ * HtmlInputHidden.cs:
+ * HtmlInputImage.cs:
+ * HtmlInputRadioButton.cs:
+ * HtmlInputText.cs:
+ * HtmlSelect.cs:
+ * HtmlTable.cs:
+ * HtmlTableCell.cs:
+ * HtmlTableRow.cs:
+ * HtmlTextArea.cs: added almost all missing attributes.
+
+2002-07-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlControl.cs: the attributes must use ViewState as its StateBag,
+ if not style values are lost between postbacks.
+
+2002-07-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlAnchor.cs:
+ * HtmlButton.cs:
+ * HtmlInputButton.cs:
+ * HtmlInputCheckBox.cs:
+ * HtmlInputHidden.cs:
+ * HtmlInputImage.cs:
+ * HtmlInputText.cs:
+ * HtmlTextArea.cs: Initialize EventHandlerList indexer.
+
+ * HtmlContainerControl.cs: almost rewritten to use a LiteralControl
+ instead of maintaining some flags and strings. Implemented
+ LoadViewState.
+
+ * HtmlControl.cs: fixed constructor and added ViewStateIgnoreCase.
+
+ * HtmlSelect.cs: fixed TrackViewState, SaveViewState, SelectedIndices
+ and Value.
+
+2002-07-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlGenericControl.cs: fixed TagName signature and get/set.
+ * HtmlInputImage.cs: added attribute and fixed signature of ServerClick.
+ * HtmlInputText.cs: added attribute.
+
+2002-07-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlForm.cs: don't render action attribute.
+
+2002-07-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlContainerControl.cs:
+ (CreateControlCollection): added. All containers must have a non-empty
+ control collection.
+
+2002-06-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.UI.HtmlControls/HtmlAnchor.cs:
+ * System.Web.UI.HtmlControls/HtmlButton.cs:
+ * System.Web.UI.HtmlControls/HtmlControl.cs:
+ * System.Web.UI.HtmlControls/HtmlForm.cs:
+ * System.Web.UI.HtmlControls/HtmlGenericControl.cs:
+ * System.Web.UI.HtmlControls/HtmlInputButton.cs:
+ * System.Web.UI.HtmlControls/HtmlInputCheckBox.cs:
+ * System.Web.UI.HtmlControls/HtmlInputControl.cs:
+ * System.Web.UI.HtmlControls/HtmlInputFile.cs:
+ * System.Web.UI.HtmlControls/HtmlInputHidden.cs:
+ * System.Web.UI.HtmlControls/HtmlInputImage.cs:
+ * System.Web.UI.HtmlControls/HtmlInputRadioButton.cs:
+ * System.Web.UI.HtmlControls/HtmlInputText.cs:
+ * System.Web.UI.HtmlControls/HtmlSelect.cs:
+ * System.Web.UI.HtmlControls/HtmlTable.cs:
+ * System.Web.UI.HtmlControls/HtmlTableCell.cs:
+ * System.Web.UI.HtmlControls/HtmlTableRow.cs:
+ * System.Web.UI.HtmlControls/HtmlTextArea.cs:
+
+ Fixes based on class status page:
+
+ - Add attributes (DefaultEvent, ParseChildren).
+ - Fix declarations.
+ - Explicitly implement some interfaces (IPostBackDataHandler
+ and IPostBackEventHandler).
+ - Implemented some missing methods.
+
+2002-06-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlForm.cs:
+ (RenderChildren): use OnFormRender and OnFormPostRender.
+
+2002-06-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlSelect.cs:
+ (RenderAttributes): new -> override and fixes stack overflow.
+ (RenderChildren): only 1 option can be selected at any given time
+ except when Multiple property is true.
+ (Multiple): the attribute value is either "true" or "false", not
+ "multiple".
+
+ * HtmlTable.cs:
+ (Add):
+ (AddAt): allow HtmlTableRow as children, not HtmlTableCell.
+
+ * HtmlTableCell.cs:
+ (RenderEndTag): new -> override.
+
+ * HtmlTableRow.cs:
+ (RenderChildren): fixed another stack overflow.
+ (RenderEndTag): new -> override.
+
+ * HtmlTextArea.cs:
+ (RenderAttributes): new -> override.
+
+
+2002-06-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlInputHidden.cs: fixed constructor.
+
+ * HtmlInputRadioButton.cs:
+ (RenderAttributes): fixed stack overflow.
+
+ (Name):
+ (RenderedName): new -> override.
+
+ (Value): new property.
+
+ * HtmlInputText.cs:
+ (RenderAttributes): fixed the same kind of stack overflow and make
+ string comparison case insensitive.
+
+2002-06-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlForm.cs: fixed name of Enctype property and render enctype
+ enctype attribute.
+
+ * HtmlInputControl.cs: tag type is "input", not "type".
+
+2002-06-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlControl.cs: Render contents moved to new RenderBeginTag method,
+ defined in MS docs.
+
+ * HtmlForm.cs: Render output when no IE browser.
+
+ * HtmlInputButton.cs: added constructor without arguments. Xsp used it,
+ though now it always use the other .ctor.
+
+ * HtmlInputControl.cs: cosmetic changes and implemented set_Name.
+
+2002-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlButton.cs: RenderAttributes is an override, not new.
+
+ * HtmlContainerControl.cs: use the new Render method in HtmlControl.
+
+ * HtmlControl.cs: added Render method to render the tag and its
+ attributes. Works for container and non-containers.
+
+ * HtmlImage.cs: RenderAttributes don't need to be new. Implemented
+ Height property.
+
+2002-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlContainerControl.cs: some formatting and use HttpUtility.Encode
+ instead of Page.Server to encode InnerText.
+
+2002-06-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlAnchor.cs:
+ (RenderAttributes): new -> override and fixed little bug that made
+ it cause an stack overflow.
+
+ * HtmlContainerControl.cs: reformatted and added tag and attributes
+ rendering.
+
+ * HtmlGenericControl.cs: removed TagName, which is already in
+ HtmlControl.
+
+ * HtmlTable.cs:
+ (RenderEndTag): new -> override.
+
+2002-06-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.UI.HtmlControls/HtmlForm.cs:
+ (RenderAttributes): changed new by override.
+ (Name): allow setting the property.
+
+2002-05-10 Duncan Mak <duncan@ximian.com>
+
+ * HtmlTableCellCollection.cs (this): Updated the indexer to return
+ the right type, HtmlTableCell instead of HtmlTableRow.
+
+ * HtmlInputImage.cs (OnServerClick): Commented out parts that
+ won't compile.
+
+ * HtmlForm.cs (RenderAttributes):
+ (RenderChildren): Commented out code that doesn't compile.
+
+2002-05-07 Duncan Mak <duncan@ximian.com>
+
+ * HtmlSelect.cs (TrackViewState): Added 'new' keyword to avoid
+ clashing with the method defined in the parent class.
+ (OnDataBinding): Added missing casts.
+
+ * HtmlForm.cs (Render): Fixed call too SetAttribute, need to cast
+ 'this' to IAttributeAccessor before calling interface method.
+ Also renamed some calls to reflect changes in the API.
+
+ * HtmlControl.cs (WriteOnClickAttribute): Made it not static and
+ fixed a typo.
+
+2001-09-03 Leen Toelen <toelen@hotmail.com>
+
+ * HtmlAnchor.cs: Initial implementation.
+ * HtmlTextArea.cs: Initial implementation.
+
+2001-08-22 Bob Smith <bob@thestuff.net>
+
+ * HtmlContainerControl.cs: Initial implementation.
+ * HtmlControl.cs: Initial implementation.
+ * HtmlGenericControl.cs: Initial implementation.
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs
new file mode 100644
index 00000000000..010312f848c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs
@@ -0,0 +1,118 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ [DefaultEvent("ServerClick")]
+ public class HtmlAnchor : HtmlContainerControl, IPostBackEventHandler{
+
+ private static readonly object EventServerClick = new object ();
+
+ public HtmlAnchor(): base("a"){}
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender (e);
+ if (Page != null && Events [EventServerClick] != null)
+ Page.RequiresPostBackScript ();
+ }
+
+ protected virtual void OnServerClick(EventArgs e){
+ EventHandler handler;
+ handler = (EventHandler) Events[EventServerClick];
+ if(handler != null) handler.Invoke(this, e);
+ }
+
+ protected override void RenderAttributes(HtmlTextWriter writer){
+ if ( Events[EventServerClick] != null){
+ Attributes.Remove("href");
+ base.RenderAttributes(writer);
+ writer.WriteAttribute("href", Page.GetPostBackClientHyperlink(this,String.Empty));
+ }
+ else{
+ PreProcessRelativeReference(writer,"href");
+ base.RenderAttributes(writer);
+ }
+ }
+
+ void System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(string eventArgument){
+ OnServerClick(EventArgs.Empty);
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("Fires when the control is clicked.")]
+ public event EventHandler ServerClick{
+ add{
+ Events.AddHandler(EventServerClick, value);
+ }
+ remove{
+ Events.RemoveHandler(EventServerClick, value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Action")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public string HRef{
+ get{
+ string attr = Attributes["href"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["href"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Navigation")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public string Name{
+ get{
+ string attr = Attributes["name"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["name"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Navigation")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public string Target{
+ get{
+ string attr = Attributes["target"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["target"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public string Title{
+ get{
+ string attr = Attributes["title"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["title"] = AttributeToString(value);
+ }
+ }
+
+ } // class HtmlAnchor
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs
new file mode 100644
index 00000000000..1bc75655859
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs
@@ -0,0 +1,92 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ [DefaultEvent("ServerClick")]
+ public class HtmlButton : HtmlContainerControl, IPostBackEventHandler{
+
+ private static readonly object EventServerClick = new object ();
+
+ //Checked
+ public HtmlButton(): base("button"){}
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender (e);
+ if (Page != null && Events [EventServerClick] != null)
+ Page.RequiresPostBackScript ();
+ }
+
+ //Checked
+ protected virtual void OnServerClick(EventArgs e){
+ EventHandler handler;
+ handler = (EventHandler) Events[EventServerClick];
+ if(handler != null){
+ handler.Invoke(this, e);
+ }
+ }
+
+ protected override void RenderAttributes (HtmlTextWriter writer)
+ {
+ if (Page != null && Events [EventServerClick] != null) {
+ string script = Page.GetPostBackClientEvent (this, String.Empty);
+ AttributeCollection coll = Attributes;
+ if (coll ["language"] != null)
+ coll.Remove ("language");
+ writer.WriteAttribute ("language", "javascript");
+
+ string onclick;
+ if ((onclick = coll ["onclick"]) != null) {
+ script = onclick + " " + script;
+ coll.Remove ("onclick");
+ }
+
+ writer.WriteAttribute ("onclick", script);
+ }
+ base.RenderAttributes(writer);
+ }
+
+ void System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(string eventArgument){
+ if (CausesValidation){
+ Page.Validate();
+ }
+ OnServerClick(EventArgs.Empty);
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("Fires when the control is clicked.")]
+ public event EventHandler ServerClick{
+ add{
+ Events.AddHandler(EventServerClick, value);
+ }
+ remove{
+ Events.RemoveHandler(EventServerClick, value);
+ }
+ }
+
+ [DefaultValue(true)]
+ [WebCategory("Behavior")]
+ public bool CausesValidation{
+ get{
+ object attr = ViewState["CausesValidation"];
+ if (attr != null){
+ return (Boolean) attr;
+ }
+ return true;
+ }
+ set{
+ ViewState["CausesValidation"] = (Boolean) value;
+ }
+ }
+
+ } // class HtmlButton
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlContainerControl.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlContainerControl.cs
new file mode 100644
index 00000000000..79299fe1c06
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlContainerControl.cs
@@ -0,0 +1,122 @@
+//
+// System.Web.UI.HtmlControls.HtmlContainerControl.cs
+//
+// Authors:
+// Bob Smith <bob@thestuff.net>
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) Bob Smith
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+using System.ComponentModel;
+using System.Text;
+using System.Web;
+using System.Web.UI;
+
+//LAMESPEC: The dox talk about HttpException but are very ambigious.
+//TODO: Check to see if Render really is overridden instead of a LiteralControl being added. It apears that this is the
+//case due to testing. Anything inside the block is overwritten by the content of this control, so it doesnt apear
+//to do anything with children.
+// a doc references this. add? protected override ControlCollection CreateControlCollection();
+
+//TODO: If Test.InnerText = Test.InnerHtml without ever assigning anything into InnerHtml, you get this:
+// Exception Details: System.Web.HttpException: Cannot get inner content of Message because the contents are not literal.
+//[HttpException (0x80004005): Cannot get inner content of Message because the contents are not literal.]
+// System.Web.UI.HtmlControls.HtmlContainerControl.get_InnerHtml() +278
+// ASP.test3_aspx.AnchorBtn_Click(Object Source, EventArgs E) in \\genfs2\www24\bobsmith11\test3.aspx:6
+// System.Web.UI.HtmlControls.HtmlAnchor.OnServerClick(EventArgs e) +108
+// System.Web.UI.HtmlControls.HtmlAnchor.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +26
+// System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
+// System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +149
+// System.Web.UI.Page.ProcessRequestMain() +660
+
+
+namespace System.Web.UI.HtmlControls
+{
+ public abstract class HtmlContainerControl : HtmlControl{
+
+ public HtmlContainerControl () : this ("span") {}
+
+ public HtmlContainerControl (string tag) : base(tag) {}
+
+ [BrowsableAttribute(false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public virtual string InnerHtml
+ {
+ get {
+ if (Controls.Count == 0)
+ return String.Empty;
+
+ bool is_literal = true;
+ StringBuilder text = new StringBuilder ();
+ foreach (Control ctrl in Controls) {
+ LiteralControl lc = ctrl as LiteralControl;
+ if (lc == null) {
+ is_literal = false;
+ break;
+ }
+ text.Append (lc.Text);
+ }
+
+ if (!is_literal)
+ throw new HttpException ("There is no literal content!");
+
+ return text.ToString ();
+ }
+
+ set {
+ Controls.Clear ();
+ Controls.Add (new LiteralControl (value));
+ ViewState ["innerhtml"] = value;
+ }
+ }
+
+ [BrowsableAttribute(false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public virtual string InnerText
+ {
+ get {
+ return InnerHtml; //FIXME: decode it
+ }
+
+ set {
+ InnerHtml = value; //FIXME: encode it
+ }
+ }
+
+ protected override void Render (HtmlTextWriter writer)
+ {
+ RenderBeginTag (writer);
+ RenderChildren (writer);
+ RenderEndTag (writer);
+ }
+
+ protected virtual void RenderEndTag (HtmlTextWriter writer)
+ {
+ writer.WriteEndTag (TagName);
+ }
+
+ protected override void RenderAttributes (HtmlTextWriter writer)
+ {
+ ViewState.Remove ("innerhtml");
+ base.RenderAttributes (writer);
+ }
+
+ protected override ControlCollection CreateControlCollection ()
+ {
+ return new ControlCollection (this);
+ }
+
+ protected override void LoadViewState (object savedState)
+ {
+ if (savedState != null) {
+ base.LoadViewState (savedState);
+ string inner = ViewState ["innerhtml"] as string;
+ if (inner != null)
+ InnerHtml = inner;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlControl.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlControl.cs
new file mode 100644
index 00000000000..52893ecbcf7
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlControl.cs
@@ -0,0 +1,133 @@
+//
+// System.Web.UI.HtmlControls.HtmlControl.cs
+//
+// Author
+// Bob Smith <bob@thestuff.net>
+//
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ [ToolboxItem(false)]
+ public abstract class HtmlControl : Control, IAttributeAccessor
+ {
+ private string _tagName = "span";
+ private AttributeCollection _attributes;
+ private bool _disabled = false;
+
+ public HtmlControl() : this ("span") {}
+
+ public HtmlControl(string tag)
+ {
+ _tagName = tag;
+ }
+
+ protected override ControlCollection CreateControlCollection ()
+ {
+ return new EmptyControlCollection (this);
+ }
+
+ internal static string AttributeToString(int n){
+ if (n != -1)return n.ToString(NumberFormatInfo.InvariantInfo);
+ return null;
+ }
+
+ internal static string AttributeToString(string s){
+ if (s != null && s.Length != 0) return s;
+ return null;
+ }
+
+ internal void PreProcessRelativeReference(HtmlTextWriter writer, string attribName){
+ string attr = Attributes[attribName];
+ if (attr != null){
+ if (attr.Length != 0){
+ try{
+ attr = ResolveUrl(attr);
+ }
+ catch (Exception e) {
+ throw new HttpException(attribName + " property had malformed url");
+ }
+ writer.WriteAttribute(attribName, attr);
+ Attributes.Remove(attribName);
+ }
+ }
+ }
+
+ string System.Web.UI.IAttributeAccessor.GetAttribute(string name){
+ return Attributes[name];
+ }
+
+ void System.Web.UI.IAttributeAccessor.SetAttribute(string name, string value){
+ Attributes[name] = value;
+ }
+
+ protected virtual void RenderBeginTag (HtmlTextWriter writer)
+ {
+ writer.WriteBeginTag (TagName);
+ RenderAttributes (writer);
+ writer.Write ('>');
+ }
+
+ protected override void Render (HtmlTextWriter writer)
+ {
+ RenderBeginTag (writer);
+ }
+
+ protected virtual void RenderAttributes(HtmlTextWriter writer){
+ if (ID != null){
+ writer.WriteAttribute("id",ClientID);
+ }
+ Attributes.Render(writer);
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public AttributeCollection Attributes
+ {
+ get {
+ if (_attributes == null)
+ _attributes = new AttributeCollection (ViewState);
+ return _attributes;
+ }
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Behavior")]
+ public bool Disabled
+ {
+ get { return _disabled; }
+ set { _disabled = value; }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public CssStyleCollection Style
+ {
+ get { return Attributes.CssStyle; }
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Appearance")]
+ public virtual string TagName
+ {
+ get { return _tagName; }
+ }
+
+ protected override bool ViewStateIgnoresCase
+ {
+ get {
+ return true;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs
new file mode 100644
index 00000000000..4f0b4f1f33e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs
@@ -0,0 +1,176 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ public class HtmlForm : HtmlContainerControl{
+
+ private static string SmartNavIncludeScriptKey = "SmartNavIncludeScript";
+
+ public HtmlForm(): base("form"){}
+
+ protected override void RenderAttributes(HtmlTextWriter writer){
+ writer.WriteAttribute("name", RenderedName);
+ Attributes.Remove("name");
+ writer.WriteAttribute("method", Method);
+ Attributes.Remove("method");
+ writer.WriteAttribute("action", Action, true);
+ Attributes.Remove("action");
+ if (Enctype != null){
+ writer.WriteAttribute ("enctype", Enctype);
+ Attributes.Remove ("enctype");
+ }
+
+
+// string clientOnSubmit = Page.ClientOnSubmitEvent;
+// if (clientOnSubmit != null && clientOnSubmit.Length > 0){
+// if (Attributes["onsubmit"] != null){
+// clientOnSubmit = String.Concat(clientOnSubmit,Attributes["onsubmit"]);
+// Attributes.Remove("onsubmit");
+// }
+// writer.WriteAttribute("language","javascript");
+// writer.WriteAttribute("onsubmit",clientOnSubmit);
+// }
+ if (ID == null){
+ writer.WriteAttribute("id",ClientID);
+ }
+ base.RenderAttributes(writer);
+ }
+
+ protected override void Render(HtmlTextWriter output){
+ if (Page.SmartNavigation == false){
+ base.Render (output);
+ return;
+ }
+
+ ((IAttributeAccessor) this).SetAttribute("_smartNavigation","true");
+ HttpBrowserCapabilities browserCap = Context.Request.Browser;
+ if (browserCap.Browser.ToLower() != "ie" && browserCap.MajorVersion < 5){
+ base.Render(output);
+ return;
+ }
+ output.WriteLine("<IFRAME ID=_hifSmartNav NAME=_hifSmartNav STYLE=display:none ></IFRAME>");
+
+ if (browserCap.MinorVersion < 0.5 && browserCap.MajorVersion != 5)
+ Page.RegisterClientScriptFile("SmartNavIncludeScript","JScript","SmartNavIE5.js");
+ else if (Page.IsPostBack) Page.RegisterClientScriptFile("SmartNavIncludeScript","JScript","SmartNav.js");
+ base.Render(output);
+ }
+
+ protected override void RenderChildren (HtmlTextWriter writer)
+ {
+ Page.OnFormRender (writer,ClientID);
+ base.RenderChildren (writer);
+ Page.OnFormPostRender (writer,ClientID);
+ }
+
+ protected override void OnInit(EventArgs e){
+ base.OnInit(e);
+ Page.RegisterViewStateHandler();
+ }
+
+ internal string Action{
+ get{
+ string executionFilePath = Context.Request.CurrentExecutionFilePath;
+ string filePath = Context.Request.FilePath;
+ string attr;
+ if (String.ReferenceEquals(executionFilePath, filePath) == true){
+ attr = filePath;
+ int lastSlash = attr.LastIndexOf('/');
+ if (lastSlash >= 0)
+ attr = attr.Substring(lastSlash + 1);
+ }
+ else{
+ attr = System.Web.Util.UrlUtils.MakeRelative(filePath,executionFilePath);
+ }
+ string queryString = Context.Request.QueryStringRaw;
+ if (queryString != null && queryString.Length > 0)
+ attr = String.Concat(attr, '?', queryString);
+ return attr;
+ }
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Behavior")]
+ public string Enctype{
+ get{
+ string attr = Attributes["enctype"];
+ if (attr != null){
+ return attr;
+ }
+ return null;
+ }
+ set{
+ Attributes["enctype"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Behavior")]
+ public string Method{
+ get{
+ string attr = Attributes["method"];
+ if (attr != null){
+ return attr;
+ }
+ return "post";
+ }
+ set{
+ Attributes["method"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Behavior")]
+ public string Target{
+ get{
+ string attr = Attributes["target"];
+ if (attr != null){
+ return attr;
+ }
+ return String.Empty;
+ }
+ set{
+ Attributes["target"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Appearance")]
+ public virtual string Name{
+ get{
+ string attr = Attributes["name"];
+ if (attr != null){
+ return attr;
+ }
+ return String.Empty;
+ }
+ set {
+ Attributes ["Name"] = value;
+ }
+ }
+
+ internal string RenderedName{
+ get{
+ string attr = Name;
+ if (attr.Length > 0){
+ return attr;
+ }
+ return UniqueID;
+ }
+ }
+
+ } // class HtmlForm
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlGenericControl.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlGenericControl.cs
new file mode 100644
index 00000000000..a7c4b2300e5
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlGenericControl.cs
@@ -0,0 +1,46 @@
+//
+// System.Web.UI.HtmlControls.HtmlGenericControl.cs
+//
+// Authors:
+// Bob Smith <bob@thestuff.net>
+// Gonzalo Paniagua (gonzalo@ximian.com)
+//
+// (C) Bob Smith
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ [ConstructorNeedsTag]
+ public class HtmlGenericControl : HtmlContainerControl {
+ private string tagName;
+
+ public HtmlGenericControl() :
+ this ("span")
+ {
+ }
+
+ public HtmlGenericControl (string tag) :
+ base ()
+ {
+ if (tag == null)
+ tag = "";
+ tagName = tag;
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Appearance")]
+ public new string TagName
+ {
+ get { return tagName; }
+ set { tagName = value; }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs
new file mode 100755
index 00000000000..5cf3ce795d8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs
@@ -0,0 +1,121 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+using System.Globalization;
+
+namespace System.Web.UI.HtmlControls{
+ public class HtmlImage : HtmlControl{
+
+ public HtmlImage(): base("img"){}
+
+ protected override void RenderAttributes(HtmlTextWriter writer){
+ PreProcessRelativeReference(writer,"src");
+ base.RenderAttributes(writer);
+ writer.Write(" /");
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Layout")]
+ public string Align{
+ get{
+ string attr = Attributes["align"];
+ if (attr != null){
+ return attr;
+ }
+ return String.Empty;
+ }
+ set{
+ Attributes["align"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Appearance")]
+ public string Alt{
+ get{
+ string attr = Attributes["alt"];
+ if (attr != null){
+ return attr;
+ }
+ return String.Empty;
+ }
+ set{
+ Attributes["alt"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue(0)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Appearance")]
+ public int Border{
+ get{
+ string attr = Attributes["border"];
+ if (attr != null){
+ return Int32.Parse(attr,CultureInfo.InvariantCulture);
+ }
+ return -1;
+ }
+ set{
+ Attributes["border"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue(100)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Layout")]
+ public int Height
+ {
+ get {
+ string attr = Attributes ["height"];
+ if (attr != null)
+ return Int32.Parse (attr, CultureInfo.InvariantCulture);
+
+ return -1;
+ }
+
+ set { Attributes["height"] = AttributeToString (value); }
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Behavior")]
+ public string Src{
+ get{
+ string attr = Attributes["src"];
+ if (attr != null){
+ return attr;
+ }
+ return String.Empty;
+ }
+ set{
+ Attributes["src"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue(100)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Layout")]
+ public int Width{
+ get{
+ string attr = Attributes["width"];
+ if (attr != null){
+ return Int32.Parse(attr,CultureInfo.InvariantCulture);
+ }
+ return -1;
+ }
+ set{
+ Attributes["width"] = AttributeToString(value);
+ }
+ }
+
+ } // class HtmlImage
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs
new file mode 100755
index 00000000000..6940df113e2
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs
@@ -0,0 +1,99 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ [DefaultEvent("ServerClick")]
+ public class HtmlInputButton : HtmlInputControl, IPostBackEventHandler{
+
+ private static readonly object EventServerClick = new object ();
+
+ public HtmlInputButton(): base ("button")
+ {
+ }
+
+ public HtmlInputButton(string type): base(type){}
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender(e);
+ if (Page != null && Events [EventServerClick] != null)
+ Page.RequiresPostBackScript ();
+ }
+
+ protected override void RenderAttributes (HtmlTextWriter writer)
+ {
+ if (Page != null && CausesValidation) {
+ string type = Type;
+ if (String.Compare (type, "button", true) == 0 || String.Compare (type, "submit", true) == 0) {
+ string script = Page.GetPostBackClientEvent (this, String.Empty);
+ AttributeCollection coll = Attributes;
+ if (coll ["language"] != null)
+ coll.Remove ("language");
+ writer.WriteAttribute ("language", "javascript");
+
+ string onclick;
+ if ((onclick = coll ["onclick"]) != null) {
+ script = onclick + " " + script;
+ coll.Remove ("onclick");
+ }
+
+ writer.WriteAttribute ("onclick", script);
+ }
+ }
+
+ base.RenderAttributes (writer);
+ }
+
+ protected virtual void OnServerClick(EventArgs e){
+ EventHandler handler = (EventHandler) Events[EventServerClick];
+ if (handler != null){
+ handler.Invoke(this, e);
+ }
+ }
+
+ void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
+ {
+ if(CausesValidation == true){
+ Page.Validate();
+ }
+ OnServerClick(EventArgs.Empty);
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("Fires when the control is clicked.")]
+ public event EventHandler ServerClick{
+ add{
+ Events.AddHandler(EventServerClick, value);
+ }
+ remove{
+ Events.RemoveHandler(EventServerClick, value);
+ }
+ }
+
+ [DefaultValue(true)]
+ [WebCategory("Behavior")]
+ public bool CausesValidation{
+ get{
+ object causesVal = ViewState["CausesValidation"];
+ if (causesVal != null){
+ return (Boolean) causesVal;
+ }
+ return true;
+ }
+ set{
+ ViewState["CausesValidation"] = (Boolean) value;
+ }
+ }
+
+ } // end of System.Web.UI.HtmlControls.HtmlInputButton
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs
new file mode 100755
index 00000000000..26b7e204cd8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs
@@ -0,0 +1,85 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ [DefaultEvent("ServerChange")]
+ public class HtmlInputCheckBox : HtmlInputControl, IPostBackDataHandler{
+
+ private static readonly object EventServerChange = new object ();
+
+ public HtmlInputCheckBox(): base("checkbox"){}
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ string postValue = postCollection [postDataKey];
+ bool postChecked = false;
+ bool retval = false;
+
+ if (postValue != null)
+ postChecked = postValue.Length > 0;
+
+ if (Checked != postChecked){
+ retval = true;
+ Checked = postChecked;
+ }
+
+ return retval;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ OnServerChange (EventArgs.Empty);
+ }
+
+ protected virtual void OnServerChange(EventArgs e){
+ EventHandler handler = (EventHandler) Events[EventServerChange];
+ if (handler != null) handler.Invoke(this, e);
+ }
+
+ protected override void OnPreRender(EventArgs e){
+ if (Page != null && !Disabled)
+ Page.RegisterRequiresPostBack(this);
+ if (Events[EventServerChange] != null && !Disabled)
+ ViewState.SetItemDirty("checkbox",false);
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("Fires when the checked satte of the control is changed.")]
+ public event EventHandler ServerChange{
+ add{
+ Events.AddHandler(EventServerChange, value);
+ }
+ remove{
+ Events.RemoveHandler(EventServerChange, value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Misc")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool Checked{
+ get{
+ string attr = Attributes["checked"];
+ if (attr != null)
+ return attr.Equals("checked");
+ return false;
+ }
+ set{
+ Attributes["checked"] = (value == true)? "checked": null;
+ }
+ }
+
+ } // class HtmlInputCheckBox
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputControl.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputControl.cs
new file mode 100755
index 00000000000..ee23654859f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputControl.cs
@@ -0,0 +1,70 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+using System.Globalization;
+
+namespace System.Web.UI.HtmlControls
+{
+
+ public abstract class HtmlInputControl : HtmlControl
+ {
+
+ public HtmlInputControl (string type) : base ("input")
+ {
+ Attributes ["type"] = type;
+ }
+
+ protected override void RenderAttributes (HtmlTextWriter writer)
+ {
+ writer.WriteAttribute ("name",RenderedName);
+ Attributes.Remove ("name");
+ base.RenderAttributes (writer);
+ writer.Write (" /");
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Behavior")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual string Name
+ {
+ get { return UniqueID; }
+ set { }
+ }
+
+ protected virtual string RenderedName
+ {
+ get { return Name; }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Behavior")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Type
+ {
+ get {
+ string _type = Attributes ["type"];
+ return ((_type != null) ? _type : String.Empty);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual string Value
+ {
+ get {
+ string attr = Attributes ["value"];
+ return ((attr != null) ? attr : String.Empty);
+ }
+
+ set { Attributes["value"] = value; }
+ }
+ } // class HtmlInputControl
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs
new file mode 100755
index 00000000000..75d2d033a01
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs
@@ -0,0 +1,88 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+using System.Globalization;
+using System.Collections.Specialized;
+
+namespace System.Web.UI.HtmlControls{
+ [ValidationProperty("Value")]
+ public class HtmlInputFile : HtmlInputControl, IPostBackDataHandler{
+
+ public HtmlInputFile():base("file"){}
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ string postValue = postCollection [postDataKey];
+ if (postValue != null)
+ Value = postValue;
+ return false;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Behavior")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Accept{
+ get{
+ string attr = Attributes["accept"];
+ if (attr != null)
+ return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["accept"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Behavior")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int MaxLength{
+ get{
+ string attr = Attributes["maxlength"];
+ if (attr != null)
+ return Int32.Parse(attr, CultureInfo.InvariantCulture);
+ return -1;
+ }
+ set{
+ Attributes["accept"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Size{
+ get{
+ string attr = Attributes["size"];
+ if (attr != null)
+ return Int32.Parse(attr, CultureInfo.InvariantCulture);
+ return -1;
+ }
+ set{
+ Attributes["size"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Misc")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public HttpPostedFile PostedFile{
+ get{
+ return Context.Request.Files[RenderedName];
+ }
+ }
+
+ } // class HtmlInputFile
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs
new file mode 100755
index 00000000000..16229466344
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs
@@ -0,0 +1,62 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ [DefaultEvent("ServerChange")]
+ public class HtmlInputHidden : HtmlInputControl, IPostBackDataHandler{
+
+ private static readonly object EventServerChange = new object ();
+
+ public HtmlInputHidden () : base ("hidden")
+ {
+ }
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ string postValue = postCollection [postDataKey];
+ if (postValue != null)
+ Value = postValue;
+ return false;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ // don't need anything. LoadPostData always returns false.
+ }
+
+ protected virtual void OnServerChange (EventArgs e)
+ {
+ EventHandler handler = (EventHandler) Events [EventServerChange];
+ if (handler != null) handler.Invoke (this, e);
+ }
+
+ protected override void OnPreRender(EventArgs e){
+ if (Events[EventServerChange] != null && !Disabled)
+ ViewState.SetItemDirty("value",false);
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("Fires when the value of the control changes.")]
+ public event EventHandler ServerChange{
+ add{
+ Events.AddHandler(EventServerChange, value);
+ }
+ remove{
+ Events.RemoveHandler(EventServerChange, value);
+ }
+ }
+
+ } // class HtmlInputFile
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs
new file mode 100755
index 00000000000..fc690e4f990
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs
@@ -0,0 +1,145 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ [DefaultEvent("ServerClick")]
+ public class HtmlInputImage : HtmlInputControl, IPostBackEventHandler, IPostBackDataHandler{
+
+ private static readonly object EventServerClick = new object ();
+ private int _x, _y;
+
+ public HtmlInputImage(): base("image"){}
+
+ protected override void OnPreRender(EventArgs e){
+ if (Page != null && !Disabled){
+ Page.RegisterRequiresPostBack(this);
+ }
+ }
+
+ protected override void RenderAttributes(HtmlTextWriter writer)
+ {
+ base.RenderAttributes (writer);
+ // Anything else?
+ }
+
+ protected virtual void OnServerClick(ImageClickEventArgs e){
+ ImageClickEventHandler handler = (ImageClickEventHandler) Events[EventServerClick];
+ if (handler != null) handler (this, e);
+ }
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ string postX = postCollection[String.Concat(RenderedName,".x")];
+ string postY = postCollection[String.Concat(RenderedName,".y")];
+ if (postX != null && postY != null && postX.Length >= 0 && postY.Length >= 0){
+ _x = Int32.Parse(postX, CultureInfo.InvariantCulture);
+ _y = Int32.Parse(postY, CultureInfo.InvariantCulture);
+ Page.RegisterRequiresRaiseEvent(this);
+ }
+ return false;
+ }
+
+ void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
+ {
+ if (CausesValidation)
+ Page.Validate();
+ OnServerClick (new ImageClickEventArgs(_x, _y));
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("Fires when the image is clicked.")]
+ public event ImageClickEventHandler ServerClick{
+ add{
+ Events.AddHandler(EventServerClick, value);
+ }
+ remove{
+ Events.RemoveHandler(EventServerClick, value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Align{
+ get{
+ string attr = Attributes["align"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["align"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Alt{
+ get{
+ string attr = Attributes["alt"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["alt"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Border{
+ get{
+ string attr = Attributes["border"];
+ if (attr != null) return Int32.Parse(attr,CultureInfo.InvariantCulture);
+ return -1;
+ }
+ set{
+ Attributes["border"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue(true)]
+ [WebCategory("Behavior")]
+ public bool CausesValidation{
+ get{
+ object causesVal = ViewState["CausesValidation"];
+ if (causesVal != null) return (Boolean) causesVal;
+ return true;
+ }
+ set{
+ ViewState["CausesValidation"] = (Boolean) value;
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Src{
+ get{
+ string attr = Attributes["src"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["src"] = AttributeToString(value);
+ }
+ }
+ } // class HtmlInputImage
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs
new file mode 100755
index 00000000000..d8ba51d79f7
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs
@@ -0,0 +1,134 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ [DefaultEvent("ServerChange")]
+ public class HtmlInputRadioButton : HtmlInputControl, IPostBackDataHandler{
+
+ private static readonly object EventServerChange;
+
+ public HtmlInputRadioButton(): base("radio"){}
+
+ protected override void OnPreRender(EventArgs e){
+ if (Page != null && !Disabled){
+ Page.RegisterRequiresPostBack(this);
+ }
+ if (Events[EventServerChange] != null && !Disabled){
+ ViewState.SetItemDirty("checked", false);
+ }
+ }
+
+ protected virtual void OnServerChange(EventArgs e){
+ EventHandler handler = (EventHandler) Events[EventServerChange];
+ if (handler != null){
+ handler.Invoke(this, e);
+ }
+ }
+
+ protected override void RenderAttributes(HtmlTextWriter writer){
+ writer.WriteAttribute("value", Value);
+ Attributes.Remove("value");
+ base.RenderAttributes(writer);
+ }
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ string postValue = postCollection [postDataKey];
+ bool myBool = false;
+ if (postValue != null && postValue.Equals (Value)) {
+ if (!Checked) {
+ Checked = true;
+ myBool = true;
+ }
+ } else {
+ if (Checked) {
+ Checked = false;
+ myBool = false;
+ }
+ }
+ return myBool;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ OnServerChange (EventArgs.Empty);
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("Fires when the checked state of the control changes.")]
+ public event EventHandler ServerChange{
+ add{
+ Events.AddHandler(EventServerChange, value);
+ }
+ remove{
+ Events.RemoveHandler(EventServerChange, value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Misc")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool Checked{
+ get{
+ string attr = Attributes["checked"];
+ if (attr != null){
+ return attr.Equals("checked");
+ }
+ return false;
+ }
+ set{
+ if (value != true){
+ Attributes["checked"] = null;
+ }
+ Attributes["checked"] = "checked";
+ }
+ }
+ public override string Name
+ {
+ get {
+ string attr = Attributes ["name"]; // Gotta use "name" to group radio buttons
+ return (attr == null) ? String.Empty : attr;
+ }
+ set { Attributes ["name"] = value; }
+ }
+
+ protected override string RenderedName{
+ get{
+ string attr = base.RenderedName;
+ string id = UniqueID;
+ int indexOfX = id.LastIndexOf('X');
+ if (indexOfX != 0 && indexOfX >= 0){
+ attr = String.Concat(attr, id.Substring(0,indexOfX+1));
+ }
+ return attr;
+ }
+ }
+
+ public override string Value
+ {
+ get {
+ string v = Attributes ["value"];
+ if (v != null && v != "")
+ return v;
+ v = ID;
+ Attributes ["value"] = v;
+ return v;
+ }
+
+ set { Attributes ["value"] = value; }
+ }
+
+ } // class HtmlInputRadioButton
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs
new file mode 100755
index 00000000000..cbbbb33e5b9
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs
@@ -0,0 +1,113 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+
+ [DefaultEvent("ServerChange")]
+ [ValidationProperty("Value")]
+ public class HtmlInputText : HtmlInputControl, IPostBackDataHandler{
+
+ private static readonly object EventServerChange = new object ();
+
+ public HtmlInputText(string type):base(type){}
+ public HtmlInputText():base("text"){}
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ if (Events [EventServerChange] == null && !Disabled)
+ ViewState.SetItemDirty("value",false);
+ }
+
+ protected virtual void OnServerChange (EventArgs e)
+ {
+ EventHandler handler = (EventHandler) Events [EventServerChange];
+ if (handler != null) handler (this, e);
+ }
+
+ protected override void RenderAttributes(HtmlTextWriter writer){
+ //hide value when password box
+ if (String.Compare (Type, "password",true) == 0)
+ ViewState.Remove ("value");
+
+ base.RenderAttributes(writer);
+ }
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ string currentValue = Value;
+ string[] postedValue = postCollection.GetValues (postDataKey);
+ if (!currentValue.Equals (postedValue)){
+ Value = postedValue [0];
+ return true;
+ }
+ return false;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ OnServerChange (EventArgs.Empty);
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("Fires when the the text within the control changes.")]
+ public event EventHandler ServerChange{
+ add{
+ Events.AddHandler(EventServerChange, value);
+ }
+ remove{
+ Events.RemoveHandler(EventServerChange, value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Behavior")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int MaxLength{
+ get{
+ string attr = (String) ViewState["maxlength"];
+ if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
+ return -1;
+ }
+ set{
+ Attributes["maxlength"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Size{
+ get{
+ string attr = (String) ViewState["size"];
+ if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
+ return -1;
+ }
+ set{
+ Attributes["size"] = AttributeToString(value);
+ }
+ }
+
+ public override string Value{
+ get{
+ string attr = Attributes["value"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["value"] = AttributeToString(value);
+ }
+ }
+
+ } // class HtmlInputText
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs
new file mode 100755
index 00000000000..9ace6eab302
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs
@@ -0,0 +1,463 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Globalization;
+using System.ComponentModel;
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace System.Web.UI.HtmlControls{
+
+ [DefaultEvent("ServerChange")]
+ [ValidationProperty("Value")]
+ public class HtmlSelect : HtmlContainerControl, IPostBackDataHandler{
+
+
+ private int _cachedSelectedIndex;
+ private object _dataSource;
+ private static readonly object EventServerChange = new object ();
+ private ListItemCollection _items;
+
+ public HtmlSelect():base("select"){
+ _cachedSelectedIndex = -1;
+ }
+
+ protected override void AddParsedSubObject(object obj){
+ if (obj as ListItem != null) {
+ this.Items.Add((ListItem) obj);
+ return;
+ }
+ throw new HttpException("HtmlSelect cannot have children of Type " + obj.GetType().Name);
+ }
+
+ protected virtual void ClearSelection()
+ {
+ foreach (ListItem item in Items)
+ item.Selected = false;
+ }
+
+ protected override ControlCollection CreateControlCollection(){
+ return new EmptyControlCollection(this);
+ }
+
+ /*
+ * Helper method for LoadViewState. Any change to Select (int [])
+ * should be done here too.
+ */
+ void Select (object [] selectedIndices)
+ {
+ ClearSelection();
+ int count = Items.Count;
+ foreach (int current in selectedIndices) {
+ if (current >= 0 && current < count)
+ Items [current].Selected = true;
+ }
+ }
+
+ protected override void LoadViewState(object savedState)
+ {
+ if (savedState != null) {
+ Triplet state = (Triplet) savedState;
+ base.LoadViewState (state.First);
+ Items.LoadViewState (state.Second);
+ object indices = state.Third;
+ if (indices != null)
+ Select ((object []) indices);
+ }
+ }
+
+ protected override void OnDataBinding(EventArgs e){
+ base.OnDataBinding(e);
+ IEnumerable resolvedDataSource = System.Web.Util.DataSourceHelper.GetResolvedDataSource(DataSource, DataMember);
+ if ( resolvedDataSource != null){
+ string text = DataTextField;
+ string value = DataValueField;
+ Items.Clear();
+ ICollection rdsCollection = resolvedDataSource as ICollection;
+ if (rdsCollection != null){
+ Items.Capacity = rdsCollection.Count;
+ }
+ bool valid = false;
+ if (text.Length >= 0 && value.Length >= 0)
+ valid = true;
+ ListItem li = new ListItem();
+ IEnumerator current = resolvedDataSource.GetEnumerator();
+ while(current.MoveNext()){
+ if (valid == true){
+ if (text.Length >= 0)
+ li.Text = DataBinder.GetPropertyValue(current, text) as string;
+ if (value.Length >= 0)
+ li.Value = DataBinder.GetPropertyValue(current, value) as string;
+ }
+ else{
+ li.Value = li.Text = current.ToString();
+ }
+ }
+ Items.Add(li);
+ }
+ if ( _cachedSelectedIndex != -1){
+ SelectedIndex = _cachedSelectedIndex;
+ _cachedSelectedIndex = -1;
+ }
+ }
+
+ protected override void OnPreRender(EventArgs e){
+ if (Page != null && Size >= 0 && !Disabled){
+ Page.RegisterRequiresPostBack(this);
+ }
+ }
+
+ protected virtual void OnServerChange(EventArgs e){
+ EventHandler handler = (EventHandler) Events[EventServerChange];
+ if (handler != null)
+ handler.Invoke(this,e);
+ }
+
+ protected override void RenderAttributes(HtmlTextWriter writer){
+ writer.WriteAttribute("name", Name);
+ Attributes.Remove("name");
+ Attributes.Remove("DataValueField");
+ Attributes.Remove("DataTextField");
+ Attributes.Remove("DataMember");
+ base.RenderAttributes(writer);
+ }
+
+ protected override void RenderChildren(HtmlTextWriter writer){
+ //flush output
+ writer.WriteLine();
+ // increase indent level, improves readability
+ writer.Indent = writer.Indent + 1;
+ if (Items.Count >= 0){
+ // display all options, and set the selected option
+ bool rendered_selected = false;
+ foreach (ListItem option in Items){
+ //write begin tag with attributes
+ writer.WriteBeginTag("option");
+ if (!rendered_selected && option.Selected){
+ writer.WriteAttribute("selected","selected");
+ if (!Multiple)
+ rendered_selected = true;
+ }
+ else if (option.Selected){
+ option.Selected = false;
+ }
+
+ writer.WriteAttribute("value",option.Value,true);
+ option.Attributes.Remove("text");
+ option.Attributes.Remove("value");
+ option.Attributes.Remove("selected");
+ option.Attributes.Render(writer);
+ writer.Write('>');
+ //write the option text
+ HttpUtility.HtmlEncode(option.Text, writer);
+ //close the current option tag
+ writer.WriteEndTag("option");
+ //flush output
+ writer.WriteLine();
+ }
+ }
+ // set the indent level back to normal
+ writer.Indent = writer.Indent - 1;
+ }
+
+ protected override object SaveViewState ()
+ {
+ object baseViewState = base.SaveViewState ();
+ object itemsViewState = Items.SaveViewState ();
+ object indices = null;
+
+ if (Events[EventServerChange] != null || !Disabled || Visible)
+ indices = SelectedIndices;
+
+ if (indices != null || baseViewState != null || itemsViewState != null)
+ return new Triplet (baseViewState, itemsViewState, indices);
+
+ return null;
+ }
+
+ /* Any change here should also be done to Select (object []) */
+ protected virtual void Select(int[] selectedIndices){
+ // unselect all options
+ ClearSelection();
+ // iterate through options, and set when selected
+ foreach (int current in selectedIndices){
+ if (current >= 0 && current < Items.Count){
+ Items[current].Selected = true;
+ }
+ }
+ }
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ //get the posted selectedIndices[]
+ string [] postedValueColl = postCollection.GetValues(postDataKey);
+ bool changed = false;
+ if (postedValueColl != null){
+ if (!Multiple){
+ //single selection
+ //int postedValue = Items.FindIndexByValue(postedValueColl[0]);
+ int postedValue = Items.IndexOf(Items.FindByValue(postedValueColl[0]));
+ if (postedValue != SelectedIndex){
+ //set the SelectedIndex
+ SelectedIndex = postedValue;
+ changed = true;
+ }
+ }
+ else{
+ //multiple selection
+ int postedValueCount = postedValueColl.Length;
+ int[] arr= new int[postedValueCount];
+ //fill an array with the posted Values
+ for (int i = 0; i <= postedValueCount; i++)
+ arr[i] = Items.IndexOf(Items.FindByValue(postedValueColl[i]));
+ //test if everything went fine
+ if( postedValueCount == SelectedIndices.Length)
+ for (int i = 0; i <= postedValueCount; i++)
+ if(arr[i] == SelectedIndices[i])
+ changed = true;
+ else
+ changed = true;
+ //commit the posted Values
+ if(changed)
+ Select(arr);
+ }
+ }
+ else if (SelectedIndex != -1){
+ SelectedIndex = -1;
+ changed = true;
+ }
+ return changed;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ OnServerChange (EventArgs.Empty);
+ }
+
+ //starts tracking changes to the viewstate
+ protected override void TrackViewState(){
+ base.TrackViewState();
+ Items.TrackViewState();
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("Fires when the selection changes.")]
+ public event EventHandler ServerChange{
+ add{
+ Events.AddHandler(EventServerChange, value);
+ }
+ remove{
+ Events.RemoveHandler(EventServerChange, value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Data")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [WebSysDescription("The data member of the select.")]
+ public virtual string DataMember{
+ get{
+ object viewStateDataMember = ViewState["DataMember"];
+ if ( viewStateDataMember != null) return (String) viewStateDataMember;
+ return String.Empty;
+ }
+ set{
+ Attributes["DataMember"] = HtmlControl.AttributeToString(value);
+ }
+ }
+
+ [DefaultValue(null)]
+ [WebCategory("Data")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [WebSysDescription("The data source used to populate the list with data.")]
+ public virtual object DataSource{
+ get{
+ return _dataSource;
+ }
+ set{
+ if (value != null && value is IListSource){
+ if (value is IEnumerable){
+ _dataSource = value;
+ }
+ else{
+ throw new ArgumentException("Invalid dataSource type");
+ }
+ }
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Data")]
+ [WebSysDescription("The field in the data source that provides the item value.")]
+ public virtual string DataTextField{
+ get{
+ string attr = Attributes["DataTextField"];
+ if (attr != null){
+ return attr;
+ }
+ return String.Empty;
+ }
+ set{
+ Attributes["DataTextField"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Data")]
+ [WebSysDescription("The field in the data source that provides the item value.")]
+ public virtual string DataValueField{
+ get{
+ string attr = Attributes["DataValueField"];
+ if (attr != null)return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["DataValueField"] = AttributeToString(value);
+ }
+ }
+
+ public override string InnerHtml{
+ get{
+ throw new NotSupportedException("InnerHtml is not supported by " + this.GetType().Name);
+ }
+ set{
+ throw new NotSupportedException("InnerHtml is not supported by " + this.GetType().Name);
+ }
+ }
+
+ public override string InnerText{
+ get{
+ throw new NotSupportedException("InnerText is not supported by " + this.GetType().Name);
+ }
+ set{
+ throw new NotSupportedException("InnerText is not supported by " + this.GetType().Name);
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public ListItemCollection Items{
+ get{
+ if (_items == null){
+ _items = new ListItemCollection();
+ if (IsTrackingViewState) _items.TrackViewState();
+ }
+ return _items;
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Behavior")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool Multiple{
+ get{
+ string attr = Attributes["multiple"];
+ if (attr != null) return (0 == String.Compare (attr, "true", true));
+ return false;
+ }
+ set{
+ Attributes["multiple"] = value.ToString ();
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Behavior")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Name{
+ get{
+ return UniqueID;
+ }
+ set{
+ //LAMESPEC
+ return;
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual int SelectedIndex {
+ get{
+ for (int i=0; i<Items.Count; i++){
+ if (Items[i].Selected == true) return i;
+ }
+ if (Size<=1 && !Multiple){
+ if(Items.Count > 0) Items[0].Selected = true;
+ return 0;
+ }
+ return -1;
+ }
+ set{
+ if(Items.Count == 0){
+ _cachedSelectedIndex = value;
+ return;
+ }
+
+ if (value < -1 || value >= Items.Count)
+ throw new ArgumentOutOfRangeException();
+
+ ClearSelection();
+ if (value >= 0)
+ Items[value].Selected = true;
+ }
+ }
+
+ protected virtual int[] SelectedIndices {
+ get{
+ int[] indices = new int[3];
+ int indicesCount = 0;
+ for(int i=0; i < Items.Count; i++){
+ if (Items[i].Selected){
+ if( indicesCount == (int) indices.Length){
+ int[] temp = new int[indicesCount + indicesCount];
+ indices.CopyTo(temp,0);
+ indices = temp;
+ }
+ indices[indicesCount] = i;
+ indicesCount++;
+ }
+ }
+ int[] arr = new int[indicesCount];
+ System.Array.Copy(indices,0,arr,0,indicesCount);
+ return arr;
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Size{
+ get{
+ string attr = Attributes["size"];
+ if (attr != null){
+ return Int32.Parse(attr, CultureInfo.InvariantCulture);;
+ }
+ return -1;
+ }
+ set{
+ Attributes["size"] = AttributeToString(value);
+ }
+ }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Value {
+ get{
+ int selectedIndex = SelectedIndex;
+ if (selectedIndex >=0 && selectedIndex < Items.Count){
+ return Items[selectedIndex].Value;
+ }
+ return String.Empty;
+ }
+ set{
+ int findValue = Items.IndexOf(Items.FindByValue(value));
+ if (findValue >= 0) SelectedIndex = findValue;
+ }
+ }
+
+ } // class HtmlSelect
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs
new file mode 100755
index 00000000000..00a00ad0429
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs
@@ -0,0 +1,199 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+using System.Globalization;
+
+namespace System.Web.UI.HtmlControls{
+
+ [ParseChildren(true, "Rows")]
+ public class HtmlTable : HtmlContainerControl {
+ private HtmlTableRowCollection _rows;
+
+ public HtmlTable():base("table"){}
+
+ protected override ControlCollection CreateControlCollection(){
+ return new HtmlTableRowControlCollection(this);
+ }
+
+ protected override void RenderChildren(HtmlTextWriter writer){
+ writer.WriteLine();
+ writer.Indent = writer.Indent + 1;
+ base.RenderChildren(writer);
+ writer.Indent = writer.Indent - 1;
+ }
+
+ protected override void RenderEndTag(HtmlTextWriter writer){
+ base.RenderEndTag(writer);
+ writer.WriteLine();
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Align {
+ get{
+ string attr = Attributes["align"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["align"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string BgColor {
+ get{
+ string attr = Attributes["bgcolor"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["bgcolor"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue(-1)]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Border {
+ get{
+ string attr = Attributes["border"];
+ if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
+ return -1;
+ }
+ set{
+ Attributes["border"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string BorderColor {
+ get{
+ string attr = Attributes["bordercolor"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["bordercolor"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int CellPadding {
+ get{
+ string attr = Attributes["cellpadding"];
+ if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
+ return -1;
+ }
+ set{
+ Attributes["cellpadding"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int CellSpacing {
+ get{
+ string attr = Attributes["cellspacing"];
+ if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
+ return -1;
+ }
+ set{
+ Attributes["cellspacing"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Height {
+ get{
+ string attr = Attributes["height"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["height"] = AttributeToString(value);
+ }
+ }
+
+ public override string InnerHtml {
+ get{
+ throw new NotSupportedException("InnerHtml property not supported by HtmlTable");
+ }
+ set{
+ throw new NotSupportedException("InnerHtml property not supported by HtmlTable");
+ }
+ }
+
+ public override string InnerText {
+ get{
+ throw new NotSupportedException("InnerText property not supported by HtmlTable");
+ }
+ set{
+ throw new NotSupportedException("InnerText property not supported by HtmlTable");
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual HtmlTableRowCollection Rows {
+ get{
+ if (_rows == null) _rows = new HtmlTableRowCollection(this);
+ return _rows;
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Width {
+ get{
+ string attr = Attributes["width"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["width"] = AttributeToString(value);
+ }
+ }
+
+ protected class HtmlTableRowControlCollection : ControlCollection {
+
+ internal HtmlTableRowControlCollection(Control owner): base(owner){}
+
+ public override void Add(Control child){
+ if ((child as HtmlTableRow) != null){
+ base.Add(child);
+ }
+ else{
+ throw new ArgumentException("HtmlTableRow cannot have children of type " + child.GetType().Name);
+ }
+ }
+
+ public override void AddAt(int index, Control child){
+ if ((child as HtmlTableRow) != null){
+ base.AddAt(index,child);
+ }
+ else{
+ throw new ArgumentException("HtmlTableRow cannot have children of type " + child.GetType().Name);
+ }
+ }
+ } // end of HtmlTableRowControlCollection
+ }
+ // end of System.Web.UI.HtmlControl
+}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs
new file mode 100755
index 00000000000..6d12c9b00bc
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs
@@ -0,0 +1,158 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+using System.Globalization;
+
+namespace System.Web.UI.HtmlControls{
+ [ConstructorNeedsTag]
+ public class HtmlTableCell : HtmlContainerControl {
+ public HtmlTableCell(): base("td"){}
+
+ public HtmlTableCell(string tagName): base(tagName){}
+
+ protected override void RenderEndTag(HtmlTextWriter writer){
+ base.RenderEndTag(writer);
+ writer.WriteLine();
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Align {
+ get{
+ string attr = Attributes["align"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["align"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string BgColor {
+ get{
+ string attr = Attributes["bgcolor"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["bgcolor"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string BorderColor {
+ get{
+ string attr = Attributes["bordercolor"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["bordercolor"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int ColSpan {
+ get{
+ string attr = Attributes["colspan"];
+ if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
+ return -1;
+ }
+ set{
+ Attributes["colspan"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Height {
+ get{
+ string attr = Attributes["height"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["height"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Behavior")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool NoWrap {
+ get{
+ string attr = Attributes["colspan"];
+ if (attr != null) return attr.Equals("nowrap");
+ return false;
+ }
+ set{
+ if (value == true){
+ Attributes["nowrap"] = "nowrap";
+ }
+ else{
+ Attributes["nowrap"] = null;
+ }
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int RowSpan {
+ get{
+ string attr = Attributes["rowspan"];
+ if (attr != null) return Int32.Parse(attr, CultureInfo.InvariantCulture);
+ return -1;
+ }
+ set{
+ Attributes["rowspan"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string VAlign {
+ get{
+ string attr = Attributes["valign"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["valign"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Width {
+ get{
+ string attr = Attributes["width"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["width"] = AttributeToString(value);
+ }
+ }
+
+ }
+ // System.Web.UI.HtmlControls.HtmlTableCell
+
+}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCellCollection.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCellCollection.cs
new file mode 100755
index 00000000000..e6926f10eb7
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCellCollection.cs
@@ -0,0 +1,84 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.Collections;
+
+namespace System.Web.UI.HtmlControls{
+ public sealed class HtmlTableCellCollection : ICollection {
+ private HtmlTableRow _owner;
+
+ internal HtmlTableCellCollection(HtmlTableRow owner){
+ _owner = owner;
+ }
+
+ public void Add(HtmlTableCell cell){
+ Insert(-1, cell);
+ }
+
+ public void Clear(){
+ if (_owner.HasControls()) _owner.Controls.Clear();
+ }
+
+ public void CopyTo(Array array, int index){
+ IEnumerator tablecell = this.GetEnumerator();
+ while(tablecell.MoveNext()){
+ index = index + 1;
+ array.SetValue(tablecell.Current, index);
+ }
+ }
+
+ public IEnumerator GetEnumerator(){
+ return _owner.Controls.GetEnumerator();
+ }
+
+ public void Insert(int index, HtmlTableCell cell){
+ _owner.Controls.AddAt(index,cell);
+ }
+
+ public void Remove(HtmlTableCell cell){
+ _owner.Controls.Remove(cell);
+ }
+
+ public void RemoveAt(int index){
+ _owner.Controls.RemoveAt(index);
+ }
+
+ public int Count {
+ get{
+ if (_owner.HasControls()) return _owner.Controls.Count;
+ return 0;
+ }
+ }
+
+ public bool IsReadOnly {
+ get{
+ return false;
+ }
+ }
+
+ public bool IsSynchronized {
+ get{
+ return false;
+ }
+ }
+
+ public HtmlTableCell this[int index] {
+ get{
+ return _owner.Controls[index] as HtmlTableCell;
+ }
+ }
+
+ public object SyncRoot {
+ get{
+ return null;
+ }
+ }
+
+ } // end of System.Web.UI.HtmlControls.HtmlTableCellCollection
+
+}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs
new file mode 100755
index 00000000000..d282a7039bf
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs
@@ -0,0 +1,156 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.HtmlControls{
+ [ParseChildren(true, "Cells")]
+ public class HtmlTableRow : HtmlContainerControl {
+ private HtmlTableCellCollection _cells;
+ public HtmlTableRow():base("tr"){}
+
+ protected override ControlCollection CreateControlCollection(){
+ return new HtmlTableCellControlCollection(this);
+ }
+
+ protected override void RenderChildren(HtmlTextWriter writer){
+ writer.WriteLine();
+ writer.Indent = writer.Indent + 1;
+ base.RenderChildren(writer);
+ writer.Indent = writer.Indent - 1;
+ }
+
+ protected override void RenderEndTag(HtmlTextWriter writer){
+ base.RenderEndTag(writer);
+ writer.WriteLine();
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Align {
+ get{
+ string attr = Attributes["align"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["align"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string BgColor {
+ get{
+ string attr = Attributes["bgcolor"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["bgcolor"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string BorderColor {
+ get{
+ string attr = Attributes["bordercolor"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["bordercolor"] = AttributeToString(value);
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual HtmlTableCellCollection Cells {
+ get{
+ if (_cells == null) _cells = new HtmlTableCellCollection(this);
+ return _cells;
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Height {
+ get{
+ string attr = Attributes["height"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["height"] = AttributeToString(value);
+ }
+ }
+
+ public override string InnerHtml {
+ get{
+ throw new NotSupportedException("InnerHtml is not supported by HtmlTableRow");
+ }
+ set{
+ throw new NotSupportedException("InnerHtml is not supported by HtmlTableRow");
+ }
+ }
+
+ public override string InnerText {
+ get{
+ throw new NotSupportedException("InnerText is not supported by HtmlTableRow");
+ }
+ set{
+ throw new NotSupportedException("InnerText is not supported by HtmlTableRow");
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Layout")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string VAlign {
+ get{
+ string attr = Attributes["valign"];
+ if (attr != null) return attr;
+ return String.Empty;
+ }
+ set{
+ Attributes["valign"] = AttributeToString(value);
+ }
+ }
+
+
+
+ protected class HtmlTableCellControlCollection : ControlCollection {
+
+ internal HtmlTableCellControlCollection(Control owner): base(owner){}
+
+ public override void Add(Control child){
+ if (child is HtmlTableCell){
+ base.Add(child);
+ }
+ else{
+ throw new ArgumentException("HtmlTableRow cannot have children of Type " + child.GetType().Name);
+ }
+ }
+
+ public override void AddAt(int index, Control child){
+ if (child is HtmlTableCell){
+ base.AddAt(index,child);
+ }
+ else{
+ throw new ArgumentException("HtmlTableRow cannot have children of Type " + child.GetType().Name);
+ }
+ }
+ }
+ } // end of System.Web.UI.HtmlControls.HtmlTableRow+HtmlTableCellControlCollection
+ // end of System.Web.UI.HtmlControls.HtmlTableRow
+}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRowCollection.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRowCollection.cs
new file mode 100755
index 00000000000..987c8aed674
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRowCollection.cs
@@ -0,0 +1,83 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.Collections;
+
+namespace System.Web.UI.HtmlControls{
+ public sealed class HtmlTableRowCollection : ICollection {
+
+ private HtmlTable _owner;
+
+ internal HtmlTableRowCollection(HtmlTable owner){
+ _owner = owner;
+ }
+
+ public void Add(HtmlTableRow row){
+ Insert(-1, row);
+ }
+
+ public void Clear(){
+ if (_owner.HasControls()) _owner.Controls.Clear();
+ }
+
+ public void CopyTo(Array array, int index){
+ IEnumerator tablerow = this.GetEnumerator();
+ while (tablerow.MoveNext()){
+ index = index + 1;
+ array.SetValue(tablerow.Current, index);
+ }
+ }
+
+ public IEnumerator GetEnumerator(){
+ return _owner.Controls.GetEnumerator();
+ }
+
+ public void Insert(int index, HtmlTableRow row){
+ _owner.Controls.AddAt(index,row);
+ }
+
+ public void Remove(HtmlTableRow row){
+ _owner.Controls.Remove(row);
+ }
+
+ public void RemoveAt(int index){
+ _owner.Controls.RemoveAt(index);
+ }
+
+ public int Count {
+ get{
+ if (_owner.HasControls()) return _owner.Controls.Count;
+ return 0;
+ }
+ }
+
+ public bool IsReadOnly {
+ get{
+ return false;
+ }
+ }
+
+ public bool IsSynchronized {
+ get{
+ return false;
+ }
+ }
+
+ public HtmlTableRow this[int index] {
+ get{
+ return (HtmlTableRow) _owner.Controls[index];
+ }
+ }
+
+ public object SyncRoot {
+ get{
+ return this;
+ }
+ }
+ }//System.Web.UI.HtmlControls.HtmlTableRowCollection
+}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs
new file mode 100644
index 00000000000..87a46774449
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs
@@ -0,0 +1,137 @@
+/* System.Web.UI.HtmlControls
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+using System.Globalization;
+using System.Collections.Specialized;
+
+namespace System.Web.UI.HtmlControls{
+
+ [DefaultEvent("ServerChange")]
+ [ValidationProperty("Value")]
+ public class HtmlTextArea : HtmlContainerControl, IPostBackDataHandler{
+
+ private static readonly object EventServerChange = new object ();
+
+ public HtmlTextArea(): base("textarea"){}
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Cols{
+ get{
+ string attr = Attributes["cols"];
+ if (attr != null){
+ return Int32.Parse(attr, CultureInfo.InvariantCulture);
+ }
+ return -1;
+ }
+ set{
+ Attributes["cols"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public int Rows{
+ get{
+ string attr = Attributes["rows"];
+ if (attr != null){
+ return Int32.Parse(attr, CultureInfo.InvariantCulture);;
+ }
+ return -1;
+ }
+ set{
+ Attributes["rows"] = AttributeToString(value);
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Appearance")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public string Value{
+ get{
+ return InnerHtml;
+ }
+ set{
+ InnerHtml = value;
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Behavior")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public virtual string Name{
+ get{
+ if (UniqueID != null){
+ return UniqueID;
+ }
+ return String.Empty;
+ }
+ set{}
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("Fires when the text within the control changes.")]
+ public event EventHandler ServerChange{
+ add{
+ Events.AddHandler(EventServerChange, value);
+ }
+ remove{
+ Events.RemoveHandler(EventServerChange, value);
+ }
+ }
+
+ protected virtual void OnServerChange(EventArgs e){
+ EventHandler handler;
+ handler = (EventHandler) Events[EventServerChange];
+ if(handler != null){
+ handler.Invoke(this, e);
+ }
+ }
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ string currentValue = Value;
+ string postedValue = postCollection[postDataKey];
+ if (!currentValue.Equals(postedValue) && currentValue != null){
+ Value = HttpUtility.HtmlEncode(postedValue);
+ return true;
+ }
+ return false;
+ }
+
+ protected override void RenderAttributes(HtmlTextWriter writer){
+ writer.WriteAttribute("name", Name);
+ Attributes.Remove("name");
+ base.RenderAttributes(writer);
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ OnServerChange (EventArgs.Empty);
+ }
+
+ protected override void OnPreRender(EventArgs e){
+ if(Events[EventServerChange]==null || Disabled){
+ ViewState.SetItemDirty("value",false);
+ }
+ }
+
+ protected override void AddParsedSubObject(object obj){
+ if (obj is LiteralControl || obj is DataBoundLiteralControl)
+ AddParsedSubObject(obj);
+ else
+ throw new NotSupportedException("HtmlTextArea cannot have children of Type " + obj.GetType().Name);
+ }
+
+ } // class HtmlTextArea
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/.cvsignore b/mcs/class/System.Web/System.Web.UI.WebControls/.cvsignore
new file mode 100644
index 00000000000..13fc1fc7660
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/.cvsignore
@@ -0,0 +1,2 @@
+*.exe
+*.xml
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/AdCreatedEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/AdCreatedEventArgs.cs
new file mode 100755
index 00000000000..d0e94b87f88
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/AdCreatedEventArgs.cs
@@ -0,0 +1,92 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: AdCreatedEventArgs
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class AdCreatedEventArgs: EventArgs
+ {
+
+ private IDictionary adProperties;
+ private string alternateText;
+ private string imageUrl;
+ private string navigateUrl;
+
+ public AdCreatedEventArgs(IDictionary adProperties): base()
+ {
+ Initialize();
+ this.adProperties = adProperties;
+ if(adProperties!=null)
+ {
+ imageUrl = (string)adProperties["ImageUrl"];
+ navigateUrl = (string)adProperties["NavigateUrl"];
+ alternateText = (string)adProperties["AlternateText"];
+ }
+ }
+
+ private void Initialize()
+ {
+ alternateText = string.Empty;
+ imageUrl = string.Empty;
+ navigateUrl = string.Empty;
+ }
+
+ public IDictionary AdProperties
+ {
+ get
+ {
+ return adProperties;
+ }
+ }
+
+ public string AlternateText
+ {
+ get
+ {
+ return alternateText;
+ }
+ set
+ {
+ alternateText = value;
+ }
+ }
+
+ public string ImageUrl
+ {
+ get
+ {
+ return imageUrl;
+ }
+ set
+ {
+ imageUrl = value;
+ }
+ }
+
+ public string NavigateUrl
+ {
+ get
+ {
+ return navigateUrl;
+ }
+ set
+ {
+ navigateUrl = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/AdCreatedEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/AdCreatedEventHandler.cs
new file mode 100755
index 00000000000..57359aa5b30
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/AdCreatedEventHandler.cs
@@ -0,0 +1,17 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Delegate: AdCreatedEventHandler
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void AdCreatedEventHandler(object sender, AdCreatedEventArgs e);
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/AdRotator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/AdRotator.cs
new file mode 100755
index 00000000000..7b1e4bb91c4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/AdRotator.cs
@@ -0,0 +1,364 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: AdRotator
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Web;
+using System.Web.Caching;
+using System.Web.UI;
+using System.Xml;
+using System.Web.Util;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("AdCreated")]
+ [DefaultProperty("AdvertisementFile")]
+ //TODO: [Designer("??")]
+ [ToolboxData("<{0}:AdRotator runat=\"server\" Height=\"60px\" "
+ + "Width=\"468\"></{0}:AdRotator>")]
+ public class AdRotator: WebControl
+ {
+
+ private string advertisementFile;
+ private static readonly object AdCreatedEvent = new object();
+
+ // Will be set values during (On)PreRender-ing
+ private string alternateText;
+ private string imageUrl;
+ private string navigateUrl;
+
+ private string fileDirectory;
+
+ class AdRecord
+ {
+ public IDictionary adProps;
+ public int hits; // or impressions or clicks
+ public string keyword;
+
+ public AdRecord(IDictionary adProps)
+ {
+ this.adProps = adProps;
+ hits = 0;
+ keyword = String.Empty;
+ }
+ }
+
+/*
+ * Loading / Saving data from/to ad file and all the manipulations wrt to the URL...
+ * are incorporated by the following functions.
+ * GetData(string)
+ * LoadAdFile(string)
+ * IsAdMatching(AdRecord)
+ * ResolveAdUrl(string)
+ * SelectAd()
+ * The exact control flow will be detailed. Let me first write the functions
+ */
+
+ private AdRecord[] LoadAdFile(string file)
+ {
+ Stream fStream;
+ ArrayList list;
+ XmlReader reader;
+ XmlDocument document;
+ XmlNode topNode, innerNode;
+ IDictionary hybridDict = null;
+ AdRecord[] adsArray = null;
+ try
+ {
+ fStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
+ } catch(Exception e)
+ {
+ throw new HttpException("AdRotator: Unable to open file");
+ }
+ try
+ {
+ list = new ArrayList();
+ reader = new XmlTextReader(fStream);
+ document = new XmlDocument();
+ document.Load(reader);
+ if(document.DocumentElement!=null)
+ {
+ if(document.DocumentElement.LocalName=="Advertisements")
+ {
+ topNode = document.DocumentElement.FirstChild;
+ while(topNode!=null)
+ {
+ if(topNode.LocalName=="Ad")
+ {
+ innerNode = topNode.FirstChild;
+ while(innerNode!=null)
+ {
+ if(innerNode.NodeType==XmlNodeType.Element)
+ {
+ if(hybridDict==null)
+ {
+ hybridDict = new HybridDictionary();
+ }
+ hybridDict.Add(innerNode.LocalName, innerNode.InnerText);
+ }
+ innerNode = innerNode.NextSibling;
+ }
+ if (hybridDict!=null) {
+ list.Add (hybridDict);
+ hybridDict = null;
+ }
+ }
+ topNode = topNode.NextSibling;
+ }
+ }
+ }
+ if(list.Count>0)
+ {
+ adsArray = new AdRecord[list.Count];
+ for(int i=0; i < list.Count; i++)
+ {
+ adsArray[i] = new AdRecord((IDictionary)list[i]);
+ }
+ }
+ } catch(Exception e)
+ {
+ throw new HttpException("AdRotator_Parse_Error" + file);
+ } finally
+ {
+ fStream.Close();
+ }
+ if(adsArray == null)
+ {
+ throw new HttpException("AdRotator_No_Advertisements_Found");
+ }
+ return adsArray;
+ }
+
+ [MonoTODO("CacheDependency does nothing")]
+ private AdRecord[] GetData(string file)
+ {
+ string physPath = MapPathSecure(file);
+ string AdKey = "AdRotatorCache: " + physPath;
+ fileDirectory = UrlUtils.GetDirectory(UrlUtils.Combine(TemplateSourceDirectory, file));
+ Cache cache = HttpRuntime.Cache;
+ AdRecord[] records = (AdRecord[])cache[AdKey];
+ if(records==null)
+ {
+ records = LoadAdFile(physPath);
+ if(records==null)
+ {
+ return null;
+ }
+ cache.Insert(AdKey, records, new CacheDependency(physPath));
+ }
+ return records;
+ }
+
+ private IDictionary SelectAd()
+ {
+ AdRecord[] records = GetData(AdvertisementFile);
+ if(records!=null && records.Length!=0)
+ {
+ int impressions = 0;
+ for(int i=0 ; i < records.Length; i++)
+ {
+ if(IsAdMatching(records[i]))
+ impressions += records[i].hits;
+ }
+ if(impressions!=0)
+ {
+ int rnd = (new Random()).Next(impressions) + 1;
+ int counter = 0;
+ int index = 0;
+ for(int i=0; i < records.Length; i++)
+ {
+ if(IsAdMatching(records[i]))
+ {
+ if(rnd <= (counter + records[i].hits))
+ {
+ index = i;
+ break;
+ }
+ counter += records[i].hits;
+ }
+ }
+ 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)
+ return (0 == String.Compare (currAd.keyword, KeywordFilter, true));
+
+ return true;
+ }
+
+ private string ResolveAdUrl(string relativeUrl)
+ {
+ if(relativeUrl.Length==0 || !UrlUtils.IsRelativeUrl(relativeUrl))
+ return relativeUrl;
+ string fullUrl = String.Empty;
+ if(fileDirectory != null)
+ fullUrl = fileDirectory;
+ if(fullUrl.Length == 0)
+ fullUrl = TemplateSourceDirectory;
+ if(fullUrl.Length == 0)
+ return relativeUrl;
+ return (fullUrl + relativeUrl);
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("AdRotator_OnAdCreated")]
+ public event AdCreatedEventHandler AdCreated
+ {
+ add
+ {
+ Events.AddHandler(AdCreatedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(AdCreatedEvent, value);
+ }
+ }
+
+ public AdRotator(): base()
+ {
+ advertisementFile = string.Empty;
+ fileDirectory = null;
+ }
+
+ [Bindable(true)]
+ [DefaultValue("")]
+ //[Editor("??")]
+ [WebCategory("Behaviour")]
+ [WebSysDescription("AdRotator_AdvertisementFile")]
+ public string AdvertisementFile
+ {
+ get
+ {
+ return advertisementFile;
+ }
+ set
+ {
+ advertisementFile = value;
+ }
+ }
+
+ public override FontInfo Font
+ {
+ get
+ {
+ return Font;
+ }
+ }
+
+ [Bindable(true)]
+ [DefaultValue("")]
+ [WebCategory("Behaviour")]
+ [WebSysDescription("AdRotator_KeywordFilter")]
+ public string KeywordFilter
+ {
+ get
+ {
+ object o = ViewState["KeywordFilter"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ if(value!=null)
+ ViewState["KeywordFilter"] = value.Trim();
+ }
+ }
+
+ [Bindable(true)]
+ [DefaultValue("")]
+ [TypeConverter(typeof(TargetConverter))]
+ [WebCategory("Behaviour")]
+ [WebSysDescription("AdRotator_Target")]
+ public string Target
+ {
+ get
+ {
+ object o = ViewState["Target"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["Target"] = value;
+ }
+ }
+
+ protected override ControlCollection CreateControlCollection()
+ {
+ return new EmptyControlCollection(this);
+ }
+
+ protected virtual void OnAdCreated(AdCreatedEventArgs e)
+ {
+ if(Events!=null)
+ {
+ AdCreatedEventHandler aceh = (AdCreatedEventHandler)(Events[AdCreatedEvent]);
+ if(aceh!=null)
+ aceh(this, e);
+ }
+ }
+
+ protected override void OnPreRender(EventArgs e)
+ {
+ if(AdvertisementFile!=String.Empty)
+ {
+ AdCreatedEventArgs acea = new AdCreatedEventArgs(SelectAd());
+ imageUrl = acea.ImageUrl;
+ navigateUrl = acea.NavigateUrl;
+ alternateText = acea.AlternateText;
+ }
+ }
+
+ protected override void Render(HtmlTextWriter writer)
+ {
+ HyperLink hLink = new HyperLink();
+ Image adImage = new Image();
+ foreach(IEnumerable current in Attributes.Keys)
+ {
+ hLink.Attributes[(string)current] = Attributes[(string)current];
+ }
+ if(ID != null && ID.Length > 0)
+ hLink.ID = ID;
+ hLink.Target = Target;
+ hLink.AccessKey = AccessKey;
+ hLink.Enabled = Enabled;
+ hLink.TabIndex = TabIndex;
+ if (navigateUrl != null && navigateUrl.Length != 0)
+ hLink.NavigateUrl = ResolveAdUrl (navigateUrl);
+ hLink.RenderBeginTag(writer);
+ if(ControlStyleCreated)
+ {
+ adImage.ApplyStyle(ControlStyle);
+ }
+ if(imageUrl!=null && imageUrl.Length > 0)
+ adImage.ImageUrl = ResolveAdUrl(imageUrl);
+ adImage.AlternateText = alternateText;
+ adImage.ToolTip = ToolTip;
+ adImage.RenderControl(writer);
+ hLink.RenderEndTag(writer);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/BaseCompareValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/BaseCompareValidator.cs
new file mode 100755
index 00000000000..5509eca53e8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/BaseCompareValidator.cs
@@ -0,0 +1,311 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: BaseCompareValidator
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ public abstract class BaseCompareValidator: BaseValidator
+ {
+ protected BaseCompareValidator(): base()
+ {
+ }
+
+ public static bool CanConvert(string text, ValidationDataType type)
+ {
+ object o = null;
+ return Convert(text, type, out o);
+ }
+
+ [DefaultValue(ValidationDataType.String)]
+ [WebCategory("Behaviour")]
+ [WebSysDescription("RangeValidator_Type")]
+ public ValidationDataType Type
+ {
+ get
+ {
+ object o = ViewState["Type"];
+ if(o!=null)
+ return (ValidationDataType)o;
+ return ValidationDataType.String;
+ }
+ set
+ {
+ if(!System.Enum.IsDefined(typeof(ValidationDataType), value))
+ throw new ArgumentException();
+ ViewState["Type"] = value;
+ }
+ }
+
+ protected static int CutoffYear
+ {
+ get
+ {
+ return DateTimeFormatInfo.CurrentInfo.Calendar.TwoDigitYearMax;
+ }
+ }
+
+ protected static int GetFullYear(int shortYear)
+ {
+ int century = DateTime.Today.Year - (DateTime.Today.Year % 100);
+ if(century < CutoffYear)
+ {
+ return (shortYear + century);
+ }
+ return (shortYear + century - 100);
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender(writer);
+ if(RenderUplevel)
+ {
+ writer.AddAttribute("type", PropertyConverter.EnumToString(typeof(ValidationDataType), Type));
+ NumberFormatInfo currInfo = NumberFormatInfo.CurrentInfo;
+ if(Type == ValidationDataType.Double)
+ {
+ writer.AddAttribute("decimalchar", currInfo.NumberDecimalSeparator);
+ return;
+ }
+ if(Type == ValidationDataType.Currency)
+ {
+ writer.AddAttribute("decimalchar", currInfo.CurrencyDecimalSeparator);
+ string grpSep = currInfo.CurrencyGroupSeparator;
+ if(grpSep[0] == 0xA0)
+ {
+ grpSep = " ";
+ }
+ writer.AddAttribute("groupchar", grpSep);
+ writer.AddAttribute("digits", currInfo.CurrencyDecimalDigits.ToString(NumberFormatInfo.InvariantInfo));
+ return;
+ }
+ if(Type == ValidationDataType.Date)
+ {
+ writer.AddAttribute("cutoffyear", CutoffYear.ToString());
+ writer.AddAttribute("century", ( DateTime.Today.Year - (DateTime.Today.Year % 100) ).ToString());
+ return;
+ }
+ }
+ }
+
+ protected override bool DetermineRenderUplevel()
+ {
+ if(Type == ValidationDataType.Date && DateTimeFormatInfo.CurrentInfo.Calendar.GetType() != typeof(GregorianCalendar))
+ {
+ return false;
+ }
+ return base.DetermineRenderUplevel();
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ protected static bool Compare(string leftText, string rightText, ValidationCompareOperator op, ValidationDataType type)
+ {
+ object left = null, right = null;
+ if(!Convert(leftText, type, out left))
+ {
+ return false;
+ }
+ if(op == ValidationCompareOperator.DataTypeCheck)
+ {
+ return true;
+ }
+ if(!Convert(rightText, type, out right))
+ {
+ return true;
+ }
+ int compareResult = 0;
+ switch(type)
+ {
+ case ValidationDataType.String:
+ compareResult = ((String)left).CompareTo(right);
+ break;
+ case ValidationDataType.Integer:
+ compareResult = ((int)left).CompareTo(right);
+ break;
+ case ValidationDataType.Double:
+ compareResult = ((Double)left).CompareTo(right);
+ break;
+ case ValidationDataType.Date:
+ compareResult = ((DateTime)left).CompareTo(right);
+ break;
+ case ValidationDataType.Currency:
+ compareResult = ((Decimal)left).CompareTo(right);
+ break;
+ }
+ switch(op)
+ {
+ case ValidationCompareOperator.Equal:
+ return (compareResult == 0);
+ case ValidationCompareOperator.NotEqual:
+ return (compareResult != 0);
+ case ValidationCompareOperator.GreaterThan:
+ return (compareResult > 0);
+ case ValidationCompareOperator.GreaterThanEqual:
+ return (compareResult >= 0);
+ case ValidationCompareOperator.LessThan:
+ return (compareResult < 0);
+ case ValidationCompareOperator.LessThanEqual:
+ return (compareResult <= 0);
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ protected static string GetDateElementOrder()
+ {
+ string pattern = DateTimeFormatInfo.CurrentInfo.ShortDatePattern;
+
+ //TODO: What are the various possibilities?
+ // I can think of only y*/M*/d*, d*/M*/y*, M*/d*/y*
+ if(pattern.IndexOf('y') < pattern.IndexOf('M'))
+ {
+ return "ymd";
+ }
+ if(pattern.IndexOf('M') < pattern.IndexOf('d'))
+ {
+ return "mdy";
+ }
+ return "dmy";
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ protected static bool Convert(string text, ValidationDataType type, out object convertedValue)
+ {
+ convertedValue = null;
+ try
+ {
+ switch(type)
+ {
+ case ValidationDataType.String: convertedValue = text;
+ break;
+ case ValidationDataType.Integer: convertedValue = Int32.Parse(text, CultureInfo.InvariantCulture);
+ break;
+ case ValidationDataType.Double:
+ Match matchDouble = Regex.Match(text, @"^\s*([-\+])?(\d+)?(\"
+ + NumberFormatInfo.CurrentInfo.NumberDecimalSeparator
+ + @"(\d+))?\s*$");
+ if(matchDouble.Success)
+ {
+ string sign = (matchDouble.Groups[1].Success ? matchDouble.Groups[1].Value : "+");
+ string decPart = (matchDouble.Groups[2].Success ? matchDouble.Groups[2].Value : "0");
+ string mantissa = (matchDouble.Groups[4].Success ? matchDouble.Groups[4].Value : "0");
+ convertedValue = Double.Parse(sign + decPart + "." + mantissa, CultureInfo.InvariantCulture);
+ }
+ break;
+ case ValidationDataType.Date:
+ if(DateTimeFormatInfo.CurrentInfo.Calendar.GetType() != typeof(GregorianCalendar))
+ {
+ convertedValue = DateTime.Parse(text);
+ break;
+ }
+ string order = GetDateElementOrder();
+ int date = 0, mth = 0, year = 0;
+ Match matchDate = Regex.Match(text, @"^\s*((\d{4})|(\d{2}))([\.\/-])(\d{1,2})\4(\d{1,2})\s*$");
+ if(matchDate.Success && order == "ymd")
+ {
+ date = Int32.Parse(matchDate.Groups[6].Value, CultureInfo.InvariantCulture);
+ mth = Int32.Parse(matchDate.Groups[5].Value, CultureInfo.InvariantCulture);
+ year = Int32.Parse((matchDate.Groups[2].Success ? matchDate.Groups[2].Value : matchDate.Groups[3].Value), CultureInfo.InvariantCulture);
+ } else
+ {
+ matchDate = Regex.Match(text, @"^\s*(\d{1,2})([\.\/-])(\d{1,2})\2((\d{4}|\d{2}))\s*$");
+ if(matchDate.Success)
+ {
+ if(order == "dmy")
+ {
+ date = Int32.Parse(matchDate.Groups[1].Value, CultureInfo.InvariantCulture);
+ mth = Int32.Parse(matchDate.Groups[3].Value, CultureInfo.InvariantCulture);
+ year = Int32.Parse((matchDate.Groups[5].Success ? matchDate.Groups[5].Value : matchDate.Groups[6].Value), CultureInfo.InvariantCulture);
+ }
+ if(order == "mdy")
+ {
+ date = Int32.Parse(matchDate.Groups[3].Value, CultureInfo.InvariantCulture);
+ mth = Int32.Parse(matchDate.Groups[1].Value, CultureInfo.InvariantCulture);
+ year = Int32.Parse((matchDate.Groups[5].Success ? matchDate.Groups[5].Value : matchDate.Groups[6].Value), CultureInfo.InvariantCulture);
+ }
+ }
+ }
+ year = (year < 100 ? GetFullYear(year) : year);
+ if(matchDate.Success && date!=0 && mth!=0 && year!=0)
+ {
+ convertedValue = new DateTime(year, mth, date);
+ }
+ break;
+ case ValidationDataType.Currency:
+ string decSep = NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator;
+ string grpSep = NumberFormatInfo.CurrentInfo.CurrencyGroupSeparator;
+ int decDig = NumberFormatInfo.CurrentInfo.CurrencyDecimalDigits;
+ if(grpSep[0] == 0xA0)
+ {
+ grpSep = " ";
+ }
+ string[] patternArray = new string[5];
+ patternArray[0] = "^\\s*([-\\+])?(((\\d+)\\";
+ patternArray[1] = grpSep;
+ patternArray[2] = @")*)(\d+)";
+ if(decDig > 0)
+ {
+ string[] decPattern = new string[5];
+ decPattern[0] = "(\\";
+ decPattern[1] = decSep;
+ decPattern[2] = @"(\d{1,";
+ decPattern[3] = decDig.ToString(NumberFormatInfo.InvariantInfo);
+ decPattern[4] = @"}))";
+ patternArray[3] = String.Concat(decPattern);
+
+ } else
+ {
+ patternArray[3] = String.Empty;
+ }
+ patternArray[4] = @"?\s*$";
+ Match matchCurrency = Regex.Match(text, String.Concat(patternArray));
+ if(matchCurrency.Success)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(matchCurrency.Groups[1]);
+ CaptureCollection cc = matchCurrency.Groups[4].Captures;
+ foreach(IEnumerable current in cc)
+ {
+ sb.Append((Capture)current);
+ }
+ sb.Append(matchCurrency.Groups[5]);
+ if(decDig > 0)
+ {
+ sb.Append(".");
+ sb.Append(matchCurrency.Groups[7]);
+ }
+ convertedValue = Decimal.Parse(sb.ToString(), CultureInfo.InvariantCulture);
+ }
+ break;
+ }
+ } catch(Exception e)
+ {
+ convertedValue = null;
+ }
+ return (convertedValue != null);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs
new file mode 100755
index 00000000000..aabd78d585e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs
@@ -0,0 +1,277 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: BaseDataList
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("SelectedIndexChanged")]
+ [DefaultProperty("DataSource")]
+ [ParseChildren(true)]
+ [PersistChildren(false)]
+ //TODO: [Designer("??")]
+ public abstract class BaseDataList: WebControl
+ {
+ private static readonly object SelectedIndexChangedEvent = new object();
+ internal static string ItemCountViewStateKey = "_!ItemCount";
+
+ private DataKeyCollection dataKeys;
+ private object dataSource;
+
+ public BaseDataList() : base()
+ {
+ }
+
+ public static bool IsBindableType(Type type)
+ {
+ if(type.IsPrimitive || type == typeof(string) || type == typeof(DateTime) || type == typeof(Decimal))
+ return true;
+ return false;
+ }
+
+ public override ControlCollection Controls
+ {
+ get
+ {
+ EnsureChildControls();
+ return base.Controls;
+ }
+ }
+
+ public override void DataBind()
+ {
+ OnDataBinding(EventArgs.Empty);
+ }
+
+ [WebCategory("Action")]
+ [WebSysDescription("BaseDataList_OnSelectedIndexChanged")]
+ public event EventHandler SelectedIndexChanged
+ {
+ add
+ {
+ Events.AddHandler(SelectedIndexChangedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(SelectedIndexChangedEvent, value);
+ }
+ }
+
+ [Bindable(true)]
+ [DefaultValue(-1)]
+ [WebCategory("Layout")]
+ [WebSysDescription("BaseDataList_CellPadding")]
+ public virtual int CellPadding
+ {
+ get
+ {
+ if(!ControlStyleCreated)
+ return -1;
+ return ((TableStyle)ControlStyle).CellPadding;
+ }
+ set
+ {
+ ((TableStyle)ControlStyle).CellPadding = value;
+ }
+ }
+
+ [Bindable(true)]
+ [DefaultValue(-1)]
+ [WebCategory("Layout")]
+ [WebSysDescription("BaseDataList_CellSpacing")]
+ public virtual int CellSpacing
+ {
+ get
+ {
+ if(!ControlStyleCreated)
+ return -1;
+ return ((TableStyle)ControlStyle).CellSpacing;
+ }
+ set
+ {
+ ((TableStyle)ControlStyle).CellSpacing = value;
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Data")]
+ [WebSysDescription("BaseDataList_DataKeyField")]
+ public virtual string DataKeyField
+ {
+ get
+ {
+ object o = ViewState["DataKeyField"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataKeyField"] = value;
+ }
+ }
+
+ [Browsable(true)]
+ //[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [WebSysDescription("BaseDataList_DataKeys")]
+ public DataKeyCollection DataKeys
+ {
+ get
+ {
+ if( dataKeys==null )
+ dataKeys = new DataKeyCollection(DataKeysArray);
+ return dataKeys;
+
+ }
+ }
+
+ [DefaultValue("")]
+ [WebCategory("Data")]
+ [WebSysDescription("BaseDataList_DataMember")]
+ public string DataMember
+ {
+ get
+ {
+ object o = ViewState["DataMember"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataMember"] = value;
+ }
+ }
+
+ [Bindable(true)]
+ //[DefaultValue(null)]
+ //[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Data")]
+ [WebSysDescription("BaseDataList_DataSource")]
+ public virtual object DataSource
+ {
+ get
+ {
+ return dataSource;
+ }
+ set
+ {
+ if( (value!=null) && (value is IListSource || value is IEnumerable) )
+ {
+ dataSource = value;
+ } else
+ {
+ throw new ArgumentException(HttpRuntime.FormatResourceString("Invalid_DataSource_Type", ID));
+ }
+ }
+ }
+
+ [Bindable(true)]
+ [DefaultValue(GridLines.Both)]
+ [WebCategory("Appearance")]
+ [WebSysDescription("BaseDataList_GridLines")]
+ public virtual GridLines GridLines
+ {
+ get
+ {
+ if(ControlStyleCreated)
+ return ((TableStyle)ControlStyle).GridLines;
+ return GridLines.Both;
+ }
+ set
+ {
+ ((TableStyle)ControlStyle).GridLines = value;
+ }
+ }
+
+ [Bindable(true)]
+ [DefaultValue(HorizontalAlign.NotSet)]
+ [WebCategory("Layout")]
+ [WebSysDescription("BaseDataList_HorizontalAlign")]
+ public virtual HorizontalAlign HorizontalAlign
+ {
+ get
+ {
+ if(ControlStyleCreated)
+ return ((TableStyle)ControlStyle).HorizontalAlign;
+ return HorizontalAlign.NotSet;
+ }
+ set
+ {
+ ((TableStyle)ControlStyle).HorizontalAlign = value;
+ }
+ }
+
+ protected ArrayList DataKeysArray
+ {
+ get
+ {
+ object o = ViewState["DataKeys"];
+ if(o == null)
+ {
+ o = new ArrayList();
+ ViewState["DataKeys"] = o;
+ }
+ return (ArrayList)o;
+ }
+ }
+
+ protected override void AddParsedSubObject(object o)
+ {
+ // Preventing literal controls from being added as children.
+ }
+
+ protected override void CreateChildControls()
+ {
+ Controls.Clear();
+ if(ViewState[ItemCountViewStateKey]!=null)
+ {
+ CreateControlHierarchy(false);
+ ClearChildViewState();
+ }
+ }
+
+ protected override void OnDataBinding(EventArgs e)
+ {
+ base.OnDataBinding(e);
+ Controls.Clear();
+ ClearChildViewState();
+ CreateControlHierarchy(true);
+ ChildControlsCreated = true;
+ TrackViewState();
+ }
+
+ protected virtual void OnSelectedIndexChanged(EventArgs e)
+ {
+ if(Events != null)
+ {
+ EventHandler eh = (EventHandler)(Events[SelectedIndexChangedEvent]);
+ if(eh!=null)
+ eh(this, e);
+ }
+ }
+
+ protected override void Render(HtmlTextWriter writer)
+ {
+ PrepareControlHierarchy();
+ RenderContents(writer);
+ }
+
+ protected abstract void PrepareControlHierarchy();
+ protected abstract void CreateControlHierarchy(bool useDataSource);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs
new file mode 100755
index 00000000000..76db43afad9
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs
@@ -0,0 +1,414 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: BaseValidator
+ *
+ * Authors: Gaurav Vaish, Gonzalo Paniagua Javier
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>, <gonzalo@ximian.com>
+ * Implementation: yes
+ * Status: 80%
+ *
+ * (C) Gaurav Vaish (2001)
+ * (c) 2002 Ximian, Inc. (http://www.ximian.com)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+using System.Drawing;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultProperty("ErrorMessage")]
+ //TODO: [Designer("??")]
+ public abstract class BaseValidator: Label, IValidator
+ {
+ private bool isValid;
+ private bool isPreRenderCalled;
+ private bool isPropertiesChecked;
+ private bool propertiesValid;
+ private bool renderUplevel;
+
+ protected BaseValidator() : base()
+ {
+ isValid = true;
+ ForeColor = Color.Red;
+ propertiesValid = true;
+ isPropertiesChecked = false;
+ renderUplevel = false;
+ }
+
+ public string ControlToValidate
+ {
+ get
+ {
+ object o = ViewState["ControlToValidate"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["ControlToValidate"] = value;
+ }
+ }
+
+ public ValidatorDisplay Display
+ {
+ get
+ {
+ object o = ViewState["Display"];
+ if(o != null)
+ {
+ return (ValidatorDisplay)o;
+ }
+ return ValidatorDisplay.Static;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(ValidatorDisplay), value))
+ {
+ throw new ArgumentException();
+ }
+ ViewState["ValidatorDisplay"] = value;
+ }
+ }
+
+ public bool EnableClientScript
+ {
+ get
+ {
+ object o = ViewState["EnableClientScript"];
+ if(o != null)
+ {
+ return (bool)o;
+ }
+ return true;
+ }
+ set
+ {
+ ViewState["EnableClientScript"] = value;
+ }
+ }
+
+ public override bool Enabled
+ {
+ get
+ {
+ return base.Enabled;
+ }
+ set
+ {
+ if (value == false)
+ isValid = true;
+ base.Enabled = value;
+ }
+ }
+
+ public string ErrorMessage
+ {
+ get
+ {
+ object o = ViewState["ErrorMessage"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["ErrorMessage"] = value;
+ }
+ }
+
+ public override Color ForeColor
+ {
+ get
+ {
+ return base.ForeColor;
+ }
+ set
+ {
+ base.ForeColor = value;
+ }
+ }
+
+ public bool IsValid
+ {
+ get { return isValid; }
+ set { isValid = value; }
+ }
+
+ public static PropertyDescriptor GetValidationProperty(object component)
+ {
+ System.ComponentModel.AttributeCollection coll = TypeDescriptor.GetAttributes (component);
+ Type type = typeof (ValidationPropertyAttribute);
+ ValidationPropertyAttribute attrib = (ValidationPropertyAttribute) coll [type];
+ if (attrib != null && attrib.Name != null)
+ return (TypeDescriptor.GetProperties (component)) [attrib.Name];
+ return null;
+ }
+
+ public void Validate()
+ {
+ if(!Visible || (Visible && !Enabled))
+ {
+ IsValid = true;
+ }
+ Control ctrl = Parent;
+ while(ctrl != null)
+ {
+ if(!ctrl.Visible)
+ {
+ IsValid = true;
+ return;
+ }
+ ctrl = ctrl.Parent;
+ }
+ isPropertiesChecked = false;
+ if(!PropertiesValid)
+ {
+ IsValid = true;
+ return;
+ }
+ IsValid = EvaluateIsValid();
+ }
+
+ protected bool PropertiesValid
+ {
+ get
+ {
+ if(!isPropertiesChecked)
+ {
+ propertiesValid = ControlPropertiesValid();
+ isPropertiesChecked = true;
+ }
+ return propertiesValid;
+ }
+ }
+
+ protected bool RenderUplevel
+ {
+ get
+ {
+ return renderUplevel;
+ }
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ bool enabled = base.Enabled;
+ if (enabled)
+ Enabled = true;
+
+ base.AddAttributesToRender(writer);
+ if(RenderUplevel)
+ {
+ if(ID == null)
+ {
+ writer.AddAttribute("id", ClientID);
+ }
+ if(ControlToValidate.Length > 0)
+ {
+ writer.AddAttribute("controltovalidate", GetControlRenderID(ControlToValidate));
+ }
+ if(ErrorMessage.Length > 0)
+ {
+ writer.AddAttribute("errormessage", ErrorMessage, true);
+ }
+ if(Display == ValidatorDisplay.Static)
+ {
+ writer.AddAttribute("display", Enum.Format(typeof(ValidatorDisplay), Display, "G").Replace('_','-'));
+ //writer.AddAttribute("display", PropertyConverter.EnumToString(typeof(ValidatorDisplay), Display));
+ }
+ if(!IsValid)
+ {
+ writer.AddAttribute("isvalid", "False");
+ }
+
+ ControlStyle.AddAttributesToRender (writer, this);
+ if(!enabled)
+ {
+ writer.AddAttribute("enabled", "False");
+ }
+ }
+
+ if(enabled)
+ {
+ Enabled = false;
+ }
+ }
+
+ protected void CheckControlValidationProperty(string name, string propertyName)
+ {
+ Control ctrl = NamingContainer.FindControl(name);
+ if(ctrl == null)
+ {
+ throw new HttpException(HttpRuntime.FormatResourceString("Validator_control_not_found",
+ name, propertyName/*, ID*/));
+ }
+ PropertyDescriptor pd = GetValidationProperty(ctrl);
+ if(pd == null)
+ {
+ throw new HttpException(HttpRuntime.FormatResourceString("Validator_bad_control_type",
+ name, propertyName/*, ID*/));
+ }
+ }
+
+ protected virtual bool ControlPropertiesValid()
+ {
+ if(ControlToValidate.Length == 0)
+ {
+ throw new HttpException(HttpRuntime.FormatResourceString("Validator_control_blank", ID));
+ }
+ CheckControlValidationProperty(ControlToValidate, "ControlToValidate");
+ return true;
+ }
+
+ [MonoTODO]
+ protected virtual bool DetermineRenderUplevel()
+ {
+ Page page = Page;
+ if(page == null || page.Request == null)
+ {
+ return false;
+ }
+
+ if(EnableClientScript)
+ {
+ // By now, return false
+ return false;
+ //throw new NotImplementedException();
+ ////TODO: I need to get the (Browser->Dom_version_major >= 4 &&
+ //// Brower->Ecma_script_version >= 1.2)
+ }
+ return false;
+ }
+
+ protected string GetControlRenderID(string name)
+ {
+ Control ctrl = FindControl(name);
+ if(ctrl != null)
+ {
+ return ctrl.ClientID;
+ }
+ return String.Empty;
+ }
+
+ protected string GetControlValidationValue(string name)
+ {
+ Control ctrl = NamingContainer.FindControl(name);
+ if(ctrl != null)
+ {
+ PropertyDescriptor pd = GetValidationProperty(ctrl);
+ if(pd != null)
+ {
+ object item = pd.GetValue (ctrl);
+ if (item is ListItem)
+ return ((ListItem) item).Value;
+
+ if (item == null)
+ return String.Empty;
+
+ return item.ToString ();
+ }
+ }
+ return null;
+ }
+
+ protected override void OnInit(EventArgs e)
+ {
+ base.OnInit(e);
+ Page.Validators.Add(this);
+ }
+
+ protected override void OnPreRender(EventArgs e)
+ {
+ base.OnPreRender(e);
+ isPreRenderCalled = true;
+ isPropertiesChecked = false;
+ renderUplevel = DetermineRenderUplevel();
+ if(renderUplevel)
+ {
+ RegisterValidatorCommonScript();
+ }
+ }
+
+ protected override void OnUnload(EventArgs e)
+ {
+ if(Page != null)
+ {
+ Page.Validators.Remove(this);
+ }
+ base.OnUnload(e);
+ }
+
+ [MonoTODO("Damn_This_Is_Really_Frustrating___by_Gaurav")]
+ protected void RegisterValidatorCommonScript()
+ {
+ if(Page.IsClientScriptBlockRegistered("ValidatorIncludeScript"))
+ return;
+
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO("I_have_to_know_javascript_for_this_I_know_it_but_for_ALL_browsers_NO")]
+ protected virtual void RegisterValidatorDeclaration()
+ {
+ throw new NotImplementedException();
+ //TODO: Since I have to access document.<ClientID> and register
+ // as page validator. Now this is Browser dependent :((
+
+ // This does not render anything on Mozilla, and does on IE
+ }
+
+ [MonoTODO("Render_ing_always_left")]
+ protected override void Render (HtmlTextWriter writer)
+ {
+ bool valid;
+
+ if (!Enabled)
+ return;
+
+ if (isPreRenderCalled) {
+ valid = IsValid;
+ } else {
+ isPropertiesChecked = true;
+ propertiesValid = true;
+ renderUplevel = false;
+ valid = true;
+ }
+
+ if (PropertiesValid) {
+ if (Page != null)
+ Page.VerifyRenderingInServerForm (this);
+
+ ValidatorDisplay dis = Display;
+ if (RenderUplevel) {
+ //FIXME: as of now, don't do client-side validation
+ throw new NotImplementedException();
+ }
+
+ if (!valid) {
+ RenderBeginTag (writer);
+ if (Text.Trim ().Length > 0 || HasControls ()) {
+ RenderContents (writer);
+ RenderEndTag (writer);
+ } else {
+ writer.Write (ErrorMessage);
+ }
+ RenderEndTag (writer);
+ return;
+ }
+ } else {
+ writer.Write ("&nbsp;");
+ }
+ }
+
+ protected abstract bool EvaluateIsValid();
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/BorderStyle.cs b/mcs/class/System.Web/System.Web.UI.WebControls/BorderStyle.cs
new file mode 100755
index 00000000000..93c04f1f213
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/BorderStyle.cs
@@ -0,0 +1,29 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: BorderStyle
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum BorderStyle
+ {
+ NotSet,
+ None,
+ Dotted,
+ Dashed,
+ Solid,
+ Double,
+ Groove,
+ Ridge,
+ Inset,
+ Outset
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/BoundColumn.cs b/mcs/class/System.Web/System.Web.UI.WebControls/BoundColumn.cs
new file mode 100755
index 00000000000..abc63c2b9a0
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/BoundColumn.cs
@@ -0,0 +1,179 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: BoundColumn
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 60%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class BoundColumn : DataGridColumn
+ {
+ public static readonly string thisExpr = "!";
+
+ private bool boundFieldDescriptionValid;
+ private string boundField;
+ private string formatting;
+
+ private PropertyDescriptor desc;
+
+ public BoundColumn(): base()
+ {
+ }
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ desc = null;
+ boundField = DataField;
+ formatting = DataFormatString;
+ boundFieldDescriptionValid = false;
+ }
+
+ public override void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
+ {
+ base.InitializeCell(cell, columnIndex, itemType);
+
+ Control bindCtrl = null;
+ Control toAdd = null;
+ switch(itemType)
+ {
+ case ListItemType.Item : goto case ListItemType.SelectedItem;
+ case ListItemType.AlternatingItem
+ : goto case ListItemType.SelectedItem;
+ case ListItemType.SelectedItem
+ : if(DataField.Length != 0)
+ bindCtrl = cell;
+ break;
+ case ListItemType.EditItem
+ : if(!ReadOnly)
+ {
+ TextBox box = new TextBox();
+ toAdd = box;
+ if(DataField.Length != 0)
+ bindCtrl = box;
+ }
+ break;
+ }
+ if(toAdd != null)
+ cell.Controls.Add(toAdd);
+ if(bindCtrl != null)
+ bindCtrl.DataBinding += new EventHandler(OnDataBindColumn);
+ //throw new NotImplementedException();
+ }
+
+ private void OnDataBindColumn(object sender, EventArgs e)
+ {
+ Control senderCtrl = (Control)sender;
+ DataGridItem item = (DataGridItem)senderCtrl.NamingContainer;
+ object data = item.DataItem;
+
+ if(!boundFieldDescriptionValid)
+ {
+ if(boundField != BoundColumn.thisExpr)
+ {
+ desc = TypeDescriptor.GetProperties(data).Find(boundField, true);
+ if(desc == null && !DesignMode)
+ {
+ throw new HttpException(
+ HttpRuntime.FormatResourceString("File_Not_Found",
+ boundField));
+ }
+ boundFieldDescriptionValid = true;
+ }
+ }
+ object value = data;
+ string val = String.Empty;
+ if(desc == null && DesignMode)
+ {
+ throw new NotImplementedException();
+ } else
+ {
+ if(desc != null)
+ value = desc.GetValue(data);
+ val = FormatDataValue(value);
+ }
+ if(senderCtrl is TableCell)
+ {
+ if(val.Length == 0)
+ val = "&nbsp;";
+ ((TableCell)senderCtrl).Text = val;
+ } else
+ {
+ ((TextBox)senderCtrl).Text = val;
+ }
+ }
+
+ public virtual string DataField
+ {
+ get
+ {
+ object o = ViewState["DataField"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataField"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual string DataFormatString
+ {
+ get
+ {
+ object o = ViewState["DataFormatString"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataFormatString"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual bool ReadOnly
+ {
+ get
+ {
+ object o = ViewState["ReadOnly"];
+ if(o != null)
+ return (bool)o;
+ return false;
+ }
+ set
+ {
+ ViewState["ReadOnly"] = value;
+ }
+ }
+
+ protected virtual string FormatDataValue(Object dataValue)
+ {
+ string retVal = String.Empty;
+ if(dataValue != null)
+ {
+ if(formatting.Length == 0)
+ retVal = dataValue.ToString();
+ else
+ retVal = String.Format(formatting, dataValue);
+ }
+ return retVal;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
new file mode 100755
index 00000000000..9410807bae7
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
@@ -0,0 +1,172 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: Button
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("Click")]
+ [DefaultProperty("Text")]
+ //TODO: [Designer("??")]
+ //TODO: [DataBindingHandler("??UI.Design.TextDataBindingHandler??")]
+ [ToolboxData("<{0}:Button runat=\"server\" Text=\"Button\"></{0}:Button>")]
+ public class Button : WebControl, IPostBackEventHandler
+ {
+ private static readonly object ClickEvent = new object();
+ private static readonly object CommandEvent = new object();
+
+ //private EventHandlerList ehList;
+
+ public Button(): base (HtmlTextWriterTag.Input)
+ {
+ }
+
+ public bool CausesValidation
+ {
+ get
+ {
+ Object cv = ViewState["CausesValidation"];
+ if(cv!=null)
+ return (Boolean)cv;
+ return true;
+ }
+ set
+ {
+ ViewState["CausesValidation"] = value;
+ }
+ }
+
+ public string CommandArgument
+ {
+ get
+ {
+ string ca = (string) ViewState["CommandArgument"];
+ if(ca!=null)
+ return ca;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["CommandArgument"] = value;
+ }
+ }
+
+ public string CommandName
+ {
+ get
+ {
+ string cn = (string)ViewState["CommandName"];
+ if(cn!=null)
+ return cn;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["CommandName"] = value;
+ }
+ }
+
+ public string Text
+ {
+ get
+ {
+ string text = (string)ViewState["Text"];
+ if(text!=null)
+ return text;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["Text"] = value;
+ }
+ }
+
+ public event EventHandler Click
+ {
+ add
+ {
+ Events.AddHandler(ClickEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ClickEvent, value);
+ }
+ }
+
+ public event CommandEventHandler Command
+ {
+ add
+ {
+ Events.AddHandler(CommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(CommandEvent, value);
+ }
+ }
+
+ protected virtual void OnClick(EventArgs e)
+ {
+ if(Events != null)
+ {
+ EventHandler eh = (EventHandler)(Events[ClickEvent]);
+ if(eh!= null)
+ eh(this,e);
+ }
+ }
+
+ protected virtual void OnCommand(CommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ CommandEventHandler eh = (CommandEventHandler)(Events[CommandEvent]);
+ if(eh!= null)
+ eh(this,e);
+ }
+ RaiseBubbleEvent(this, e);
+ }
+
+ void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
+ {
+ if (CausesValidation)
+ Page.Validate ();
+
+ OnClick (EventArgs.Empty);
+ OnCommand (new CommandEventArgs (CommandName, CommandArgument));
+ }
+
+ protected override void AddAttributesToRender (HtmlTextWriter writer)
+ {
+ if (Page != null)
+ Page.VerifyRenderingInServerForm (this);
+
+ writer.AddAttribute (HtmlTextWriterAttribute.Type, "submit");
+ writer.AddAttribute (HtmlTextWriterAttribute.Name, base.UniqueID);
+ writer.AddAttribute (HtmlTextWriterAttribute.Value, Text);
+ if (Page != null && CausesValidation && Page.Validators.Count > 0) {
+ writer.AddAttribute (System.Web.UI.HtmlTextWriterAttribute.Onclick,
+ Utils.GetClientValidatedEvent (Page));
+ writer.AddAttribute ("language", "javascript");
+ }
+ base.AddAttributesToRender (writer);
+ }
+
+ protected override void RenderContents(HtmlTextWriter writer)
+ {
+ // Preventing base classes to do anything
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ButtonColumn.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ButtonColumn.cs
new file mode 100755
index 00000000000..23db52724d6
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ButtonColumn.cs
@@ -0,0 +1,186 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: ButtonColumn
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class ButtonColumn : DataGridColumn
+ {
+ private PropertyDescriptor textFieldDescriptor;
+
+ public ButtonColumn(): base()
+ {
+ }
+
+ public override void Initialize()
+ {
+ Initialize();
+ textFieldDescriptor = null;
+ }
+
+ public override void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
+ {
+ InitializeCell(cell, columnIndex, itemType);
+ if(Enum.IsDefined(typeof(ListItemType), itemType) && itemType != ListItemType.Footer)
+ {
+ WebControl toDisplay = null;
+ if(ButtonType == ButtonColumnType.PushButton)
+ {
+ Button b = new Button();
+ b.Text = Text;
+ b.CommandName = CommandName;
+ b.CausesValidation = false;
+ toDisplay = b;
+ } else
+ {
+ LinkButton lb = new LinkButton();
+ lb.Text = Text;
+ lb.CommandName = CommandName;
+ lb.CausesValidation = false;
+ toDisplay = lb;
+ }
+ if(DataTextField.Length > 0)
+ {
+ toDisplay.DataBinding += new EventHandler(OnDataBindButtonColumn);
+ }
+ cell.Controls.Add(toDisplay);
+ }
+ }
+
+ private void OnDataBindButtonColumn(object sender, EventArgs e)
+ {
+ Control ctrl = (Control)sender;
+ object item = ((DataGridItem)ctrl.NamingContainer).DataItem;
+ if(textFieldDescriptor == null)
+ {
+ textFieldDescriptor = TypeDescriptor.GetProperties(item).Find(DataTextField, true);
+ if(textFieldDescriptor == null && !DesignMode)
+ throw new HttpException(HttpRuntime.FormatResourceString("Field_Not_Found", DataTextField));
+ }
+ string text;
+ if(textFieldDescriptor != null)
+ {
+ text = FormatDataTextValue(textFieldDescriptor.GetValue(item));
+ } else
+ {
+ text = "Sample_DataBound_Text";
+ }
+ if(ctrl is LinkButton)
+ {
+ ((LinkButton)ctrl).Text = text;
+ }
+ else
+ {
+ ((Button)ctrl).Text = text;
+ }
+ }
+
+ protected virtual string FormatDataTextValue(object dataTextValue)
+ {
+ string retVal = null;
+ if(dataTextValue != null)
+ {
+ if(DataTextFormatString.Length > 0)
+ {
+ retVal = String.Format((string)dataTextValue, DataTextFormatString);
+ }
+ else
+ {
+ retVal = dataTextValue.ToString();
+ }
+ }
+ return retVal;
+ }
+
+ public virtual ButtonColumnType ButtonType
+ {
+ get
+ {
+ object o = ViewState["ButtonType"];
+ if(o!=null)
+ return (ButtonColumnType)o;
+ return ButtonColumnType.LinkButton;
+ }
+ set
+ {
+ if(!System.Enum.IsDefined(typeof(ButtonColumnType), value))
+ throw new ArgumentException();
+ ViewState["ButtonType"] = value;
+ }
+ }
+
+ public virtual string CommandName
+ {
+ get
+ {
+ string cn = (string)ViewState["CommandName"];
+ if(cn!=null)
+ return cn;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["CommandName"] = value;
+ }
+ }
+
+ public virtual string DataTextField
+ {
+ get
+ {
+ string dtf = (string)ViewState["DataTextField"];
+ if(dtf!=null)
+ return dtf;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataTextField"] = value;
+ }
+ }
+
+ public virtual string DataTextFormatString
+ {
+ get
+ {
+ string dtfs = (string)ViewState["DataTextFormatString"];
+ if(dtfs!=null)
+ return dtfs;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataTextFormatString"] = value;
+ }
+ }
+
+ public virtual string Text
+ {
+ get
+ {
+ string text = (string)ViewState["Text"];
+ if(text!=null)
+ return text;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["Text"] = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ButtonColumnType.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ButtonColumnType.cs
new file mode 100755
index 00000000000..ed59eba315b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ButtonColumnType.cs
@@ -0,0 +1,21 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: ButtonColumnType
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum ButtonColumnType
+ {
+ LinkButton,
+ PushButton
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
new file mode 100755
index 00000000000..36d4bc1f446
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
@@ -0,0 +1,1161 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: Calendar
+ *
+ * Authors: Gaurav Vaish, Gonzalo Paniagua Javier
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>, <gonzalo@ximian.com>
+ * Implementation: yes
+ * Status: 98%
+ *
+ * (C) Gaurav Vaish (2001)
+ * (c) 2002 Ximian, Inc. (http://www.ximian.com)
+ */
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Globalization;
+using System.Text;
+using System.Web;
+using System.Web.UI;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("SelectionChanged")]
+ [DefaultProperty("SelectedDate")]
+ //TODO: [Designer("??")]
+ //[DataBindingHandler("??")]
+ public class Calendar : WebControl, IPostBackEventHandler
+ {
+ //
+ private TableItemStyle dayHeaderStyle;
+ private TableItemStyle dayStyle;
+ private TableItemStyle nextPrevStyle;
+ private TableItemStyle otherMonthDayStyle;
+ private SelectedDatesCollection selectedDates;
+ private ArrayList selectedDatesList;
+ private TableItemStyle selectedDayStyle;
+ private TableItemStyle selectorStyle;
+ private TableItemStyle titleStyle;
+ private TableItemStyle todayDayStyle;
+ private TableItemStyle weekendDayStyle;
+
+ private static readonly object DayRenderEvent = new object();
+ private static readonly object SelectionChangedEvent = new object();
+ private static readonly object VisibleMonthChangedEvent = new object();
+
+ private Color defaultTextColor;
+ private System.Globalization.Calendar globCal;
+ private DateTimeFormatInfo infoCal = DateTimeFormatInfo.CurrentInfo;
+
+ private static int MASK_WEEKEND = (0x01 << 0);
+ private static int MASK_OMONTH = (0x01 << 1);
+ private static int MASK_TODAY = (0x01 << 2);
+ private static int MASK_SELECTED = (0x01 << 3);
+ private static int MASK_DAY = (0x01 << 4);
+ private static int MASK_UNIQUE = MASK_WEEKEND | MASK_OMONTH | MASK_TODAY | MASK_SELECTED;
+
+ public Calendar(): base()
+ {
+ //TODO: Initialization
+ }
+
+ public int CellPadding
+ {
+ get
+ {
+ object o = ViewState["CellPadding"];
+ if(o!=null)
+ return (int)o;
+ return 2;
+ }
+ set
+ {
+ ViewState["CellPadding"] = value;
+ }
+ }
+
+ public int CellSpacing
+ {
+ get
+ {
+ object o = ViewState["CellSpacing"];
+ if(o!=null)
+ return (int)o;
+ return 0;
+ }
+ set
+ {
+ if(value<-1)
+ throw new ArgumentOutOfRangeException();
+ ViewState["CellSpacing"] = value;
+ }
+ }
+
+ public TableItemStyle DayHeaderStyle
+ {
+ get
+ {
+ if(dayHeaderStyle==null)
+ dayHeaderStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ dayHeaderStyle.TrackViewState();
+ return dayHeaderStyle;
+ }
+ }
+
+ public DayNameFormat DayNameFormat
+ {
+ get
+ {
+ object o = ViewState["DayNameFormat"];
+ if(o!=null)
+ return (DayNameFormat)o;
+ return DayNameFormat.Short;
+ }
+ set
+ {
+ if(!System.Enum.IsDefined(typeof(DayNameFormat),value))
+ throw new ArgumentException();
+ ViewState["DayNameFormat"] = value;
+ }
+ }
+
+ public TableItemStyle DayStyle
+ {
+ get
+ {
+ if(dayStyle==null)
+ dayStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ dayStyle.TrackViewState();
+ return dayStyle;
+ }
+ }
+
+ public FirstDayOfWeek FirstDayOfWeek
+ {
+ get
+ {
+ object o = ViewState["FirstDayOfWeek"];
+ if(o!=null)
+ return (FirstDayOfWeek)o;
+ return FirstDayOfWeek.Default;
+ }
+ set
+ {
+ if(!System.Enum.IsDefined(typeof(FirstDayOfWeek), value))
+ throw new ArgumentException();
+ ViewState["FirstDayOfWeek"] = value;
+ }
+ }
+
+ public string NextMonthText
+ {
+ get
+ {
+ object o = ViewState["NextMonthText"];
+ if(o!=null)
+ return (string)o;
+ return "&gt;";
+ }
+ set
+ {
+ ViewState["NextMonthText"] = value;
+ }
+ }
+
+ public NextPrevFormat NextPrevFormat
+ {
+ get
+ {
+ object o = ViewState["NextPrevFormat"];
+ if(o!=null)
+ return (NextPrevFormat)o;
+ return NextPrevFormat.CustomText;
+ }
+ set
+ {
+ if(!System.Enum.IsDefined(typeof(NextPrevFormat), value))
+ throw new ArgumentException();
+ ViewState["NextPrevFormat"] = value;
+ }
+ }
+
+ public TableItemStyle NextPrevStyle
+ {
+ get
+ {
+ if(nextPrevStyle == null)
+ nextPrevStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ nextPrevStyle.TrackViewState();
+ return nextPrevStyle;
+ }
+ }
+
+ public TableItemStyle OtherMonthDayStyle
+ {
+ get
+ {
+ if(otherMonthDayStyle == null)
+ otherMonthDayStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ otherMonthDayStyle.TrackViewState();
+ return otherMonthDayStyle;
+ }
+ }
+
+ public string PrevMonthText
+ {
+ get
+ {
+ object o = ViewState["PrevMonthText"];
+ if(o!=null)
+ return (string)o;
+ return "&lt;";
+ }
+ set
+ {
+ ViewState["PrevMonthText"] = value;
+ }
+ }
+
+ public DateTime SelectedDate
+ {
+ get
+ {
+ if(SelectedDates.Count > 0)
+ {
+ return SelectedDates[0];
+ }
+ return DateTime.MinValue;
+ }
+ set
+ {
+ if(value == DateTime.MinValue)
+ {
+ SelectedDates.Clear();
+ } else
+ {
+ SelectedDates.SelectRange(value, value);
+ }
+ }
+ }
+
+ public SelectedDatesCollection SelectedDates
+ {
+ get
+ {
+ if(selectedDates==null)
+ {
+ if(selectedDatesList == null)
+ selectedDatesList = new ArrayList();
+ selectedDates = new SelectedDatesCollection(selectedDatesList);
+ }
+ return selectedDates;
+ }
+ }
+
+ public TableItemStyle SelectedDayStyle
+ {
+ get
+ {
+ if(selectedDayStyle==null)
+ selectedDayStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ selectedDayStyle.TrackViewState();
+ return selectedDayStyle;
+ }
+ }
+
+ public CalendarSelectionMode SelectionMode
+ {
+ get
+ {
+ object o = ViewState["SelectionMode"];
+ if(o!=null)
+ return (CalendarSelectionMode)o;
+ return CalendarSelectionMode.Day;
+ }
+ set
+ {
+ if(!System.Enum.IsDefined(typeof(CalendarSelectionMode), value))
+ throw new ArgumentException();
+ ViewState["SelectionMode"] = value;
+ }
+ }
+
+ public string SelectMonthText
+ {
+ get
+ {
+ object o = ViewState["SelectMonthText"];
+ if(o!=null)
+ return (string)o;
+ return "&gt;&gt;";
+ }
+ set
+ {
+ ViewState["SelectMonthText"] = value;
+ }
+ }
+
+ public TableItemStyle SelectorStyle
+ {
+ get
+ {
+ if(selectorStyle==null)
+ selectorStyle = new TableItemStyle();
+ return selectorStyle;
+ }
+ }
+
+ public string SelectWeekText
+ {
+ get
+ {
+ object o = ViewState["SelectWeekText"];
+ if(o!=null)
+ return (string)o;
+ return "&gt;";
+ }
+ set
+ {
+ ViewState["SelectWeekText"] = value;
+ }
+ }
+
+ public bool ShowDayHeader
+ {
+ get
+ {
+ object o = ViewState["ShowDayHeader"];
+ if(o!=null)
+ return (bool)o;
+ return true;
+ }
+ set
+ {
+ ViewState["ShowDayHeader"] = value;
+ }
+ }
+
+ public bool ShowGridLines
+ {
+ get
+ {
+ object o = ViewState["ShowGridLines"];
+ if(o!=null)
+ return (bool)o;
+ return false;
+ }
+ set
+ {
+ ViewState["ShowGridLines"] = value;
+ }
+ }
+
+ public bool ShowNextPrevMonth
+ {
+ get
+ {
+ object o = ViewState["ShowNextPrevMonth"];
+ if(o!=null)
+ return (bool)o;
+ return true;
+ }
+ set
+ {
+ ViewState["ShowNextPrevMonth"] = value;
+ }
+ }
+
+ public bool ShowTitle
+ {
+ get
+ {
+ object o = ViewState["ShowTitle"];
+ if(o!=null)
+ return (bool)o;
+ return true;
+ }
+ set
+ {
+ ViewState["ShowTitle"] = value;
+ }
+ }
+
+ public TitleFormat TitleFormat
+ {
+ get
+ {
+ object o = ViewState["TitleFormat"];
+ if(o!=null)
+ return (TitleFormat)o;
+ return TitleFormat.MonthYear;
+ }
+ set
+ {
+ if(!System.Enum.IsDefined(typeof(TitleFormat), value))
+ throw new ArgumentException();
+ ViewState["TitleFormat"] = value;
+ }
+ }
+
+ public TableItemStyle TitleStyle
+ {
+ get
+ {
+ if(titleStyle==null)
+ titleStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ titleStyle.TrackViewState();
+ return titleStyle;
+ }
+ }
+
+ public TableItemStyle TodayDayStyle
+ {
+ get
+ {
+ if(todayDayStyle==null)
+ todayDayStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ todayDayStyle.TrackViewState();
+ return todayDayStyle;
+ }
+ }
+
+ public DateTime TodaysDate
+ {
+ get
+ {
+ object o = ViewState["TodaysDate"];
+ if(o!=null)
+ return (DateTime)o;
+ return DateTime.Today;
+ }
+ set
+ {
+ ViewState["TodaysDate"] = value.Date;
+ }
+ }
+
+ public DateTime VisibleDate
+ {
+ get
+ {
+ object o = ViewState["VisibleDate"];
+ if(o!=null)
+ return (DateTime)o;
+ return DateTime.MinValue;
+ }
+ set
+ {
+ ViewState["VisibleDate"] = value.Date;
+ }
+ }
+
+ public TableItemStyle WeekendDayStyle
+ {
+ get
+ {
+ if(weekendDayStyle == null)
+ weekendDayStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ {
+ weekendDayStyle.TrackViewState();
+ }
+ return weekendDayStyle;
+ }
+ }
+
+ public event DayRenderEventHandler DayRender
+ {
+ add
+ {
+ Events.AddHandler(DayRenderEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(DayRenderEvent, value);
+ }
+ }
+
+ public event EventHandler SelectionChanged
+ {
+ add
+ {
+ Events.AddHandler(SelectionChangedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(SelectionChangedEvent, value);
+ }
+ }
+
+ public event MonthChangedEventHandler VisibleMonthChanged
+ {
+ add
+ {
+ Events.AddHandler(VisibleMonthChangedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(VisibleMonthChangedEvent, value);
+ }
+ }
+
+ protected virtual void OnDayRender(TableCell cell, CalendarDay day)
+ {
+ if(Events!=null)
+ {
+ DayRenderEventHandler dreh = (DayRenderEventHandler)(Events[DayRenderEvent]);
+ if(dreh!=null)
+ dreh(this, new DayRenderEventArgs(cell, day));
+ }
+ }
+
+ protected virtual void OnSelectionChanged()
+ {
+ if(Events!=null)
+ {
+ EventHandler eh = (EventHandler)(Events[SelectionChangedEvent]);
+ if(eh!=null)
+ eh(this, new EventArgs());
+ }
+ }
+
+ protected virtual void OnVisibleMonthChanged(DateTime newDate, DateTime prevDate)
+ {
+ if(Events!=null)
+ {
+ MonthChangedEventHandler mceh = (MonthChangedEventHandler)(Events[VisibleMonthChangedEvent]);
+ if(mceh!=null)
+ mceh(this, new MonthChangedEventArgs(newDate, prevDate));
+ }
+ }
+
+ /// <remarks>
+ /// See test6.aspx in Tests directory for verification
+ /// </remarks>
+ void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
+ {
+ globCal = DateTimeFormatInfo.CurrentInfo.Calendar;
+ DateTime visDate = GetEffectiveVisibleDate();
+ if(eventArgument == "nextMonth")
+ {
+ VisibleDate = globCal.AddMonths(visDate, 1);
+ OnVisibleMonthChanged(VisibleDate, visDate);
+ return;
+ }
+ if(eventArgument == "prevMonth")
+ {
+ VisibleDate = globCal.AddMonths(visDate, -1);
+ OnVisibleMonthChanged(VisibleDate, visDate);
+ return;
+ }
+ if(eventArgument == "selectMonth")
+ {
+ DateTime oldDate = new DateTime(globCal.GetYear(visDate), globCal.GetMonth(visDate), 1, globCal);
+ SelectRangeInternal(oldDate, globCal.AddDays(globCal.AddMonths(oldDate, 1), -1), visDate);
+ return;
+ }
+ if(String.Compare(eventArgument, 0, "selectWeek", 0, "selectWeek".Length)==0)
+ {
+ int week = -1;
+ try
+ {
+ week = Int32.Parse(eventArgument.Substring("selectWeek".Length));
+ } catch(Exception e)
+ {
+ }
+ if(week >= 0 && week <= 5)
+ {
+ DateTime weekStart = globCal.AddDays(GetFirstCalendarDay(visDate), week * 7);
+ SelectRangeInternal(weekStart, globCal.AddDays(weekStart, 6), visDate);
+ }
+ return;
+ }
+ if(String.Compare(eventArgument, 0, "selectDay", 0, "selectDay".Length)==0)
+ {
+ int day = -1;
+ try
+ {
+ day = Int32.Parse(eventArgument.Substring("selectDay".Length));
+ } catch(Exception e)
+ {
+ }
+ if(day >= 0 && day <= 42)
+ {
+ DateTime dayStart = globCal.AddDays(GetFirstCalendarDay(visDate), day);
+ SelectRangeInternal(dayStart, dayStart, visDate);
+ }
+ }
+ }
+
+ protected override void Render(HtmlTextWriter writer)
+ {
+ //TODO: Implement me
+ globCal = DateTimeFormatInfo.CurrentInfo.Calendar;
+ DateTime visDate = GetEffectiveVisibleDate();
+ DateTime firstDate = GetFirstCalendarDay(visDate);
+
+ bool isEnabled;
+ bool isHtmlTextWriter;
+ //FIXME: when Control.Site works, reactivate this
+ //if (Page == null || Site == null) {
+ // isEnabled = false;
+ // isHtmlTextWriter = false;
+ //} else {
+ isEnabled = Enabled;
+ isHtmlTextWriter = (writer.GetType() != typeof(HtmlTextWriter));
+ //}
+ defaultTextColor = ForeColor;
+ if(defaultTextColor == Color.Empty)
+ defaultTextColor = Color.Black;
+
+ Table calTable = new Table ();
+ calTable.ID = ID;
+ calTable.CopyBaseAttributes(this);
+ if(ControlStyleCreated)
+ ApplyStyle(ControlStyle);
+ calTable.Width = Width;
+ calTable.Height = Height;
+ calTable.CellSpacing = CellSpacing;
+ calTable.CellPadding = CellPadding;
+
+ if (ControlStyleCreated &&
+ ControlStyle.IsSet (WebControls.Style.BORDERWIDTH) &&
+ BorderWidth != Unit.Empty)
+ calTable.BorderWidth = BorderWidth;
+ else
+ calTable.BorderWidth = Unit.Pixel(1);
+
+ if (ShowGridLines)
+ calTable.GridLines = GridLines.Both;
+ else
+ calTable.GridLines = GridLines.None;
+
+ calTable.RenderBeginTag (writer);
+
+ if (ShowTitle)
+ RenderTitle (writer, visDate, SelectionMode, isEnabled);
+
+ if (ShowDayHeader)
+ RenderHeader (writer, firstDate, SelectionMode, isEnabled, isHtmlTextWriter);
+
+ RenderAllDays (writer, firstDate, visDate, SelectionMode, isEnabled, isHtmlTextWriter);
+
+ calTable.RenderEndTag(writer);
+ }
+
+ protected override ControlCollection CreateControlCollection()
+ {
+ return new EmptyControlCollection(this);
+ }
+
+ protected override void LoadViewState(object savedState)
+ {
+ if (savedState!=null) {
+ object[] states = (object[]) savedState;
+ if(states[0] != null)
+ base.LoadViewState(states[0]);
+ if(states[1] != null)
+ DayHeaderStyle.LoadViewState(states[1]);
+ if(states[2] != null)
+ DayStyle.LoadViewState(states[2]);
+ if(states[3] != null)
+ NextPrevStyle.LoadViewState(states[3]);
+ if(states[4] != null)
+ OtherMonthDayStyle.LoadViewState(states[4]);
+ if(states[5] != null)
+ SelectedDayStyle.LoadViewState(states[5]);
+ if(states[6] != null)
+ SelectorStyle.LoadViewState(states[6]);
+ if(states[7] != null)
+ TitleStyle.LoadViewState(states[7]);
+ if(states[8] != null)
+ TodayDayStyle.LoadViewState(states[8]);
+ if(states[9] != null)
+ WeekendDayStyle.LoadViewState(states[9]);
+
+ ArrayList dateList = ViewState ["_CalendarSelectedDates"] as ArrayList;
+ if (dateList != null)
+ selectedDates = new SelectedDatesCollection (dateList);
+ }
+ }
+
+ protected override object SaveViewState()
+ {
+ ViewState["_CalendarSelectedDates"] = (SelectedDates.Count > 0 ? selectedDates.GetDateList () : null);
+ object[] states = new object[11];
+ states[0] = base.SaveViewState();
+ states[1] = (dayHeaderStyle == null ? null : dayHeaderStyle.SaveViewState());
+ states[2] = (dayStyle == null ? null : dayStyle.SaveViewState());
+ states[3] = (nextPrevStyle == null ? null : nextPrevStyle.SaveViewState());
+ states[4] = (otherMonthDayStyle == null ? null : otherMonthDayStyle.SaveViewState());
+ states[5] = (selectedDayStyle == null ? null : selectedDayStyle.SaveViewState());
+ states[6] = (selectorStyle == null ? null : selectorStyle.SaveViewState());
+ states[7] = (titleStyle == null ? null : titleStyle.SaveViewState());
+ states[8] = (todayDayStyle == null ? null : todayDayStyle.SaveViewState());
+ states[9] = (weekendDayStyle == null ? null : weekendDayStyle.SaveViewState());
+ for(int i=0; i < states.Length; i++)
+ {
+ if(states[i]!=null)
+ return states;
+ }
+ return null;
+ }
+
+ protected override void TrackViewState()
+ {
+ base.TrackViewState();
+ if(titleStyle!=null)
+ {
+ titleStyle.TrackViewState();
+ }
+ if(nextPrevStyle!=null)
+ {
+ nextPrevStyle.TrackViewState();
+ }
+ if(dayStyle!=null)
+ {
+ dayStyle.TrackViewState();
+ }
+ if(dayHeaderStyle!=null)
+ {
+ dayHeaderStyle.TrackViewState();
+ }
+ if(todayDayStyle!=null)
+ {
+ todayDayStyle.TrackViewState();
+ }
+ if(weekendDayStyle!=null)
+ {
+ weekendDayStyle.TrackViewState();
+ }
+ if(otherMonthDayStyle!=null)
+ {
+ otherMonthDayStyle.TrackViewState();
+ }
+ if(selectedDayStyle!=null)
+ {
+ selectedDayStyle.TrackViewState();
+ }
+ if(selectorStyle!=null)
+ {
+ selectorStyle.TrackViewState();
+ }
+ }
+
+ private void RenderAllDays (HtmlTextWriter writer,
+ DateTime firstDay,
+ DateTime activeDate,
+ CalendarSelectionMode mode,
+ bool isActive,
+ bool isDownLevel)
+ {
+ TableItemStyle weeksStyle;
+ TableCell weeksCell = new TableCell ();
+ TableItemStyle weekendStyle = WeekendDayStyle;
+ TableItemStyle otherMonthStyle = OtherMonthDayStyle;
+ Unit size;
+ bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||
+ mode == CalendarSelectionMode.DayWeekMonth);
+
+ if (isWeekMode) {
+ weeksStyle = new TableItemStyle ();
+ weeksStyle.Width = Unit.Percentage (12);
+ weeksStyle.HorizontalAlign = HorizontalAlign.Center;
+ weeksStyle.CopyFrom (SelectorStyle);
+ size = Unit.Percentage (12);
+ } else {
+ size = Unit.Percentage (14);
+ }
+
+ TableItemStyle [] styles = new TableItemStyle [16];
+ int definedStyles = MASK_SELECTED;
+ if (weekendStyle != null && !weekendStyle.IsEmpty)
+ definedStyles |= MASK_WEEKEND;
+ if (otherMonthStyle != null && !otherMonthStyle.IsEmpty)
+ definedStyles |= MASK_OMONTH;
+ if (todayDayStyle != null && !todayDayStyle.IsEmpty)
+ definedStyles |= MASK_TODAY;
+ if (dayStyle != null && !dayStyle.IsEmpty)
+ definedStyles |= MASK_DAY;
+
+ bool isCalendar = GetType () == typeof (Calendar);
+ int month = globCal.GetMonth (activeDate);
+ DateTime currentDay = firstDay;
+ for (int crr = 0; crr < 6; crr++) {
+ writer.Write ("<tr>");
+ if (isWeekMode) {
+ string cellText = GetCalendarLinkText (
+ "selectWeek" + crr.ToString (),
+ SelectWeekText,
+ weeksCell.ForeColor,
+ isActive);
+
+ weeksCell.Text = cellText;
+ RenderCalendarCell (writer, weeksCell, cellText);
+ }
+
+ for (int weekDay = 0; weekDay < 7; weekDay++) {
+ string dayString = currentDay.Day.ToString ();
+ CalendarDay calDay =
+ new CalendarDay (
+ currentDay,
+ weekDay < 2,
+ currentDay == TodaysDate,
+ selectedDates.Contains (currentDay),
+ globCal.GetMonth (currentDay) != month,
+ dayString
+ );
+
+
+ int dayStyles = GetMask (calDay) & definedStyles;
+ TableItemStyle currentDayStyle = styles [dayStyles];
+ if (currentDayStyle == null) {
+ currentDayStyle = new TableItemStyle ();
+ if ((dayStyles & MASK_DAY) != 0)
+ currentDayStyle.CopyFrom (DayStyle);
+
+ if ((dayStyles & MASK_WEEKEND) != 0)
+ currentDayStyle.CopyFrom (WeekendDayStyle);
+
+ if ((dayStyles & MASK_TODAY) != 0)
+ currentDayStyle.CopyFrom (TodayDayStyle);
+
+ if ((dayStyles & MASK_OMONTH) != 0)
+ currentDayStyle.CopyFrom (OtherMonthDayStyle);
+
+ if ((dayStyles & MASK_SELECTED) != 0) {
+ currentDayStyle.ForeColor = Color.White;
+ currentDayStyle.BackColor = Color.Silver;
+ currentDayStyle.CopyFrom (SelectedDayStyle);
+ }
+
+ currentDayStyle.Width = size;
+ currentDayStyle.HorizontalAlign = HorizontalAlign.Center;
+ }
+
+ TableCell dayCell = new TableCell ();
+ dayCell.ApplyStyle (currentDayStyle);
+ calDay.IsSelectable = isActive;
+ OnDayRender (dayCell, calDay);
+ if (isActive)
+ dayCell.Text = GetCalendarLinkText (
+ "selectDay" + (crr * 7 + weekDay),
+ dayString,
+ dayCell.ForeColor,
+ true);
+ else
+ dayCell.Text = dayString;
+
+ dayCell.RenderControl (writer);
+
+ currentDay = globCal.AddDays (currentDay, 1);
+ }
+ writer.Write("</tr>");
+ }
+ }
+
+ private int GetMask (CalendarDay day)
+ {
+ int retVal = MASK_DAY;
+ if(day.IsSelected)
+ retVal |= MASK_SELECTED;
+ if(day.IsToday)
+ retVal |= MASK_TODAY;
+ if(day.IsOtherMonth)
+ retVal |= MASK_OMONTH;
+ if(day.IsWeekend)
+ retVal |= MASK_WEEKEND;
+ return retVal;
+ }
+
+ /// <remarks>
+ /// Refers to the second line of the calendar, that contains a link
+ /// to select whole month, and weekdays as defined by DayNameFormat
+ /// </remarks>
+ private void RenderHeader (HtmlTextWriter writer,
+ DateTime firstDay,
+ CalendarSelectionMode mode,
+ bool isActive,
+ bool isDownLevel)
+ {
+ writer.Write("<tr>");
+ bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||
+ mode == CalendarSelectionMode.DayWeekMonth);
+
+ TableCell headerCell = new TableCell ();
+ headerCell.HorizontalAlign = HorizontalAlign.Center;
+ string selMthText = String.Empty;
+ if (isWeekMode) {
+ if (mode == CalendarSelectionMode.DayWeekMonth) {
+ headerCell.ApplyStyle (SelectorStyle);
+ selMthText = GetCalendarLinkText ("selectMonth",
+ SelectMonthText,
+ SelectorStyle.ForeColor,
+ isActive);
+ } else {
+ headerCell.ApplyStyle (DayHeaderStyle);
+ selMthText = String.Empty;
+ }
+ RenderCalendarCell (writer, headerCell, selMthText);
+ }
+
+ TableCell dayHeaderCell = new TableCell ();
+ dayHeaderCell.HorizontalAlign = HorizontalAlign.Center;
+
+ int dayOfWeek = (int) globCal.GetDayOfWeek (firstDay);
+ DateTimeFormatInfo currDTInfo = DateTimeFormatInfo.CurrentInfo;
+ for(int currDay = dayOfWeek; currDay < dayOfWeek + 7; currDay++) {
+ DayOfWeek effDay = (DayOfWeek) Enum.ToObject (typeof (DayOfWeek), currDay % 7);
+ string currDayContent;
+ switch(DayNameFormat) {
+ case DayNameFormat.Full:
+ currDayContent = currDTInfo.GetDayName (effDay);
+ break;
+ case DayNameFormat.FirstLetter:
+ currDayContent = currDTInfo.GetDayName (effDay).Substring (0,1);
+ break;
+ case DayNameFormat.FirstTwoLetters:
+ currDayContent = currDTInfo.GetDayName (effDay).Substring (0,2);
+ break;
+ case DayNameFormat.Short:
+ goto default;
+ default:
+ currDayContent = currDTInfo.GetAbbreviatedDayName (effDay);
+ break;
+ }
+
+ RenderCalendarCell(writer, dayHeaderCell, currDayContent);
+ }
+ writer.Write ("</tr>");
+ }
+
+ private void RenderTitle (HtmlTextWriter writer,
+ DateTime visibleDate,
+ CalendarSelectionMode mode,
+ bool isActive)
+ {
+ writer.Write("<tr>");
+ Table innerTable = new Table ();
+ TableCell titleCell = new TableCell();
+ bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||
+ mode == CalendarSelectionMode.DayWeekMonth);
+
+ titleCell.ColumnSpan = (isWeekMode ? 8 : 7);
+ titleCell.BackColor = Color.Silver;
+
+ innerTable.GridLines = GridLines.None;
+ innerTable.Width = Unit.Percentage (100);
+ innerTable.CellSpacing = 0;
+ ApplyTitleStyle (innerTable, titleCell, TitleStyle);
+
+ titleCell.RenderBeginTag (writer);
+ innerTable.RenderBeginTag (writer);
+
+ writer.Write ("<tr>");
+ string prevContent = String.Empty;
+ if (ShowNextPrevMonth) {
+ TableCell prevCell = new TableCell ();
+ prevCell.Width = Unit.Percentage (15);
+ prevCell.HorizontalAlign = HorizontalAlign.Left;
+ if (NextPrevFormat == NextPrevFormat.CustomText) {
+ prevContent = PrevMonthText;
+ } else {
+ int pMthInt = globCal.GetMonth(globCal.AddMonths (visibleDate, -1));
+ if (NextPrevFormat == NextPrevFormat.FullMonth)
+ prevContent = infoCal.GetMonthName (pMthInt);
+ else
+ prevContent = infoCal.GetAbbreviatedMonthName (pMthInt);
+ }
+ prevCell.ApplyStyle (NextPrevStyle);
+ RenderCalendarCell (writer,
+ prevCell,
+ GetCalendarLinkText ("prevMonth",
+ prevContent,
+ NextPrevStyle.ForeColor,
+ isActive)
+ );
+ }
+
+ TableCell currCell = new TableCell ();
+ currCell.Width = Unit.Percentage (70);
+ if (TitleStyle.HorizontalAlign == HorizontalAlign.NotSet)
+ currCell.HorizontalAlign = HorizontalAlign.Center;
+ else
+ currCell.HorizontalAlign = TitleStyle.HorizontalAlign;
+
+ currCell.Wrap = TitleStyle.Wrap;
+ string currMonthContent = String.Empty;
+ if (TitleFormat == TitleFormat.Month) {
+ currMonthContent = visibleDate.ToString ("MMMM");
+ } else {
+ string cmcFmt = infoCal.YearMonthPattern;
+ if (cmcFmt.IndexOf (',') >= 0)
+ cmcFmt = "MMMM yyyy";
+
+ currMonthContent = visibleDate.ToString (cmcFmt);
+ }
+
+ RenderCalendarCell (writer, currCell, currMonthContent);
+
+ string nextContent = String.Empty;
+ if (ShowNextPrevMonth) {
+ TableCell nextCell = new TableCell ();
+ nextCell.Width = Unit.Percentage(15);
+ nextCell.HorizontalAlign = HorizontalAlign.Left;
+ if (NextPrevFormat == NextPrevFormat.CustomText) {
+ nextContent = NextMonthText;
+ } else {
+ int nMthInt = globCal.GetMonth (globCal.AddMonths (visibleDate, 1));
+ if(NextPrevFormat == NextPrevFormat.FullMonth)
+ nextContent = infoCal.GetMonthName(nMthInt);
+ else
+ nextContent = infoCal.GetAbbreviatedMonthName(nMthInt);
+ }
+ nextCell.ApplyStyle(NextPrevStyle);
+ RenderCalendarCell (writer,
+ nextCell,
+ GetCalendarLinkText ("nextMonth",
+ nextContent,
+ NextPrevStyle.ForeColor,
+ isActive)
+ );
+ }
+
+ writer.Write("</tr>");
+ innerTable.RenderEndTag(writer);
+ titleCell.RenderEndTag(writer);
+
+ writer.Write("</tr>");
+ }
+
+ private void ApplyTitleStyle(Table table, TableCell cell, TableItemStyle style)
+ {
+ if(style.BackColor != Color.Empty)
+ {
+ cell.BackColor = style.BackColor;
+ }
+ if(style.BorderStyle != BorderStyle.NotSet)
+ {
+ cell.BorderStyle = style.BorderStyle;
+ }
+ if(style.BorderColor != Color.Empty)
+ {
+ cell.BorderColor = style.BorderColor;
+ }
+ if(style.BorderWidth != Unit.Empty)
+ {
+ cell.BorderWidth = style.BorderWidth;
+ }
+ if(style.Height != Unit.Empty)
+ {
+ cell.Height = style.Height;
+ }
+ if(style.VerticalAlign != VerticalAlign.NotSet)
+ {
+ cell.VerticalAlign = style.VerticalAlign;
+ }
+
+ if(style.ForeColor != Color.Empty)
+ {
+ table.ForeColor = style.ForeColor;
+ } else if(ForeColor != Color.Empty)
+ {
+ table.ForeColor = ForeColor;
+ }
+
+ table.Font.CopyFrom(style.Font);
+ table.Font.MergeWith(Font);
+ }
+
+ private void RenderCalendarCell (HtmlTextWriter writer, TableCell cell, string text)
+ {
+ cell.RenderBeginTag(writer);
+ writer.Write(text);
+ cell.RenderEndTag(writer);
+ }
+
+ private DateTime GetFirstCalendarDay(DateTime visibleDate)
+ {
+ int fow = (int) FirstDayOfWeek;
+ if (fow == 7)
+ fow = (int) infoCal.FirstDayOfWeek;
+
+ int days = (int) globCal.GetDayOfWeek (visibleDate) - fow;
+ if (days <= 0)
+ days += 7;
+ return globCal.AddDays (visibleDate, -days);
+ }
+
+ private DateTime GetEffectiveVisibleDate()
+ {
+ DateTime dt = VisibleDate;
+ if (VisibleDate == DateTime.MinValue)
+ dt = TodaysDate;
+
+ return globCal.AddDays (dt, 1 - globCal.GetDayOfMonth (dt));
+ }
+
+ /// <summary>
+ /// Creates text to be displayed, with all attributes if to be
+ /// shown as a hyperlink
+ /// </summary>
+ private string GetCalendarLinkText (string eventArg,
+ string text,
+ Color foreground,
+ bool isLink)
+ {
+ if (isLink) {
+ StringBuilder dispVal = new StringBuilder ();
+ dispVal.Append ("<a href=\"");
+ dispVal.Append (Page.GetPostBackClientHyperlink (this, eventArg));
+ dispVal.Append ("\" style=\"color: ");
+ if (foreground.IsEmpty) {
+ dispVal.Append (ColorTranslator.ToHtml (defaultTextColor));
+ } else {
+ dispVal.Append (ColorTranslator.ToHtml (foreground));
+ }
+ dispVal.Append ("\">");
+ dispVal.Append (text);
+ dispVal.Append ("</a>");
+ return dispVal.ToString ();
+ }
+ return text;
+ }
+
+ private string GetHtmlForCell (TableCell cell, bool showLinks)
+ {
+ StringWriter sw = new StringWriter ();
+ HtmlTextWriter htw = new HtmlTextWriter (sw);
+ cell.RenderBeginTag (htw);
+ if(showLinks) {
+ htw.Write (GetCalendarLinkText ("{0}", "{1}", cell.ForeColor, showLinks));
+ } else {
+ htw.Write ("{0}");
+ }
+ cell.RenderEndTag (htw);
+ return sw.ToString();
+ }
+
+ internal void SelectRangeInternal (DateTime fromDate, DateTime toDate, DateTime visibleDate)
+ {
+ TimeSpan span = toDate - fromDate;
+ if (SelectedDates.Count != span.Days + 1 ||
+ SelectedDates [0] != fromDate ||
+ SelectedDates [SelectedDates.Count - 1] != toDate) {
+ SelectedDates.SelectRange (fromDate, toDate);
+ OnSelectionChanged ();
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CalendarDay.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CalendarDay.cs
new file mode 100644
index 00000000000..bcd835c45e3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/CalendarDay.cs
@@ -0,0 +1,100 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: CalendarDay
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class CalendarDay
+ {
+ private DateTime date;
+ private bool isWeekend;
+ private bool isToday;
+ private bool isSelected;
+ private bool isOtherMonth;
+ private bool isSelectable;
+ private string dayNumberText;
+
+ public CalendarDay(DateTime date, bool isWeekend, bool isToday, bool isSelected, bool isOtherMonth, string dayNumberText)
+ {
+ this.date = date;
+ this.isWeekend = isWeekend;
+ this.isToday = isToday;
+ this.isSelected = isSelected;
+ this.isOtherMonth = isOtherMonth;
+ this.dayNumberText = dayNumberText;
+ }
+
+ public DateTime Date
+ {
+ get
+ {
+ return date;
+ }
+ }
+
+ public string DayNumberText
+ {
+ get
+ {
+ return dayNumberText;
+ }
+ }
+
+ public bool IsOtherMonth
+ {
+ get
+ {
+ return isOtherMonth;
+ }
+ }
+
+ public bool IsSelectable
+ {
+ get
+ {
+ return isSelectable;
+ }
+ set
+ {
+ isSelectable = value;
+ }
+ }
+
+ public bool IsSelected
+ {
+ get
+ {
+ return isSelected;
+ }
+ }
+
+ public bool IsToday
+ {
+ get
+ {
+ return isToday;
+ }
+ }
+
+ public bool IsWeekend
+ {
+ get
+ {
+ return isWeekend;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CalendarSelectionMode.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CalendarSelectionMode.cs
new file mode 100755
index 00000000000..54dd298f2e4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/CalendarSelectionMode.cs
@@ -0,0 +1,23 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: CalendarSelectionMode
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum CalendarSelectionMode
+ {
+ None,
+ Day,
+ DayWeek,
+ DayWeekMonth
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
new file mode 100644
index 00000000000..51dc36cedf5
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
@@ -0,0 +1,977 @@
+2003-01-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * BaseDataList.cs: what can I say for this one? I spent so many time
+ until I finally found this that I'm gonna miss this f....g bug... ;-).
+ Farewell. Now we can get events from image buttons inside Data*.
+
+ * DataList.cs: now the value stored in ViewState for item count is
+ correct.
+
+2003-01-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataGrid.cs: default value for ShowHeaders is true. Fixed style for
+ Header and Footer.
+ * DataGridColumn.cs: added SetOwner method.
+ * DataGridColumnCollection.cs: set the owner of the column when added.
+
+2003-01-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * BoundColumn.cs: typo.
+ * DataGrid.cs: use 'as' instead of casting. Typo.
+ * HyperLinkColumn.cs: call OnColumnChanged when any property change.
+ Mono-stylized.
+
+2003-01-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HyperLink.cs: fixes bug #36336.
+
+2003-01-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataList.cs: fixed IRepeatInfoUser.GetItemStyle.
+
+2002-12-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * BaseValidator.cs: return an empty string in GetControlValidationValue
+ when GetValue returned null.
+
+ * CompareValidator.cs: fixed EvaluateIsValid.
+
+ * RegularExpressionValidator.cs: fixed EvaluateIsValid.
+
+2002-12-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Xml.cs: use MapPathSecure to get the path of the document.
+
+2002-12-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataList.cs: fixed header & footer.
+
+2002-12-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataList.cs: for header and footer don't use data source.
+ Instantiate in the DataListItem, not in the DataList.
+ databind-template.aspx works now.
+
+2002-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * BaseDataList.cs:
+ (Render): call RenderContents (), not base.RenderContents ().
+
+ * DataList.cs: style.
+
+ But I still haven't found what i'm looking for....
+
+2002-11-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Calendar.cs: fixed loading/saving selected dates.
+ * SelectedDatesCollection.cs: added internal function to get the
+ underlying ArrayList.
+
+ Calendar navigation works again. Selecting dates too.
+
+2002-11-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataList.cs: added a few attributes and fixed infinite recursion.
+
+2002-11-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ListItemCollection.cs: fixed LoadViewState.
+
+2002-11-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * TableItemStyle.cs: TypeDescriptor.GetConverter seems to fail.
+ Commented out some code until it works.
+
+2002-10-29 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * BaseCompareValidator.cs - Fixed operator bug in
+ Compare(string, string, ...)
+ * CompareValidator.cs - EvaluateIsValid() : Implemented.
+
+2002-10-28 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * BoundColumn.cs - InitializeCell(TableCell, int, ListItemType)
+ : Implemented.
+ - All Properties : Now make use of ViewState.
+
+2002-10-28 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * BaseValidator.cs - Uncomment NotImplementedException.
+
+2002-10-28 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * BaseValidator.cs - Minor changes in TODO comments.
+
+2002-10-28 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * BaseValidator.cs - DetermineRenderUpLevel() : Uncomment
+ the NotImplementedException being thrown.
+ * DataGridPagerStyle.cs - Mode { set; } : Implemented.
+ * DataGridLinkButton.cs - Added new class (private) : Implemented.
+ * DataGrid.cs - InitializePager(DataGridItem, int,
+ PagedDataSource) : Implemented.
+
+2002-10-28 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataList.cs - PrepareControlHierarchy() : Implemented.
+
+2002-10-28 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataList.cs - RenderContents(HtmlTextWriter) : Implemented.
+ - GetItem(ListItemType, int) : Removed TODO.
+ - CreateControlHierarchy(bool) : Implemented.
+ - CreateItem(int, ListItemType) : Implemented.
+ - CreateItem(int, ListItemType,
+ bool, object) : Implemented.
+ - InitializeItem(DataItem) : Implemented.
+ * DataGrid.cs - CreateControlHierarchy(bool) : Bug fix.
+ The ViewState["_!ItemCount"],
+ ViewState["_!DataSource_ItemCount"]
+ are shared by DataList and DataGrid, and hence
+ should share the same name.
+ - ResolveDataSource(object, string)
+ : Removed. Use System.Web.UI.Utils.DataSourceHelper
+ ::GetResolvedDataSource(object, string).
+
+
+2002-09-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataGrid.cs: fixed compilation
+
+2002-09-12 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * PagedDataSource.cs - FirstIndexInPage : Fixed bug.
+ * DataGrid.cs - CreateControlHierarchy(bool)
+ : working towards completion.
+ - ResolveDataSource(object, string)
+ : stubbed new method
+ - CreateItem(....)
+ : stubbed new method
+ Well. It's almost done.
+ * DataGridTableInternal.cs
+ - Added new internal class.
+
+2002-08-28 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataSourceInternal.cs - Added new class (internal).
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * FontUnit.cs:
+ * HorizontalAlign.cs:
+ * Unit.cs:
+ * VerticalAlign.cs: fixes based on class status page.
+
+ * HorizontalAlignConverter.cs: implemented.
+ * VerticalAlignConverter.cs: implemented.
+
+ * FontUnitConverter.cs: implemented GetStandardValues ().
+
+ * WebColorConverter.cs: implemented ConvertFrom () and ConvertTo ().
+
+2002-08-19 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataGrid.cs - AutoCreateColumns: Bug fixes.
+
+2002-08-19 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataGrid.cs - AutoCreateColumns: completed, hopefully!
+
+2002-08-19 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataGrid.cs - Working on the undocumented protected
+ method CreateColumnSet. AutoCreateColumns method
+ stubbed. Left CreateControlHierarchy for the time
+ being, looks like I'm going insane. ;-)
+
+2002-08-19 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * Button.cs - Steffen's OnCommand bug fix.
+
+2002-08-12 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataGrid.cs - Added protected method (skeleton)
+ CreateColumnSet(PagedDataSource, bool)
+ Still trying to know how will it be used
+ and what for...
+
+2002-08-10 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * PagedDataSource.cs: fixed compilation.
+
+2002-08-08 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataGrid.cs - Added private method
+ CreatePagedDataSource
+ - Started work on
+ CreateControlHierarchy(bool)
+ * PagedDataSource.cs - Bug fixed.
+ CurrentPageIndex is writable.
+
+2002-08-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataGrid.cs: fixed typo.
+ * DataGridPagerStyle.cs: added IsPagerOnTop and IsPagerOnBottom.
+
+2002-08-06 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataGridColumn.cs - Added internal methods to get the
+ various styles (needed in DataGrid.cs)
+ * DataGrid.cs - Completed the method
+ PrepareControlHierarchy()
+
+2002-08-06 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataGrid.cs - Wokring on PrepareControlHierarchy()
+ - Added private method
+ PrepareControlHierarchyForItem()
+
+2002-08-05 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataGrid.cs - Completed method
+ OnBubbleEvent(object, EventArgs)
+
+2002-07-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Xml.cs: implemented document/transform load.
+
+2002-07-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Calendar.cs: added myself to the list of authors.
+ * DropDownList.cs: fixed a few properties.
+ * ListControl.cs: fixed SelectedIndex.
+
+2002-07-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Calendar.cs: lots of fixes. Render days. Still left to persist
+ selected days when changing month.
+
+ * Unit.cs: fixed Percentage and Pixel.
+
+ * WebControl.cs: a few properties are now using ControlStyle instead
+ of ViewState to persist.
+
+2002-07-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * BaseValidator.cs: it works now.
+ * DataGridColumn.cs: added attribute and made it abstract.
+ * RequiredFieldValidator.cs: fixed return value in EvaluateIsValid.
+
+2002-07-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * TextBox.cs: default for Wrap is true.
+ (OnPreRender): don't save Text if there are no listeners on TextChanged.
+
+2002-07-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DropDownList.cs:
+ (ToolTip): fixed.
+
+ * ListItem.cs:
+ (LoadViewState): fixed.
+
+ * ListItemCollection.cs:
+ (TrackViewState): use items instead of 'this' in foreach.
+
+ * Style.cs:
+ (LoadViewState): more checking of parameters.
+
+ * WebControl.cs: implemented LoadViewState and SaveViewState.
+
+
+2002-07-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ListItem.cs: there was no code to unset the flags!!!
+
+2002-07-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * FontUnit.cs: use a hashtable for mapping size name to value.
+ * HyperLink.cs: fixed a bug and a typo.
+ * Unit.cs: some fixes to internal constructor.
+
+2002-07-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ListControl.cs: fixed a couple of range checks.
+ * WebControl.cs: MS lies! Not all WebControls must be rendered inside
+ an HtmlForm (p.e., Label).
+
+2002-07-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AdRotator.cs:
+ * Button.cs:
+ * Calendar.cs:
+ * CheckBox.cs:
+ * CheckBoxList.cs:
+ * DataList.cs:
+ * DropDownList.cs:
+ * HyperLink.cs:
+ * HyperLinkColumn.cs:
+ * Image.cs:
+ * ImageButton.cs:
+ * Label.cs:
+ * LinkButton.cs:
+ * ListBox.cs:
+ * Panel.cs:
+ * PlaceHolder.cs:
+ * RadioButton.cs:
+ * RadioButtonList.cs:
+ * Table.cs:
+ * TableRow.cs:
+ * TextBox.cs:
+ * WebControl.cs: removed attributes added by mistake (i used
+ GetCustomAttributes (true), d'oh!).
+
+ * DataListItem.cs: implemented RenderItem.
+
+ * Repeater.cs: implemented CreateItem and InitializeItem.
+
+2002-07-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * BaseDataList.cs: a couple of fiex and added attributes.
+ * DataGrid.cs: little fixes.
+
+2002-07-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * CheckBoxList.cs:
+ * DataGrid.cs:
+ * DataList.cs:
+ * DropDownList.cs:
+ * ListBox.cs:
+ * PlaceHolder.cs:
+ * RadioButton.cs:
+ * RadioButtonList.cs:
+ * TableRow.cs:
+ * WebControl.cs:
+ * Xml.cs: forgot to add using System.ComponentModel.
+
+ * BaseValidator.cs: use explicitly
+ System.ComponentModel.AttributeCollection as there is another class
+ with the same name under System.Web.UI.
+
+2002-07-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AdRotator.cs:
+ * Button.cs:
+ * Calendar.cs:
+ * CheckBox.cs:
+ * CheckBoxList.cs:
+ * DataGrid.cs:
+ * DataList.cs:
+ * DropDownList.cs:
+ * HyperLink.cs:
+ * Image.cs:
+ * ImageButton.cs:
+ * Label.cs:
+ * LinkButton.cs:
+ * ListBox.cs:
+ * Panel.cs:
+ * PlaceHolder.cs:
+ * RadioButton.cs:
+ * RadioButtonList.cs:
+ * Table.cs:
+ * TableRow.cs:
+ * TextBox.cs:
+ * WebControl.cs:
+ * Xml.cs: added/fixed all attributes used by xsp.
+
+ * BaseValidator.cs: some fixes.
+
+2002-07-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Table.cs:
+ (AddAttributesToRender): correctly default to border=1.
+
+2002-07-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AdRotator.cs:
+ (LoadAdFile): make the dictionary null after every iteration.
+
+ * LinkButton.cs:
+ * ListControl.cs:
+ * ListItem.cs: fixed warnings.
+
+Mon Jul 1 16:23:15 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * Style.cs, TableRow.cs, DataListItem.cs: fix compilation.
+
+2002-06-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataGridColumn.cs:
+ * DataGridPagerStyle.cs:
+ * DataList.cs:
+ * DataListItem.cs:
+ * Image.cs:
+ * LinkButton.cs:
+ * ListControl.cs:
+ * ListItem.cs:
+ * ListItemCollection.cs:
+ * Repeater.cs:
+ * ServerValidateEventArgs.cs:
+ * Style.cs:
+ * TableRow.cs:
+ * WebControl.cs:
+ * Xml.cs: more class status page based changes.
+
+2002-06-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Button.cs:
+ (.ctor): fixed to render the correct tag.
+ (IPostBAckEventHandler.RaisePostBackEvent): fixed.
+
+2002-06-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * WebControl.cs:
+ (AddAttributesToRender): call Page.VerifyRenderingInServerForm. All
+ WebControl derived classes should be rendered inside a HtmlForm.
+
+2002-06-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Repeater.cs: implemented CreateControlHierarchy. Fixed some event
+ processing methods.
+
+2002-06-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * RadioButtonList.cs: implemented IRepeatInfoUser.RenderItem.
+ * RepeatInfo.cs: implemented DoHorizontalRendering.
+
+2002-06-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.UI.WebControls/Repeater.cs:
+ (Controls):
+ (OnDataBinding): fixed stack overflow.
+
+2002-06-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * RadioButtonList.cs: implemented IRepeatInfoUser.RenderItem.
+ * RepeatInfo.cs: implemented DoHorizontalRendering.
+
+2002-06-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * WebControl.cs:
+ (CopyBaseAttributes): copy Attributes and don't throw exception.
+
+2002-06-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ListBox.cs: mono-stylized.
+ (AddAttributesToRender): call parent class method.
+
+2002-06-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Style.cs: fixed IsEmpty and Width.
+
+ * Table.cs: mono-stylized.
+ (TableRowControlCollection.AddAt): fixed.
+ (AddAttributesToRender): fixed.
+
+ * TableCell.cs: mono-stylized.
+ (.ctor): use PreventAutoID.
+ (AddAttributesToRender): fixed.
+ (AddParsedSubObject): fixed.
+
+ * TableRow.cs: mono-stylized. Added
+ ParseChildren attribute.
+
+ * TableStyle.cs:
+ (get_GridLine): fixed.
+
+2002-06-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Panel.cs: fixed stack overflow.
+ * Unit.cs: use Int32.Parse and Single.Parse instead of Int32Converter
+ and SingleConverter.
+
+2002-06-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * RadioButton.cs: mono-stylized and some little fixes.
+
+ * TextBox.cs: mono-stylized.
+ (MaxLength): fixed typo.
+
+ (AddAttributesToRender): don't render the text between the tags for
+ SingleLine, use value attribute for it. Don't render the text for
+ Password.
+
+ (OnPreRender): don't throw exception and call base.OnPreRender.
+
+ (Render): for MultiLine, render the text between the opening and
+ closing tags encoded as HTML.
+
+2002-06-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ImageButton.cs:
+ (AddAttributesToRender): fixer another stack overflow.
+
+ * WebControl.cs:
+ (TagName): modified to use TagKey instead of tagKey as the property
+ can be overriden.
+
+2002-06-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * LinkButton.cs: mono-stylized.
+ (AddParsedSubObject):
+ (RenderControls): little fixes.
+
+ * WebControl.cs:
+ (AddAttributesToRender): fixed usage of IEnumerator.
+
+2002-06-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Literal.cs: beautified.
+
+2002-06-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Label.cs: beautified and fixed a couple of 'classic' bugs.
+
+ * WebControl.cs: use Span as default tag when no other provided in
+ constructor. That is what MS renders.
+
+2002-06-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Button.cs:
+ (AddAttributesToRender): fixed (classic) stack overflow.
+
+ * CheckBox.cs: mono-stylized.
+ (AutoPostBack): fixed stack overflow.
+ (Render): fixed alignment issues. Also set the For attribute always
+ for the label.
+
+2002-06-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * 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 <gonzalo@ximian.com>
+
+ * WebControl.cs: added attributes PersistChildrenAttribute and
+ ParseChildrenAttribute.
+
+2002-05-24 Duncan Mak <duncan@ximian.com>
+
+ * DataGridItem.cs (SetItemType): Changed function signature to
+ match 1.0 spec.
+
+ * ListItemCollection.cs (this): Changes the visibility level of
+ the indexer.
+
+ * Repeater.cs (OnItemCommand):
+ (OnItemCreated):
+ (OnItemDataBound): Added necessary casts.
+
+2002-05-07 Duncan Mak <duncan@ximian.com>
+
+ * Button.cs (AddAttributesToRender):
+ * ImageButton.cs (AddAttributesToRender): Added a missing argument to the
+ GetClientValidatedEvent method.
+
+2002-03-27 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * Removed extra methods, corrected access modifiers to several
+ methods.
+
+2002-03-26 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * <SeveralFiles>.cs - Added some attributes
+ * FontUnitConverter.cs - Added stubs for GetStandardValues*(..)
+ methods. Will complete them later. Right now, busy with
+ the attributes part.
+ * RepeaterItem.cs - Completed.
+
+ Oh God! Mercy! I will die applying attributes. I look at the missing
+ part in the class-status - daemon! Kyrie eleison!
+
+2002-03-19 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ Some bug fixes
+
+ * AdRotator.cs - Added definition for Font.
+ * BaseCompareValidator.cs - Added definition for Controls.
+ * Calendar.cs - SelectMonthText definition corrected.
+ * DataList.cs - Added definition for SeparatorTemplate.
+ * BorderStyle.cs - Namespace correction. It belongs not to UI,
+ but to UI.WebControls.
+
+2002-03-17 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ Finally, I have made it. Today I did a second build for the
+ System.Web assembly. It compiled 195 classes today.
+ I am waiting eagerly for the runtime to come up so that the objects
+ may be tested to their last levels. Several of the methods are still
+ under the tag of "TODO" throwing NotImplementedException. Well, I
+ hope to remove them soon, but how far is this soon - even I don't
+ know, though I am happy to make the build a success even before
+ the vacations to come.
+
+2002-03-07 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ Yesterday and today I tried to do some building of the aseembly,
+ but was dumped with uncoutably infinite errors. ;-)
+ I have put the copies of the recent errors on my home page, want
+ to have a look at them? See:
+ http://mastergaurav.virtualave.net/mono/
+ I don't know what to do with these errors. Oh! The buggy me! How
+ will I overcome myself. Hopefully, by when my vacations over, I
+ should have made a repository where the build will not fail.
+
+2002-03-05 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ I am now going to do a build that will include the
+ System.Web.UI.WebControls namespace. Hoping that I will make it
+ soon. My exams are coming near and I have to pack up soon.
+
+
+2002-03-04 Gaurav Vaish <gvaish@iitk.ac.in>
+
+Comments:
+ And with this, ie, today's work, all the objects mentioned in the
+ namespace appear in the implementation. But it may not be worth
+ trying to go for a build because of dependence of several of the
+ internal methods that may clash with already available assembly
+ System.Web.
+
+ Also, the classes lack possible attributes, like those informing
+ about child-controls etc. But I have to first create the attribute
+ classes before I attach the attributes to the classes.
+
+ * CustomValidator.cs - Completed. In process realized that
+ I have to complete / rejuvinate BaseValidator class.
+ * BaseValidator.cs - Complete rejuvination. Completed 80%
+ of the job. All that is left is Render(HtmlTextWriter),
+ DetermineRenderUplevel(), RegisterValidatorCommonScript()
+ RegisterValidatorDeclaration()
+ * DataGridPagerStyle.cs - Completed. That adds one more missle
+ in my artillery.
+ * DataKeyCollection.cs - Completed. Petty small.
+ * Repeater.cs - Work started off. This is a quite
+ heavy class. Hooh!
+ * DataGridItemEventArgs.cs,
+ * DataGridShortCommandEventArgs.cs,
+ * DataListItemEventArgs.cs,
+ * MonthChangedEventArgs.cs,
+ * RepeaterItemEventArgs.cs,
+ * ServerValidateEventArgs.cs,
+ * DataGridPageChangedEventArgs.cs
+ - Damn, I marked them "*", while they
+ did not exist.
+ * Repeater.cs - Done all except for an undocumented
+ method CreateControlHierarchy(bool). Though the method
+ is quite clear by its name, but it will take some time
+ for me to come with some material to flush in.
+
+2002-03-03 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * SelectedDatesCollection.cs - Completed.
+ * PagedDataSource.cs - Completed. Pathetically nice class.
+ * RegularExpressionValidator.cs
+ - Completed. Ridiculously small and
+ annoyinglyc crazy-driving class, basically the method
+ EvaluateIsValid().
+ * RangeValidator.cs - Completed.
+ * DataGridColumn.cs - Completed.
+ * EditCommandColumn.cs - All is complete except for the
+ InitializeCell(TableCell, int, ListItemType) method.
+ * DataListItem.cs - All done except for a longish method
+ RenderItem(HtmlTextWriter, bool, bool)
+
+2002-03-02 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * RepeaterItemCollection.cs - Completed.
+ I love *Collection classes. I am planning to make a
+ program that will generate a *Collection class. It's so
+ simple and the same. ;-)
+ * DataGridColumnCollection.cs - Completed.
+ ... except probably for *ColumnCollection classes, where
+ you have to put in some more effort. Still, these class
+ generation can be automated.
+ * DataListItemCollection.cs - Completed.
+ See, how easily, in less than a quarter of a minute, I
+ completed this class - manually. Copy-Paste/Cut-Replace.
+
+2002-02-21 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * DataGrid.cs - Following methods implemented:
+ TrackViewState(), LoadViewState(object), SaveViewState(),
+ On* -- The event raisers.
+ OnBubbleEvent(object, EventArgs) is still incomplete.
+ * DataGridItem.cs - Initial Implementation
+ * DataGridItemCollection.cs - Completed.
+
+2002-02-08 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * DataGrid.cs - Initial Implementation. Worked
+ primarily with some properties.
+
+2002-02-07 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * ListBox.cs - Completed. Implemented
+ LoadPostData(string, NameValueCollection)
+ * RequiredFieldValidator.cs - Completed. Pretty simple class.
+
+2002-02-06 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * ListBox.cs - Implemented the following:
+ RaisePostDataChangedEvent()
+
+2002-02-02 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * ListBox.cs - Supports the following properties:
+ BorderColor, BorderStyle, BorderWidth, Rows, SelectionMode,
+ ToolTip.
+ Methods:
+ AddAttributesToRender(HtmlTextWriter), OnPreRender(EventArgs),
+ RenderContents(HtmlTextWriter)
+
+
+2002-02-01 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * TargetConverter.cs - Completed
+ * TemplateColumn.cs - Completed
+ * DataList.cs - Corrected the get-er methods for the
+ *Style objects. Corrected the get/set-er methods for ViewState
+ related objects.
+ Addded support for properties:
+ GridLines, HeaderStyle, HeaderTemplate, ItemStyle, ItemTemplate,
+ RepeatColumns, RepeatDirection, RepeatLayout, SelectedIndex,
+ SelectedItem, SelectedItemStyle, SelectedItemTemplate,
+ SeparatorStyle, SeparatorItemTemplate.
+ Events:
+ CancelCommand, DeleteCommand, EditCommand, ItemCommand,
+ ItemCreated, ItemDataBound, UpdateCommand.
+ Methods:
+ CreateControlStyle(), LoadViewState(object),
+ SaveViewState(), TrackViewState
+ Event handlers:
+ OnBubbleEvent, OnCancelCommand, OnDeleteCommand,
+ OnEditCommand, OnItemCommand, OnItemCreated,
+ OnItemDataBound, OnUpdateCommand
+ Added dummy methods for some undocumented methods:
+ CreateControlHierarchy(bool), CreateItem(int, ListItemType),
+ CreateItem(int, ListItemType, bool, object),
+ PrepareControlHierarchy(), InitializeItem(DataListItem)
+ * ListBox.cs - Started working.
+
+
+
+2002-01-31 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * RepeaterInfo.cs - Initial Implementation. Done all
+ except for RepeatDirection.Vertical
+ * TableStyle.cs - Completed
+
+2002-01-30 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * DropDownList.cs - Completed
+ * ListItemCollection.cs - Added method FindByValueInternal to
+ assist in the derived classes.
+ Discovered bug in FindByValue. Removed
+ * UnitConverter.cs - Completed
+ * PlaceHolder.cs - What can be simpler than this?
+ * PlaceHolderControlBuilder.cs
+ - Uh! Damn cool one.
+ * RadioButtonList.cs - Initial Implementation. All is done
+ except for the implementation of
+ method IRepeatInfoUser.RenderItem(...)
+ * ValidatedControlConverter.cs
+ ^^^^^^^^^^^^^^^^^^^^^^^^^ - Looks complete. Doubtful though !!
+ * ValidationSummary.cs - Initial Implementation.
+ * WebColorConverter.cs - Initial Implementation
+
+2002-01-27 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * FontNamesConverter.cs - Completed
+ * FontUnitConverter.cs - Partial Implementation
+ * ListItemControlBuilder.cs - Completed
+
+2002-01-27 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * TextBox.cs - All done except *Render* methods
+ * TextBoxControlBuilder.cs - Completed
+ * Xml.cs - Partial Implementation
+
+2002-01-26 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * RadioButton.cs - Completed
+ * TextBox.cs - Partial Implementation
+
+2002-01-25 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * Panel.cs - Completed
+ * TableItemStyle.cs - Completed
+
+2002-01-18 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * TableCellCollection.cs - Completed
+ * TableRowCollection.cs - Completed
+ * TableHeaderCell.cs - Completed
+ * TableRow.cs - Completed
+
+2002-01-09 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * TableCellControlBuilder.cs - Completed
+ * Table.cs - Completed
+ * TableCell.cs - Completed
+
+2002-01-07 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * CheckBoxList.cs - Completed
+ * ButtonColumn.cs - Completed
+ * Button.cs - Completed
+
+2001-12-28 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * HyperLink.cs - Completed
+ * Image.cs - Completed
+ * ImageButton.cs - Completed
+ * Label.cs - Completed
+ * LabelControlBuilder.cs - Completed
+ * LinkButton.cs - Completed
+ * LinkButtonControlBuilder.cs - Completed
+ * Literal.cs - Completed
+ * LieteralControlBuilder.cs - Completed
+ * FontUnit.cs - Completed
+
+
+2001-12-27 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * Calendar.cs - Completed the functions of Render*,
+ ViewStates (Track/View/Save),
+ RaisePostBackEvent.
+ Left: RenderAllDays (partially)
+
+2001-12-21 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * Calendar.cs - Added some more functions
+ * Style.cs - Completed
+ * ListItem.cs - Completed
+ * ListItemCollection.cs - Completed
+
+ Made the first successful build of System.Web.dll that included
+ System.Web.UI.WebControls!
+
+2001-12-20 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ FontInfo.cs - Complete revamp. Completed
+
+2001-12-19 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ ListItemCollection.cs - Completed
+ ListItem.cs - Initial Implementation
+ Style.cs - Initial Implementation
+
+ Right now I am in a total mood to do a successful build. Creating so many
+ classes, completing classes in System.Web System.Web.UI namespaces.
+
+2001-12-18 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ TODO - Properly added
+ CheckBox.cs - Completed
+ BaseDataList.cs - Completed
+ DayRenderEventArgs.cs - Completed
+ RepeaterItem.cs - Initial implementation
+
+2001-12-17 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ BaseCompareValidator.cs - Completed
+ AdRotator.cs - Completed
+
+2001-12-15 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ CommandEventArgs.cs - Completed
+ DataGridCommandEventArgs.cs - Completed
+ RepeaterCommandEventArgs.cs - Completed
+ DataListCommandEventArgs.cs - Completed
+ CompareValidator.cs - Partial Implementation
+
+2001-12-02 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ CheckBoxList.cs - Partial Implementation.
+ All except "Render"
+
+2001-12-01 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ ListControl.cs - Completed
+
+2001-11-30 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ CheckBox.cs - Completed
+ ListControl.cs - Initial Implementation
+ CheckBoxList.cs - Started with it, but first needed
+ ListControl. Left it.
+
+2001-11-29 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ CalendarDay.cs - Making a note that this
+ has been implemented
+ Calendar.cs - Making a note that have made some changes.
+ Unimplmented functions throw
+ NotImplementedException
+ CheckBox.cs - Can now "Render" and "LoadPostData"
+
+
+2001-11-08 Gaurav Vaish <gvaish@iitk.ac.in>
+ WebControl.cs - Total Revamp, Partial Implementation
+ AdRotator.cs - Able to load files
+ AdCreatedEventArgs.cs - Implemented
+
+2001-11-05 Gaurav Vaish <gvaish@iitk.ac.in>
+ Calendar.cs - Initial Implementation
+ ButtonColumn.cs - Initial Implementation
+ Button.cs - Initial Implementation
+ BoundColumn.cs - Initial Implementation
+ BaseCompareValidator.cs - Minor Changes
+ DataList.cs, BaseValidator.cs, BaseDataList.cs
+ - Added more functions, other changes
+
+2001-10-28 Gaurav Vaish <gvaish@iitk.ac.in>
+ WebControl.cs - Initial Implementation
+ DataList.cs - Initial Implementation
+ BaseValidator.cs - Initial Implementation
+ BaseDataList.cs - Initial Implementation
+
+2001-10-27 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ AdCreatedEventArgs.cs - Initial Implementation
+ AdCratedEventHandler.cs - Implemented
+ AdRotator.cs - Initial Implementation
+ BorderStyle.cs - Implemented
+ ButtonColumnStyle.cs - Implemented
+ CalendarSelectionMode.cs - Implemented
+ DayNameFormat.cs - Implemented
+ FirstDayOfWeek - Implemented
+ FontInfo.cs - Partial Implementation
+ FontSize.cs - Implemented
+ GridLines.cs - Implemented
+ HorizontalAlign.cs - Implemented
+ HyperLink.cs - Initial Implementation
+ ImageAlign.cs - Implemented
+ IRepeatInfoUser.cs - Implemented
+ ListItemType.cs - Implemented
+ ListSelectionMode.cs - Implemented
+ NextPrevFormat.cs - Implemented
+ PagerMode.cs - Implemented
+ PagerPosition.cs - Implemented
+ RepeatDirection.cs - Implemented
+ RepeatLayout.cs - Implemented
+ TextAlign.cs - Implemented
+ TextBoxMode.cs - Implemented
+ TitleFormat.cs - Implemented
+ UnitType.cs - Implemented
+ ValidationCompareOperator.cs
+ - Implemented
+ ValidationDataType.cs - Implemented
+ ValidationSummaryDisplayMode.cs
+ - Implemented
+ ValidatorDisplay.cs - Implemented
+ VerticalAlign.cs - Implemented
+
+
+
+// File Created 2001-11-13
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
new file mode 100644
index 00000000000..70931a89d88
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
@@ -0,0 +1,215 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: CheckBox
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ * Thanks to Leen Toelen (toelen@hotmail.com)'s classes that helped me
+ * to write the contents of the function LoadPostData(...)
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("CheckedChanged")]
+ [DefaultProperty("Text")]
+ //[DataBindingHanlder("??")]
+ //[Designer("??")]
+ public class CheckBox : WebControl, IPostBackDataHandler
+ {
+ private static readonly object CheckedChangedEvent = new object();
+
+ public CheckBox(): base(HtmlTextWriterTag.Input)
+ {
+ }
+
+ public virtual bool AutoPostBack
+ {
+ get {
+ object o = ViewState ["AutoPostBack"];
+ return (o == null) ? false : (bool) o;
+ }
+
+ set { ViewState ["AutoPostBack"] = value; }
+ }
+
+ public virtual bool Checked
+ {
+ get {
+ object o = ViewState ["Checked"];
+ return (o == null) ? false : (bool) o;
+ }
+
+ set { ViewState ["Checked"] = value; }
+ }
+
+ public virtual string Text
+ {
+ get {
+ object o = ViewState ["Text"];
+ return (o == null) ? String.Empty : (string) o;
+ }
+
+ set { ViewState ["Text"] = value; }
+ }
+
+ private bool SaveCheckedViewState
+ {
+ get {
+ if (Events [CheckedChangedEvent] != null){
+ if (!Enabled)
+ return true;
+
+ Type type = GetType ();
+ if (type == typeof (CheckBox))
+ return false;
+
+ if (type == typeof (RadioButton))
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public virtual TextAlign TextAlign
+ {
+ get {
+ object o = ViewState ["TextAlign"];
+ return (o == null) ? TextAlign.Right : (TextAlign) o;
+ }
+
+ set {
+ if (!System.Enum.IsDefined (typeof (TextAlign), value))
+ throw new ArgumentException ();
+ ViewState ["TextAlign"] = value;
+ }
+ }
+
+ public event EventHandler CheckedChanged
+ {
+ add { Events.AddHandler (CheckedChangedEvent, value); }
+ remove { Events.RemoveHandler (CheckedChangedEvent, value); }
+ }
+
+ protected virtual void OnCheckedChanged(EventArgs e)
+ {
+ if(Events != null){
+ EventHandler eh = (EventHandler) (Events [CheckedChangedEvent]);
+ if(eh != null)
+ eh (this, e);
+ }
+ }
+
+ protected override void OnPreRender(EventArgs e)
+ {
+ if (Page != null && Enabled)
+ Page.RegisterRequiresPostBack (this);
+
+ if (SaveCheckedViewState)
+ ViewState.SetItemDirty ("checked", false);
+ }
+
+ protected override void Render (HtmlTextWriter writer)
+ {
+ bool hasBeginRendering = false;
+ if(ControlStyleCreated && !ControlStyle.IsEmpty){
+ hasBeginRendering = true;
+ ControlStyle.AddAttributesToRender (writer, this);
+ }
+
+ if (!Enabled){
+ hasBeginRendering = true;
+ writer.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled");
+ }
+
+ if (ToolTip.Length > 0){
+ hasBeginRendering = true;
+ writer.AddAttribute (HtmlTextWriterAttribute.Title, ToolTip);
+ }
+
+ if (Attributes.Count > 0){
+ string val = Attributes ["value"];
+ Attributes.Remove ("value");
+ if (Attributes.Count > 0){
+ hasBeginRendering = true;
+ Attributes.AddAttributes (writer);
+ }
+
+ if (val != null)
+ Attributes ["value"] = val;
+ }
+
+ if (hasBeginRendering)
+ writer.RenderBeginTag (HtmlTextWriterTag.Span);
+
+ if (Text.Length > 0){
+ TextAlign ta = TextAlign;
+ if(ta == TextAlign.Right)
+ RenderInputTag (writer, ClientID);
+ writer.AddAttribute (HtmlTextWriterAttribute.For, ClientID);
+ writer.RenderBeginTag (HtmlTextWriterTag.Label);
+ writer.Write (Text);
+ writer.RenderEndTag ();
+ if(ta == TextAlign.Left)
+ RenderInputTag (writer, ClientID);
+ }
+ else
+ RenderInputTag (writer, ClientID);
+
+ if (hasBeginRendering)
+ writer.RenderEndTag ();
+ }
+
+ internal virtual void RenderInputTag (HtmlTextWriter writer, string clientId)
+ {
+ writer.AddAttribute (HtmlTextWriterAttribute.Id, clientId);
+ writer.AddAttribute( HtmlTextWriterAttribute.Type, "checkbox");
+ writer.AddAttribute (HtmlTextWriterAttribute.Name, UniqueID);
+ if (Checked)
+ writer.AddAttribute (HtmlTextWriterAttribute.Checked, "checked");
+
+ if (AutoPostBack){
+ writer.AddAttribute (HtmlTextWriterAttribute.Onclick,
+ Page.GetPostBackClientEvent (this, String.Empty));
+ writer.AddAttribute ("language", "javascript");
+ }
+
+ if (AccessKey.Length > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Accesskey, AccessKey);
+
+ if (TabIndex != 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Tabindex,
+ TabIndex.ToString (NumberFormatInfo.InvariantInfo));
+
+ writer.RenderBeginTag (HtmlTextWriterTag.Input);
+ writer.RenderEndTag ();
+ }
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
+ {
+ string postedVal = postCollection [postDataKey];
+ bool postChecked = false;
+ if(postedVal != null)
+ postChecked = postedVal.Length > 0;
+ Checked = postChecked;
+ return (postChecked == false);
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent()
+ {
+ OnCheckedChanged (EventArgs.Empty);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CheckBoxList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CheckBoxList.cs
new file mode 100644
index 00000000000..7c2af02c758
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/CheckBoxList.cs
@@ -0,0 +1,252 @@
+/**
+* Namespace: System.Web.UI.WebControls
+* Class: CheckBoxList
+*
+* Author: Gaurav Vaish
+* Maintainer: gvaish@iitk.ac.in
+* Contact: <gvaish@iitk.ac.in>
+* Implementation: yes
+* Status: 100%
+*
+* (C) Gaurav Vaish (2001)
+*/
+
+using System;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class CheckBoxList: ListControl, IRepeatInfoUser, INamingContainer, IPostBackDataHandler
+ {
+ CheckBox checkBoxRepeater;
+ bool isChangeNotified;
+
+ public CheckBoxList()
+ {
+ checkBoxRepeater = new CheckBox();
+ checkBoxRepeater.ID = "0";
+ checkBoxRepeater.EnableViewState = false;
+ checkBoxRepeater.Controls.Add(this);
+ isChangeNotified = false;
+ }
+
+ public virtual int CellPadding
+ {
+ get
+ {
+ return (ControlStyleCreated ? ((TableStyle)ControlStyle).CellPadding : -1);
+ }
+ set
+ {
+ ((TableStyle)ControlStyle).CellPadding = value;
+ }
+ }
+
+ public virtual int CellSpacing
+ {
+ get
+ {
+ return (ControlStyleCreated ? ((TableStyle)ControlStyle).CellSpacing : -1);
+ }
+ set
+ {
+ ((TableStyle)ControlStyle).CellSpacing = value;
+ }
+ }
+
+ public virtual int RepeatColumns
+ {
+ get
+ {
+ object o = ViewState["RepeatColumns"];
+ if(o!=null)
+ return (int)o;
+ return 0;
+ }
+ set
+ {
+ if(value < 0)
+ throw new ArgumentOutOfRangeException();
+ ViewState["RepeatColumns"] = value;
+ }
+ }
+
+ public virtual RepeatDirection RepeatDirection
+ {
+ get
+ {
+ object o = ViewState["RepeatDirection"];
+ if(o!=null)
+ return (RepeatDirection)o;
+ return RepeatDirection.Vertical;
+ }
+ set
+ {
+ if(!System.Enum.IsDefined(typeof(RepeatDirection),value))
+ throw new ArgumentException();
+ ViewState["RepeatDirection"] = value;
+ }
+ }
+
+ public virtual RepeatLayout RepeatLayout
+ {
+ get
+ {
+ object o = ViewState["RepeatLayout"];
+ if(o!=null)
+ return (RepeatLayout)o;
+ return RepeatLayout.Table;
+ }
+ set
+ {
+ if(!System.Enum.IsDefined(typeof(RepeatLayout), value))
+ throw new ArgumentException();
+ ViewState["RepeatLayout"] = value;
+ }
+ }
+
+ public virtual TextAlign TextAlign
+ {
+ get
+ {
+ object o = ViewState["TextAlign"];
+ if(o!=null)
+ return (TextAlign)o;
+ return TextAlign.Right;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(TextAlign), value))
+ throw new ArgumentException();
+ ViewState["TextAlign"] = value;
+ }
+ }
+
+ protected override Style CreateControlStyle()
+ {
+ return new TableStyle(ViewState);
+ }
+
+ protected override Control FindControl(string id, int pathOffset)
+ {
+ return this;
+ }
+
+ protected override void OnPreRender(EventArgs e)
+ {
+ checkBoxRepeater.AutoPostBack = AutoPostBack;
+ if(Page!=null)
+ {
+ for(int i=0; i < Items.Count; i++)
+ {
+ if(Items[i].Selected)
+ {
+ checkBoxRepeater.ID = i.ToString(NumberFormatInfo.InvariantInfo);
+ Page.RegisterRequiresPostBack(checkBoxRepeater);
+ }
+ }
+ }
+ }
+
+ protected override void Render(HtmlTextWriter writer)
+ {
+ RepeatInfo ri = new RepeatInfo();
+ checkBoxRepeater.TabIndex = TabIndex;
+ bool dirtyFlag = false;
+ short tTabIndex = TabIndex;
+ Style s = (ControlStyleCreated ? ControlStyle : null);
+ if(TabIndex > 0)
+ {
+ if(!ViewState.IsItemDirty("TabIndex"))
+ dirtyFlag = true;
+ TabIndex = 0;
+ }
+ ri.RepeatColumns = RepeatColumns;
+ ri.RepeatLayout = RepeatLayout;
+ ri.RepeatDirection = RepeatDirection;
+ ri.RenderRepeater(writer, this, s, this);
+ if(tTabIndex > 0)
+ {
+ TabIndex = tTabIndex;
+ }
+ if(dirtyFlag)
+ {
+ ViewState.SetItemDirty("TabIndex", false);
+ }
+ }
+
+ bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
+ {
+ int index = Int32.Parse(postDataKey.Substring(UniqueID.Length + 1));
+ if(index >= 0 && index < Items.Count)
+ {
+ bool exists = (postCollection[postDataKey]!=null);
+ if(Items[index].Selected != exists)
+ {
+ Items[index].Selected = exists;
+ if(!isChangeNotified)
+ {
+ isChangeNotified = true;
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent()
+ {
+ OnSelectedIndexChanged(EventArgs.Empty);
+ }
+
+ bool IRepeatInfoUser.HasFooter
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ bool IRepeatInfoUser.HasHeader
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ bool IRepeatInfoUser.HasSeparators
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ int IRepeatInfoUser.RepeatedItemCount
+ {
+ get
+ {
+ return Items.Count;
+ }
+ }
+
+ Style IRepeatInfoUser.GetItemStyle(ListItemType itemType, int repeatIndex)
+ {
+ return null;
+ }
+
+ void IRepeatInfoUser.RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
+ {
+ checkBoxRepeater.ID = repeatIndex.ToString(NumberFormatInfo.InvariantInfo);
+ checkBoxRepeater.Text = Items[repeatIndex].Text;
+ checkBoxRepeater.TextAlign = TextAlign;
+ checkBoxRepeater.Checked = Items[repeatIndex].Selected;
+ checkBoxRepeater.RenderControl(writer);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CommandEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CommandEventArgs.cs
new file mode 100644
index 00000000000..145280eb7e3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/CommandEventArgs.cs
@@ -0,0 +1,50 @@
+/**
+* Namespace: System.Web.UI.WebControls
+* Class: CommandEventArgs
+*
+* Author: Gaurav Vaish
+* Maintainer: gvaish@iitk.ac.in
+* Implementation: yes
+* Status: 100%
+*
+* (C) Gaurav Vaish (2001)
+*/
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class CommandEventArgs : EventArgs
+ {
+ private string cmdName;
+ private object cmdArg;
+
+ public CommandEventArgs(CommandEventArgs e) : this(e.CommandName, e.CommandArgument)
+ {
+ }
+
+ public CommandEventArgs(string commandName, object argument)
+ {
+ cmdName = commandName;
+ cmdArg = argument;
+ }
+
+ public string CommandName
+ {
+ get
+ {
+ return cmdName;
+ }
+ }
+
+ public object CommandArgument
+ {
+ get
+ {
+ return cmdArg;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CommandEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CommandEventHandler.cs
new file mode 100644
index 00000000000..e806b1e952c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/CommandEventHandler.cs
@@ -0,0 +1,17 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Delegate: CommandEventHandler
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void CommandEventHandler(object sender, CommandEventArgs e);
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CompareValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CompareValidator.cs
new file mode 100644
index 00000000000..c6d19b53fb1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/CompareValidator.cs
@@ -0,0 +1,92 @@
+/**
+* Namespace: System.Web.UI.WebControls
+* Class: CompareValidator
+*
+* Author: Gaurav Vaish
+* Maintainer: gvaish@iitk.ac.in
+* Implementation: yes
+* Status: 80%
+*
+* (C) Gaurav Vaish (2001)
+*/
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [ToolboxData("<{0}:CompareValidator runat=\"server\""
+ + "ErrorMessage=\"CompareValidator\"></{0}:CompareValidator>")]
+ public class CompareValidator: BaseCompareValidator
+ {
+ public CompareValidator()
+ {
+ // Intitalize();
+ }
+
+ public string ControlToCompare
+ {
+ get
+ {
+ object o = ViewState["ControlToCompare"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+
+ set
+ {
+ ViewState["ControlToCompare"] = value;
+ }
+ }
+
+ public ValidationCompareOperator Operator
+ {
+ get
+ {
+ object o = ViewState["Operator"];
+ if(o!=null)
+ return (ValidationCompareOperator)o;
+ return ValidationCompareOperator.Equal;
+ }
+ set
+ {
+ if(!System.Enum.IsDefined(typeof(ValidationCompareOperator), value))
+ throw new ArgumentException();
+ ViewState["Operator"] = value;
+ }
+ }
+
+ public string ValueToCompare
+ {
+ get
+ {
+ object o = ViewState["ValueToCompare"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["ValueToCompare"] = value;
+ }
+ }
+
+ protected override bool EvaluateIsValid ()
+ {
+ string ctrl = GetControlValidationValue (ControlToValidate);
+ if (ctrl == null || ctrl.Length == 0)
+ return true;
+
+ string cmp;
+ if (ControlToCompare.Length > 0) {
+ cmp = GetControlValidationValue (ControlToCompare);
+ } else {
+ cmp = ValueToCompare;
+ }
+
+ return Compare (ctrl, cmp, Operator, Type);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CustomValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CustomValidator.cs
new file mode 100644
index 00000000000..192cab3bcad
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/CustomValidator.cs
@@ -0,0 +1,113 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: CustomValidator
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("ServerValidate")]
+ [ToolboxData("<{0}:CustomValidator runat=\"server\""
+ + "ErrorMessage=\"CustomValidator\">"
+ + "</{0}:CustomValidator>")]
+ public class CustomValidator : BaseValidator
+ {
+ private static readonly object ServerValidateEvent = new object();
+
+ public CustomValidator()
+ {
+ }
+
+ public string ClientValidationFunction
+ {
+ get
+ {
+ object o = ViewState["ClientValidationFunction"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["ClientValidationFunction"] = value;
+ }
+ }
+
+ public event ServerValidateEventHandler ServerValidate
+ {
+ add
+ {
+ Events.AddHandler(ServerValidateEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ServerValidateEvent, value);
+ }
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender(writer);
+ if(RenderUplevel)
+ {
+ writer.AddAttribute("evaluationfunction", "CustomValidatorEvaluateIsValid");
+ if(ClientValidationFunction.Length > 0)
+ {
+ writer.AddAttribute("clientvalidationfunction", ClientValidationFunction);
+ }
+ }
+ }
+
+ protected override bool ControlPropertiesValid()
+ {
+ if(ControlToValidate.Length > 0)
+ {
+ CheckControlValidationProperty(ControlToValidate, "ControlToValidate");
+ }
+ return true;
+ }
+
+ protected virtual bool OnServerValidate(string value)
+ {
+ if(Events != null)
+ {
+ ServerValidateEventHandler sveh = (ServerValidateEventHandler)(Events[ServerValidateEvent]);
+ if(sveh != null)
+ {
+ ServerValidateEventArgs args = new ServerValidateEventArgs(value, true);
+ sveh(this, args);
+ return args.IsValid;
+ }
+ }
+ return true;
+ }
+
+ protected override bool EvaluateIsValid()
+ {
+ string ctrl = ControlToValidate;
+ if(ctrl.Length > 0)
+ {
+ ctrl = GetControlValidationValue(ctrl);
+ if(ctrl== null || ctrl.Length == 0)
+ {
+ return true;
+ }
+ }
+ return OnServerValidate(ctrl);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs
new file mode 100644
index 00000000000..63e4841bb97
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs
@@ -0,0 +1,1445 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGrid
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 95%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+using System.Web.Util;
+using System.ComponentModel;
+using System.Reflection;
+
+namespace System.Web.UI.WebControls
+{
+ //TODO: [Designer("??")]
+ //TODO: [Editor("??")]
+ [DefaultEvent("SelectedIndexChanged")]
+ [DefaultProperty("DataSource")]
+ [ParseChildren(true)]
+ [PersistChildren(false)]
+ public class DataGrid : BaseDataList, INamingContainer
+ {
+ public const string CancelCommandName = "Cancel";
+ public const string DeleteCommandName = "Delete";
+ public const string EditCommandName = "Edit";
+ public const string NextPageCommandArgument = "Next";
+ public const string PageCommandName = "Page";
+ public const string PrevPageCommandArgument = "Prev";
+ public const string SelectCommandName = "Select";
+ public const string SortCommandName = "Sort";
+ public const string UpdateCommandName = "Update";
+
+ private TableItemStyle alternatingItemStyle;
+ private TableItemStyle editItemStyle;
+ private TableItemStyle headerStyle;
+ private TableItemStyle footerStyle;
+ private TableItemStyle itemStyle;
+ private TableItemStyle selectedItemStyle;
+ private DataGridPagerStyle pagerStyle;
+
+ private DataGridColumnCollection columns;
+ private ArrayList columnsArrayList;
+ private DataGridItemCollection items;
+ private ArrayList itemsArrayList;
+ private PagedDataSource pagedDataSource;
+
+ private ArrayList autoGenColsArrayList;
+ private IEnumerator storedData;
+ private object storedDataFirst;
+ private bool storedDataValid;
+
+ private static readonly object CancelCommandEvent = new object();
+ private static readonly object DeleteCommandEvent = new object();
+ private static readonly object EditCommandEvent = new object();
+ private static readonly object ItemCommandEvent = new object();
+ private static readonly object ItemCreatedEvent = new object();
+ private static readonly object ItemDataBoundEvent = new object();
+ private static readonly object PageIndexChangedEvent = new object();
+ private static readonly object SortCommandEvent = new object();
+ private static readonly object UpdateCommandEvent = new object();
+
+ public DataGrid(): base()
+ {
+ }
+
+ public virtual bool AllowCustomPaging
+ {
+ get
+ {
+ object o = ViewState["AllowCustomPaging"];
+ if(o != null)
+ return (bool)o;
+ return false;
+ }
+ set
+ {
+ ViewState["AllowCustomPaging"] = value;
+ }
+ }
+
+ public virtual bool AllowPaging
+ {
+ get
+ {
+ object o = ViewState["AllowPaging"];
+ if(o != null)
+ return (bool)o;
+ return false;
+ }
+ set
+ {
+ ViewState["AllowPaging"] = value;
+ }
+ }
+
+ public virtual bool AllowSorting
+ {
+ get
+ {
+ object o = ViewState["AllowSorting"];
+ if(o != null)
+ return (bool)o;
+ return false;
+ }
+ set
+ {
+ ViewState["AllowSorting"] = value;
+ }
+ }
+
+ public virtual TableItemStyle AlternatingItemStyle
+ {
+ get
+ {
+ if(alternatingItemStyle == null)
+ {
+ alternatingItemStyle = new TableItemStyle();
+ }
+ if(IsTrackingViewState)
+ {
+ alternatingItemStyle.TrackViewState();
+ }
+ return alternatingItemStyle;
+ }
+ }
+
+ public virtual bool AutoGenerateColumns
+ {
+ get
+ {
+ object o = ViewState["AutoGenerateColumns"];
+ if(o != null)
+ return (bool)o;
+ return false;
+ }
+ set
+ {
+ ViewState["AutoGenerateColumns"] = value;
+ }
+ }
+
+ public virtual string BackImageUrl
+ {
+ get
+ {
+ object o = ViewState["BackImageUrl"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["BackImageUrl"] = value;
+ }
+ }
+
+ public virtual DataGridColumnCollection Columns
+ {
+ get
+ {
+ if(columns == null)
+ {
+ columnsArrayList = new ArrayList();
+ columns = new DataGridColumnCollection(this, columnsArrayList);
+ if(IsTrackingViewState)
+ {
+ ((IStateManager)columns).TrackViewState();
+ }
+ }
+ return columns;
+ }
+ }
+
+ public int CurrentPageIndex
+ {
+ get
+ {
+ object o = ViewState["CurrentPageIndex"];
+ if(o != null)
+ return (int)o;
+ return 0;
+ }
+ set
+ {
+ if(value < 0)
+ throw new ArgumentOutOfRangeException();
+ ViewState["CurrentPageIndex"] = value;
+ }
+ }
+
+ public virtual int EditItemIndex
+ {
+ get
+ {
+ object o = ViewState["EditItemIndex"];
+ if(o != null)
+ return (int)o;
+ return -1;
+ }
+ set
+ {
+ if(value < -1)
+ throw new ArgumentOutOfRangeException();
+ ViewState["EditItemIndex"] = value;
+ }
+ }
+
+ public virtual TableItemStyle EditItemStyle
+ {
+ get
+ {
+ if(editItemStyle == null)
+ {
+ editItemStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ {
+ editItemStyle.TrackViewState();
+ }
+ }
+ return editItemStyle;
+ }
+ }
+
+ public virtual TableItemStyle FooterStyle
+ {
+ get
+ {
+ if(footerStyle == null)
+ {
+ footerStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ {
+ footerStyle.TrackViewState();
+ }
+ }
+ return footerStyle;
+ }
+ }
+
+ public virtual TableItemStyle HeaderStyle
+ {
+ get
+ {
+ if(headerStyle == null)
+ {
+ headerStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ {
+ headerStyle.TrackViewState();
+ }
+ }
+ return headerStyle;
+ }
+ }
+
+ public virtual DataGridItemCollection Items
+ {
+ get
+ {
+ if(items == null)
+ {
+ if(itemsArrayList == null)
+ EnsureChildControls();
+ if(itemsArrayList == null)
+ {
+ itemsArrayList = new ArrayList();
+ }
+ items = new DataGridItemCollection(itemsArrayList);
+ }
+ return items;
+ }
+ }
+
+ public virtual TableItemStyle ItemStyle
+ {
+ get
+ {
+ if(itemStyle == null)
+ {
+ itemStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ {
+ itemStyle.TrackViewState();
+ }
+ }
+ return itemStyle;
+ }
+ }
+
+ public int PageCount
+ {
+ get
+ {
+ if(pagedDataSource != null)
+ {
+ return pagedDataSource.PageCount;
+ }
+ object o = ViewState["PageCount"];
+ if(o != null)
+ return (int)o;
+ return 0;
+ }
+ }
+
+ public virtual DataGridPagerStyle PagerStyle
+ {
+ get
+ {
+ if(pagerStyle == null)
+ {
+ pagerStyle = new DataGridPagerStyle(this);
+ if(IsTrackingViewState)
+ {
+ pagerStyle.TrackViewState();
+ }
+ }
+ return pagerStyle;
+ }
+ }
+
+ public virtual int PageSize
+ {
+ get
+ {
+ object o = ViewState["PageSize"];
+ if(o != null)
+ return (int)o;
+ return 10;
+ }
+ set
+ {
+ if(value < 1)
+ throw new ArgumentOutOfRangeException();
+ ViewState["PageSize"] = value;
+ }
+ }
+
+ public virtual int SelectedIndex
+ {
+ get
+ {
+ object o = ViewState["SelectedIndex"];
+ if(o != null)
+ return (int)o;
+ return -1;
+ }
+ set
+ {
+ if(value < -1)
+ throw new ArgumentOutOfRangeException();
+ int prevVal = SelectedIndex;
+ ViewState["SelectedIndex"] = value;
+ if(items != null)
+ {
+ if(prevVal !=-1 && prevVal < items.Count)
+ {
+ DataGridItem prev = (DataGridItem)items[prevVal];
+ if(prev.ItemType != ListItemType.EditItem)
+ {
+ ListItemType newType = ListItemType.Item;
+ if( (prevVal % 2) != 0)
+ {
+ newType = ListItemType.AlternatingItem;
+ }
+ prev.SetItemType(newType);
+ }
+ }
+ }
+ }
+ }
+
+ public virtual DataGridItem SelectedItem
+ {
+ get
+ {
+ if(SelectedIndex == -1)
+ return null;
+ return Items[SelectedIndex];
+ }
+ }
+
+ public virtual TableItemStyle SelectedItemStyle
+ {
+ get
+ {
+ if(selectedItemStyle == null)
+ {
+ selectedItemStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ {
+ selectedItemStyle.TrackViewState();
+ }
+ }
+ return selectedItemStyle;
+ }
+ }
+
+ public virtual bool ShowFooter
+ {
+ get
+ {
+ object o = ViewState["ShowFooter"];
+ if(o != null)
+ return (bool)o;
+ return false;
+ }
+ set
+ {
+ ViewState["ShowFooter"] = value;
+ }
+ }
+
+ public virtual bool ShowHeader
+ {
+ get
+ {
+ object o = ViewState["ShowHeader"];
+ if(o != null)
+ return (bool)o;
+ return true;
+ }
+ set
+ {
+ ViewState["ShowHeader"] = value;
+ }
+ }
+
+ public virtual int VirtualItemCount
+ {
+ get
+ {
+ object o = ViewState["VirtualItemCount"];
+ if(o != null)
+ return (int)o;
+ return 0;
+ }
+ set
+ {
+ if(value < 0)
+ throw new ArgumentOutOfRangeException();
+ ViewState["VirtualItemCount"] = value;
+ }
+ }
+
+ public event DataGridCommandEventHandler CancelCommand
+ {
+ add
+ {
+ Events.AddHandler(CancelCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(CancelCommandEvent, value);
+ }
+ }
+
+ public event DataGridCommandEventHandler DeleteCommand
+ {
+ add
+ {
+ Events.AddHandler(DeleteCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(DeleteCommandEvent, value);
+ }
+ }
+
+ public event DataGridCommandEventHandler EditCommand
+ {
+ add
+ {
+ Events.AddHandler(EditCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(EditCommandEvent, value);
+ }
+ }
+
+ public event DataGridCommandEventHandler ItemCommand
+ {
+ add
+ {
+ Events.AddHandler(ItemCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ItemCommandEvent, value);
+ }
+ }
+
+ public event DataGridCommandEventHandler ItemCreated
+ {
+ add
+ {
+ Events.AddHandler(ItemCreatedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ItemCreatedEvent, value);
+ }
+ }
+
+ public event DataGridCommandEventHandler ItemDataBound
+ {
+ add
+ {
+ Events.AddHandler(ItemDataBoundEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ItemDataBoundEvent, value);
+ }
+ }
+
+ public event DataGridCommandEventHandler PageIndexChanged
+ {
+ add
+ {
+ Events.AddHandler(PageIndexChangedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(PageIndexChangedEvent, value);
+ }
+ }
+
+ public event DataGridCommandEventHandler SortCommand
+ {
+ add
+ {
+ Events.AddHandler(SortCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(SortCommandEvent, value);
+ }
+ }
+
+ public event DataGridCommandEventHandler UpdateCommand
+ {
+ add
+ {
+ Events.AddHandler(UpdateCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(UpdateCommandEvent, value);
+ }
+ }
+
+ protected override Style CreateControlStyle()
+ {
+ TableStyle style = new TableStyle(ViewState);
+ style.GridLines = GridLines.Both;
+ style.CellSpacing = 0;
+ return style;
+ }
+
+ protected override void LoadViewState(object savedState)
+ {
+ if(savedState != null)
+ {
+ object[] states = (object[])savedState;
+ if(states != null)
+ {
+ base.LoadViewState(states[0]);
+ if(columns != null)
+ ((IStateManager)columns).LoadViewState(states[1]);
+ if(pagerStyle != null)
+ pagerStyle.LoadViewState(states[2]);
+ if(headerStyle != null)
+ headerStyle.LoadViewState(states[3]);
+ if(footerStyle != null)
+ footerStyle.LoadViewState(states[4]);
+ if(itemStyle != null)
+ itemStyle.LoadViewState(states[5]);
+ if(alternatingItemStyle != null)
+ alternatingItemStyle.LoadViewState(states[6]);
+ if(selectedItemStyle != null)
+ selectedItemStyle.LoadViewState(states[7]);
+ if(editItemStyle != null)
+ editItemStyle.LoadViewState(states[8]);
+ }
+ }
+ }
+
+ protected override object SaveViewState()
+ {
+ object[] states = new object[9];
+ states[0] = SaveViewState();
+ states[1] = (columns == null ? null : ((IStateManager)columns).SaveViewState());
+ states[2] = (pagerStyle == null ? null : pagerStyle.SaveViewState());
+ states[3] = (headerStyle == null ? null : headerStyle.SaveViewState());
+ states[4] = (footerStyle == null ? null : footerStyle.SaveViewState());
+ states[5] = (itemStyle == null ? null : itemStyle.SaveViewState());
+ states[6] = (alternatingItemStyle == null ? null : alternatingItemStyle.SaveViewState());
+ states[7] = (selectedItemStyle == null ? null : selectedItemStyle.SaveViewState());
+ states[8] = (editItemStyle == null ? null : editItemStyle.SaveViewState());
+ return states;
+ }
+
+ protected override void TrackViewState()
+ {
+ base.TrackViewState();
+ if(alternatingItemStyle != null)
+ {
+ alternatingItemStyle.TrackViewState();
+ }
+ if(editItemStyle != null)
+ {
+ editItemStyle.TrackViewState();
+ }
+ if(headerStyle != null)
+ {
+ headerStyle.TrackViewState();
+ }
+ if(footerStyle != null)
+ {
+ footerStyle.TrackViewState();
+ }
+ if(itemStyle != null)
+ {
+ itemStyle.TrackViewState();
+ }
+ if(selectedItemStyle != null)
+ {
+ selectedItemStyle.TrackViewState();
+ }
+ if(pagerStyle != null)
+ {
+ pagerStyle.TrackViewState();
+ }
+
+ if(columns != null)
+ {
+ ((IStateManager)columns).TrackViewState();
+ }
+ }
+
+ protected override bool OnBubbleEvent(object source, EventArgs e)
+ {
+ bool retVal = false;
+ if(e is DataGridCommandEventArgs)
+ {
+ DataGridCommandEventArgs ea = (DataGridCommandEventArgs)e;
+ retVal = true;
+ OnItemCommand(ea);
+ string cmd = ea.CommandName;
+ if(String.Compare(cmd, "select", true) == 0)
+ {
+ SelectedIndex = ea.Item.ItemIndex;
+ OnSelectedIndexChanged(EventArgs.Empty);
+ } else if(String.Compare(cmd,"page", true) == 0)
+ {
+ int cIndex = CurrentPageIndex;
+ string cea = (string) ea.CommandArgument;
+ if(String.Compare(cea, "prev", true) == 0)
+ {
+ cIndex--;
+ } else if(String.Compare(cea, "next", true) == 0)
+ {
+ cIndex++;
+ }
+ OnPageIndexChanged(new DataGridPageChangedEventArgs(source, cIndex));
+ } else if(String.Compare(cmd, "sort", true) == 0)
+ {
+ OnSortCommand(new DataGridSortCommandEventArgs(source, ea));
+ } else if(String.Compare(cmd, "edit", true) == 0)
+ {
+ OnEditCommand(ea);
+ } else if(String.Compare(cmd, "update", true) == 0)
+ {
+ OnUpdateCommand(ea);
+ } else if(String.Compare(cmd, "cancel", true) == 0)
+ {
+ OnCancelCommand(ea);
+ } else if(String.Compare(cmd, "delete", true) == 0)
+ {
+ OnDeleteCommand(ea);
+ }
+ }
+ return retVal;
+ }
+
+ protected virtual void OnCancelCommand(DataGridCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataGridCommandEventHandler dceh = (DataGridCommandEventHandler)(Events[CancelCommandEvent]);
+ if(dceh != null)
+ dceh(this, e);
+ }
+ }
+
+ protected virtual void OnDeleteCommand(DataGridCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataGridCommandEventHandler dceh = (DataGridCommandEventHandler)(Events[DeleteCommandEvent]);
+ if(dceh != null)
+ dceh(this, e);
+ }
+ }
+
+ protected virtual void OnEditCommand(DataGridCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataGridCommandEventHandler dceh = (DataGridCommandEventHandler)(Events[EditCommandEvent]);
+ if(dceh != null)
+ dceh(this, e);
+ }
+ }
+
+ protected virtual void OnItemCommand(DataGridCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataGridCommandEventHandler dceh = (DataGridCommandEventHandler)(Events[ItemCommandEvent]);
+ if(dceh != null)
+ dceh(this, e);
+ }
+ }
+
+ protected virtual void OnItemCreated(DataGridItemEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataGridItemEventHandler dceh = (DataGridItemEventHandler)(Events[ItemCreatedEvent]);
+ if(dceh != null)
+ dceh(this, e);
+ }
+ }
+
+ protected virtual void OnItemDataBound(DataGridItemEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataGridItemEventHandler dceh = (DataGridItemEventHandler)(Events[ItemDataBoundEvent]);
+ if(dceh != null)
+ dceh(this, e);
+ }
+ }
+
+ protected virtual void OnPageIndexChanged(DataGridPageChangedEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataGridPageChangedEventHandler dceh = (DataGridPageChangedEventHandler)(Events[PageIndexChangedEvent]);
+ if(dceh != null)
+ dceh(this, e);
+ }
+ }
+
+ protected virtual void OnSortCommand(DataGridSortCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataGridSortCommandEventHandler dceh = (DataGridSortCommandEventHandler)(Events[SortCommandEvent]);
+ if(dceh != null)
+ dceh(this, e);
+ }
+ }
+
+ protected virtual void OnUpdateCommand(DataGridCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataGridCommandEventHandler dceh = (DataGridCommandEventHandler)(Events[UpdateCommandEvent]);
+ if(dceh != null)
+ dceh(this, e);
+ }
+ }
+
+ protected override void PrepareControlHierarchy()
+ {
+ if(Controls.Count > 0)
+ {
+ Table display = (Table)Controls[0];
+ display.CopyBaseAttributes(this);
+ if(ControlStyleCreated)
+ {
+ display.ApplyStyle(ControlStyle);
+ } else
+ {
+ display.GridLines = GridLines.Both;
+ display.CellSpacing = 0;
+ }
+ TableRowCollection rows = display.Rows;
+ if(rows.Count > 0)
+ {
+ int nCols = Columns.Count;
+ DataGridColumn[] cols = new DataGridColumn[nCols];
+ Style deployStyle;
+ int counter;
+ if(nCols > 0)
+ {
+ Columns.CopyTo(cols, 0);
+ }
+ deployStyle = null;
+ if(alternatingItemStyle != null)
+ {
+ deployStyle = new TableItemStyle();
+ deployStyle.CopyFrom(itemStyle);
+ deployStyle.CopyFrom(alternatingItemStyle);
+ } else
+ {
+ deployStyle = itemStyle;
+ }
+ for(counter = 0; counter < rows.Count; counter++)
+ {
+ PrepareControlHierarchyForItem(cols, (DataGridItem) rows[counter], counter, deployStyle);
+ }
+ }
+ }
+ }
+
+ private void PrepareControlHierarchyForItem(DataGridColumn[] cols, DataGridItem item, int index, Style deployStyle)
+ {
+ switch(item.ItemType)
+ {
+ case ListItemType.Header: if(!ShowHeader)
+ {
+ item.Visible = false;
+ break;
+ }
+ if(headerStyle != null)
+ {
+ item.MergeStyle(headerStyle);
+ }
+ goto case ListItemType.Separator;
+ case ListItemType.Footer: if(!ShowFooter)
+ {
+ item.Visible = false;
+ break;
+ }
+ if(footerStyle != null)
+ {
+ item.MergeStyle(footerStyle);
+ }
+ goto case ListItemType.Separator;
+ case ListItemType.Item : item.MergeStyle(itemStyle);
+ goto case ListItemType.Separator;
+ case ListItemType.AlternatingItem:
+ item.MergeStyle(deployStyle);
+ goto case ListItemType.Separator;
+ case ListItemType.SelectedItem:
+ Style selStyle = new TableItemStyle();
+ if( (item.ItemIndex % 2) == 0)
+ {
+ selStyle.CopyFrom(itemStyle);
+ } else
+ {
+ selStyle.CopyFrom(deployStyle);
+ }
+ selStyle.CopyFrom(selectedItemStyle);
+ item.MergeStyle(selStyle);
+ goto case ListItemType.Separator;
+ case ListItemType.EditItem:
+ Style edStyle = new TableItemStyle();
+ if( (item.ItemIndex % 2) == 0)
+ {
+ edStyle.CopyFrom(itemStyle);
+ } else
+ {
+ edStyle.CopyFrom(deployStyle);
+ }
+ edStyle.CopyFrom(editItemStyle);
+ item.MergeStyle(edStyle);
+ goto case ListItemType.Separator;
+ case ListItemType.Pager : if(pagerStyle == null)
+ {
+ break;
+ }
+ if(!pagerStyle.Visible)
+ {
+ item.Visible = false;
+ }
+ if(index == 0)
+ {
+ if(!pagerStyle.IsPagerOnTop)
+ {
+ item.Visible = false;
+ break;
+ }
+ } else
+ {
+ if(!pagerStyle.IsPagerOnBottom)
+ {
+ item.Visible = false;
+ break;
+ }
+ }
+ item.MergeStyle(pagerStyle);
+ goto case ListItemType.Separator;
+ case ListItemType.Separator:
+ TableCellCollection cells = item.Cells;
+ int cellCount = cells.Count;
+ if(cellCount > 0 && item.ItemType != ListItemType.Pager)
+ {
+ for(int i = 0; i < cellCount; i++)
+ {
+ Style colStyle = null;
+ if(cols[i].Visible)
+ {
+ switch (item.ItemType)
+ {
+ case ListItemType.Header : colStyle = cols[i].HeaderStyleInternal;
+ break;
+ case ListItemType.Footer : colStyle = cols[i].FooterStyleInternal;
+ break;
+ default : colStyle = cols[i].ItemStyleInternal;
+ break;
+ }
+ item.MergeStyle(colStyle);
+ } else
+ {
+ cells[i].Visible = false;
+ }
+ }
+ }
+ break;
+ default : goto case ListItemType.Separator;
+ }
+ }
+
+ protected override void CreateControlHierarchy(bool useDataSource)
+ {
+ IEnumerator pageSourceEnumerator;
+ int itemCount;
+ ArrayList dataKeys;
+ ArrayList columns;
+ IEnumerable resolvedDS;
+ ICollection collResolvedDS;
+ int pageDSCount;
+ int colCount;
+ DataGridColumn[] cols;
+ Table deployTable;
+ TableRowCollection deployRows;
+ ListItemType deployType;
+ int indexCounter;
+ string dkField;
+ bool dsUse;
+ bool pgEnabled;
+ int editIndex;
+ int selIndex;
+
+ pagedDataSource = CreatePagedDataSource();
+ pageSourceEnumerator = null;
+ itemCount = -1;
+ dataKeys = DataKeysArray;
+ columns = null;
+ if(itemsArrayList != null)
+ {
+ itemsArrayList.Clear();
+ } else
+ {
+ itemsArrayList = new ArrayList();
+ }
+ if(!useDataSource)
+ {
+ itemCount = (int) ViewState["_!ItemCount"];
+ pageDSCount = (int) ViewState["_!DataSource_ItemCount"];
+ if(itemCount != -1)
+ {
+ if(pagedDataSource.IsCustomPagingEnabled)
+ {
+ pagedDataSource.DataSource = new DataSourceInternal(itemCount);
+ } else
+ {
+ pagedDataSource.DataSource = new DataSourceInternal(pageDSCount);
+ }
+ pageSourceEnumerator = pagedDataSource.GetEnumerator();
+ columns = CreateColumnSet(null, false);
+ itemsArrayList.Capacity = itemCount;
+ }
+ } else
+ {
+ dataKeys.Clear();
+ resolvedDS = DataSourceHelper.GetResolvedDataSource(DataSource, DataMember);
+ if(resolvedDS != null)
+ {
+ collResolvedDS = resolvedDS as ICollection;
+ if(pagedDataSource.IsPagingEnabled && !pagedDataSource.IsCustomPagingEnabled
+ && collResolvedDS == null)
+ {
+ throw new HttpException(HttpRuntime.FormatResourceString("DataGrid_Missing_VirtualItemCount", ID));
+ }
+ pagedDataSource.DataSource = resolvedDS;
+ if(pagedDataSource.IsPagingEnabled && (pagedDataSource.CurrentPageIndex < 0 ||
+ pagedDataSource.CurrentPageIndex >= pagedDataSource.PageCount))
+ {
+ throw new HttpException(HttpRuntime.FormatResourceString("DataGrid_Invalid_Current_PageIndex", ID));
+ }
+ columns = CreateColumnSet(pagedDataSource, useDataSource);
+ if(storedDataValid)
+ {
+ pageSourceEnumerator = storedData;
+ } else
+ {
+ pageSourceEnumerator = pagedDataSource.GetEnumerator();
+ }
+ if(collResolvedDS != null)
+ {
+ pageDSCount = pagedDataSource.Count;
+ dataKeys.Capacity = pageDSCount;
+ itemsArrayList.Capacity = pageDSCount;
+ }
+ }
+ colCount = 0;
+ if(columns != null)
+ colCount = columns.Count;
+ int currentSourceIndex;
+ if(colCount > 0)
+ {
+ cols = (DataGridColumn []) columns.ToArray (typeof (DataGridColumn));
+ foreach(DataGridColumn current in cols)
+ {
+ current.Initialize();
+ }
+ deployTable = new DataGridTableInternal();
+ Controls.Add(deployTable);
+ deployRows = deployTable.Rows;
+
+ indexCounter = 0;
+ currentSourceIndex = 0;
+ dkField = DataKeyField;
+
+ dsUse = (useDataSource) ? (dkField.Length > 0) : false;
+ pgEnabled = pagedDataSource.IsPagingEnabled;
+ editIndex = EditItemIndex;
+ selIndex = SelectedIndex;
+ if(pgEnabled)
+ {
+ currentSourceIndex = pagedDataSource.FirstIndexInPage;
+ CreateItem(-1, -1, ListItemType.Pager, false, null,
+ cols, deployRows, pagedDataSource);
+ }
+ itemCount = 0;
+ CreateItem(-1, -1, ListItemType.Header, useDataSource, null,
+ cols, deployRows, null);
+
+ if(storedDataValid && storedDataFirst != null)
+ {
+ if(dsUse)
+ {
+ dataKeys.Add(DataBinder.GetPropertyValue(storedDataFirst, dkField));
+ }
+ deployType = ListItemType.Item;
+ if(indexCounter == editIndex)
+ {
+ deployType = ListItemType.EditItem;
+ } else if(indexCounter == selIndex)
+ {
+ deployType = ListItemType.SelectedItem;
+ }
+ itemsArrayList.Add(CreateItem(0, currentSourceIndex, deployType,
+ useDataSource, storedDataFirst,
+ cols, deployRows, null));
+ itemCount++;
+ indexCounter++;
+ currentSourceIndex++;
+ storedDataValid = false;
+ storedDataFirst = null;
+ }
+
+ while(pageSourceEnumerator.MoveNext())
+ {
+ object current = pageSourceEnumerator.Current;
+ if(dsUse)
+ {
+ dataKeys.Add(DataBinder.GetPropertyValue(current, dkField));
+ }
+ deployType = ListItemType.Item;
+ if(indexCounter == editIndex)
+ {
+ deployType = ListItemType.EditItem;
+ } else if(indexCounter == selIndex)
+ {
+ deployType = ListItemType.SelectedItem;
+ }
+ itemsArrayList.Add(CreateItem(indexCounter, currentSourceIndex,
+ deployType, useDataSource, current,
+ cols, deployRows, null));
+ itemCount++;
+ indexCounter++;
+ currentSourceIndex++;
+ }
+
+ CreateItem(-1, -1, ListItemType.Footer, useDataSource, null,
+ cols, deployRows, null);
+
+ if(pgEnabled)
+ {
+ CreateItem(-1, -1, ListItemType.Pager, false, null, cols, deployRows,
+ pagedDataSource);
+ }
+ }
+
+ if(useDataSource)
+ {
+ if(pageSourceEnumerator != null)
+ {
+ ViewState["_!ItemCount"] = itemCount;
+ if(pagedDataSource.IsPagingEnabled)
+ {
+ ViewState["PageCount"] = pagedDataSource.PageCount;
+ ViewState["_!DataSource_ItemCount"] = pagedDataSource.DataSourceCount;
+ } else
+ {
+ ViewState["PageCount"] = 1;
+ ViewState["_!DataSource_ItemCount"] = itemCount;
+ }
+ } else
+ {
+ ViewState["_!ItemCount"] = -1;
+ ViewState["_!DataSource_ItemCount"] = -1;
+ ViewState["PageCount"] = 0;
+ }
+ }
+ }
+ pagedDataSource = null;
+ }
+
+ private DataGridItem CreateItem(int itemIndex, int dsIndex, ListItemType type,
+ bool bind, object item, DataGridColumn[] columns,
+ TableRowCollection rows, PagedDataSource dataSrc)
+
+ {
+ DataGridItem retVal;
+ DataGridItemEventArgs args;
+
+ retVal = CreateItem(itemIndex, dsIndex, type);
+ args = new DataGridItemEventArgs(retVal);
+
+ if(type != ListItemType.Pager)
+ {
+ InitializeItem(retVal, columns);
+ if(bind)
+ {
+ retVal.DataItem = item;
+ }
+ OnItemCreated(args);
+ rows.Add(retVal);
+ if(bind)
+ {
+ retVal.DataBind();
+ OnItemDataBound(args);
+ retVal.DataItem = null;
+ }
+ } else
+ {
+ InitializePager(retVal, columns.Length, dataSrc);
+ OnItemCreated(args);
+ rows.Add(retVal);
+ }
+ return retVal;
+ }
+
+ protected virtual DataGridItem CreateItem(int itemIndex, int dataSourceIndex, ListItemType itemType)
+ {
+ return new DataGridItem(itemIndex, dataSourceIndex, itemType);
+ }
+
+ protected virtual void InitializeItem(DataGridItem item, DataGridColumn[] columns)
+ {
+ TableCellCollection cells = item.Cells;
+ TableCell cCell;
+
+ for(int i = 0; i < columns.Length; i++)
+ {
+ cCell = new TableCell();
+ columns[i].InitializeCell(cCell, i, item.ItemType);
+ cells.Add(cCell);
+ }
+ }
+
+ protected virtual void InitializePager(DataGridItem item,
+ int columnSpan, PagedDataSource pagedDataSource)
+ {
+ TableCell toAdd = new TableCell();
+ toAdd.ColumnSpan = columnSpan;
+
+ if(PagerStyle.Mode == PagerMode.NextPrev)
+ {
+ if(!pagedDataSource.IsFirstPage)
+ {
+ LinkButton link = new DataGridLinkButton();
+ link.Text = PagerStyle.PrevPageText;
+ link.CommandName = "Page";
+ link.CommandArgument = "Prev";
+ link.CausesValidation = false;
+ toAdd.Controls.Add(link);
+ } else
+ {
+ Label label = new Label();
+ label.Text = PagerStyle.PrevPageText;
+ toAdd.Controls.Add(label);
+ }
+ toAdd.Controls.Add(new LiteralControl("&nbsp;"));
+ if(!pagedDataSource.IsLastPage)
+ {
+ LinkButton link = new DataGridLinkButton();
+ link.Text = PagerStyle.NextPageText;
+ link.CommandName = "Page";
+ link.CommandArgument = "Next";
+ link.CausesValidation = false;
+ toAdd.Controls.Add(link);
+ } else
+ {
+ Label label = new Label();
+ label.Text = PagerStyle.NextPageText;
+ toAdd.Controls.Add(label);
+ }
+ } else
+ {
+ int pageCount = pagedDataSource.PageCount;
+ int currPage = pagedDataSource.CurrentPageIndex + 1;
+ int btnCount = PagerStyle.PageButtonCount;
+ int numberOfPages = btnCount;
+ if(numberOfPages > pageCount)
+ numberOfPages = pageCount;
+ int firstPageNumber = 1; // 10
+ int lastPageNumber = numberOfPages; // 11
+ if(currPage > lastPageNumber)
+ {
+ firstPageNumber = (pagedDataSource.CurrentPageIndex / btnCount) * btnCount + 1;
+ lastPageNumber = firstPageNumber + btnCount - 1;
+ if(lastPageNumber > pageCount)
+ lastPageNumber = pageCount;
+ if((lastPageNumber - firstPageNumber + 1) < btnCount)
+ firstPageNumber = Math.Max(1, lastPageNumber - btnCount + 1);
+ }
+ if(firstPageNumber != 1)
+ {
+ LinkButton toAddBtn = new DataGridLinkButton();
+ toAddBtn.Text = "...";
+ toAddBtn.CommandName = "Page";
+ toAddBtn.CommandArgument = (lastPageNumber - 1).ToString(NumberFormatInfo.InvariantInfo);
+ toAddBtn.CausesValidation = false;
+ toAdd.Controls.Add(toAddBtn);
+ toAdd.Controls.Add(new LiteralControl("&nbsp;"));
+ }
+ for(int i = firstPageNumber; i <= lastPageNumber; i++)
+ {
+ string argText = i.ToString(NumberFormatInfo.InvariantInfo);
+ if(i == currPage)
+ {
+ Label cPageLabel = new Label();
+ cPageLabel.Text = argText;
+ toAdd.Controls.Add(cPageLabel);
+ } else
+ {
+ LinkButton indexButton = new DataGridLinkButton();
+ indexButton.Text = argText;
+ indexButton.CommandName = "Page";
+ indexButton.CommandArgument = argText;
+ indexButton.CausesValidation = false;
+ toAdd.Controls.Add(indexButton);
+ }
+ if(i < lastPageNumber)
+ toAdd.Controls.Add(new LiteralControl("&nbsp;"));
+ }
+ if(pageCount > lastPageNumber)
+ {
+ toAdd.Controls.Add(new LiteralControl("&nbsp;"));
+ LinkButton contLink = new DataGridLinkButton();
+ contLink.Text = "...";
+ contLink.CommandName = "Page";
+ contLink.CommandArgument = (lastPageNumber + 1).ToString(NumberFormatInfo.InvariantInfo);
+ contLink.CausesValidation = false;
+ toAdd.Controls.Add(contLink);
+ }
+ }
+ item.Cells.Add(toAdd);
+ }
+
+ private PagedDataSource CreatePagedDataSource()
+ {
+ PagedDataSource retVal;
+
+ retVal = new PagedDataSource();
+ retVal.CurrentPageIndex = CurrentPageIndex;
+ retVal.PageSize = PageSize;
+ retVal.AllowPaging = AllowPaging;
+ retVal.AllowCustomPaging = AllowCustomPaging;
+ retVal.VirtualCount = VirtualItemCount;
+
+ return retVal;
+ }
+
+ ///<summary>
+ /// UnDocumented method
+ /// </summary>
+ protected ArrayList CreateColumnSet(PagedDataSource source, bool useDataSource)
+ {
+ DataGridColumn[] cols = new DataGridColumn[Columns.Count];
+ Columns.CopyTo(cols, 0);
+ ArrayList l_columns = new ArrayList();
+ ArrayList auto_columns = null;
+
+ foreach(DataGridColumn current in cols)
+ {
+ l_columns.Add(current);
+ }
+ if(AutoGenerateColumns)
+ {
+ l_columns = null;
+ if(useDataSource)
+ {
+ auto_columns = AutoCreateColumns(source);
+ autoGenColsArrayList = auto_columns;
+ } else
+ {
+ auto_columns = autoGenColsArrayList;
+ }
+ if(auto_columns != null)
+ {
+ foreach(object current in auto_columns)
+ {
+ l_columns.Add(current);
+ }
+ }
+ }
+ return l_columns;
+ }
+
+ /// <summary>
+ /// Generates the columns when AutoGenerateColumns is true.
+ /// This method is called by CreateColumnSet when dataSource
+ /// is to be used and columns need to be generated automatically.
+ /// </summary>
+ private ArrayList AutoCreateColumns(PagedDataSource source)
+ {
+ if(source != null)
+ {
+ ArrayList retVal = new ArrayList();
+ PropertyDescriptorCollection props = source.GetItemProperties(new PropertyDescriptor[0]);
+ Type prop_type;
+ BoundColumn b_col;
+ if(props == null)
+ {
+ prop_type = null;
+ PropertyInfo prop_item = source.DataSource.GetType().GetProperty("Item",
+ BindingFlags.Instance | BindingFlags.Static |
+ BindingFlags.Public, null, null,
+ new Type[] { typeof(int) }, null);
+ if(prop_item != null)
+ {
+ prop_type = prop_item.GetType();
+ }
+ if(prop_type != null && prop_type == typeof(object))
+ {
+ object fitem = null;
+ IEnumerator en = source.GetEnumerator();
+ if(en.MoveNext())
+ fitem = en.Current;
+ if(fitem != null)
+ {
+ prop_type = fitem.GetType();
+ }
+ StoreEnumerator(en, fitem);
+ if(fitem != null && fitem is ICustomTypeDescriptor)
+ {
+ props = TypeDescriptor.GetProperties(fitem);
+ } else if(prop_type != null)
+ {
+ if(IsBindableType(prop_type))
+ {
+ b_col = new BoundColumn();
+ // b_col.TrackViewState();
+ b_col.HeaderText = "Item";
+ b_col.SortExpression = "Item";
+ b_col.DataField = BoundColumn.thisExpr;
+ //b_col.SetOwner(this);
+ retVal.Add(b_col);
+ } else
+ {
+ props = TypeDescriptor.GetProperties(prop_type);
+ }
+ }
+ }
+ }
+ if(props != null && props.Count > 0)
+ {
+ //IEnumerable p_en = props.GetEnumerator();
+ try
+ {
+ foreach(PropertyDescriptor current in props)
+ {
+ if(IsBindableType(current.PropertyType))
+ {
+ b_col = new BoundColumn();
+ // b_col.TrackViewState();
+ b_col.HeaderText = current.Name;
+ b_col.SortExpression = current.Name;
+ b_col.DataField = current.Name;
+ // b_col.IsReadOnly = current.IsReadOnly;
+ // b_col.SetOwner(this);
+ retVal.Add(b_col);
+ }
+ }
+ } finally
+ {
+ if(props is IDisposable)
+ ((IDisposable)props).Dispose();
+ }
+ }
+ if(retVal.Count > 0)
+ {
+ return retVal;
+ }
+ throw new HttpException(HttpRuntime.FormatResourceString("DataGrid_NoAutoGenColumns", ID));
+ }
+ return null;
+ }
+
+ internal void StoreEnumerator(IEnumerator source, object firstItem)
+ {
+ storedData = source;
+ storedDataFirst = firstItem;
+ storedDataValid = true;
+ }
+
+ internal void OnColumnsChanged()
+ {
+ }
+
+ internal void OnPagerChanged()
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs
new file mode 100644
index 00000000000..8c210eac4ad
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs
@@ -0,0 +1,408 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGridColumn
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [TypeConverter(typeof(ExpandableObjectConverter))]
+ public abstract class DataGridColumn : IStateManager
+ {
+ private StateBag viewState;
+ private bool marked;
+ private TableItemStyle footerStyle;
+ private TableItemStyle headerStyle;
+ private TableItemStyle itemStyle;
+
+ private DataGrid owner;
+ private bool designMode;
+
+ public DataGridColumn()
+ {
+ viewState = new StateBag();
+ }
+
+ internal TableItemStyle FooterStyleInternal
+ {
+ get
+ {
+ return footerStyle;
+ }
+ }
+
+ internal TableItemStyle HeaderStyleInternal
+ {
+ get
+ {
+ return headerStyle;
+ }
+ }
+
+ internal TableItemStyle ItemStyleInternal
+ {
+ get
+ {
+ return itemStyle;
+ }
+ }
+
+ public virtual TableItemStyle FooterStyle
+ {
+ get
+ {
+ if(footerStyle == null)
+ {
+ footerStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ {
+ footerStyle.TrackViewState();
+ }
+ }
+ return footerStyle;
+ }
+ }
+
+ public virtual TableItemStyle HeaderStyle
+ {
+ get
+ {
+ if(headerStyle == null)
+ {
+ headerStyle= new TableItemStyle();
+ if(IsTrackingViewState)
+ {
+ headerStyle.TrackViewState();
+ }
+ }
+ return headerStyle;
+ }
+ }
+
+ public virtual TableItemStyle ItemStyle
+ {
+ get
+ {
+ if(itemStyle == null)
+ {
+ itemStyle = new TableItemStyle();
+ if(IsTrackingViewState)
+ {
+ itemStyle.TrackViewState();
+ }
+ }
+ return itemStyle;
+ }
+ }
+
+ public virtual string FooterText
+ {
+ get
+ {
+ object o = ViewState["FooterText"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["FooterText"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual string HeaderImageUrl
+ {
+ get
+ {
+ object o = ViewState["HeaderImageUrl"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["HeaderImageUrl"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual string HeaderText
+ {
+ get
+ {
+ object o = ViewState["HeaderText"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["HeaderText"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual string SortExpression
+ {
+ get
+ {
+ object o = ViewState["SortExpression"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["SortExpression"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ public bool Visible
+ {
+ get
+ {
+ object o = ViewState["Visible"];
+ if(o != null)
+ {
+ return (bool)o;
+ }
+ return true;
+ }
+ set
+ {
+ ViewState["Visible"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual void Initialize()
+ {
+ if(owner != null && owner.Site != null)
+ {
+ designMode = owner.Site.DesignMode;
+ }
+ }
+
+ public virtual void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
+ {
+ switch(itemType)
+ {
+ case ListItemType.Header : InitializeCellHeader(cell, columnIndex);
+ break;
+ case ListItemType.Footer : InitializeCellFooter(cell, columnIndex);
+ break;
+ default : return;
+ }
+ }
+
+ private void InitializeCellHeader(TableCell cell, int columnIndex)
+ {
+ WebControl ctrl = null;
+ bool sort = true;
+ string sortExpr = "";
+ ImageButton headButton;
+ Image headImage;
+ LinkButtonInternal link;
+
+ if(owner != null)
+ {
+ sort = owner.AllowSorting;
+ }
+ if(sort)
+ {
+ sortExpr = SortExpression;
+ if(sortExpr.Length == 0)
+ {
+ sort = false;
+ }
+ }
+ if(HeaderImageUrl.Length > 0)
+ {
+ if(sort)
+ {
+ headButton = new ImageButton();
+ headButton.ImageUrl = HeaderImageUrl;
+ headButton.CommandName = "Sort";
+ headButton.CommandArgument = sortExpr;
+ headButton.CausesValidation = false;
+ ctrl = headButton;
+ } else
+ {
+ headImage = new Image();
+ headImage.ImageUrl = HeaderImageUrl;
+ ctrl = headImage;
+ }
+ } else
+ {
+ if(sort)
+ {
+ link = new LinkButtonInternal();
+ link.Text = HeaderText;
+ link.CommandName = "Sort";
+ link.CommandArgument = sortExpr;
+ link.CausesValidation = false;
+ ctrl = link;
+ } else
+ {
+ if(HeaderText.Length > 0)
+ {
+ cell.Text = HeaderText;
+ } else
+ {
+ cell.Text = "&nbsp;";
+ }
+ }
+ }
+ if(ctrl != null)
+ {
+ cell.Controls.Add(ctrl);
+ }
+ }
+
+ private void InitializeCellFooter(TableCell cell, int columnIndex)
+ {
+ cell.Text = (FooterText.Length > 0 ? FooterText : "&nbsp;");
+ }
+
+ public override string ToString()
+ {
+ return String.Empty;
+ }
+
+ protected bool DesignMode
+ {
+ get
+ {
+ return designMode;
+ }
+ }
+
+ protected DataGrid Owner
+ {
+ get
+ {
+ return owner;
+ }
+ }
+
+ protected StateBag ViewState
+ {
+ get
+ {
+ return viewState;
+ }
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ protected virtual void OnColumnChanged()
+ {
+ if(owner != null)
+ {
+ owner.OnColumnsChanged();
+ }
+ }
+
+ internal void SetOwner (DataGrid datagrid)
+ {
+ owner = datagrid;
+ }
+
+ protected virtual object SaveViewState()
+ {
+ object[] states = new object[4];
+ states[0] = ViewState.SaveViewState();
+ states[1] = (footerStyle == null ? null : footerStyle.SaveViewState());
+ states[2] = (headerStyle == null ? null : headerStyle.SaveViewState());
+ states[3] = (itemStyle == null ? null : itemStyle.SaveViewState());
+ return states;
+ }
+
+ protected virtual void LoadViewState(object savedState)
+ {
+ if(savedState!= null)
+ {
+ object[] states = (object[]) savedState;
+ if(states != null)
+ {
+ ViewState.LoadViewState(states[0]);
+ FooterStyle.LoadViewState(states[1]);
+ HeaderStyle.LoadViewState(states[2]);
+ ItemStyle.LoadViewState(states[3]);
+ }
+ }
+ }
+
+ protected virtual void TrackViewState()
+ {
+ marked = true;
+ ViewState.TrackViewState();
+ if(footerStyle != null)
+ {
+ footerStyle.TrackViewState();
+ }
+ if(headerStyle != null)
+ {
+ headerStyle.TrackViewState();
+ }
+ if(itemStyle != null)
+ {
+ itemStyle.TrackViewState();
+ }
+ }
+
+ protected bool IsTrackingViewState
+ {
+ get
+ {
+ return marked;
+ }
+ }
+
+ void IStateManager.LoadViewState(object savedState)
+ {
+ LoadViewState(savedState);
+ }
+
+ object IStateManager.SaveViewState()
+ {
+ return SaveViewState();
+ }
+
+ void IStateManager.TrackViewState()
+ {
+ TrackViewState();
+ }
+
+ bool IStateManager.IsTrackingViewState
+ {
+ get
+ {
+ return IsTrackingViewState;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs
new file mode 100644
index 00000000000..3e27ed35764
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs
@@ -0,0 +1,186 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGridColumnCollection
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: ??%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class DataGridColumnCollection : ICollection, IEnumerable, IStateManager
+ {
+ private DataGrid owner;
+ private ArrayList columns;
+ private bool trackViewState = false;
+
+ public DataGridColumnCollection(DataGrid owner, ArrayList columns)
+ {
+ this.owner = owner;
+ this.columns = columns;
+ }
+
+ public int Count
+ {
+ get
+ {
+ return columns.Count;
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public DataGridColumn this[int index]
+ {
+ get
+ {
+ return (DataGridColumn)(columns[index]);
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public void Add(DataGridColumn column)
+ {
+ AddAt(-1, column);
+ }
+
+ public void AddAt(int index, DataGridColumn column)
+ {
+ if(index == -1)
+ {
+ columns.Add(column);
+ } else
+ {
+ columns.Insert(index, column);
+ }
+
+ column.SetOwner (owner);
+ if(trackViewState)
+ {
+ ((IStateManager)column).TrackViewState();
+ }
+ OnColumnsChanged();
+ }
+
+ internal void OnColumnsChanged()
+ {
+ if(owner != null)
+ {
+ owner.OnColumnsChanged();
+ }
+ }
+
+ public void Clear()
+ {
+ columns.Clear();
+ OnColumnsChanged();
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ foreach(DataGridColumn current in this)
+ {
+ array.SetValue(current, index++);
+ }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return columns.GetEnumerator();
+ }
+
+ public int IndexOf(DataGridColumn column)
+ {
+ if(column != null)
+ {
+ return columns.IndexOf(column);
+ }
+ return -1;
+ }
+
+ public void Remove(DataGridColumn column)
+ {
+ if(column != null)
+ {
+ RemoveAt(IndexOf(column));
+ }
+ }
+
+ public void RemoveAt(int index)
+ {
+ if(index >= 0 && index < columns.Count)
+ {
+ columns.RemoveAt(index);
+ OnColumnsChanged();
+ }
+ //This exception is not documented, but thrown
+ throw new ArgumentOutOfRangeException("string");
+ }
+
+ object IStateManager.SaveViewState()
+ {
+ ArrayList retVal = new ArrayList(columns.Count);
+ foreach(DataGridColumn current in this)
+ {
+ retVal.Add(((IStateManager)current).SaveViewState());
+ }
+ return retVal;
+ }
+
+ void IStateManager.LoadViewState(object savedState)
+ {
+ if(savedState != null && savedState is ArrayList)
+ {
+ int currentIndex = 0;
+ foreach(DataGridColumn current in (ArrayList)savedState)
+ {
+ ((IStateManager)columns[currentIndex ++]).LoadViewState(current);
+ }
+ }
+ }
+
+ void IStateManager.TrackViewState()
+ {
+ trackViewState = true;
+ }
+
+ bool IStateManager.IsTrackingViewState
+ {
+ get
+ {
+ return trackViewState;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridCommandEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridCommandEventArgs.cs
new file mode 100644
index 00000000000..e5850371123
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridCommandEventArgs.cs
@@ -0,0 +1,46 @@
+/**
+* Namespace: System.Web.UI.WebControls
+* Class: DataGridCommandEventArgs
+*
+* Author: Gaurav Vaish
+* Maintainer: gvaish@iitk.ac.in
+* Implementation: yes
+* Status: 100%
+*
+* (C) Gaurav Vaish (2001)
+*/
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class DataGridCommandEventArgs : CommandEventArgs
+ {
+ DataGridItem dgItem;
+ object cmdSrc;
+
+ public DataGridCommandEventArgs(DataGridItem item, object commandSource, CommandEventArgs originalArgs): base(originalArgs)
+ {
+ dgItem = item;
+ cmdSrc = originalArgs;
+ }
+
+ public object CommandSource
+ {
+ get
+ {
+ return cmdSrc;
+ }
+ }
+
+ public DataGridItem Item
+ {
+ get
+ {
+ return dgItem;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridCommandEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridCommandEventHandler.cs
new file mode 100644
index 00000000000..bd06eed39f4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridCommandEventHandler.cs
@@ -0,0 +1,17 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Delegate: DataGridCommandEventHandler
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void DataGridCommandEventHandler(object sender, DataGridCommandEventArgs e);
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItem.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItem.cs
new file mode 100644
index 00000000000..5833b0f5b3b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItem.cs
@@ -0,0 +1,86 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGridItem
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class DataGridItem : TableRow, INamingContainer
+ {
+ private int itemIndex;
+ private int dataSetIndex;
+ private ListItemType itemType;
+ private object dataItem;
+
+ public DataGridItem(int itemIndex, int dataSetIndex, ListItemType itemType): base()
+ {
+ this.itemIndex = itemIndex;
+ this.dataSetIndex = dataSetIndex;
+ this.itemType = itemType;
+ }
+
+ public virtual object DataItem
+ {
+ get
+ {
+ return dataItem;
+ }
+ set
+ {
+ dataItem = value;
+ }
+ }
+
+ public virtual int DataSetIndex
+ {
+ get
+ {
+ return dataSetIndex;
+ }
+ }
+
+ public virtual int ItemIndex
+ {
+ get
+ {
+ return itemIndex;
+ }
+ }
+
+ public virtual ListItemType ItemType
+ {
+ get
+ {
+ return itemType;
+ }
+ }
+
+ protected override bool OnBubbleEvent(object source, EventArgs e)
+ {
+ if(e is CommandEventArgs)
+ {
+ DataGridCommandEventArgs args = new DataGridCommandEventArgs(this, source, (CommandEventArgs)e);
+ RaiseBubbleEvent(this, args);
+ return true;
+ }
+ return false;
+ }
+
+ protected internal virtual void SetItemType(ListItemType itemType)
+ {
+ this.itemType = itemType;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemCollection.cs
new file mode 100644
index 00000000000..8f73b541336
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemCollection.cs
@@ -0,0 +1,83 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGridItemCollection
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class DataGridItemCollection : ICollection, IEnumerable
+ {
+ private ArrayList items;
+
+ public DataGridItemCollection(ArrayList items)
+ {
+ this.items = items;
+ }
+
+ public int Count
+ {
+ get
+ {
+ return items.Count;
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public DataGridItem this[int index]
+ {
+ get
+ {
+ return (DataGridItem)(items[index]);
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ foreach(DataGridItem current in this)
+ {
+ array.SetValue(current, index++);
+ }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return items.GetEnumerator();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemEventArgs.cs
new file mode 100644
index 00000000000..4418b4cf00a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemEventArgs.cs
@@ -0,0 +1,37 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGridItemEventArgs
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class DataGridItemEventArgs : EventArgs
+ {
+ DataGridItem item;
+
+ public DataGridItemEventArgs(DataGridItem item)
+ {
+ this.item = item;
+ }
+
+ public DataGridItem Item
+ {
+ get
+ {
+ return item;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemEventHandler.cs
new file mode 100644
index 00000000000..de0f92cfa30
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridItemEventHandler.cs
@@ -0,0 +1,17 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Delegate: DataGridItemEventHandler
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void DataGridItemEventHandler(object sender, DataGridItemEventArgs e);
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridLinkButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridLinkButton.cs
new file mode 100755
index 00000000000..dab62d84d63
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridLinkButton.cs
@@ -0,0 +1,54 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGridLinkButton
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish_mono@lycos.com
+ * Contact: <gvaish_mono@lycos.com>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Drawing;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ class DataGridLinkButton : LinkButton
+ {
+ public DataGridLinkButton() : base()
+ {
+ }
+
+ protected override void Render(HtmlTextWriter writer)
+ {
+ SetForeColor();
+ base.Render(writer);
+ }
+
+ private void SetForeColor()
+ {
+ if(!ControlStyle.IsSet(System.Web.UI.WebControls.Style.FORECOLOR))
+ {
+ Control ctrl = this;
+ int level = 0;
+ while(level < 3)
+ {
+ ctrl = ctrl.Parent;
+ Color foreColor = ((WebControl)ctrl).ForeColor;
+ if(foreColor != Color.Empty)
+ {
+ ForeColor = foreColor;
+ return;
+ }
+ level++;
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridPageChangedEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridPageChangedEventArgs.cs
new file mode 100644
index 00000000000..d63ac4940f9
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridPageChangedEventArgs.cs
@@ -0,0 +1,47 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGridPageChangedEventArgs
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class DataGridPageChangedEventArgs : EventArgs
+ {
+ private object source;
+ private int npIndex;
+
+ public DataGridPageChangedEventArgs(object commandSource, int newPageIndex)
+ {
+ source = commandSource;
+ npIndex = newPageIndex;
+ }
+
+ public object CommandSource
+ {
+ get
+ {
+ return source;
+ }
+ }
+
+ public int NewPageIndex
+ {
+ get
+ {
+ return npIndex;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridPageChangedEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridPageChangedEventHandler.cs
new file mode 100644
index 00000000000..83dfc6d0dde
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridPageChangedEventHandler.cs
@@ -0,0 +1,16 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void DataGridPageChangedEventHandler(object sender, DataGridPageChangedEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridPagerStyle.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridPagerStyle.cs
new file mode 100644
index 00000000000..ea602ef5166
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridPagerStyle.cs
@@ -0,0 +1,257 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGridPagerStyle
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class DataGridPagerStyle : TableItemStyle
+ {
+ DataGrid owner;
+
+ private static int MODE = (0x01 << 19);
+ private static int NEXT_PG_TEXT = (0x01 << 20);
+ private static int PG_BTN_COUNT = (0x01 << 21);
+ private static int POSITION = (0x01 << 22);
+ private static int VISIBLE = (0x01 << 23);
+ private static int PREV_PG_TEXT = (0x01 << 24);
+
+ internal DataGridPagerStyle(DataGrid owner): base()
+ {
+ this.owner = owner;
+ }
+
+ internal bool IsPagerOnTop
+ {
+ get {
+ PagerPosition p = Position;
+ return (p == PagerPosition.Top || p == PagerPosition.TopAndBottom);
+ }
+ }
+
+ internal bool IsPagerOnBottom
+ {
+ get {
+ PagerPosition p = Position;
+ return (p == PagerPosition.Bottom || p == PagerPosition.TopAndBottom);
+ }
+ }
+
+ public PagerMode Mode
+ {
+ get
+ {
+ if(IsSet(MODE))
+ {
+ return (PagerMode)ViewState["Mode"];
+ }
+ return PagerMode.NextPrev;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(PagerMode), value))
+ {
+ throw new ArgumentOutOfRangeException("value");
+ }
+ ViewState["Mode"] = value;
+ Set(MODE);
+ }
+ }
+
+ public string NextPageText
+ {
+ get
+ {
+ if(IsSet(NEXT_PG_TEXT))
+ {
+ return (string)ViewState["NextPageText"];
+ }
+ return "&gt;";
+ }
+ set
+ {
+ ViewState["NextPageText"] = value;
+ Set(NEXT_PG_TEXT);
+ }
+ }
+
+ public string PrevPageText
+ {
+ get
+ {
+ if(IsSet(PREV_PG_TEXT))
+ {
+ return (string)ViewState["PrevPageText"];
+ }
+ return "&lt;";
+ }
+ set
+ {
+ ViewState["PrevPageText"] = value;
+ Set(PREV_PG_TEXT);
+ }
+ }
+
+ public int PageButtonCount
+ {
+ get
+ {
+ if(IsSet(PG_BTN_COUNT))
+ {
+ return (int)ViewState["PageButtonCount"];
+ }
+ return 10;
+ }
+ set
+ {
+ ViewState["PageButtonCount"] = value;
+ Set(PG_BTN_COUNT);
+ }
+ }
+
+ public PagerPosition Position
+ {
+ get
+ {
+ if(IsSet(POSITION))
+ {
+ return (PagerPosition)ViewState["Position"];
+ }
+ return PagerPosition.Bottom;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(PagerPosition), value))
+ {
+ throw new ArgumentException();
+ }
+ ViewState["Position"] = value;
+ Set(POSITION);
+ }
+ }
+
+ public bool Visible
+ {
+ get
+ {
+ if(IsSet(VISIBLE))
+ {
+ return (bool)ViewState["Visible"];
+ }
+ return true;
+ }
+ set
+ {
+ ViewState["Visible"] = value;
+ Set(PG_BTN_COUNT);
+ }
+ }
+
+ public override void CopyFrom(Style s)
+ {
+ if(s != null && !s.IsEmpty && s is DataGridPagerStyle)
+ {
+ base.CopyFrom(s);
+ DataGridPagerStyle from = (DataGridPagerStyle)s;
+ if(from.IsSet(MODE))
+ {
+ Mode = from.Mode;
+ }
+ if(from.IsSet(NEXT_PG_TEXT))
+ {
+ NextPageText = from.NextPageText;
+ }
+ if(from.IsSet(PG_BTN_COUNT))
+ {
+ PageButtonCount = from.PageButtonCount;
+ }
+ if(from.IsSet(POSITION))
+ {
+ Position = from.Position;
+ }
+ if(from.IsSet(VISIBLE))
+ {
+ Visible = from.Visible;
+ }
+ if(from.IsSet(PREV_PG_TEXT))
+ {
+ PrevPageText = from.PrevPageText;
+ }
+ }
+ }
+
+ public override void MergeWith(Style s)
+ {
+ if(s != null && !s.IsEmpty && s is DataGridPagerStyle)
+ {
+ base.MergeWith(s);
+ DataGridPagerStyle with = (DataGridPagerStyle)s;
+ if(with.IsSet(MODE) && !IsSet(MODE))
+ {
+ Mode = with.Mode;
+ }
+ if(with.IsSet(NEXT_PG_TEXT) && !IsSet(NEXT_PG_TEXT))
+ {
+ NextPageText = with.NextPageText;
+ }
+ if(with.IsSet(PG_BTN_COUNT) && !IsSet(PG_BTN_COUNT))
+ {
+ PageButtonCount = with.PageButtonCount;
+ }
+ if(with.IsSet(POSITION) && !IsSet(POSITION))
+ {
+ Position = with.Position;
+ }
+ if(with.IsSet(VISIBLE) && !IsSet(VISIBLE))
+ {
+ Visible = with.Visible;
+ }
+ if(with.IsSet(PREV_PG_TEXT) && !IsSet(PREV_PG_TEXT))
+ {
+ PrevPageText = with.PrevPageText;
+ }
+ }
+ }
+
+ public override void Reset()
+ {
+ if(IsSet(MODE))
+ {
+ ViewState.Remove("Mode");
+ }
+ if(IsSet(NEXT_PG_TEXT))
+ {
+ ViewState.Remove("NextPageText");
+ }
+ if(IsSet(PG_BTN_COUNT))
+ {
+ ViewState.Remove("PageButtonCount");
+ }
+ if(IsSet(POSITION))
+ {
+ ViewState.Remove("Position");
+ }
+ if(IsSet(VISIBLE))
+ {
+ ViewState.Remove("Visible");
+ }
+ if(IsSet(PREV_PG_TEXT))
+ {
+ ViewState.Remove("PrevPageText");
+ }
+ base.Reset();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridSortCommandEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridSortCommandEventArgs.cs
new file mode 100644
index 00000000000..564451fbb7a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridSortCommandEventArgs.cs
@@ -0,0 +1,47 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGridSortCommandEventArgs
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class DataGridSortCommandEventArgs : EventArgs
+ {
+ private object source;
+ private string sortExpr;
+
+ public DataGridSortCommandEventArgs(object commandSource, DataGridCommandEventArgs dce)
+ {
+ source = commandSource;
+ sortExpr = (string)dce.CommandArgument;
+ }
+
+ public object CommandSource
+ {
+ get
+ {
+ return source;
+ }
+ }
+
+ public string SortExpression
+ {
+ get
+ {
+ return sortExpr;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridSortCommandEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridSortCommandEventHandler.cs
new file mode 100644
index 00000000000..b9a1d2653b7
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridSortCommandEventHandler.cs
@@ -0,0 +1,16 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void DataGridSortCommandEventHandler(object sender, DataGridSortCommandEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridTableInternal.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridTableInternal.cs
new file mode 100755
index 00000000000..e5d29f97570
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridTableInternal.cs
@@ -0,0 +1,31 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataGridTableInternal
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish_mono@lycos.com
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class DataGridTableInternal : Table
+ {
+ public DataGridTableInternal() : base()
+ {
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender(writer);
+ if(ID == null)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Id, Parent.ClientID);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataKeyCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataKeyCollection.cs
new file mode 100644
index 00000000000..f4a010ac49b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataKeyCollection.cs
@@ -0,0 +1,83 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataKeyCollection
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class DataKeyCollection : ICollection, IEnumerable
+ {
+ private ArrayList keys;
+
+ public DataKeyCollection(ArrayList keys)
+ {
+ this.keys = keys;
+ }
+
+ public int Count
+ {
+ get
+ {
+ return keys.Count;
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public object this[int index]
+ {
+ get
+ {
+ return keys[index];
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ foreach(object current in this)
+ {
+ array.SetValue(current, index++);
+ }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return keys.GetEnumerator();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs
new file mode 100755
index 00000000000..3e78627f0c4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs
@@ -0,0 +1,876 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataList
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 98%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+using System.Web.Util;
+
+namespace System.Web.UI.WebControls
+{
+ //TODO: [Designer("??")]
+ //TODO: [Editor("??")]
+ public class DataList: BaseDataList, INamingContainer, IRepeatInfoUser
+ {
+ public const string CancelCommandName = "Cancel";
+ public const string DeleteCommandName = "Delete";
+ public const string EditCommandName = "Edit";
+ public const string SelectCommandName = "Select";
+ public const string UpdateCommandName = "Update";
+
+ static readonly object CancelCommandEvent = new object ();
+ static readonly object DeleteCommandEvent = new object ();
+ static readonly object EditCommandEvent = new object ();
+ static readonly object ItemCommandEvent = new object ();
+ static readonly object ItemCreatedEvent = new object ();
+ static readonly object ItemDataBoundEvent = new object ();
+ static readonly object UpdateCommandEvent = new object ();
+
+ TableItemStyle alternatingItemStyle;
+ TableItemStyle editItemStyle;
+ TableItemStyle footerStyle;
+ TableItemStyle headerStyle;
+ TableItemStyle itemStyle;
+ TableItemStyle selectedItemStyle;
+ TableItemStyle separatorStyle;
+
+ ITemplate alternatingItemTemplate;
+ ITemplate editItemTemplate;
+ ITemplate footerTemplate;
+ ITemplate headerTemplate;
+ ITemplate itemTemplate;
+ ITemplate selectedItemTemplate;
+ ITemplate separatorTemplate;
+ ITemplate separatorItemTemplate;
+
+ ArrayList itemsArray;
+ DataListItemCollection items;
+
+ bool extractTemplateRows;
+
+ public DataList ()
+ {
+ }
+
+ [DefaultValue(null)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+ [NotifyParentProperty(true)]
+ [WebCategory("Style")]
+ [WebSysDescription("The style applied to alternating items.")]
+ public virtual TableItemStyle AlternatingItemStyle {
+ get {
+ if (alternatingItemStyle == null) {
+ alternatingItemStyle = new TableItemStyle ();
+ if (IsTrackingViewState)
+ alternatingItemStyle.TrackViewState ();
+ }
+
+ return alternatingItemStyle;
+ }
+ }
+
+ [Browsable(false)]
+ [DefaultValue(null)]
+ [TemplateContainer(typeof(DataListItem))]
+ [WebSysDescription("The template used for alternating items.")]
+ public virtual ITemplate AlternatingItemTemplate {
+ get { return alternatingItemTemplate; }
+ set { alternatingItemTemplate = value; }
+ }
+
+ [DefaultValue(-1)]
+ [WebCategory("Misc")]
+ [WebSysDescription("The index of the item shown in edit mode.")]
+ public virtual int EditItemIndex {
+ get {
+ object o = ViewState ["EditItemIndex"];
+ if (o != null)
+ return (int) o;
+
+ return -1;
+ }
+
+ set { ViewState ["EditItemIndex"] = value; }
+ }
+
+ [DefaultValue(null)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+ [NotifyParentProperty(true)]
+ [WebCategory("Style")]
+ [WebSysDescription("The style applied to items in edit mode.")]
+ public virtual TableItemStyle EditItemStyle {
+ get {
+ if (editItemStyle == null) {
+ editItemStyle = new TableItemStyle ();
+ if (IsTrackingViewState)
+ editItemStyle.TrackViewState ();
+ }
+
+ return editItemStyle;
+ }
+ }
+
+ public virtual ITemplate EditItemTemplate {
+ get { return editItemTemplate; }
+ set { editItemTemplate = value; }
+ }
+
+ public virtual bool ExtractTemplateRows {
+ get {
+ object o = ViewState ["ExtractTemplateRows"];
+ if (o != null)
+ return (bool) o;
+
+ return false;
+ }
+
+ set { ViewState ["ExtractTemplateRows"] = value; }
+ }
+
+ public virtual TableItemStyle FooterStyle {
+ get {
+ if (footerStyle == null) {
+ footerStyle = new TableItemStyle ();
+ if (IsTrackingViewState)
+ footerStyle.TrackViewState ();
+ }
+
+ return footerStyle;
+ }
+ }
+
+ public virtual ITemplate FooterTemplate {
+ get { return footerTemplate; }
+ set { footerTemplate = value; }
+ }
+
+ public override GridLines GridLines {
+ get { return base.GridLines; }
+ set { base.GridLines = value; }
+ }
+
+ public virtual TableItemStyle HeaderStyle {
+ get {
+ if (headerStyle == null) {
+ headerStyle = new TableItemStyle ();
+ if (IsTrackingViewState)
+ headerStyle.TrackViewState ();
+ }
+
+ return headerStyle;
+ }
+ }
+
+ public virtual ITemplate HeaderTemplate {
+ get { return headerTemplate; }
+ set { headerTemplate = value; }
+ }
+
+ public virtual DataListItemCollection Items {
+ get {
+ if (items == null) {
+ if (itemsArray == null) {
+ EnsureChildControls ();
+ itemsArray = new ArrayList ();
+ }
+ items = new DataListItemCollection (itemsArray);
+ }
+
+ return items;
+ }
+ }
+
+ public virtual TableItemStyle ItemStyle {
+ get {
+ if (itemStyle == null) {
+ itemStyle = new TableItemStyle ();
+ if (IsTrackingViewState)
+ itemStyle.TrackViewState ();
+ }
+
+ return itemStyle;
+ }
+ }
+
+ public virtual ITemplate ItemTemplate {
+ get { return itemTemplate; }
+ set { itemTemplate = value; }
+ }
+
+ public virtual int RepeatColumns {
+ get {
+ object o = ViewState ["RepeatColumns"];
+ if (o != null)
+ return (int) o;
+
+ return 0;
+ }
+ set {
+ if (value < 0)
+ throw new ArgumentOutOfRangeException ("value");
+
+ ViewState ["RepeatColumns"] = value;
+ }
+ }
+
+ public virtual RepeatDirection RepeatDirection {
+ get {
+ object o = ViewState ["RepeatDirection"];
+ if (o != null)
+ return (RepeatDirection) o;
+
+ return RepeatDirection.Vertical;
+ }
+ set {
+ if (!Enum.IsDefined (typeof (RepeatDirection), value))
+ throw new ArgumentException ("value");
+
+ ViewState ["RepeatDirection"] = value;
+ }
+ }
+
+ public virtual RepeatLayout RepeatLayout {
+ get {
+ object o = ViewState ["RepeatLayout"];
+ if (o != null)
+ return (RepeatLayout) o;
+
+ return RepeatLayout.Table;
+ }
+ set {
+ if (!Enum.IsDefined (typeof (RepeatLayout), value))
+ throw new ArgumentException ("value");
+
+ ViewState ["RepeatLayout"] = value;
+ }
+ }
+
+ public virtual int SelectedIndex {
+ get {
+ object o = ViewState ["SelectedIndex"];
+ if (o != null)
+ return (int) o;
+
+ return -1;
+ }
+ set {
+ //FIXME: Looks like a bug in Microsoft's specs.
+ // Exception is missing in document. I haven't tested the case
+ // But I think exception should follow
+ if (value < -1)
+ throw new ArgumentOutOfRangeException("value");
+
+ int prevSel = SelectedIndex;
+ ViewState ["SelectedIndex"] = value;
+ DataListItem prevSelItem;
+ ListItemType liType;
+
+ if (itemsArray != null) {
+ if (prevSel >= 0 && prevSel < itemsArray.Count) {
+ prevSelItem = (DataListItem) itemsArray [prevSel];
+ if (prevSelItem.ItemType != ListItemType.EditItem) {
+ liType = ((prevSel % 2) == 0 ? ListItemType.AlternatingItem :
+ ListItemType.Item);
+
+ prevSelItem.SetItemType (liType);
+ }
+ }
+
+ if (value >= 0 && value < itemsArray.Count) {
+ prevSelItem = (DataListItem) itemsArray [value];
+ if (prevSelItem.ItemType != ListItemType.EditItem) {
+ prevSelItem.SetItemType (ListItemType.SelectedItem);
+ }
+ }
+ }
+ }
+ }
+
+ public virtual DataListItem SelectedItem {
+ get {
+ if (SelectedIndex == -1)
+ return null;
+
+ return Items [SelectedIndex];
+ }
+ }
+
+ public virtual TableItemStyle SelectedItemStyle {
+ get {
+ if (selectedItemStyle == null) {
+ selectedItemStyle = new TableItemStyle ();
+ if (IsTrackingViewState)
+ selectedItemStyle.TrackViewState ();
+ }
+
+ return selectedItemStyle;
+ }
+ }
+
+ public virtual ITemplate SelectedItemTemplate {
+ get { return selectedItemTemplate; }
+ set { selectedItemTemplate = value; }
+ }
+
+ public virtual TableItemStyle SeparatorStyle {
+ get {
+ if (separatorStyle == null) {
+ separatorStyle = new TableItemStyle ();
+ if (IsTrackingViewState)
+ separatorStyle.TrackViewState ();
+ }
+
+ return separatorStyle;
+ }
+ }
+
+ public virtual ITemplate SeparatorTemplate {
+ get { return separatorTemplate; }
+ set { separatorTemplate = value; }
+ }
+
+ public virtual ITemplate SeparatorItemTemplate {
+ get { return separatorItemTemplate; }
+ set { separatorItemTemplate = value; }
+ }
+
+ public virtual bool ShowHeader {
+ get {
+ object o = ViewState ["ShowHeader"];
+ if (o != null)
+ return (bool) o;
+
+ return true;
+ }
+ set { ViewState ["ShowHeader"] = value; }
+ }
+
+ public virtual bool ShowFooter {
+ get {
+ object o = ViewState ["ShowFooter"];
+ if (o != null)
+ return (bool) o;
+
+ return true;
+ }
+ set
+ {
+ ViewState["ShowFooter"] = value;
+ }
+ }
+
+ public event DataListCommandEventHandler CancelCommand {
+ add { Events.AddHandler (CancelCommandEvent, value); }
+ remove { Events.RemoveHandler (CancelCommandEvent, value); }
+ }
+
+ public event DataListCommandEventHandler DeleteCommand {
+ add { Events.AddHandler (DeleteCommandEvent, value); }
+ remove { Events.RemoveHandler (DeleteCommandEvent, value); }
+ }
+
+ public event DataListCommandEventHandler EditCommand {
+ add { Events.AddHandler (EditCommandEvent, value); }
+ remove { Events.RemoveHandler (EditCommandEvent, value); }
+ }
+
+ public event DataListCommandEventHandler ItemCommand {
+ add { Events.AddHandler (ItemCommandEvent, value); }
+ remove { Events.RemoveHandler (ItemCommandEvent, value); }
+ }
+
+ public event DataListCommandEventHandler ItemCreated {
+ add { Events.AddHandler (ItemCreatedEvent, value); }
+ remove { Events.RemoveHandler (ItemCreatedEvent, value); }
+ }
+
+ public event DataListCommandEventHandler ItemDataBound {
+ add { Events.AddHandler (ItemDataBoundEvent, value); }
+ remove { Events.RemoveHandler (ItemDataBoundEvent, value); }
+ }
+
+ public event DataListCommandEventHandler UpdateCommand {
+ add { Events.AddHandler (UpdateCommandEvent, value); }
+ remove { Events.RemoveHandler (UpdateCommandEvent, value); }
+ }
+
+ protected override Style CreateControlStyle ()
+ {
+ TableStyle retVal = new TableStyle (ViewState);
+ retVal.CellSpacing = 0;
+ return retVal;
+ }
+
+ protected override void LoadViewState (object savedState)
+ {
+ if (savedState == null)
+ return;
+
+ object [] states = (object []) savedState;
+
+ if (states [0] != null)
+ base.LoadViewState (states [0]);
+ if (states [1] != null)
+ alternatingItemStyle.LoadViewState (states [1]);
+ if (states [2] != null)
+ editItemStyle.LoadViewState (states [2]);
+ if (states [3] != null)
+ footerStyle.LoadViewState (states [3]);
+ if (states [4] != null)
+ headerStyle.LoadViewState (states [4]);
+ if (states [5] != null)
+ itemStyle.LoadViewState (states [5]);
+ if (states [6] != null)
+ selectedItemStyle.LoadViewState (states [6]);
+ if (states [7] != null)
+ separatorStyle.LoadViewState (states [7]);
+ }
+
+ protected override object SaveViewState()
+ {
+ object [] states = new object [8];
+ states [0] = base.SaveViewState ();
+ states [1] = (alternatingItemStyle == null ? null : alternatingItemStyle.SaveViewState ());
+ states [2] = (editItemStyle == null ? null : editItemStyle.SaveViewState ());
+ states [3] = (footerStyle == null ? null : footerStyle.SaveViewState ());
+ states [4] = (headerStyle == null ? null : headerStyle.SaveViewState ());
+ states [5] = (itemStyle == null ? null : itemStyle.SaveViewState ());
+ states [6] = (selectedItemStyle == null ? null : selectedItemStyle.SaveViewState ());
+ states [7] = (separatorStyle == null ? null : separatorStyle.SaveViewState ());
+ return states;
+ }
+
+ protected override void TrackViewState ()
+ {
+ base.TrackViewState ();
+ if (alternatingItemStyle != null)
+ alternatingItemStyle.TrackViewState ();
+ if (editItemStyle != null)
+ editItemStyle.TrackViewState ();
+ if (footerStyle != null)
+ footerStyle.TrackViewState ();
+ if (headerStyle != null)
+ headerStyle.TrackViewState ();
+ if (itemStyle != null)
+ itemStyle.TrackViewState ();
+ if (selectedItemStyle != null)
+ selectedItemStyle.TrackViewState ();
+ if (separatorStyle != null)
+ separatorStyle.TrackViewState ();
+ }
+
+ protected override bool OnBubbleEvent (object source, EventArgs e)
+ {
+ if (!(e is DataListCommandEventArgs))
+ return false;
+
+ DataListCommandEventArgs args = (DataListCommandEventArgs) e;
+ OnItemCommand (args);
+ string cmdName = args.CommandName.ToLower ();
+
+ if (cmdName == "cancel") {
+ OnCancelCommand (args);
+ } else if (cmdName == "delete") {
+ OnDeleteCommand (args);
+ } else if (cmdName == "edit") {
+ OnEditCommand (args);
+ } else if (cmdName == "select") {
+ SelectedIndex = args.Item.ItemIndex;
+ OnSelectedIndexChanged (EventArgs.Empty);
+ } else if (cmdName == "update") {
+ OnUpdateCommand (args);
+ }
+
+ return true;
+ }
+
+ void InvokeCommandEvent (DataListCommandEventArgs args, object key)
+ {
+ DataListCommandEventHandler dlceh = (DataListCommandEventHandler) Events [key];
+ if (dlceh != null)
+ dlceh (this, args);
+ }
+
+ void InvokeItemEvent (DataListItemEventArgs args, object key)
+ {
+ DataListItemEventHandler dlieh = (DataListItemEventHandler) Events [key];
+ if (dlieh != null)
+ dlieh (this, args);
+ }
+
+ protected virtual void OnCancelCommand (DataListCommandEventArgs e)
+ {
+ InvokeCommandEvent (e, CancelCommandEvent);
+ }
+
+ protected virtual void OnDeleteCommand (DataListCommandEventArgs e)
+ {
+ InvokeCommandEvent (e, DeleteCommandEvent);
+ }
+
+ protected virtual void OnEditCommand (DataListCommandEventArgs e)
+ {
+ InvokeCommandEvent (e, EditCommandEvent);
+ }
+
+ protected virtual void OnItemCommand (DataListCommandEventArgs e)
+ {
+ InvokeCommandEvent (e, ItemCommandEvent);
+ }
+
+ protected virtual void OnItemCreated (DataListItemEventArgs e)
+ {
+ InvokeItemEvent (e, ItemCreatedEvent);
+ }
+
+ protected virtual void OnItemDataBound (DataListItemEventArgs e)
+ {
+ InvokeItemEvent (e, ItemDataBoundEvent);
+ }
+
+ protected virtual void OnUpdateCommand (DataListCommandEventArgs e)
+ {
+ InvokeCommandEvent (e, UpdateCommandEvent);
+ }
+
+ protected override void RenderContents (HtmlTextWriter writer)
+ {
+ if (Controls.Count == 0)
+ return;
+
+ RepeatInfo repeater = new RepeatInfo ();
+ Table templateTable = null;
+ if (extractTemplateRows) {
+ repeater.RepeatDirection = RepeatDirection.Vertical;
+ repeater.RepeatLayout = RepeatLayout.Flow;
+ repeater.RepeatColumns = 1;
+ repeater.OuterTableImplied = true;
+
+ templateTable = new Table ();
+ templateTable.ID = ClientID;
+ templateTable.CopyBaseAttributes (this);
+ templateTable.ApplyStyle (ControlStyle);
+ templateTable.RenderBeginTag (writer);
+ } else {
+ repeater.RepeatDirection = RepeatDirection;
+ repeater.RepeatLayout = RepeatLayout;
+ repeater.RepeatColumns = RepeatColumns;
+ }
+
+ repeater.RenderRepeater (writer, this, ControlStyle, this);
+ if (templateTable != null) {
+ templateTable.RenderEndTag (writer);
+ }
+ }
+
+ private DataListItem GetItem (ListItemType itemType, int repeatIndex)
+ {
+ DataListItem retVal = null;
+ switch (itemType) {
+ case ListItemType.Header:
+ retVal = (DataListItem) Controls [0];
+ break;
+ case ListItemType.Footer:
+ retVal = (DataListItem) Controls [Controls.Count - 1];
+ break;
+ case ListItemType.Item:
+ goto case ListItemType.EditItem;
+ case ListItemType.AlternatingItem:
+ goto case ListItemType.EditItem;
+ case ListItemType.SelectedItem:
+ goto case ListItemType.EditItem;
+ case ListItemType.EditItem:
+ retVal = (DataListItem) Controls [repeatIndex];
+ break;
+ case ListItemType.Separator:
+ int index = 2 * repeatIndex + 1;
+ if (headerTemplate != null)
+ index ++;
+ retVal = (DataListItem) Controls [index];
+ break;
+ }
+ return retVal;
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ protected override void CreateControlHierarchy (bool useDataSource)
+ {
+ IEnumerable source = null;
+ ArrayList dkeys = DataKeysArray;
+
+ if (itemsArray != null) {
+ itemsArray.Clear ();
+ } else {
+ itemsArray = new ArrayList ();
+ }
+
+ extractTemplateRows = ExtractTemplateRows;
+ if (!useDataSource) {
+ int count = (int) ViewState ["_!ItemCount"];
+ if (count != -1) {
+ source = new DataSourceInternal (count);
+ itemsArray.Capacity = count;
+ }
+ } else {
+ dkeys.Clear ();
+ source = DataSourceHelper.GetResolvedDataSource (DataSource, DataMember);
+ if (source is ICollection) {
+ dkeys.Capacity = ((ICollection) source).Count;
+ itemsArray.Capacity = ((ICollection) source).Count;
+ }
+ }
+
+ int itemCount = 0;
+ if (source != null) {
+ int index = 0;
+ int editIndex = EditItemIndex;
+ int selIndex = SelectedIndex;
+ string dataKey = DataKeyField;
+
+ if (headerTemplate != null)
+ CreateItem (-1, ListItemType.Header, useDataSource, null);
+
+ foreach (object current in source) {
+ if (!useDataSource)
+ dkeys.Add (DataBinder.GetPropertyValue (current, dataKey));
+
+ ListItemType type = ListItemType.Item;
+ if (index == editIndex) {
+ type = ListItemType.EditItem;
+ } else if (index == selIndex) {
+ type = ListItemType.SelectedItem;
+ } else if ((index % 2) != 0) {
+ type = ListItemType.AlternatingItem;
+ }
+
+ itemsArray.Add (CreateItem (index, type, useDataSource, current));
+ if (separatorTemplate != null)
+ CreateItem (index, ListItemType.Separator, useDataSource, null);
+ itemCount++;
+ index++;
+ }
+
+ if (footerTemplate != null)
+ CreateItem (-1, ListItemType.Footer, useDataSource, null);
+ }
+
+ if (useDataSource)
+ ViewState ["_!ItemCount"] = (source != null ? itemCount : -1);
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ protected virtual DataListItem CreateItem (int itemIndex, ListItemType itemType)
+ {
+ return new DataListItem (itemIndex, itemType);
+ }
+
+ private DataListItem CreateItem (int itemIndex, ListItemType itemType, bool dataBind, object dataItem)
+ {
+ DataListItem retVal = CreateItem (itemIndex, itemType);
+ DataListItemEventArgs e = new DataListItemEventArgs (retVal);
+ InitializeItem (retVal);
+ if (dataBind)
+ retVal.DataItem = dataItem;
+
+ OnItemCreated (e);
+ Controls.Add (retVal);
+
+ if (dataBind) {
+ retVal.DataBind ();
+ OnItemDataBound (e);
+ retVal.DataItem = null;
+ }
+
+ return retVal;
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ protected override void PrepareControlHierarchy ()
+ {
+ if (Controls.Count == 0)
+ return;
+
+ Style defaultStyle = null;
+ Style rowStyle = null;
+
+ if (alternatingItemStyle != null) {
+ defaultStyle = new TableItemStyle ();
+ defaultStyle.CopyFrom (itemStyle);
+ defaultStyle.CopyFrom (alternatingItemStyle);
+ } else {
+ defaultStyle = itemStyle;
+ }
+
+ foreach (DataListItem current in Controls) {
+ rowStyle = null;
+ switch (current.ItemType) {
+ case ListItemType.Header:
+ if (headerStyle != null)
+ rowStyle = headerStyle;
+ break;
+ case ListItemType.Footer:
+ if (footerStyle != null)
+ rowStyle = footerStyle;
+ break;
+ case ListItemType.Separator:
+ rowStyle = separatorStyle;
+ break;
+ case ListItemType.Item:
+ rowStyle = itemStyle;
+ break;
+ case ListItemType.AlternatingItem:
+ rowStyle = defaultStyle;
+ break;
+ case ListItemType.SelectedItem:
+ rowStyle = new TableItemStyle ();
+ if ((current.ItemIndex % 2) == 0) {
+ rowStyle.CopyFrom (itemStyle);
+ } else {
+ rowStyle.CopyFrom (defaultStyle);
+ }
+ rowStyle.CopyFrom (selectedItemStyle);
+ break;
+ case ListItemType.EditItem:
+ rowStyle = new TableItemStyle ();
+ if ((current.ItemIndex % 2) == 0) {
+ rowStyle.CopyFrom (itemStyle);
+ } else {
+ rowStyle.CopyFrom (defaultStyle);
+ }
+
+ if (current.ItemIndex == SelectedIndex)
+ rowStyle.CopyFrom (selectedItemStyle);
+
+ rowStyle.CopyFrom (editItemStyle);
+ break;
+ }
+
+ if (rowStyle == null)
+ continue;
+
+ if (!extractTemplateRows) {
+ current.MergeStyle (rowStyle);
+ continue;
+ }
+
+ foreach (Control currentCtrl in current.Controls) {
+ if (!(currentCtrl is Table))
+ continue;
+
+ foreach (TableRow cRow in ((Table) currentCtrl).Rows)
+ cRow.MergeStyle (rowStyle);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ protected virtual void InitializeItem (DataListItem item)
+ {
+ ListItemType type = item.ItemType;
+ ITemplate template = itemTemplate;
+
+ switch (type) {
+ case ListItemType.Header:
+ template = headerTemplate;
+ break;
+ case ListItemType.Footer:
+ template = footerTemplate;
+ break;
+ case ListItemType.AlternatingItem:
+ if (alternatingItemTemplate != null)
+ template = alternatingItemTemplate;
+ break;
+ case ListItemType.SelectedItem:
+ if (selectedItemTemplate != null) {
+ template = selectedItemTemplate;
+ break;
+ }
+
+ if ((item.ItemIndex % 2) != 0)
+ goto case ListItemType.AlternatingItem;
+ break;
+ case ListItemType.EditItem:
+ if (editItemTemplate != null) {
+ template = editItemTemplate;
+ break;
+ }
+
+ if (item.ItemIndex == SelectedIndex)
+ goto case ListItemType.SelectedItem;
+
+ if ((item.ItemIndex % 2) != 0)
+ goto case ListItemType.AlternatingItem;
+ break;
+ case ListItemType.Separator:
+ template = separatorTemplate;
+ break;
+ }
+
+ if (template != null)
+ template.InstantiateIn (item);
+ }
+
+ bool IRepeatInfoUser.HasFooter {
+ get { return (ShowFooter && footerTemplate != null); }
+ }
+
+ bool IRepeatInfoUser.HasHeader {
+ get { return (ShowHeader && headerTemplate != null); }
+ }
+
+ bool IRepeatInfoUser.HasSeparators {
+ get { return (separatorItemTemplate != null); }
+ }
+
+ int IRepeatInfoUser.RepeatedItemCount {
+ get {
+ if (itemsArray != null)
+ return itemsArray.Count;
+
+ return 0;
+ }
+ }
+
+ void IRepeatInfoUser.RenderItem (ListItemType itemType,
+ int repeatIndex,
+ RepeatInfo repeatInfo,
+ HtmlTextWriter writer)
+ {
+ DataListItem item = GetItem (itemType, repeatIndex);
+ if (item != null)
+ item.RenderItem (writer,
+ extractTemplateRows,
+ (repeatInfo.RepeatLayout == RepeatLayout.Table));
+ }
+
+ Style IRepeatInfoUser.GetItemStyle (ListItemType itemType, int repeatIndex)
+ {
+ DataListItem item = GetItem (itemType, repeatIndex);
+ if (item == null || !item.ControlStyleCreated)
+ return null;
+
+ return item.ControlStyle;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataListCommandEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataListCommandEventArgs.cs
new file mode 100644
index 00000000000..93511a27730
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataListCommandEventArgs.cs
@@ -0,0 +1,46 @@
+/**
+* Namespace: System.Web.UI.WebControls
+* Class: DataListCommandEventArgs
+*
+* Author: Gaurav Vaish
+* Maintainer: gvaish@iitk.ac.in
+* Implementation: yes
+* Status: 100%
+*
+* (C) Gaurav Vaish (2001)
+*/
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class DataListCommandEventArgs: CommandEventArgs
+ {
+ private DataListItem dlItem;
+ private object cmdSrc;
+
+ public DataListCommandEventArgs(DataListItem item, object commandSource, CommandEventArgs originalArgs): base(originalArgs)
+ {
+ dlItem = item;
+ cmdSrc = commandSource;
+ }
+
+ public object CommandSource
+ {
+ get
+ {
+ return cmdSrc;
+ }
+ }
+
+ public DataListItem Item
+ {
+ get
+ {
+ return dlItem;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataListCommandEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataListCommandEventHandler.cs
new file mode 100644
index 00000000000..59df1b2fe50
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataListCommandEventHandler.cs
@@ -0,0 +1,16 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void DataListCommandEventHandler(object sender, DataListCommandEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataListItem.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataListItem.cs
new file mode 100644
index 00000000000..8c820047a8a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataListItem.cs
@@ -0,0 +1,112 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataListItem
+ *
+ * Authors: Gaurav Vaish, Gonzalo Paniagua (gonzalo@ximian.com)
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ * (c) 2002 Ximian, Inc. (http://www.ximian.com)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [ToolboxItem(false)]
+ public class DataListItem : WebControl, INamingContainer
+ {
+ int itemIndex;
+ ListItemType itemType;
+ object dataItem;
+
+ public DataListItem(int itemIndex, ListItemType itemType)
+ {
+ this.itemIndex = itemIndex;
+ this.itemType = itemType;
+ }
+
+ public virtual object DataItem
+ {
+ get
+ {
+ return dataItem;
+ }
+ set
+ {
+ dataItem = value;
+ }
+ }
+
+ public virtual int ItemIndex
+ {
+ get
+ {
+ return itemIndex;
+ }
+ }
+
+ public virtual ListItemType ItemType
+ {
+ get
+ {
+ return itemType;
+ }
+ }
+
+ public virtual void RenderItem (HtmlTextWriter writer, bool extractRows, bool tableLayout)
+ {
+ if (extractRows){
+ Table tbl = null;
+ foreach (Control ctrl in Controls){
+ if (ctrl is Table){
+ tbl = (Table) ctrl;
+ break;
+ }
+ }
+
+ if (tbl == null)
+ throw new HttpException ("Template table not found!");
+
+ foreach (TableRow row in tbl.Rows)
+ row.RenderControl (writer);
+ } else {
+ if (tableLayout)
+ RenderContents (writer);
+ else
+ RenderControl (writer);
+ }
+
+ }
+
+ protected override Style CreateControlStyle()
+ {
+ return new TableItemStyle();
+ }
+
+ protected override bool OnBubbleEvent(object source, EventArgs e)
+ {
+ if(e is CommandEventArgs)
+ {
+ RaiseBubbleEvent(this, new DataListCommandEventArgs(this, source, (CommandEventArgs)e));
+ return true;
+ }
+ return false;
+ }
+
+ protected internal virtual void SetItemType(ListItemType itemType)
+ {
+ if(Enum.IsDefined(typeof(ListItemType), itemType))
+ {
+ this.itemType = itemType;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataListItemCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataListItemCollection.cs
new file mode 100644
index 00000000000..b98df0906d1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataListItemCollection.cs
@@ -0,0 +1,83 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataListItemCollection
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class DataListItemCollection : ICollection, IEnumerable
+ {
+ private ArrayList items;
+
+ public DataListItemCollection(ArrayList items)
+ {
+ this.items = items;
+ }
+
+ public int Count
+ {
+ get
+ {
+ return items.Count;
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public DataListItem this[int index]
+ {
+ get
+ {
+ return (DataListItem)(items[index]);
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ foreach(DataListItem current in this)
+ {
+ array.SetValue(current, index++);
+ }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return items.GetEnumerator();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataListItemEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataListItemEventArgs.cs
new file mode 100644
index 00000000000..f9488bea1a6
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataListItemEventArgs.cs
@@ -0,0 +1,37 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataListItemEventArgs
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class DataListItemEventArgs : EventArgs
+ {
+ private DataListItem item;
+
+ public DataListItemEventArgs(DataListItem item)
+ {
+ this.item = item;
+ }
+
+ public DataListItem Item
+ {
+ get
+ {
+ return item;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataListItemEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataListItemEventHandler.cs
new file mode 100644
index 00000000000..3310857658d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataListItemEventHandler.cs
@@ -0,0 +1,16 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void DataListItemEventHandler(object sender, DataListItemEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataSourceInternal.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataSourceInternal.cs
new file mode 100755
index 00000000000..aa0d2885777
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataSourceInternal.cs
@@ -0,0 +1,108 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DataSourceInternal
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish_mono@lycos.com
+ * Contact: gvaish_mono@lycos.com
+ * Implementation: Yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ internal class DataSourceInternal : ICollection, IEnumerable
+ {
+ private int itemCount;
+
+ public DataSourceInternal(int itemCount)
+ {
+ this.itemCount = itemCount;
+ }
+
+ public int Count
+ {
+ get
+ {
+ return itemCount;
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ IEnumerator e = GetEnumerator();
+ while(e.MoveNext())
+ {
+ array.SetValue(e.Current, index);
+ index++;
+ }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return new DataSourceEnumeratorInternal(itemCount);
+ }
+
+ private class DataSourceEnumeratorInternal : IEnumerator
+ {
+ private int count;
+ private int index;
+
+ public DataSourceEnumeratorInternal(int count)
+ {
+ this.count = count;
+ this.index = -1;
+ }
+
+ public bool MoveNext()
+ {
+ index++;
+ return (index < count);
+ }
+
+ public object Current
+ {
+ get
+ {
+ return null;
+ }
+ }
+
+ public void Reset()
+ {
+ this.index = -1;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DayNameFormat.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DayNameFormat.cs
new file mode 100755
index 00000000000..39aaffb4b83
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DayNameFormat.cs
@@ -0,0 +1,23 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: DayNameFormat
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum DayNameFormat
+ {
+ Full,
+ Short,
+ FirstLetter,
+ FirstTwoLetters
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DayRenderEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DayRenderEventArgs.cs
new file mode 100644
index 00000000000..a7e50cf9cdd
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DayRenderEventArgs.cs
@@ -0,0 +1,43 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Delegate: DayRenderEventArgs
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class DayRenderEventArgs
+ {
+ private TableCell cell;
+ private CalendarDay day;
+
+ public DayRenderEventArgs(TableCell cell, CalendarDay day)
+ {
+ this.cell = cell;
+ this.day = day;
+ }
+
+ public TableCell Cell
+ {
+ get
+ {
+ return cell;
+ }
+ }
+
+ public CalendarDay Day
+ {
+ get
+ {
+ return day;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DayRenderEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DayRenderEventHandler.cs
new file mode 100644
index 00000000000..1501321ffb9
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DayRenderEventHandler.cs
@@ -0,0 +1,17 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Delegate: DayRenderEventHandler
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void DayRenderEventHandler(object sender, DayRenderEventArgs e);
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs
new file mode 100644
index 00000000000..6f05c7eab35
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs
@@ -0,0 +1,160 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: DropDownList
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Drawing;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [ValidationProperty("SelectedItem")]
+ public class DropDownList : ListControl, IPostBackDataHandler
+ {
+ public DropDownList(): base()
+ {
+ }
+
+ public override Color BorderColor
+ {
+ get
+ {
+ return base.BorderColor;
+ }
+ set
+ {
+ base.BorderColor = value;
+ }
+ }
+
+ public override BorderStyle BorderStyle
+ {
+ get
+ {
+ return base.BorderStyle;
+ }
+ set
+ {
+ base.BorderStyle = value;
+ }
+ }
+
+ public override Unit BorderWidth
+ {
+ get
+ {
+ return base.BorderWidth;
+ }
+ set
+ {
+ base.BorderWidth = value;
+ }
+ }
+
+ public override int SelectedIndex
+ {
+ get
+ {
+ int index = base.SelectedIndex;
+ if (index < 0 && Items.Count > 0) {
+ index = 0;
+ Items [0].Selected = true;
+ }
+ return index;
+ }
+ set
+ {
+ base.SelectedIndex = value;
+ }
+ }
+
+ public override string ToolTip
+ {
+ // MS ignores the tooltip for this one
+ get {
+ return String.Empty;
+ }
+ set {
+ }
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ if(Page != null)
+ {
+ Page.VerifyRenderingInServerForm(this);
+ }
+ writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
+ base.AddAttributesToRender(writer);
+
+ if(AutoPostBack && Page != null)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Onchange, Page.GetPostBackClientEvent(this,""));
+ writer.AddAttribute("language", "javascript");
+ }
+ }
+
+ protected override ControlCollection CreateControlCollection()
+ {
+ return new EmptyControlCollection(this);
+ }
+
+ protected override void RenderContents(HtmlTextWriter writer)
+ {
+ if(Items != null)
+ {
+ bool selected = false;
+ foreach(ListItem current in Items)
+ {
+ writer.WriteBeginTag("option");
+ if(current.Selected)
+ {
+ if(selected)
+ {
+ throw new HttpException(HttpRuntime.FormatResourceString("Cannot_Multiselect_In_DropDownList"));
+ }
+ selected = true;
+ writer.WriteAttribute("selected", "selected", false);
+ }
+ writer.WriteAttribute("value", current.Value, true);
+ writer.Write('>');
+ HttpUtility.HtmlEncode(current.Text, writer);
+ writer.WriteEndTag("option");
+ writer.WriteLine();
+ }
+ }
+ }
+
+ bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
+ {
+ string[] vals = postCollection.GetValues(postDataKey);
+ if(vals != null)
+ {
+ int index = Items.FindByValueInternal(vals[0]);
+ if(index != SelectedIndex)
+ {
+ SelectedIndex = index;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent()
+ {
+ OnSelectedIndexChanged(EventArgs.Empty);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/EditCommandColumn.cs b/mcs/class/System.Web/System.Web.UI.WebControls/EditCommandColumn.cs
new file mode 100644
index 00000000000..7779f07ce11
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/EditCommandColumn.cs
@@ -0,0 +1,109 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: EditCommandColumn
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 95%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class EditCommandColumn : DataGridColumn
+ {
+ public EditCommandColumn(): base()
+ {
+ }
+
+ public virtual ButtonColumnType ButtonType
+ {
+ get
+ {
+ object o = ViewState["ButtonType"];
+ if(o != null)
+ {
+ return (ButtonColumnType)o;
+ }
+ return ButtonColumnType.LinkButton;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(ButtonColumnType), value))
+ {
+ throw new ArgumentException();
+ }
+ ViewState["ButtonType"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual string CancelText
+ {
+ get
+ {
+ object o = ViewState["CancelText"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["CancelText"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual string EditText
+ {
+ get
+ {
+ object o = ViewState["EditText"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["EditText"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual string UpdateText
+ {
+ get
+ {
+ object o = ViewState["UpdateText"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["UpdateText"] = value;
+ OnColumnChanged();
+ }
+ }
+
+ [MonoTODO]
+ public override void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
+ {
+ base.InitializeCell(cell, columnIndex, itemType);
+ //TODO: I have to read some documents.
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/FirstDayOfWeek.cs b/mcs/class/System.Web/System.Web.UI.WebControls/FirstDayOfWeek.cs
new file mode 100755
index 00000000000..3b618c7acbf
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/FirstDayOfWeek.cs
@@ -0,0 +1,27 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: FirstDayOfWeek
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum FirstDayOfWeek
+ {
+ Sunday,
+ Monday,
+ Tuesday,
+ Wednesday,
+ Thursday,
+ Friday,
+ Saturday,
+ Default
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/FontInfo.cs b/mcs/class/System.Web/System.Web.UI.WebControls/FontInfo.cs
new file mode 100755
index 00000000000..1dcf22b9c7a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/FontInfo.cs
@@ -0,0 +1,253 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: FontInfo
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Text;
+using System.Reflection;
+using System.Web;
+using System.Web.UI;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [TypeConverter(typeof(ExpandableObjectConverter))]
+ public sealed class FontInfo
+ {
+ private Style infoOwner;
+
+ internal FontInfo(Style owner)
+ {
+ infoOwner = owner;
+ }
+
+ /// <summary>
+ /// Default constructor
+ /// <remarks>
+ /// The default constructor is made private to prevent any instances being made.
+ /// </remarks>
+ /// </summary>
+ private FontInfo()
+ {
+ }
+
+ public bool Bold
+ {
+ get
+ {
+ if(infoOwner.IsSet(Style.FONT_BOLD))
+ return (bool)(infoOwner.ViewState["FontInfoBold"]);
+ return false;
+ }
+ set
+ {
+ infoOwner.ViewState["FontInfoBold"] = value;
+ infoOwner.Set(Style.FONT_BOLD);
+ }
+ }
+
+ public bool Italic
+ {
+ get
+ {
+ if(infoOwner.IsSet(Style.FONT_ITALIC))
+ return (bool)(infoOwner.ViewState["FontInfoItalic"]);
+ return false;
+ }
+ set
+ {
+ infoOwner.ViewState["FontInfoItalic"] = value;
+ infoOwner.Set(Style.FONT_ITALIC);
+ }
+ }
+
+ public bool Overline
+ {
+ get
+ {
+ if(infoOwner.IsSet(Style.FONT_OLINE))
+ return (bool)(infoOwner.ViewState["FontInfoOverline"]);
+ return false;
+ }
+ set
+ {
+ infoOwner.ViewState["FontInfoOverline"] = value;
+ infoOwner.Set(Style.FONT_OLINE);
+ }
+ }
+
+ public bool Strikeout
+ {
+ get
+ {
+ if(infoOwner.IsSet(Style.FONT_STRIKE))
+ return (bool)(infoOwner.ViewState["FontInfoStrikeout"]);
+ return false;
+ }
+ set
+ {
+ infoOwner.ViewState["FontInfoStrikeout"] = value;
+ infoOwner.Set(Style.FONT_STRIKE);
+ }
+ }
+
+ public bool Underline
+ {
+ get
+ {
+ if(infoOwner.IsSet(Style.FONT_ULINE))
+ return (bool)(infoOwner.ViewState["FontInfoUnderline"]);
+ return false;
+ }
+ set
+ {
+ infoOwner.ViewState["FontInfoUnderline"] = value;
+ infoOwner.Set(Style.FONT_ULINE);
+ }
+ }
+
+ //TODO: How do I check if the value is negative. FontUnit is struct not enum
+ public FontUnit Size
+ {
+ get
+ {
+ if(infoOwner.IsSet(Style.FONT_SIZE))
+ return (FontUnit)(infoOwner.ViewState["FontInfoSize"]);
+ return FontUnit.Empty;
+ }
+ set
+ {
+ infoOwner.ViewState["FontInfoSize"] = value;
+ infoOwner.Set(Style.FONT_SIZE);
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ if(Names!=null)
+ return Names[0];
+ return String.Empty;
+ }
+ set
+ {
+ if(value == null)
+ throw new ArgumentException();
+ string[] strArray = null;
+ if(value.Length > 0)
+ {
+ strArray = new string[1];
+ strArray[0] = value;
+ }
+ Names = strArray;
+ }
+ }
+
+ public string[] Names
+ {
+ get
+ {
+ if(infoOwner.IsSet(Style.FONT_NAMES))
+ return (string[])(infoOwner.ViewState["FontInfoNames"]);
+ return (new string[0]);
+ }
+ set
+ {
+ if(value!=null)
+ {
+ infoOwner.ViewState["FontInfoNames"] = value;
+ infoOwner.Set(Style.FONT_NAMES);
+ }
+ }
+ }
+
+ internal void Reset()
+ {
+ if(infoOwner.IsSet(Style.FONT_NAMES))
+ infoOwner.ViewState.Remove("FontInfoNames");
+ if(infoOwner.IsSet(Style.FONT_BOLD))
+ infoOwner.ViewState.Remove("FontInfoBold");
+ if(infoOwner.IsSet(Style.FONT_ITALIC))
+ infoOwner.ViewState.Remove("FontInfoItalic");
+ if(infoOwner.IsSet(Style.FONT_STRIKE))
+ infoOwner.ViewState.Remove("FontInfoStrikeout");
+ if(infoOwner.IsSet(Style.FONT_OLINE))
+ infoOwner.ViewState.Remove("FontInfoOverline");
+ if(infoOwner.IsSet(Style.FONT_ULINE))
+ infoOwner.ViewState.Remove("FontInfoUnderline");
+ if(infoOwner.IsSet(Style.FONT_SIZE) && infoOwner.Font.Size != FontUnit.Empty)
+ infoOwner.ViewState.Remove("FontInfoSize");
+ }
+
+ internal Style Owner
+ {
+ get
+ {
+ return infoOwner;
+ }
+ }
+
+ public void CopyFrom(FontInfo source)
+ {
+ if(source!=null)
+ {
+ if(source.Owner.IsSet(Style.FONT_NAMES))
+ Names = source.Names;
+ if(source.Owner.IsSet(Style.FONT_BOLD))
+ Bold = source.Bold;
+ if(source.Owner.IsSet(Style.FONT_ITALIC))
+ Italic = source.Italic;
+ if(source.Owner.IsSet(Style.FONT_STRIKE))
+ Strikeout = source.Strikeout;
+ if(source.Owner.IsSet(Style.FONT_OLINE))
+ Overline = source.Overline;
+ if(source.Owner.IsSet(Style.FONT_ULINE))
+ Underline = source.Underline;
+ if(source.Owner.IsSet(Style.FONT_SIZE) && source.Size != FontUnit.Empty)
+ Size = source.Size;
+ }
+ }
+
+ public void MergeWith(FontInfo with)
+ {
+ if(with!=null)
+ {
+ if(with.Owner.IsSet(Style.FONT_NAMES) && !infoOwner.IsSet(Style.FONT_NAMES))
+ Names = with.Names;
+ if(with.Owner.IsSet(Style.FONT_BOLD) && !infoOwner.IsSet(Style.FONT_BOLD))
+ Bold = with.Bold;
+ if(with.Owner.IsSet(Style.FONT_ITALIC) && !infoOwner.IsSet(Style.FONT_ITALIC))
+ Italic = with.Italic;
+ if(with.Owner.IsSet(Style.FONT_STRIKE) && !infoOwner.IsSet(Style.FONT_STRIKE))
+ Strikeout = with.Strikeout;
+ if(with.Owner.IsSet(Style.FONT_OLINE) && !infoOwner.IsSet(Style.FONT_OLINE))
+ Overline = with.Overline;
+ if(with.Owner.IsSet(Style.FONT_ULINE) && !infoOwner.IsSet(Style.FONT_ULINE))
+ Underline = with.Underline;
+ if(with.Owner.IsSet(Style.FONT_SIZE) && with.Size != FontUnit.Empty && !infoOwner.IsSet(Style.FONT_SIZE))
+ Size = with.Size;
+ }
+ }
+
+ public bool ShouldSerializeNames()
+ {
+ return (Names.Length > 0);
+ }
+
+ public override string ToString()
+ {
+ return ( (Name.Length > 0) ? (Name.ToString() + ", " + Size.ToString()) : Size.ToString() );
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/FontNamesConverter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/FontNamesConverter.cs
new file mode 100644
index 00000000000..3a04e327a56
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/FontNamesConverter.cs
@@ -0,0 +1,63 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: FontNamesConverter
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Globalization;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class FontNamesConverter : TypeConverter
+ {
+ public FontNamesConverter(): base()
+ {
+ }
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ return (sourceType == typeof(string));
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ if(value is string)
+ {
+ string fontNames = (string)value;
+ if(fontNames.Length == 0)
+ {
+ return (new string[0]);
+ }
+ string[] names = fontNames.Split(new char[] { ','});
+ for(int i=0; i < names.Length; i++)
+ {
+ names[i] = names[i].Trim();
+ }
+ return names;
+ }
+ throw GetConvertFromException(value);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if(destinationType == typeof(string))
+ {
+ if(value == null || ((string[])value) == null)
+ return String.Empty;
+ return String.Join(",", (string[])value);
+ }
+ throw GetConvertToException(value, destinationType);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/FontSize.cs b/mcs/class/System.Web/System.Web.UI.WebControls/FontSize.cs
new file mode 100755
index 00000000000..f72e3d455aa
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/FontSize.cs
@@ -0,0 +1,30 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: FontSize
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum FontSize
+ {
+ NotSet,
+ AsUnit,
+ Smaller,
+ Larger,
+ XXSmall,
+ XSmall,
+ Small,
+ Medium,
+ Large,
+ XLarge,
+ XXLarge
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/FontUnit.cs b/mcs/class/System.Web/System.Web.UI.WebControls/FontUnit.cs
new file mode 100644
index 00000000000..b89207207b2
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/FontUnit.cs
@@ -0,0 +1,215 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Struct: FontUnit
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [TypeConverter(typeof(FontUnitConverter))]
+ public struct FontUnit
+ {
+ public static readonly FontUnit Empty = new FontUnit();
+ public static readonly FontUnit Large = new FontUnit(FontSize.Large);
+ public static readonly FontUnit Larger = new FontUnit(FontSize.Larger);
+ public static readonly FontUnit Medium = new FontUnit(FontSize.Medium);
+ public static readonly FontUnit Small = new FontUnit(FontSize.Small);
+ public static readonly FontUnit Smaller = new FontUnit(FontSize.Smaller);
+ public static readonly FontUnit XLarge = new FontUnit(FontSize.XLarge);
+ public static readonly FontUnit XSmall = new FontUnit(FontSize.XSmall);
+ public static readonly FontUnit XXLarge = new FontUnit(FontSize.XXLarge);
+ public static readonly FontUnit XXSmall = new FontUnit(FontSize.XXSmall);
+
+ private FontSize type;
+ private Unit val;
+
+ private static Hashtable sizeTable;
+
+ static FontUnit ()
+ {
+ sizeTable = new Hashtable (CaseInsensitiveHashCodeProvider.Default,
+ CaseInsensitiveComparer.Default);
+ sizeTable.Add ("smaller", 2);
+ sizeTable.Add ("larger", 3);
+ sizeTable.Add ("xx-small", 4);
+ sizeTable.Add ("xxsmall", 4);
+ sizeTable.Add ("x-small", 5);
+ sizeTable.Add ("xsmall", 5);
+ sizeTable.Add ("small", 6);
+ sizeTable.Add ("medium", 7);
+ sizeTable.Add ("large", 8);
+ sizeTable.Add ("xlarge", 9);
+ sizeTable.Add ("x-large", 9);
+ sizeTable.Add ("xxlarge", 10);
+ sizeTable.Add ("xx-large", 10);
+ }
+
+ public FontUnit(FontSize type)
+ {
+ if(!Enum.IsDefined(typeof(FontSize), type))
+ throw new ArgumentException();
+ this.type = type;
+ if(this.type == FontSize.AsUnit)
+ {
+ val = Unit.Point(10);
+ } else
+ {
+ val = Unit.Empty;
+ }
+ }
+
+ public FontUnit(int value)
+ {
+ type = FontSize.AsUnit;
+ val = Unit.Point(value);
+ }
+
+ public FontUnit(string value): this(value, CultureInfo.CurrentCulture)
+ {
+ }
+
+ public FontUnit(Unit value)
+ {
+ if(value.IsEmpty)
+ {
+ type = FontSize.NotSet;
+ val = Unit.Empty;
+ } else
+ {
+ type = FontSize.AsUnit;
+ val = value;
+ }
+ }
+
+ public FontUnit(string value, CultureInfo culture)
+ {
+ type = FontSize.NotSet;
+ val = Unit.Empty;
+ if(value != null && value != String.Empty)
+ {
+ string low = value.ToLower(culture);
+ int size = GetTypeFromString(low);
+ if (size != -1)
+ {
+ type = (FontSize)size;
+ } else {
+ val = new Unit(value, culture, UnitType.Point);
+ type = FontSize.AsUnit;
+ }
+ }
+ }
+
+ private static int GetTypeFromString(string strVal)
+ {
+ if (!(sizeTable.ContainsKey (strVal)))
+ return -1;
+ return (int) sizeTable [strVal];
+ }
+
+ public static FontUnit Parse(string s)
+ {
+ return Parse(s, CultureInfo.CurrentCulture);
+ }
+
+ public static FontUnit Parse(string s, CultureInfo culture)
+ {
+ return new FontUnit(s, culture);
+ }
+
+ public static FontUnit Point(int n)
+ {
+ return new FontUnit(n);
+ }
+
+ public static bool operator ==(FontUnit left, FontUnit right)
+ {
+ return (left.type == right.type && left.val == right.val);
+ }
+
+ public static bool operator !=(FontUnit left, FontUnit right)
+ {
+ return !(left == right);
+ }
+
+ public static implicit operator FontUnit(int n)
+ {
+ return FontUnit.Point(n);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if(obj!= null && obj is FontUnit)
+ {
+ FontUnit that = (FontUnit)obj;
+ return (this.type == that.type && this.val == that.val);
+ }
+ return false;
+ }
+
+ public override int GetHashCode()
+ {
+ return ( (type.GetHashCode() << 2) | val.GetHashCode() );
+ }
+
+ public override string ToString()
+ {
+ return ToString(CultureInfo.CurrentCulture);
+ }
+
+ public string ToString(CultureInfo culture)
+ {
+ if(IsEmpty)
+ {
+ return String.Empty;
+ }
+ //string strRepr = String.Empty;
+ switch(type)
+ {
+ case FontSize.AsUnit: return val.ToString(culture);
+ case FontSize.XXSmall: return "XX-Small";
+ case FontSize.XSmall: return "X-Small";
+ case FontSize.XLarge: return "X-Large";
+ case FontSize.XXLarge: return "XX-Large";
+ default: return PropertyConverter.EnumToString(typeof(FontSize), type);
+ }
+ }
+
+ public bool IsEmpty
+ {
+ get
+ {
+ return (type == FontSize.NotSet);
+ }
+ }
+
+ public FontSize Type
+ {
+ get
+ {
+ return type;
+ }
+ }
+
+ public Unit Unit
+ {
+ get
+ {
+ return val;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/FontUnitConverter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/FontUnitConverter.cs
new file mode 100644
index 00000000000..e4a92b2e207
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/FontUnitConverter.cs
@@ -0,0 +1,92 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: FontUnitConverter
+ *
+ * Author: Gaurav Vaish, Gonzalo Paniagua Javier
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>, <gonzalo@ximian.com>
+ * Implementation: yes
+ * Status: 95%
+ *
+ * (C) Gaurav Vaish (2002)
+ * (c) 2002 Ximian, Inc. (http://www.ximian.com)
+ */
+
+using System;
+using System.Globalization;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class FontUnitConverter : TypeConverter
+ {
+ static StandardValuesCollection valuesCollection;
+ static string creatingValues = "creating value collection";
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if(sourceType == typeof(string))
+ return true;
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ if(value == null)
+ return null;
+ if(value is string)
+ {
+ string val = ((string)value).Trim();
+ if(val.Length == 0)
+ {
+ return FontUnit.Empty;
+ }
+ return FontUnit.Parse(val, culture);
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if(value != null && value is FontUnit)
+ {
+ FontUnit val = (FontUnit)value;
+ if(val.Type == FontSize.NotSet)
+ {
+ return String.Empty;
+ }
+ return val.ToString(culture);
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
+ {
+ if (valuesCollection != null)
+ return valuesCollection;
+
+ lock (creatingValues) {
+ if (valuesCollection != null)
+ return valuesCollection;
+
+ Array values = Enum.GetValues (typeof (FontUnit));
+ Array.Sort (values);
+ valuesCollection = new StandardValuesCollection (values);
+ }
+
+ return valuesCollection;
+ }
+
+ public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
+ {
+ return false;
+ }
+
+ public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
+ {
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/GridLines.cs b/mcs/class/System.Web/System.Web.UI.WebControls/GridLines.cs
new file mode 100755
index 00000000000..b013b5a1779
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/GridLines.cs
@@ -0,0 +1,23 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: GridLines
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum GridLines
+ {
+ None,
+ Horizontal,
+ Vertical,
+ Both
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/HorizontalAlign.cs b/mcs/class/System.Web/System.Web.UI.WebControls/HorizontalAlign.cs
new file mode 100755
index 00000000000..4440f296d71
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/HorizontalAlign.cs
@@ -0,0 +1,27 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: HorizontalAlign
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [TypeConverter(typeof(HorizontalAlignConverter))]
+ public enum HorizontalAlign
+ {
+ NotSet,
+ Left,
+ Center,
+ Right,
+ Justify
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/HorizontalAlignConverter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/HorizontalAlignConverter.cs
new file mode 100644
index 00000000000..27ff78ba4e2
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/HorizontalAlignConverter.cs
@@ -0,0 +1,51 @@
+//
+// System.Web.UI.WebControls.HorizontalAlignConverter
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.ComponentModel;
+using System.Globalization;
+
+namespace System.Web.UI.WebControls
+{
+ class HorizontalAlignConverter : EnumConverter
+ {
+ public HorizontalAlignConverter () : base (typeof(HorizontalAlign))
+ {
+ }
+
+ // The base class is enough to handle everything.
+ // The methods are here just to make the class status page happy.
+ // Add some optimizations?
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
+ {
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value)
+ {
+ return base.ConvertFrom (context, culture, value);
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
+ {
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value,
+ Type destinationType)
+ {
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs
new file mode 100755
index 00000000000..62c8dc83b09
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs
@@ -0,0 +1,176 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: HyperLink
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: gvaish@iitk.ac.in, myscripts_2001@yahoo.com
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultProperty("Text")]
+ //[Designer(??)]
+ [ControlBuilder(typeof(HyperLinkControlBuilder))]
+ //[DataBindingHandler("??")]
+ [ParseChildren(false)]
+ [ToolboxData("<{0}:HyperLink runat=\"server\">HyperLink</{0}:HyperLink>")]
+ public class HyperLink: WebControl
+ {
+ bool textSet;
+
+ public HyperLink(): base(HtmlTextWriterTag.A)
+ {
+ }
+
+ public virtual string ImageUrl
+ {
+ get
+ {
+ object o = ViewState["ImageUrl"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["ImageUrl"] = value;
+ }
+ }
+
+ public string NavigateUrl
+ {
+ get
+ {
+ object o = ViewState["NavigateUrl"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["NavigateUrl"] = value;
+ }
+ }
+
+ public string Target
+ {
+ get
+ {
+ object o = ViewState["Target"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["Target"] = value;
+ }
+ }
+
+ public virtual string Text
+ {
+ get {
+ object o = ViewState ["Text"];
+ if (o != null)
+ return (string) o;
+
+ return String.Empty;
+ }
+ set {
+ ViewState["Text"] = value;
+ textSet = true;
+ }
+ }
+
+ string InternalText
+ {
+ get { return Text; }
+ set { ViewState["Text"] = value; }
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender(writer);
+ if(NavigateUrl.Length > 0)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Href, NavigateUrl);
+ }
+ if(Target.Length > 0)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Target, Target);
+ }
+ }
+
+ protected override void AddParsedSubObject(object obj)
+ {
+ if(HasControls())
+ {
+ base.AddParsedSubObject(obj);
+ return;
+ }
+ if(obj is LiteralControl)
+ {
+ // This is a hack to workaround the behaviour of the code generator, which
+ // may split a text in several LiteralControls if there's a special character
+ // such as '<' in it.
+ if (textSet) {
+ Text = ((LiteralControl)obj).Text;
+ textSet = false;
+ } else {
+ InternalText += ((LiteralControl)obj).Text;
+ }
+ //
+
+ return;
+ }
+ if(Text.Length > 0)
+ {
+ base.AddParsedSubObject(new LiteralControl (Text));
+ Text = String.Empty;
+ }
+ base.AddParsedSubObject (obj);
+ }
+
+ protected override void LoadViewState(object savedState)
+ {
+ if(savedState != null)
+ {
+ base.LoadViewState(savedState);
+ object o = ViewState["Text"];
+ if(o!=null)
+ Text = (string)o;
+ }
+ }
+
+ protected override void RenderContents(HtmlTextWriter writer)
+ {
+ if(ImageUrl.Length > 0)
+ {
+ Image img = new Image();
+ img.ImageUrl = ResolveUrl(ImageUrl);
+ if(ToolTip.Length > 0)
+ img.ToolTip = ToolTip;
+ if(Text.Length > 0)
+ img.AlternateText = Text;
+ img.RenderControl(writer);
+ return;
+ }
+ if(HasControls())
+ {
+ base.RenderContents(writer);
+ return;
+ }
+ writer.Write(Text);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/HyperLinkColumn.cs b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLinkColumn.cs
new file mode 100644
index 00000000000..9f636c97c58
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLinkColumn.cs
@@ -0,0 +1,213 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: HyperLinkColumn
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class HyperLinkColumn: DataGridColumn
+ {
+ PropertyDescriptor textFieldDescriptor;
+ PropertyDescriptor urlFieldDescriptor;
+
+ public HyperLinkColumn ()
+ {
+ }
+
+ public virtual string DataNavigateUrlField {
+ get {
+ object o = ViewState ["DataNavigateUrlField"];
+ if (o != null)
+ return (string) o;
+ return String.Empty;
+ }
+
+ set {
+ ViewState ["DataNavigateUrlField"] = value;
+ OnColumnChanged ();
+ }
+ }
+
+ public virtual string DataNavigateUrlFormatString {
+ get {
+ object o = ViewState ["DataNavigateUrlFormatString"];
+ if (o != null)
+ return (string) o;
+ return String.Empty;
+ }
+
+ set {
+ ViewState ["DataNavigateUrlFormatString"] = value;
+ OnColumnChanged ();
+ }
+ }
+
+ public virtual string DataTextField {
+ get {
+ object o = ViewState ["DataTextField"];
+ if (o != null)
+ return (string) o;
+ return String.Empty;
+ }
+ set {
+ ViewState ["DataTextField"] = value;
+ OnColumnChanged ();
+ }
+ }
+
+ public virtual string DataTextFormatString {
+ get {
+ object o = ViewState ["DataTextFormatString"];
+ if (o != null)
+ return (string) o;
+ return String.Empty;
+ }
+
+ set {
+ ViewState ["DataTextFormatString"] = value;
+ OnColumnChanged ();
+ }
+ }
+
+ public virtual string NavigateUrl {
+ get {
+ object o = ViewState ["NavigateUrl"];
+ if (o != null)
+ return (string) o;
+ return String.Empty;
+ }
+
+ set {
+ ViewState ["NavigateUrl"] = value;
+ OnColumnChanged ();
+ }
+ }
+
+ public virtual string Target {
+ get {
+ object o = ViewState ["Target"];
+ if (o != null)
+ return (string) o;
+ return String.Empty;
+ }
+
+ set {
+ ViewState ["Target"] = value;
+ OnColumnChanged ();
+ }
+ }
+
+ public virtual string Text {
+ get {
+ object o = ViewState ["Text"];
+ if (o != null)
+ return (string) o;
+ return String.Empty;
+ }
+
+ set {
+ ViewState ["Text"] = value;
+ OnColumnChanged ();
+ }
+ }
+
+ public override void Initialize ()
+ {
+ textFieldDescriptor = null;
+ urlFieldDescriptor = null;
+ base.Initialize ();
+ }
+
+ public override void InitializeCell (TableCell cell, int columnIndex, ListItemType itemType)
+ {
+ base.InitializeCell (cell, columnIndex, itemType);
+
+ if (itemType != ListItemType.Header && itemType != ListItemType.Footer) {
+ HyperLink toDisplay = new HyperLink ();
+ toDisplay.Text = Text;
+ toDisplay.NavigateUrl = NavigateUrl;
+ toDisplay.Target = Target;
+
+ if (DataTextField.Length > 0 || DataNavigateUrlField.Length > 0)
+ toDisplay.DataBinding += new EventHandler (OnDataBindHyperLinkColumn);
+
+ cell.Controls.Add (toDisplay);
+ }
+ }
+
+ private void OnDataBindHyperLinkColumn (object sender, EventArgs e)
+ {
+ HyperLink link = (HyperLink) sender;
+ object item = ((DataGridItem) link.NamingContainer).DataItem;
+
+ if (textFieldDescriptor == null && urlFieldDescriptor == null) {
+ PropertyDescriptorCollection properties = TypeDescriptor.GetProperties (item);
+ textFieldDescriptor = properties.Find (DataTextField, true);
+ if (textFieldDescriptor == null && !DesignMode)
+ throw new HttpException (HttpRuntime.FormatResourceString (
+ "Field_Not_Found", DataTextField));
+
+ urlFieldDescriptor = properties.Find (DataNavigateUrlField, true);
+ if (urlFieldDescriptor == null && !DesignMode)
+ throw new HttpException (HttpRuntime.FormatResourceString (
+ "Field_Not_Found", DataNavigateUrlField));
+ }
+
+ if (textFieldDescriptor != null) {
+ link.Text = FormatDataTextValue (textFieldDescriptor.GetValue (item));
+ } else {
+ link.Text = "Sample_DataBound_Text";
+ }
+
+ if (urlFieldDescriptor != null) {
+ link.NavigateUrl = FormatDataNavigateUrlValue (urlFieldDescriptor.GetValue (item));
+ } else {
+ link.NavigateUrl = "url";
+ }
+ }
+
+ protected virtual string FormatDataNavigateUrlValue (object dataUrlValue)
+ {
+ if (dataUrlValue == null)
+ return String.Empty;
+
+ string retVal;
+ if (DataNavigateUrlFormatString.Length > 0) {
+ retVal = String.Format (DataNavigateUrlFormatString, dataUrlValue);
+ } else {
+ retVal = dataUrlValue.ToString ();
+ }
+
+ return retVal;
+ }
+
+ protected virtual string FormatDataTextValue (object dataTextValue)
+ {
+ if (dataTextValue == null)
+ return String.Empty;
+
+ string retVal;
+ if (DataTextFormatString.Length > 0) {
+ retVal = String.Format (DataTextFormatString, dataTextValue);
+ } else {
+ retVal = dataTextValue.ToString ();
+ }
+
+ return retVal;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/HyperLinkControlBuilder.cs b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLinkControlBuilder.cs
new file mode 100644
index 00000000000..cca04d06622
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLinkControlBuilder.cs
@@ -0,0 +1,27 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: HyperLinkControlBuilder
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public class HyperLinkControlBuilder : ControlBuilder
+ {
+ public HyperLinkControlBuilder(): base()
+ {
+ }
+
+ public override bool AllowWhitespaceLiterals()
+ {
+ return false;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/IRepeatInfoUser.cs b/mcs/class/System.Web/System.Web.UI.WebControls/IRepeatInfoUser.cs
new file mode 100755
index 00000000000..47526f80d8e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/IRepeatInfoUser.cs
@@ -0,0 +1,29 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Interface: IRepeatInfoUser
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public interface IRepeatInfoUser
+ {
+ bool HasFooter { get; }
+ bool HasHeader { get; }
+ bool HasSeparators { get; }
+ int RepeatedItemCount { get; }
+ void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer);
+ Style GetItemStyle(ListItemType itemType, int repeatIndex);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Image.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Image.cs
new file mode 100644
index 00000000000..f3182ec9ce4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Image.cs
@@ -0,0 +1,118 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: Image
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultProperty("ImageUrl")]
+ public class Image : WebControl
+ {
+ public Image(): base(HtmlTextWriterTag.Img)
+ {
+ }
+
+ public virtual string AlternateText
+ {
+ get
+ {
+ object o = ViewState["AlternateText"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["AlternateText"] = value;
+ }
+ }
+
+ public override bool Enabled
+ {
+ get
+ {
+ return base.Enabled;
+ }
+ set
+ {
+ base.Enabled = value;
+ }
+ }
+
+ public override FontInfo Font
+ {
+ get
+ {
+ return base.Font;
+ }
+ }
+
+ public virtual ImageAlign ImageAlign
+ {
+ get
+ {
+ object o = ViewState["ImageAlign"];
+ if(o!=null)
+ return (ImageAlign)o;
+ return ImageAlign.NotSet;
+ }
+ set
+ {
+ ViewState["ImageAlign"] = value;
+ }
+ }
+
+ public virtual string ImageUrl
+ {
+ get
+ {
+ object o = ViewState["ImageUrl"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["ImageUrl"] = value;
+ }
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender(writer);
+ if(ImageUrl.Length > 0)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Src, ResolveUrl(ImageUrl));
+ }
+ if(AlternateText.Length > 0)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Alt, AlternateText);
+ }
+ if(BorderWidth.IsEmpty)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
+ }
+ if(ImageAlign != ImageAlign.NotSet)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Align, Enum.Format(typeof(ImageAlign), ImageAlign, "G"));
+ }
+ }
+
+ protected override void RenderContents(HtmlTextWriter writer)
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ImageAlign.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ImageAlign.cs
new file mode 100755
index 00000000000..5a5fa02db58
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ImageAlign.cs
@@ -0,0 +1,29 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: ImageAlign
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum ImageAlign
+ {
+ NotSet,
+ Left,
+ Right,
+ Baseline,
+ Top,
+ Middle,
+ Bottom,
+ AbsBottom,
+ AbsMiddle,
+ TextTop
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
new file mode 100644
index 00000000000..c318dd3c002
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
@@ -0,0 +1,181 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: ImageButton
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("Click")]
+ public class ImageButton: Image, IPostBackDataHandler, IPostBackEventHandler
+ {
+ private static readonly object ClickEvent = new object();
+ private static readonly object CommandEvent = new object();
+
+ private int x, y;
+
+ public ImageButton(): base()
+ {
+ }
+
+ public bool CausesValidation
+ {
+ get
+ {
+ object o = ViewState["CausesValidation"];
+ if(o!=null)
+ return (bool)o;
+ return true;
+ }
+ set
+ {
+ ViewState["CausesValidation"] = value;
+ }
+ }
+
+ public string CommandArgument
+ {
+ get
+ {
+ object o = ViewState["CommandArgument"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["CommandArgument"] = value;
+ }
+ }
+
+ public string CommandName
+ {
+ get
+ {
+ object o = ViewState["CommandName"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["CommandName"] = value;
+ }
+ }
+
+ protected override HtmlTextWriterTag TagKey
+ {
+ get
+ {
+ return HtmlTextWriterTag.Input;
+ }
+ }
+
+ public event ImageClickEventHandler Click
+ {
+ add
+ {
+ Events.AddHandler(ClickEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ClickEvent, value);
+ }
+ }
+
+ public event CommandEventHandler Command
+ {
+ add
+ {
+ Events.AddHandler(CommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(CommandEvent, value);
+ }
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Type, "image");
+ writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
+ if(Page != null && CausesValidation)
+ {
+ if(Page.Validators.Count > 0)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Utils.GetClientValidatedEvent(Page));
+ writer.AddAttribute("language", "javascript");
+ }
+ }
+ base.AddAttributesToRender(writer);
+ }
+
+ protected virtual void OnClick(ImageClickEventArgs e)
+ {
+ if(Events != null)
+ {
+ ImageClickEventHandler iceh = (ImageClickEventHandler)(Events[ClickEvent]);
+ if(iceh != null)
+ iceh(this, e);
+ }
+ }
+
+ protected virtual void OnCommand(CommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ CommandEventHandler ceh = (CommandEventHandler)(Events[CommandEvent]);
+ if(ceh != null)
+ ceh(this, e);
+ RaiseBubbleEvent(this, e);
+ }
+ }
+
+ protected override void OnPreRender(EventArgs e)
+ {
+ if(Page != null)
+ {
+ Page.RegisterRequiresPostBack(this);
+ }
+ }
+
+ bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
+ {
+ string xCoord = postCollection[UniqueID + ".x"];
+ string yCoord = postCollection[UniqueID + ".y"];
+ if(xCoord != null && yCoord != null && xCoord.Length > 0 && yCoord.Length > 0)
+ {
+ x = Int32.Parse(xCoord);
+ y = Int32.Parse(yCoord);
+ Page.RegisterRequiresRaiseEvent(this);
+ }
+ return false;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent()
+ {
+ }
+
+ void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
+ {
+ if(CausesValidation)
+ Page.Validate();
+ OnClick(new ImageClickEventArgs(x, y));
+ OnCommand(new CommandEventArgs(CommandName, CommandArgument));
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Label.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Label.cs
new file mode 100644
index 00000000000..f28f6e46db3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Label.cs
@@ -0,0 +1,86 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: Label
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultProperty("Text")]
+ //[Designer("??")]
+ //Currently mono does not handle Type in attributes
+ //[ControlBuilder(typeof(LabelControlBuilder))]
+ //[DataBindingHandler("??")]
+ [ParseChildren(false)]
+ [ToolboxData("<{0}:Label runat=\"server\">Label</{0}:Label>")]
+ public class Label : WebControl
+ {
+ public Label (): base ()
+ {
+ }
+
+ internal Label (HtmlTextWriterTag tagKey) : base (tagKey)
+ {
+ }
+
+ public virtual string Text
+ {
+ get {
+ object o = ViewState ["Text"];
+ return (o == null) ? String.Empty : (string) o;
+ }
+
+ set { ViewState ["Text"] = value; }
+ }
+
+ protected override void AddParsedSubObject (object obj)
+ {
+ if(HasControls ()){
+ base.AddParsedSubObject (obj);
+ return;
+ }
+
+ if(obj is LiteralControl){
+ Text = ((LiteralControl) obj).Text;
+ return;
+ }
+
+ if(Text.Length > 0){
+ base.AddParsedSubObject (new LiteralControl (Text));
+ Text = String.Empty;
+ }
+
+ base.AddParsedSubObject (obj);
+ }
+
+ protected override void LoadViewState (object savedState)
+ {
+ if(savedState != null) {
+ base.LoadViewState (savedState);
+ string savedText = ViewState ["Text"] as string;
+ if(savedText != null)
+ Text = savedText;
+ }
+ }
+
+ protected override void RenderContents (HtmlTextWriter writer)
+ {
+ if(HasControls ())
+ base.RenderContents (writer);
+ else
+ writer.Write (Text);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/LabelControlBuilder.cs b/mcs/class/System.Web/System.Web.UI.WebControls/LabelControlBuilder.cs
new file mode 100644
index 00000000000..5ef512cd092
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/LabelControlBuilder.cs
@@ -0,0 +1,27 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: LabelControlBuilder
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public class LabelControlBuilder : ControlBuilder
+ {
+ public LabelControlBuilder(): base()
+ {
+ }
+
+ public override bool AllowWhitespaceLiterals()
+ {
+ return false;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs
new file mode 100644
index 00000000000..89d6dea68d9
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs
@@ -0,0 +1,174 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: LinkButton
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("Click")]
+ [DefaultProperty("Text")]
+ //[Designer("??")]
+ [ControlBuilder(typeof(LinkButtonControlBuilder))]
+ //[DataBindingHandler("??")]
+ [ParseChildren(false)]
+ [ToolboxData("<{0}:LinkButton runat=\"server\">LinkButton</{0}:LinkButton>")]
+ public class LinkButton : WebControl, IPostBackEventHandler
+ {
+ private static readonly object ClickEvent = new object();
+ private static readonly object CommandEvent = new object();
+
+ public LinkButton () : base (HtmlTextWriterTag.A)
+ {
+ }
+
+ public bool CausesValidation
+ {
+ get {
+ object o = ViewState ["CausesValidation"];
+ return (o == null) ? true : (bool) o;
+ }
+
+ set { ViewState ["CausesValidation"] = value; }
+ }
+
+ public string CommandArgument
+ {
+ get {
+ object o = ViewState ["CommandArgument"];
+ return (o == null) ? String.Empty : (string) o;
+ }
+
+ set { ViewState ["CommandArgument"] = value; }
+ }
+
+ public string CommandName
+ {
+ get {
+ object o = ViewState ["CommandName"];
+ return (o == null) ? String.Empty : (string) o;
+ }
+
+ set { ViewState ["CommandName"] = value; }
+ }
+
+ public virtual string Text
+ {
+ get {
+ object o = ViewState ["Text"];
+ return (o == null) ? String.Empty : (string) o;
+ }
+
+ set { ViewState ["Text"] = value; }
+ }
+
+ public event EventHandler Click
+ {
+ add { Events.AddHandler(ClickEvent, value); }
+ remove { Events.RemoveHandler(ClickEvent, value); }
+ }
+
+ public event CommandEventHandler Command
+ {
+ add { Events.AddHandler(CommandEvent, value); }
+ remove { Events.RemoveHandler(CommandEvent, value); }
+ }
+
+ protected virtual void OnClick (EventArgs e)
+ {
+ if(Events != null){
+ EventHandler eh = (EventHandler) (Events [ClickEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+ }
+
+ protected virtual void OnCommand (CommandEventArgs e)
+ {
+ if(Events != null){
+ CommandEventHandler ceh = (CommandEventHandler) (Events [CommandEvent]);
+ if (ceh != null)
+ ceh (this, e);
+ }
+ }
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender(e);
+ }
+
+ void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
+ {
+ if (CausesValidation)
+ Page.Validate ();
+ OnClick (EventArgs.Empty);
+ OnCommand (new CommandEventArgs (CommandName, CommandArgument));
+ }
+
+ protected override void AddAttributesToRender (HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender (writer);
+ if (Enabled && Page != null){
+ if (CausesValidation && Page.Validators.Count > 0){
+ writer.AddAttribute (HtmlTextWriterAttribute.Href,
+ "javascript:" +
+ Utils.GetClientValidatedPostBack (this));
+ return;
+ }
+ writer.AddAttribute (HtmlTextWriterAttribute.Href,
+ Page.GetPostBackClientHyperlink (this, ""));
+ }
+ }
+
+ protected override void AddParsedSubObject (object obj)
+ {
+ if (HasControls ()){
+ base.AddParsedSubObject (obj);
+ return;
+ }
+
+ if (obj is LiteralControl){
+ Text = ((LiteralControl) obj).Text;
+ return;
+ }
+
+ if (Text.Length > 0){
+ base.AddParsedSubObject (new LiteralControl (Text));
+ Text = String.Empty;
+ }
+
+ base.AddParsedSubObject (obj);
+ }
+
+ protected override void LoadViewState (object savedState)
+ {
+ if (savedState != null){
+ base.LoadViewState (savedState);
+ string savedText = (string) ViewState ["Text"];
+ if (savedText != null)
+ Text = savedText;
+ }
+ }
+
+ protected override void RenderContents (HtmlTextWriter writer)
+ {
+ if (HasControls ()){
+ base.RenderContents (writer);
+ return;
+ }
+ writer.Write (Text);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/LinkButtonControlBuilder.cs b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButtonControlBuilder.cs
new file mode 100644
index 00000000000..cfb8a69b986
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButtonControlBuilder.cs
@@ -0,0 +1,31 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: LinkButtonControlBuilder
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class LinkButtonControlBuilder : ControlBuilder
+ {
+ public LinkButtonControlBuilder(): base()
+ {
+ }
+
+ public override bool AllowWhitespaceLiterals()
+ {
+ return false;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/LinkButtonInternal.cs b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButtonInternal.cs
new file mode 100644
index 00000000000..215d5efd082
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButtonInternal.cs
@@ -0,0 +1,55 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: LinkButtonInternal
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Drawing;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ internal class LinkButtonInternal : LinkButton
+ {
+ public LinkButtonInternal() : base()
+ {
+ }
+
+ protected override void Render(HtmlTextWriter writer)
+ {
+ SetForeColor();
+ Render(writer);
+ }
+
+ private void SetForeColor()
+ {
+ if(!ControlStyle.IsSet(System.Web.UI.WebControls.Style.FORECOLOR))
+ {
+ Control ctrl = this;
+ Color foreCol;
+ int ctr = 0;
+ //FIXME: this-> LinkButton-> WebControl
+ while(ctr < 2)
+ {
+ ctrl = ctrl.Parent;
+ foreCol = ((WebControl)ctrl).ForeColor;
+ if(foreCol != Color.Empty)
+ {
+ ForeColor = foreCol;
+ return;
+ }
+ ctr++;
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs
new file mode 100644
index 00000000000..5548f0da083
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs
@@ -0,0 +1,177 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: ListBox
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Drawing;
+using System.Collections;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [ValidationProperty("SelectedItem")]
+ public class ListBox : ListControl, IPostBackDataHandler
+ {
+ public ListBox () : base ()
+ {
+ }
+
+ public override Color BorderColor
+ {
+ get { return base.BorderColor; }
+ set { base.BorderColor = value; }
+ }
+
+ public override BorderStyle BorderStyle
+ {
+ get { return base.BorderStyle; }
+ set { base.BorderStyle = value; }
+ }
+
+ public override Unit BorderWidth
+ {
+ get { return base.BorderWidth; }
+ set { base.BorderWidth = value; }
+ }
+
+ public virtual int Rows
+ {
+ get {
+ object o = ViewState ["Rows"];
+ return (o == null) ? 4 : (int) o;
+ }
+
+ set {
+ if (value < 1 || value > 2000)
+ throw new ArgumentOutOfRangeException ();
+
+ ViewState ["Rows"] = value;
+ }
+ }
+
+ public virtual ListSelectionMode SelectionMode
+ {
+ get
+ {
+ object o = ViewState ["SelectionMode"];
+ return (o == null) ? ListSelectionMode.Single : (ListSelectionMode) o;
+ }
+ set
+ {
+ if (!Enum.IsDefined (typeof (ListSelectionMode), value))
+ throw new ArgumentException ();
+ ViewState ["SelectionMode"] = value;
+ }
+ }
+
+ public override string ToolTip
+ {
+ get { return String.Empty; }
+ set { /* Don't do anything. */ }
+ }
+
+ protected override void AddAttributesToRender (HtmlTextWriter writer)
+ {
+ if (Page != null)
+ Page.VerifyRenderingInServerForm (this);
+
+ writer.AddAttribute (HtmlTextWriterAttribute.Name, UniqueID);
+ base.AddAttributesToRender (writer);
+ writer.AddAttribute (HtmlTextWriterAttribute.Size,
+ Rows.ToString (NumberFormatInfo.InvariantInfo));
+
+ if (SelectionMode == ListSelectionMode.Multiple)
+ writer.AddAttribute (HtmlTextWriterAttribute.Multiple, "multiple");
+
+ if (AutoPostBack && Page != null){
+ writer.AddAttribute (HtmlTextWriterAttribute.Onchange,
+ Page.GetPostBackClientEvent (this, ""));
+ writer.AddAttribute ("language", "javascript");
+ }
+ }
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender (e);
+ if (Page != null && SelectionMode == ListSelectionMode.Multiple && Enabled)
+ Page.RegisterRequiresPostBack(this);
+ }
+
+ protected override void RenderContents (HtmlTextWriter writer)
+ {
+ bool isMultAllowed = (SelectionMode == ListSelectionMode.Multiple);
+ bool selMade = false;
+ foreach (ListItem current in Items){
+ writer.WriteBeginTag ("option");
+ if (current.Selected){
+ if (!isMultAllowed && selMade)
+ throw new HttpException ("Cannot_MultiSelect_In_Single_Mode");
+ selMade = true;
+ writer.WriteAttribute ("selected", "selected");
+ }
+ writer.WriteAttribute ("value", current.Value, true);
+ writer.Write ('>');
+ writer.Write (HttpUtility.HtmlEncode (current.Text));
+ writer.WriteEndTag ("option");
+ writer.WriteLine ();
+ }
+ }
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ string[] vals = postCollection.GetValues (postDataKey);
+ bool updated = false;
+ ArrayList selected = SelectedIndices;
+ ArrayList final = new ArrayList (vals.Length);
+ if (vals != null){
+ if (SelectionMode == ListSelectionMode.Single){
+ int index = Items.FindByValueInternal (vals [0]);
+ if (SelectedIndex != index){
+ SelectedIndex = index;
+ updated = true;
+ }
+ } else {
+ foreach (string current in vals)
+ final.Add (Items.FindByValueInternal (current));
+
+ if (selected != null && selected.Count == vals.Length){
+ for (int ctr = 0; ctr < vals.Length; ctr++){
+ if (((int) final [ctr]) != ((int) selected [ctr])){
+ updated = true;
+ break;
+ }
+ }
+ } else {
+ updated = true;
+ }
+ }
+ if (!updated)
+ Select (final);
+ } else {
+ if (SelectedIndex != -1)
+ SelectedIndex = -1;
+ updated = true;
+ }
+ return updated;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ OnSelectedIndexChanged (EventArgs.Empty);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs
new file mode 100644
index 00000000000..71d3c276c14
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs
@@ -0,0 +1,343 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: ListControl
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+using System.Web.Util;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("SelectedIndexChanged")]
+ [DefaultProperty("DataSource")]
+ //[Designer("??")]
+ //[DataBindingHandler("??")]
+ [ParseChildren(true, "Items")]
+ public abstract class ListControl: WebControl
+ {
+ private static readonly object SelectedIndexChangedEvent = new object();
+
+ private object dataSource;
+ private ListItemCollection items;
+
+ private int cachedSelectedIndex = -1;
+
+ public ListControl(): base(HtmlTextWriterTag.Select)
+ {
+ }
+
+ public event EventHandler SelectedIndexChanged
+ {
+ add
+ {
+ Events.AddHandler(SelectedIndexChangedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(SelectedIndexChangedEvent, value);
+ }
+ }
+
+ public virtual bool AutoPostBack
+ {
+ get
+ {
+ object o = ViewState["AutoPostBack"];
+ if(o!=null)
+ return (bool)o;
+ return false;
+ }
+ set
+ {
+ ViewState["AutoPostBack"] = value;
+ }
+ }
+
+ public virtual string DataMember
+ {
+ get
+ {
+ object o = ViewState["DataMember"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataMember"] = value;
+ }
+ }
+
+ public virtual object DataSource
+ {
+ get
+ {
+ return dataSource;
+ }
+ set
+ {
+ if(value != null)
+ {
+ if(value is IListSource || value is IEnumerable)
+ {
+ dataSource = value;
+ return;
+ }
+ }
+ throw new ArgumentException(HttpRuntime.FormatResourceString(ID, "Invalid DataSource Type"));
+ }
+ }
+
+ public virtual string DataTextField
+ {
+ get
+ {
+ object o = ViewState["DataTextField"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataTextField"] = value;
+ }
+ }
+
+ public virtual string DataTextFormatString
+ {
+ get
+ {
+ object o = ViewState["DataTextFormatString"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataTextFormatString"] = value;
+ }
+ }
+
+ public virtual string DataValueField
+ {
+ get
+ {
+ object o = ViewState["DataValueField"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataValueField"] = value;
+ }
+ }
+
+ public virtual ListItemCollection Items
+ {
+ get
+ {
+ if(items==null)
+ {
+ items = new ListItemCollection();
+ if(IsTrackingViewState)
+ {
+ items.TrackViewState();
+ }
+ }
+ return items;
+ }
+ }
+
+ public virtual int SelectedIndex
+ {
+ get {
+ ListItemCollection items = Items;
+ int last = items.Count;
+ for (int i = 0; i < last; i++) {
+ if (items [i].Selected)
+ return i;
+ }
+ return -1;
+ }
+ set {
+ if (value < -1 || value > Items.Count)
+ throw new ArgumentOutOfRangeException ();
+
+ ClearSelection ();
+ if (value != -1)
+ Items [value].Selected = true;
+ }
+ }
+
+ public virtual ListItem SelectedItem
+ {
+ get
+ {
+ int idx = SelectedIndex;
+ if (idx < 0)
+ return null;
+
+ return Items [idx];
+ }
+ }
+
+ internal virtual ArrayList SelectedIndices
+ {
+ get
+ {
+ ArrayList si = new ArrayList();
+ for(int i=0; i < Items.Count; i++)
+ {
+ if(Items[i].Selected)
+ si.Add(i);
+ }
+ return si;
+ }
+ }
+
+ internal void Select(ArrayList indices)
+ {
+ ClearSelection();
+ foreach(object intObj in indices)
+ {
+ int index = (int)intObj;
+ if(index >= 0 && index < Items.Count)
+ Items[index].Selected = true;
+ }
+ }
+
+ public virtual void ClearSelection()
+ {
+ for(int i=0; i < Items.Count; i++)
+ {
+ Items[i].Selected = false;
+ }
+ }
+
+ protected override void LoadViewState(object savedState)
+ {
+ //Order: BaseClass, Items (Collection), Indices
+ if(savedState != null && savedState is Triplet)
+ {
+ Triplet state = (Triplet)savedState;
+ base.LoadViewState(state.First);
+ Items.LoadViewState(state.Second);
+ object indices = state.Third;
+ if(indices != null)
+ {
+ Select((ArrayList)indices);
+ }
+ }
+ }
+
+ protected override void OnDataBinding(EventArgs e)
+ {
+ base.OnDataBinding(e);
+ IEnumerable ds = DataSourceHelper.GetResolvedDataSource (DataSource, DataMember);
+
+ if(ds != null) {
+ string dtf = DataTextField;
+ string dvf = DataValueField;
+ string dtfs = DataTextFormatString;
+ if (dtfs.Length == 0)
+ dtfs = "{0}";
+
+ Items.Clear();
+
+ bool useProperties = (dtf.Length > 0 && dvf.Length > 0);
+
+ foreach (object current in ds) {
+ ListItem li = new ListItem();
+ if (!useProperties){
+ li.Text = String.Format (dtfs, current);
+ li.Value = current.ToString ();
+ Items.Add (li);
+ continue;
+ }
+
+ object o;
+ if (dtf.Length > 0) {
+ o = DataBinder.GetPropertyValue (current, dtf, null);
+ li.Text = o.ToString ();
+ }
+
+ if (dvf.Length > 0) {
+ o = DataBinder.GetPropertyValue (current, dvf, null);
+ li.Value = o.ToString ();
+ }
+
+ Items.Add(li);
+ }
+ }
+
+ if (cachedSelectedIndex != -1) {
+ SelectedIndex = cachedSelectedIndex;
+ cachedSelectedIndex = -1;
+ }
+ }
+
+ protected virtual void OnSelectedIndexChanged(EventArgs e)
+ {
+ if(Events!=null)
+ {
+ EventHandler eh = (EventHandler)(Events[SelectedIndexChangedEvent]);
+ if(eh!=null)
+ eh(this, e);
+ }
+ }
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender(e);
+ }
+
+ protected override object SaveViewState()
+ {
+ //Order: BaseClass, Items (Collection), Indices
+ object vs = base.SaveViewState();
+ object itemSvs = Items.SaveViewState();
+ object indices = null;
+ if(SaveSelectedIndicesViewState)
+ indices = SelectedIndices;
+ if(vs!= null && itemSvs != null && indices != null)
+ {
+ return new Triplet(vs, itemSvs, indices);
+ }
+ return null;
+ }
+
+ protected override void TrackViewState()
+ {
+ base.TrackViewState();
+ Items.TrackViewState();
+ }
+
+ private bool SaveSelectedIndicesViewState
+ {
+ get
+ {
+ if( Events[SelectedIndexChangedEvent] != null && Enabled && Visible)
+ {
+ Type t = GetType();
+ // If I am a derivative, let it take of storing the selected indices.
+ if(t == typeof(DropDownList) || t == typeof(ListBox) || t == typeof(CheckBoxList) || t == typeof(RadioButtonList))
+ return false;
+ }
+ return true;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListItem.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListItem.cs
new file mode 100644
index 00000000000..44bbe9cbf1c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListItem.cs
@@ -0,0 +1,241 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: ListItem
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [TypeConverter(typeof(ExpandableObjectConverter))]
+ [ControlBuilder(typeof(ListItemControlBuilder))]
+ public sealed class ListItem : IStateManager, IParserAccessor, IAttributeAccessor
+ {
+ private AttributeCollection attributes;
+ private string text;
+ private string val;
+ private bool marked;
+ private bool selected;
+ private bool dirty_t;
+ private bool dirty_v;
+
+ public ListItem(string text, string value)
+ {
+ this.text = text;
+ this.val = value;
+ attributes = null;
+ }
+
+ public ListItem(string text): this(text, null)
+ {
+ }
+
+ public ListItem(): this(null, null)
+ {
+ }
+
+ public static ListItem FromString(string text)
+ {
+ return new ListItem(text);
+ }
+
+ public AttributeCollection Attributes
+ {
+ get
+ {
+ if(attributes == null)
+ attributes = new AttributeCollection(new StateBag(true));
+ return attributes;
+ }
+ }
+
+ public bool Selected
+ {
+ get {
+ return selected;
+ }
+
+ set {
+ selected = value;
+ }
+ }
+
+ internal bool Dirty
+ {
+ get {
+ return (dirty_t && dirty_v);
+ }
+
+ set {
+ dirty_t = value;
+ dirty_v = value;
+ }
+ }
+
+ public string Text
+ {
+ get
+ {
+ if(text!=null)
+ {
+ return text;
+ }
+ if(val!=null)
+ {
+ return val;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ text = value;
+ if (IsTrackingViewState)
+ dirty_t = true;
+ }
+ }
+
+ public string Value
+ {
+ get {
+ if (val != null)
+ return val;
+
+ if (text != null)
+ return text;
+
+ return String.Empty;
+ }
+ set
+ {
+ val = value;
+ if(IsTrackingViewState)
+ dirty_v = true;
+ }
+ }
+
+ string IAttributeAccessor.GetAttribute(string key)
+ {
+ return attributes[key];
+ }
+
+ void IAttributeAccessor.SetAttribute(string key, string value)
+ {
+ attributes[key] = value;
+ }
+
+ /// <remarks>
+ /// The data is parsed - object must be of type LiteralControl or DataBoundLiteralControl.
+ /// In latter case, throw an exception telling that the data cannot be bind-ed.
+ /// </remarks>
+ void IParserAccessor.AddParsedSubObject(object obj)
+ {
+ if(obj is LiteralControl)
+ {
+ Text = ((LiteralControl)obj).Text;
+ return;
+ }
+ if(obj is DataBoundLiteralControl)
+ {
+ throw new HttpException(HttpRuntime.FormatResourceString("Control_Cannot_DataBind","ListItem"));
+ }
+ throw new HttpException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type", "ListItem", obj.GetType().ToString()));
+ }
+
+ bool IsTrackingViewState
+ {
+ get
+ {
+ return marked;
+ }
+ }
+
+ internal void TrackViewState()
+ {
+ marked = true;
+ }
+
+ internal void LoadViewState(object state)
+ {
+ if(state is Pair)
+ {
+ Pair tv = (Pair)state;
+ if(tv.First!=null)
+ {
+ Text = (string)tv.First;
+ }
+ if(tv.Second!=null)
+ {
+ Value = (string)tv.Second;
+ }
+ }
+ }
+
+ internal object SaveViewState()
+ {
+ if (dirty_t && dirty_v)
+ return new Pair(Text, Value);
+
+ if (dirty_t)
+ return new Pair (Text, null);
+
+ if (dirty_v)
+ return new Pair(null, Value);
+
+ return null;
+ }
+
+ public override bool Equals (object o)
+ {
+ ListItem li = o as ListItem;
+ if (li == null)
+ return false;
+
+ return (Text == li.Text && Value == li.Value);
+ }
+
+ public override int GetHashCode ()
+ {
+ return base.GetHashCode ();
+ }
+
+ public override string ToString ()
+ {
+ return Text;
+ }
+
+ bool IStateManager.IsTrackingViewState
+ {
+ get
+ {
+ return IsTrackingViewState;
+ }
+ }
+
+ void IStateManager.TrackViewState()
+ {
+ TrackViewState();
+ }
+
+ object IStateManager.SaveViewState()
+ {
+ return SaveViewState();
+ }
+
+ void IStateManager.LoadViewState(object state)
+ {
+ LoadViewState(state);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListItemCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListItemCollection.cs
new file mode 100644
index 00000000000..a43de11e8d7
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListItemCollection.cs
@@ -0,0 +1,362 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: ListItemCollection
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+using System.Reflection;
+
+namespace System.Web.UI.WebControls
+{
+ //[Editor("??", typeof(Design.WebControls.ListItemCollectionEditor))]
+ public sealed class ListItemCollection : IList, ICollection, IEnumerable, IStateManager
+ {
+ private ArrayList items;
+ private bool saveAll;
+ private bool marked;
+
+ public ListItemCollection()
+ {
+ items = new ArrayList();
+ saveAll = false;
+ marked = false;
+ }
+
+ public int Capacity
+ {
+ get
+ {
+ return items.Capacity;
+ }
+ set
+ {
+ items.Capacity = value;
+ }
+ }
+
+ public int Count
+ {
+ get
+ {
+ return items.Count;
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return items.IsReadOnly;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return items.IsSynchronized;
+ }
+ }
+
+ public ListItem this[int index]
+ {
+ get
+ {
+ if(index < 0 || index >= Count)
+ return null;
+ return (ListItem)(items[index]);
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public void Add(ListItem item)
+ {
+ items.Add(item);
+ if(marked)
+ item.Dirty = true;
+ }
+
+ public void Add(string item)
+ {
+ Add(new ListItem(item));
+ }
+
+ public void AddRange(ListItem[] items)
+ {
+ foreach(ListItem item in items)
+ {
+ if(item!=null)
+ Add(item);
+ }
+ }
+
+ public void Clear()
+ {
+ items.Clear();
+ if(marked)
+ saveAll = true;
+ }
+
+ public bool Contains(ListItem item)
+ {
+ return items.Contains(item);
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ items.CopyTo(array, index);
+ }
+
+ public ListItem FindByText(string text)
+ {
+ int i=-1;
+ foreach(object current in items)
+ {
+ i++;
+ if(((ListItem)current).Text == text)
+ break;
+ }
+ return (i==-1 ? null : (ListItem)items[i]);
+ }
+
+ public ListItem FindByValue(string value)
+ {
+ foreach(ListItem current in items)
+ {
+ if(current.Value == value)
+ {
+ return current;
+ }
+ }
+ return null;
+ }
+
+ internal int FindByValueInternal(string value)
+ {
+ int i = -1;
+ foreach(ListItem current in items)
+ {
+ i++;
+ if(current.Value == value)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return items.GetEnumerator();
+ }
+
+ public int IndexOf(ListItem item)
+ {
+ return items.IndexOf(item);
+ }
+
+ public void Insert(int index, ListItem item)
+ {
+ items.Insert(index, item);
+ if(marked)
+ saveAll = true;
+ }
+
+ public void Insert(int index, string item)
+ {
+ Insert(index, new ListItem(item));
+ }
+
+ public void RemoveAt(int index)
+ {
+ if(index < 0 || index >= items.Count)
+ return;
+ items.RemoveAt(index);
+ if(marked)
+ saveAll = true;
+ }
+
+ public void Remove(ListItem item)
+ {
+ RemoveAt(IndexOf(item));
+ }
+
+ public void Remove(string item)
+ {
+ RemoveAt(IndexOf(ListItem.FromString(item)));
+ }
+
+ internal object SaveViewState ()
+ {
+ int count = Count;
+ if (saveAll) {
+ string [] keys = new string [count];
+ string [] vals = new string [count];
+ for(int i = 0; i < count; i++) {
+ keys[i] = this [i].Text;
+ vals[i] = this [i].Value;
+ }
+
+ return new Triplet (count, keys, vals);
+ }
+
+ ArrayList indices = new ArrayList ();
+ ArrayList states = new ArrayList ();
+ object o;
+ for(int i = 0; i < count; i++) {
+ o = this [i].SaveViewState ();
+ if (o == null)
+ continue;
+
+ indices.Add (i);
+ states.Add (o);
+ }
+
+ if (indices.Count > 0)
+ return new Pair (indices, states);
+
+ return null;
+ }
+
+ internal void LoadViewState (object savedState)
+ {
+ if (savedState == null)
+ return;
+
+ int i, end;
+ if (savedState is Pair) {
+ Pair pair = (Pair) savedState;
+ ArrayList indices = (ArrayList) pair.First;
+ ArrayList states = (ArrayList) pair.Second;
+
+ end = indices.Count;
+ for (i = 0; i < end; i++) {
+ if ((int) indices [i] < Count ) {
+ this [i].LoadViewState (states [i]);
+ } else {
+ ListItem temp = new ListItem ();
+ temp.LoadViewState (states [i]);
+ Add (temp);
+ }
+ }
+ } else if (savedState is Triplet) {
+ Triplet t = (Triplet) savedState;
+ items = new ArrayList ((int) t.First);
+ saveAll = true;
+ object [] text = (object []) t.Second;
+ object [] vals = (object []) t.Third;
+ end = text.Length;
+ for(i = 0; i < end; i++)
+ items.Add (new ListItem (text[i].ToString (), vals[i].ToString ()));
+ }
+ }
+
+ internal void TrackViewState()
+ {
+ marked = true;
+ foreach(ListItem current in items)
+ current.TrackViewState();
+ }
+
+ bool IList.IsFixedSize
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ object IList.this[int index]
+ {
+ get
+ {
+ return this[index];
+ }
+
+ set
+ {
+ if(index >= 0 && index < Count)
+ if(value is ListItem)
+ items[index] = (ListItem) value;
+ }
+ }
+
+ int IList.Add(object item)
+ {
+ int index = (item is ListItem ? items.Add((ListItem)item) : -1);
+ if(index!=-1 && marked)
+ ((ListItem)item).Dirty = true;
+ return index;
+ }
+
+ bool IList.Contains(object item)
+ {
+ if(item is ListItem)
+ return Contains((ListItem)item);
+ return false;
+ }
+
+ int IList.IndexOf(object item)
+ {
+ if(item is ListItem)
+ return IndexOf((ListItem)item);
+ return -1;
+ }
+
+ void IList.Insert(int index, object item)
+ {
+ if(item is ListItem)
+ Insert(index, (ListItem)item);
+ }
+
+ void IList.Remove(object item)
+ {
+ if(item is string)
+ Remove((string)item);
+ if(item is ListItem)
+ Remove((ListItem)item);
+ }
+
+ bool IStateManager.IsTrackingViewState
+ {
+ get
+ {
+ return marked;
+ }
+ }
+
+ void IStateManager.LoadViewState(object state)
+ {
+ LoadViewState(state);
+ }
+
+ object IStateManager.SaveViewState()
+ {
+ return SaveViewState();
+ }
+
+ void IStateManager.TrackViewState()
+ {
+ TrackViewState();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListItemControlBuilder.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListItemControlBuilder.cs
new file mode 100644
index 00000000000..16c60a196a7
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListItemControlBuilder.cs
@@ -0,0 +1,36 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: ListItemControlBuilder
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class ListItemControlBuilder : ControlBuilder
+ {
+ public ListItemControlBuilder(): base()
+ {
+ }
+
+ public override bool AllowWhitespaceLiterals()
+ {
+ return false;
+ }
+
+ public override bool HtmlDecodeLiterals()
+ {
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListItemType.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListItemType.cs
new file mode 100755
index 00000000000..3d45e73693a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListItemType.cs
@@ -0,0 +1,27 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: ListItemType
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum ListItemType
+ {
+ Header,
+ Footer,
+ Item,
+ AlternatingItem,
+ SelectedItem,
+ EditItem,
+ Separator,
+ Pager
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListSelectionMode.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListSelectionMode.cs
new file mode 100755
index 00000000000..f7c7967356c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListSelectionMode.cs
@@ -0,0 +1,21 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: ListSelectionMode
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum ListSelectionMode
+ {
+ Single,
+ Multiple
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Literal.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Literal.cs
new file mode 100644
index 00000000000..a2d4db5cc9e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Literal.cs
@@ -0,0 +1,62 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: Literal
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultProperty("Text")]
+ [ControlBuilder(typeof(LiteralControlBuilder))]
+ //[DataBindingHandler("??")]
+ public class Literal : Control
+ {
+ public Literal () : base ()
+ {
+ }
+
+ public string Text
+ {
+ get {
+ object o = ViewState ["Text"];
+ return (o == null) ? String.Empty : (string) o;
+ }
+
+ set { ViewState ["Text"] = value; }
+ }
+
+ protected override ControlCollection CreateControlCollection ()
+ {
+ return new EmptyControlCollection (this);
+ }
+
+ protected override void AddParsedSubObject (object obj)
+ {
+ if (!(obj is LiteralControl))
+ throw new HttpException (HttpRuntime.FormatResourceString (
+ "Cannot_Have_Children_Of_Type", "Literal",
+ obj.GetType ().Name.ToString ()));
+
+ Text = ((LiteralControl) obj).Text;
+ }
+
+ protected override void Render (HtmlTextWriter writer)
+ {
+ if (Text.Length > 0)
+ writer.Write (Text);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/LiteralControlBuilder.cs b/mcs/class/System.Web/System.Web.UI.WebControls/LiteralControlBuilder.cs
new file mode 100644
index 00000000000..75dcb77192a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/LiteralControlBuilder.cs
@@ -0,0 +1,36 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: LiteralControlBuilder
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class LiteralControlBuilder : ControlBuilder
+ {
+ public LiteralControlBuilder(): base()
+ {
+ }
+
+ public override bool AllowWhitespaceLiterals()
+ {
+ return false;
+ }
+
+ public override void AppendSubBuilder(ControlBuilder subBuilder)
+ {
+ throw new HttpException(HttpRuntime.FormatResourceString("Control_does_not_allow_children",(typeof(Literal)).ToString()));
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/MonthChangedEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/MonthChangedEventArgs.cs
new file mode 100644
index 00000000000..8de0d910c4b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/MonthChangedEventArgs.cs
@@ -0,0 +1,47 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: MonthChangedEventArgs
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class MonthChangedEventArgs
+ {
+ private DateTime nDate;
+ private DateTime pDate;
+
+ public MonthChangedEventArgs(DateTime newDate, DateTime previousDate)
+ {
+ nDate = newDate;
+ pDate = previousDate;
+ }
+
+ public DateTime NewDate
+ {
+ get
+ {
+ return nDate;
+ }
+ }
+
+ public DateTime PreviousDate
+ {
+ get
+ {
+ return pDate;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/MonthChangedEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/MonthChangedEventHandler.cs
new file mode 100644
index 00000000000..99a7a27157e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/MonthChangedEventHandler.cs
@@ -0,0 +1,16 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void MonthChangedEventHandler(object sender, MonthChangedEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/NextPrevFormat.cs b/mcs/class/System.Web/System.Web.UI.WebControls/NextPrevFormat.cs
new file mode 100755
index 00000000000..91d6cf3003b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/NextPrevFormat.cs
@@ -0,0 +1,22 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: NextPrevFormat
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum NextPrevFormat
+ {
+ CustomText,
+ ShortMonth,
+ FullMonth
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs b/mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs
new file mode 100644
index 00000000000..407d76a1a84
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs
@@ -0,0 +1,475 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: PagedDataSource
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class PagedDataSource : ICollection, IEnumerable, ITypedList
+ {
+ private int pageSize;
+ private bool allowPaging;
+ private int currentPageIndex;
+ private bool allowCustomPaging;
+ private int virtualCount;
+
+ private IEnumerable dataSource;
+
+ public PagedDataSource()
+ {
+ Initialize();
+ }
+
+ private void Initialize()
+ {
+ pageSize = 10;
+ allowPaging = false;
+ currentPageIndex = 0;
+ allowCustomPaging = false;
+ virtualCount = 0;
+ }
+
+ public bool AllowCustomPaging
+ {
+ get
+ {
+ return allowCustomPaging;
+ }
+ set
+ {
+ allowCustomPaging = value;
+ }
+ }
+
+ public bool AllowPaging
+ {
+ get
+ {
+ return allowPaging;
+ }
+ set
+ {
+ allowPaging = value;
+ }
+ }
+
+ public int Count
+ {
+ get
+ {
+ if(dataSource != null)
+ {
+ if(IsPagingEnabled)
+ {
+ return DataSourceCount;
+ }
+ if(IsCustomPagingEnabled)
+ {
+ return pageSize;
+ }
+ if(IsLastPage)
+ {
+ return (DataSourceCount - FirstIndexInPage);
+ }
+ return pageSize;
+ }
+ return 0;
+ }
+ }
+
+ public int CurrentPageIndex
+ {
+ get
+ {
+ return currentPageIndex;
+ }
+
+ set
+ {
+ currentPageIndex = value;
+ }
+ }
+
+ public IEnumerable DataSource
+ {
+ get
+ {
+ return dataSource;
+ }
+ set
+ {
+ dataSource = value;
+ }
+ }
+
+ public int DataSourceCount
+ {
+ get
+ {
+ if(dataSource != null)
+ {
+ if(IsCustomPagingEnabled)
+ {
+ return virtualCount;
+ }
+ if(dataSource is ICollection)
+ {
+ return ((ICollection)dataSource).Count;
+ }
+ throw new HttpException(HttpRuntime.FormatResourceString("PagedDataSource_Cannot_Get_Count"));
+ }
+ return 0;
+ }
+ }
+
+ public int FirstIndexInPage
+ {
+ get
+ {
+ if(dataSource != null && IsPagingEnabled && !IsCustomPagingEnabled)
+ {
+ return (currentPageIndex * pageSize);
+ }
+ return 0;
+ }
+ }
+
+ public bool IsCustomPagingEnabled
+ {
+ get
+ {
+ return (IsPagingEnabled && allowCustomPaging);
+ }
+ }
+
+ public bool IsFirstPage
+ {
+ get
+ {
+ return (!IsPagingEnabled || (CurrentPageIndex == 0));
+ }
+ }
+
+ public bool IsLastPage
+ {
+ get
+ {
+ return (!IsPagingEnabled || (CurrentPageIndex == PageCount));
+ }
+ }
+
+ public bool IsPagingEnabled
+ {
+ get
+ {
+ return (allowPaging && pageSize != 0);
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public int PageCount
+ {
+ get
+ {
+ if(dataSource != null)
+ {
+ int total = DataSourceCount;
+ if(!IsPagingEnabled)
+ {
+ return total;
+ }
+ return (total + pageSize - 1)/pageSize;
+ }
+ return 0;
+ }
+ }
+
+ public int PageSize
+ {
+ get
+ {
+ return pageSize;
+ }
+ set
+ {
+ pageSize = value;
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public int VirtualCount
+ {
+ get
+ {
+ return virtualCount;
+ }
+ set
+ {
+ virtualCount = value;
+ }
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ foreach(object current in this)
+ {
+ array.SetValue(array, index++);
+ }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ int fInd = FirstIndexInPage;
+ int count = -1;
+ if(dataSource is ICollection)
+ {
+ count = Count;
+ }
+
+ if(dataSource is IList)
+ {
+ return (new PrivateListEnumerator((IList)dataSource, fInd, count));
+ }
+ if(dataSource is Array)
+ {
+ return (new PrivateArrayEnumerator((object[])dataSource, fInd, count));
+ }
+ if(dataSource is ICollection)
+ {
+ return (new PrivateICollectionEnumerator((ICollection)dataSource, fInd, count));
+ }
+ if(allowCustomPaging)
+ {
+ return (new PrivateIEnumeratorEnumerator(dataSource.GetEnumerator(), Count));
+ }
+ return dataSource.GetEnumerator();
+ }
+
+ class PrivateIEnumeratorEnumerator : IEnumerator
+ {
+ private int index;
+ private int max;
+
+ private IEnumerator enumerator;
+
+ public PrivateIEnumeratorEnumerator(IEnumerator enumerator, int count)
+ {
+ this.enumerator = enumerator;
+ index = -1;
+ max = count;
+ }
+
+ public bool MoveNext()
+ {
+ enumerator.MoveNext();
+ index++;
+ return (index < max);
+ }
+
+ public void Reset()
+ {
+ index = -1;
+ enumerator.Reset();
+ }
+
+ public object Current
+ {
+ get
+ {
+ return enumerator.Current;
+ }
+ }
+ }
+
+ class PrivateICollectionEnumerator : IEnumerator
+ {
+ private int index;
+ private int start;
+ private int max;
+
+ private ICollection collection;
+ private IEnumerator collEnum;
+
+ public PrivateICollectionEnumerator(ICollection collection, int start, int count)
+ {
+ this.collection = collection;
+ this.start = start;
+ index = -1;
+ max = start + count;
+ if(max > collection.Count)
+ {
+ max = collection.Count;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ if(collEnum == null)
+ {
+ int cIndex = 0;
+ collEnum = collection.GetEnumerator();
+ while(cIndex < start)
+ {
+ collEnum.MoveNext();
+ }
+ }
+ collEnum.MoveNext();
+ index++;
+ return (start + index < max);
+ }
+
+ public void Reset()
+ {
+ index = -1;
+ collEnum = null;
+ }
+
+ public object Current
+ {
+ get
+ {
+ return collEnum.Current;
+ }
+ }
+ }
+
+ class PrivateArrayEnumerator : IEnumerator
+ {
+ private int index;
+ private int start;
+ private int max;
+ private object[] values;
+
+ public PrivateArrayEnumerator(object[] values, int start, int count)
+ {
+ this.values = values;
+ this.start = start;
+ index = -1;
+ max = start + count;
+ if(max > this.values.Length)
+ {
+ max = this.values.Length;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ index++;
+ return (index + start < max);
+ }
+
+ public void Reset()
+ {
+ index = -1;
+ }
+
+ public object Current
+ {
+ get
+ {
+ if(index >= 0)
+ {
+ return values[index + start];
+ }
+ throw new InvalidOperationException("Enumerator_MoveNext_Not_Called");
+ }
+ }
+ }
+
+ class PrivateListEnumerator : IEnumerator
+ {
+ private int index;
+ private int start;
+ private int max;
+ private IList collection;
+
+ public PrivateListEnumerator(IList list, int start, int count)
+ {
+ collection = list;
+ this.start = start;
+ index = -1;
+ max = start + count;
+ if(max > list.Count)
+ {
+ max = list.Count;
+ }
+ }
+
+ public bool MoveNext()
+ {
+ index++;
+ return (index + start < max);
+ }
+
+ public void Reset()
+ {
+ index = -1;
+ }
+
+ public object Current
+ {
+ get
+ {
+ if(index >= 0)
+ {
+ return collection[index + start];
+ }
+ throw new InvalidOperationException("Enumerator_MoveNext_Not_Called");
+ }
+ }
+ }
+
+ public string GetListName(PropertyDescriptor[] listAccessors)
+ {
+ return String.Empty;
+ }
+
+ public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
+ {
+ if(dataSource != null)
+ {
+ if(dataSource is ITypedList)
+ {
+ return ((ITypedList)dataSource).GetItemProperties(listAccessors);
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/PagerMode.cs b/mcs/class/System.Web/System.Web.UI.WebControls/PagerMode.cs
new file mode 100755
index 00000000000..5f99cee5773
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/PagerMode.cs
@@ -0,0 +1,21 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: PagerMode
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum PagerMode
+ {
+ NextPrev,
+ NumericPages
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/PagerPosition.cs b/mcs/class/System.Web/System.Web.UI.WebControls/PagerPosition.cs
new file mode 100755
index 00000000000..2ad9b466413
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/PagerPosition.cs
@@ -0,0 +1,22 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: PagerPosition
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum PagerPosition
+ {
+ Bottom,
+ Top,
+ TopAndBottom
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Panel.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Panel.cs
new file mode 100644
index 00000000000..82c7ea11d37
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Panel.cs
@@ -0,0 +1,97 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: Panel
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ //[Designer("??")]
+ [ParseChildren(false)]
+ [PersistChildren(true)]
+ [ToolboxData("<{0}:Panel runat=\"server\">Panel</{0}:Panel>")]
+ public class Panel: WebControl
+ {
+ public Panel(): base(HtmlTextWriterTag.Div)
+ {
+ }
+
+ public virtual string BackImageUrl
+ {
+ get
+ {
+ object o = ViewState["BackImageUrl"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["BackImageUrl"] = value;
+ }
+ }
+
+ public virtual HorizontalAlign HorizontalAlign
+ {
+ get
+ {
+ object o = ViewState["HorizontalAlign"];
+ if(o != null)
+ return (HorizontalAlign)o;
+ return HorizontalAlign.NotSet;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(HorizontalAlign), value))
+ {
+ throw new ArgumentException();
+ }
+ ViewState["HorizontalAlign"] = value;
+ }
+ }
+
+ public virtual bool Wrap
+ {
+ get
+ {
+ object o = ViewState["Wrap"];
+ if(o != null)
+ return (bool)o;
+ return true;
+ }
+ set
+ {
+ ViewState["Wrap"] = value;
+ }
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender(writer);
+ if(BackImageUrl.Length > 0)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveUrl(BackImageUrl) + ")");
+ }
+ if(HorizontalAlign != HorizontalAlign.NotSet)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Align, TypeDescriptor.GetConverter(typeof(HorizontalAlign)).ConvertToString(HorizontalAlign));
+ }
+ if(Wrap)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/PlaceHolder.cs b/mcs/class/System.Web/System.Web.UI.WebControls/PlaceHolder.cs
new file mode 100644
index 00000000000..19cc57bfd2e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/PlaceHolder.cs
@@ -0,0 +1,28 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: PlaceHolder
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [ControlBuilder(typeof(PlaceHolderControlBuilder))]
+ public class PlaceHolder : Control
+ {
+ public PlaceHolder(): base()
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/PlaceHolderControlBuilder.cs b/mcs/class/System.Web/System.Web.UI.WebControls/PlaceHolderControlBuilder.cs
new file mode 100644
index 00000000000..3bbd68c6d22
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/PlaceHolderControlBuilder.cs
@@ -0,0 +1,31 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: PlaceHolderControlBuilder
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class PlaceHolderControlBuilder : ControlBuilder
+ {
+ public PlaceHolderControlBuilder(): base()
+ {
+ }
+
+ public override bool AllowWhitespaceLiterals()
+ {
+ return false;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
new file mode 100644
index 00000000000..c999695a8aa
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
@@ -0,0 +1,125 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: RadioButton
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ //[Designer("??")]
+ public class RadioButton : CheckBox, IPostBackDataHandler
+ {
+ public RadioButton () : base ()
+ {
+ }
+
+ public virtual string GroupName
+ {
+ get {
+ object o = ViewState ["GroupName"];
+ return (o == null) ? String.Empty : (string) o;
+ }
+
+ set { ViewState ["GroupName"] = value; }
+ }
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender (e);
+ if (Page != null && Enabled && !Checked)
+ Page.RegisterRequiresPostBack (this);
+
+ if(GroupName.Length == 0)
+ GroupName = UniqueID;
+ }
+
+ internal override void RenderInputTag (HtmlTextWriter writer, string id)
+ {
+ writer.AddAttribute (HtmlTextWriterAttribute.Id, id);
+ writer.AddAttribute (HtmlTextWriterAttribute.Type, "radio");
+ writer.AddAttribute (HtmlTextWriterAttribute.Name, UniqueGroupNamePrivate);
+ writer.AddAttribute (HtmlTextWriterAttribute.Value, ValueAttributePrivate);
+
+ if (Checked)
+ writer.AddAttribute (HtmlTextWriterAttribute.Checked, "checked");
+
+ if (AutoPostBack){
+ writer.AddAttribute (HtmlTextWriterAttribute.Onclick,
+ Page.GetPostBackClientEvent (this, ""));
+ writer.AddAttribute ("language", "javascript");
+ }
+
+ if (AccessKey.Length > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Accesskey, AccessKey);
+
+ if (TabIndex > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Tabindex,
+ TabIndex.ToString (NumberFormatInfo.InvariantInfo));
+
+ writer.RenderBeginTag (System.Web.UI.HtmlTextWriterTag.Input);
+ writer.RenderEndTag ();
+ }
+
+ private string UniqueGroupNamePrivate
+ {
+ get {
+ string retVal = GroupName;
+ int unique = UniqueID.LastIndexOf (':');
+ if (unique >= 0)
+ retVal += UniqueID.Substring (unique + 1);
+
+ return retVal;
+ }
+ }
+
+ private string ValueAttributePrivate
+ {
+ get {
+ string retVal = Attributes ["value"];
+ if (retVal != null)
+ return retVal;
+
+ if (ID != null)
+ return ID;
+
+ return UniqueID;
+ }
+ }
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ bool _checked = Checked;
+ if (postCollection [UniqueGroupNamePrivate] == ValueAttributePrivate){
+ if (_checked)
+ return false;
+ Checked = true;
+ return true;
+ }
+
+ if (_checked)
+ Checked = false;
+ return true;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ OnCheckedChanged (EventArgs.Empty);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs
new file mode 100644
index 00000000000..c1f0ece4094
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs
@@ -0,0 +1,244 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: RadioButtonList
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 95%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [ValidationProperty("SelectedItem")]
+ public class RadioButtonList : ListControl, IRepeatInfoUser, INamingContainer, IPostBackDataHandler
+ {
+ private bool selectionIndexChanged;
+ private short tabIndex;
+
+ public RadioButtonList(): base()
+ {
+ selectionIndexChanged = false;
+ }
+
+ public virtual int CellPadding
+ {
+ get
+ {
+ if(ControlStyleCreated)
+ {
+ return (int)(((TableStyle)ControlStyle).CellPadding);
+ }
+ return -1;
+ }
+ set
+ {
+ ((TableStyle)ControlStyle).CellPadding = value;
+ }
+ }
+
+ public virtual int CellSpacing
+ {
+ get
+ {
+ if(ControlStyleCreated)
+ {
+ return (int)(((TableStyle)ControlStyle).CellSpacing);
+ }
+ return -1;
+ }
+ set
+ {
+ ((TableStyle)ControlStyle).CellSpacing = value;
+ }
+ }
+
+ public virtual int RepeatColumns
+ {
+ get
+ {
+ object o = ViewState["RepeatColumns"];
+ if(o != null)
+ return (int)o;
+ return 0;
+ }
+ set
+ {
+ if(value < 0)
+ throw new ArgumentOutOfRangeException("value");
+ ViewState["RepeatColumns"] = value;
+ }
+ }
+
+ public virtual RepeatDirection RepeatDirection
+ {
+ get
+ {
+ object o = ViewState["RepeatDirection"];
+ if(o != null)
+ return (RepeatDirection)o;
+ return RepeatDirection.Vertical;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(RepeatDirection), value))
+ throw new ArgumentException();
+ ViewState["RepeatDirection"] = value;
+ }
+ }
+
+ public virtual RepeatLayout RepeatLayout
+ {
+ get
+ {
+ object o = ViewState["RepeatLayout"];
+ if(o != null)
+ return (RepeatLayout)o;
+ return RepeatLayout.Table;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(RepeatLayout), value))
+ throw new ArgumentException();
+ ViewState["RepeatLayout"] = value;
+ }
+ }
+
+ public virtual TextAlign TextAlign
+ {
+ get
+ {
+ object o = ViewState["TextAlign"];
+ if(o != null)
+ return (TextAlign)o;
+ return TextAlign.Right;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(TextAlign), value))
+ throw new ArgumentException();
+ ViewState["TextAlign"] = value;
+ }
+ }
+
+ protected override Style CreateControlStyle()
+ {
+ return new TableStyle(ViewState);
+ }
+
+ protected override void Render(HtmlTextWriter writer)
+ {
+ RepeatInfo info = new RepeatInfo();
+ Style cStyle = (ControlStyleCreated ? ControlStyle : null);
+ bool dirty = false;
+ tabIndex = TabIndex;
+ if(tabIndex != 0)
+ {
+ dirty = !ViewState.IsItemDirty("TabIndex");
+ TabIndex = 0;
+ }
+ info.RepeatColumns = RepeatColumns;
+ info.RepeatDirection = RepeatDirection;
+ info.RenderRepeater(writer, this, cStyle, this);
+ if(tabIndex != 0)
+ {
+ TabIndex = tabIndex;
+ }
+ if(dirty)
+ {
+ ViewState.SetItemDirty("TabIndex", false);
+ }
+ }
+
+ bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
+ {
+ string value = postCollection[postDataKey];
+ for(int i=0; i < Items.Count; i++)
+ {
+ if(Items[i].Value == value)
+ {
+ if(i != SelectedIndex)
+ {
+ SelectedIndex = i;
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent()
+ {
+ if(selectionIndexChanged)
+ OnSelectedIndexChanged(EventArgs.Empty);
+ }
+
+ Style IRepeatInfoUser.GetItemStyle(System.Web.UI.WebControls.ListItemType itemType, int repeatIndex)
+ {
+ return null;
+ }
+
+ void IRepeatInfoUser.RenderItem (System.Web.UI.WebControls.ListItemType itemType,
+ int repeatIndex,
+ RepeatInfo repeatInfo,
+ HtmlTextWriter writer)
+ {
+ /* Create a new RadioButton as if it was defined in the page and render it */
+ RadioButton button = new RadioButton ();
+ button.GroupName = UniqueID;
+ button.TextAlign = TextAlign;
+ button.AutoPostBack = AutoPostBack;
+ button.ID = ClientID + "_" + repeatIndex.ToString (NumberFormatInfo.InvariantInfo);;
+ object view_state = ViewState ["TabIndex"];
+ if (view_state != null)
+ button.TabIndex = (short) view_state;
+ ListItem current = Items [repeatIndex];
+ button.Text = current.Text;
+ button.Attributes ["value"] = current.Value;
+ button.Checked = current.Selected;
+ button.RenderControl (writer);
+ }
+
+ bool IRepeatInfoUser.HasFooter
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ bool IRepeatInfoUser.HasHeader
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ bool IRepeatInfoUser.HasSeparators
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ int IRepeatInfoUser.RepeatedItemCount
+ {
+ get
+ {
+ return Items.Count;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RangeValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RangeValidator.cs
new file mode 100644
index 00000000000..43a496023b5
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RangeValidator.cs
@@ -0,0 +1,125 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: RangeValidator
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.Xml;
+
+namespace System.Web.UI.WebControls
+{
+ [ToolboxData("<{0}:RangeValidator runat=\"server\" "
+ + "ErrorMessage=\"RangeValidator\"></{0}:RangeValidator>")]
+ public class RangeValidator : BaseCompareValidator
+ {
+ public RangeValidator(): base()
+ {
+ }
+
+ public string MaximumValue
+ {
+ get
+ {
+ object o = ViewState["MaximumValue"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["MaximumValue"] = value;
+ }
+ }
+
+ public string MinimumValue
+ {
+ get
+ {
+ object o = ViewState["MinimumValue"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["MinimumValue"] = value;
+ }
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender(writer);
+ if(base.RenderUplevel)
+ {
+ writer.AddAttribute("evaluationfunction", "RangeValidatorEvaluateIsValid");
+ writer.AddAttribute("maximumvalue", MaximumValue);
+ writer.AddAttribute("minimumvalue", MinimumValue);
+ }
+ }
+
+ protected override bool ControlPropertiesValid()
+ {
+ string max = MaximumValue;
+ if(!CanConvert(max, Type))
+ {
+ string[] fmt = new string[4];
+ fmt[0] = max;
+ fmt[1] = "MaximumValue";
+ fmt[2] = ID;
+ fmt[3] = PropertyConverter.EnumToString(typeof(ValidationDataType), Type);
+ throw new HttpException(HttpRuntime.FormatResourceString("Validator_value_bad_type", fmt));
+ }
+ string min = MaximumValue;
+ if(!CanConvert(min, Type))
+ {
+ string[] fmt = new string[4];
+ fmt[0] = min;
+ fmt[1] = "MinimumValue";
+ fmt[2] = ID;
+ fmt[3] = PropertyConverter.EnumToString(typeof(ValidationDataType), Type);
+ throw new HttpException(HttpRuntime.FormatResourceString("Validator_value_bad_type", fmt));
+ }
+
+ if(Compare(max, min, ValidationCompareOperator.GreaterThan, ValidationDataType.Double))
+ {
+ string[] fmt = new string[3];
+ fmt[0] = min;
+ fmt[1] = max;
+ fmt[2] = PropertyConverter.EnumToString(typeof(ValidationDataType), Type);
+ throw new HttpException(HttpRuntime.FormatResourceString("Validator_range_overalap", fmt));
+ }
+ return base.ControlPropertiesValid();
+ }
+
+ protected override bool EvaluateIsValid()
+ {
+ string ctrl = GetControlValidationValue(ControlToValidate);
+ if(ctrl == null || ctrl.Trim().Length == 0)
+ {
+ return true;
+ }
+ bool retVal = Compare(ctrl, MinimumValue, ValidationCompareOperator.GreaterThanEqual,
+ ValidationDataType.String);
+ if(!retVal)
+ {
+ retVal = Compare(ctrl, MaximumValue, ValidationCompareOperator.LessThanEqual,
+ ValidationDataType.String);
+ }
+ return retVal;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RegularExpressionValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RegularExpressionValidator.cs
new file mode 100644
index 00000000000..dd2ee91de64
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RegularExpressionValidator.cs
@@ -0,0 +1,88 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: RegularExpressionValidator
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.Text.RegularExpressions;
+
+namespace System.Web.UI.WebControls
+{
+ [ToolboxData("<{0}:RegularExpressionValidator runat=\"server\" "
+ + "ErrorMessage=\"RegularExpressionValidator\">"
+ + "</{0}:RegularExpressionValidator>")]
+ public class RegularExpressionValidator : BaseValidator
+ {
+ public RegularExpressionValidator(): base()
+ {
+ }
+
+ public string ValidationExpression
+ {
+ get
+ {
+ object o = ViewState["ValidationExpression"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ try
+ {
+ Regex.IsMatch("", value);
+ } catch(Exception)
+ {
+ throw new HttpException(HttpRuntime.FormatResourceString("Validator_bad_regex", value));
+ }
+ ViewState["ValidationExpression"] = value;
+ }
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender(writer);
+ if(base.RenderUplevel)
+ {
+ writer.AddAttribute("evaluationfunction", "RegularExpressionValidatorEvaluateIsValid");
+ string exp = ValidationExpression;
+ if(exp.Length > 0)
+ {
+ writer.AddAttribute("validationexpression", exp);
+ }
+ }
+ }
+
+ protected override bool EvaluateIsValid ()
+ {
+ string ctrl = GetControlValidationValue (ControlToValidate);
+ if (ctrl == null || ctrl.Trim ().Length == 0)
+ return true;
+
+ bool retVal;
+ try {
+ Match match = Regex.Match (ctrl, ValidationExpression);
+ if (match.Success && match.Index == 0) {
+ retVal = true;
+ } else {
+ retVal = false;
+ }
+ } catch (Exception) {
+ retVal = true;
+ }
+ return retVal;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RepeatDirection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RepeatDirection.cs
new file mode 100755
index 00000000000..fc26596dafc
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RepeatDirection.cs
@@ -0,0 +1,21 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: RepeatDirection
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum RepeatDirection
+ {
+ Horizontal,
+ Vertical
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RepeatInfo.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RepeatInfo.cs
new file mode 100644
index 00000000000..79ad32eb23d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RepeatInfo.cs
@@ -0,0 +1,372 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: RepeatInfo
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class RepeatInfo
+ {
+ private bool outerTableImp;
+ private int repeatColumns;
+ private RepeatDirection repeatDirection;
+ private RepeatLayout repeatLayout;
+
+ public RepeatInfo()
+ {
+ outerTableImp = false;
+ repeatColumns = 0;
+ repeatDirection = RepeatDirection.Vertical;
+ repeatLayout = RepeatLayout.Table;
+ }
+
+ public bool OuterTableImplied
+ {
+ get
+ {
+ return outerTableImp;
+ }
+ set
+ {
+ outerTableImp = value;
+ }
+ }
+
+ public int RepeatColumns
+ {
+ get
+ {
+ return repeatColumns;
+ }
+ set
+ {
+ repeatColumns = value;
+ }
+ }
+
+ public RepeatDirection RepeatDirection
+ {
+ get
+ {
+ return repeatDirection;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(RepeatDirection), value))
+ throw new ArgumentException();
+ repeatDirection = value;
+ }
+ }
+
+ public RepeatLayout RepeatLayout
+ {
+ get
+ {
+ return repeatLayout;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(RepeatLayout), value))
+ throw new ArgumentException();
+ repeatLayout = value;
+ }
+ }
+
+ public void RenderRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
+ {
+ if(RepeatDirection == RepeatDirection.Vertical)
+ {
+ DoVerticalRendering(writer, user, controlStyle, baseControl);
+ } else
+ {
+ DoHorizontalRendering(writer, user, controlStyle, baseControl);
+ }
+ }
+
+ private void DoVerticalRendering(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
+ {
+ int total = user.RepeatedItemCount;
+ int colsCount;
+ int rowsCount;
+ if(repeatColumns == 0 || repeatColumns==1)
+ {
+ colsCount = 1;
+ rowsCount = total;
+ } else
+ {
+ colsCount = repeatColumns;
+ rowsCount = (total + repeatColumns - 1) / repeatColumns;
+ if(rowsCount ==0 && total != 0)
+ {
+ rowsCount = 1;
+ colsCount = total;
+ }
+ }
+ WebControl ctrl = null;
+ bool isTable = true;
+ bool hasSeps = user.HasSeparators;
+ if(!outerTableImp)
+ {
+ if(RepeatLayout == RepeatLayout.Table)
+ {
+ ctrl = new Table();
+ } else
+ {
+ ctrl = new WebControl(HtmlTextWriterTag.Span);
+ isTable = false;
+ }
+ }
+
+ if(ctrl != null)
+ {
+ ctrl.ID = baseControl.ClientID;
+ ctrl.CopyBaseAttributes(baseControl);
+ ctrl.ApplyStyle(controlStyle);
+ ctrl.RenderBeginTag(writer);
+ }
+
+ Style itemStyle;
+ int colSpan = 0;
+ if(user.HasHeader)
+ {
+ if(isTable)
+ {
+ writer.RenderBeginTag(HtmlTextWriterTag.Tr);
+ if(rowsCount != 1)
+ {
+ colSpan = rowsCount;
+ if(hasSeps)
+ colSpan += rowsCount;
+ writer.AddAttribute(HtmlTextWriterAttribute.Colspan, colSpan.ToString(NumberFormatInfo.InvariantInfo));
+ }
+ itemStyle = user.GetItemStyle(ListItemType.Header, -1);
+ if(itemStyle != null)
+ {
+ itemStyle.AddAttributesToRender(writer);
+ }
+ writer.RenderBeginTag(HtmlTextWriterTag.Td);
+ }
+ user.RenderItem(ListItemType.Header, -1, this, writer);
+ if(isTable)
+ {
+ writer.RenderEndTag();
+ writer.RenderEndTag();
+ } else
+ {
+ if(!outerTableImp)
+ {
+ writer.WriteFullBeginTag("br");
+ }
+ }
+ }
+
+ int rowIndex = 0;
+ int colIndex = 0;
+ int index = 0;
+ while(rowIndex < rowsCount)
+ {
+ if(isTable)
+ writer.RenderBeginTag(HtmlTextWriterTag.Tr);
+ colIndex = 0;
+ while(colIndex < colsCount)
+ {
+ index = rowIndex + colIndex * rowsCount;
+ if(index < total)
+ {
+ if(isTable)
+ {
+ itemStyle = user.GetItemStyle(ListItemType.Item, index);
+ if(itemStyle != null)
+ {
+ itemStyle.AddAttributesToRender(writer);
+ }
+ writer.RenderBeginTag(HtmlTextWriterTag.Td);
+ }
+ user.RenderItem(ListItemType.Item, index, this, writer);
+ if(isTable)
+ writer.RenderEndTag();
+ if(hasSeps && index != (total - 1))
+ {
+ if(colsCount == 1)
+ {
+ writer.RenderEndTag();
+ writer.RenderBeginTag(HtmlTextWriterTag.Tr);
+ } else
+ {
+ writer.WriteFullBeginTag("br");
+ }
+ if(isTable)
+ {
+ itemStyle = user.GetItemStyle(ListItemType.Separator, index);
+ if(itemStyle != null)
+ itemStyle.AddAttributesToRender(writer);
+ writer.RenderBeginTag(HtmlTextWriterTag.Td);
+ }
+ if(index < total)
+ user.RenderItem(ListItemType.Separator, index, this, writer);
+ if(isTable)
+ writer.RenderEndTag();
+ }
+ }
+ colIndex++;
+ }
+ if(isTable)
+ writer.RenderEndTag();
+ else
+ if(rowIndex != (rowsCount - 1) || (user.HasFooter && !outerTableImp))
+ writer.WriteFullBeginTag("br");
+ rowIndex++;
+ }
+ if(user.HasFooter)
+ {
+ if(isTable)
+ {
+ writer.RenderBeginTag(HtmlTextWriterTag.Tr);
+ if(colsCount != 1)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Colspan, colSpan.ToString(NumberFormatInfo.InvariantInfo));
+ }
+ itemStyle = user.GetItemStyle(ListItemType.Footer, -1);
+ if(itemStyle != null)
+ {
+ itemStyle.AddAttributesToRender(writer);
+ }
+ writer.RenderBeginTag(HtmlTextWriterTag.Td);
+ }
+ user.RenderItem(ListItemType.Footer, -1, this, writer);
+ if(isTable)
+ {
+ writer.RenderEndTag();
+ writer.RenderEndTag();
+ }
+ }
+ if(ctrl != null)
+ {
+ ctrl.RenderEndTag(writer);
+ }
+ }
+
+ private void DoHorizontalRendering (HtmlTextWriter writer,
+ IRepeatInfoUser user,
+ Style controlStyle,
+ WebControl baseControl)
+ {
+ /* Based on DoVerticalRendering */
+ int total = user.RepeatedItemCount;
+ int colsCount = repeatColumns;
+ int rowsCount = 0;
+
+ if (colsCount == 0)
+ colsCount = total;
+ WebControl ctrl = null;
+ bool isTable = true;
+ bool hasSeps = user.HasSeparators;
+ if (!outerTableImp){
+ isTable = (RepeatLayout == RepeatLayout.Table);
+ ctrl = (isTable) ? new Table () : new WebControl (HtmlTextWriterTag.Span);
+ ctrl.ID = baseControl.ClientID;
+ ctrl.CopyBaseAttributes (baseControl);
+ ctrl.ApplyStyle (controlStyle);
+ ctrl.RenderBeginTag (writer);
+ }
+
+ Style itemStyle;
+ int colSpan = 0;
+ if (user.HasHeader){
+ if (isTable){
+ writer.RenderBeginTag (HtmlTextWriterTag.Tr);
+ if (rowsCount != 1){
+ colSpan = rowsCount;
+ if (hasSeps)
+ colSpan += rowsCount;
+ writer.AddAttribute (HtmlTextWriterAttribute.Colspan,
+ colSpan.ToString (NumberFormatInfo.InvariantInfo));
+ }
+ itemStyle = user.GetItemStyle (ListItemType.Header, -1);
+ if (itemStyle != null)
+ itemStyle.AddAttributesToRender (writer);
+ writer.RenderBeginTag (HtmlTextWriterTag.Td);
+ }
+
+ user.RenderItem (ListItemType.Header, -1, this, writer);
+
+ if (isTable){
+ writer.RenderEndTag();
+ writer.RenderEndTag();
+ } else if (!outerTableImp)
+ writer.WriteFullBeginTag ("br");
+ }
+
+ for (int index = 0; index < total; index++){
+ if (isTable && index == 0)
+ writer.RenderBeginTag (HtmlTextWriterTag.Tr);
+
+ if (isTable){
+ itemStyle = user.GetItemStyle (ListItemType.Item, index);
+ if (itemStyle != null)
+ itemStyle.AddAttributesToRender(writer);
+ writer.RenderBeginTag(HtmlTextWriterTag.Td);
+ }
+
+ user.RenderItem(ListItemType.Item, index, this, writer);
+ if (isTable)
+ writer.RenderEndTag ();
+
+ if (hasSeps && index != (total - 1)){
+ if (isTable){
+ itemStyle = user.GetItemStyle (ListItemType.Separator, index);
+ if (itemStyle != null)
+ itemStyle.AddAttributesToRender (writer);
+ writer.RenderBeginTag (HtmlTextWriterTag.Td);
+ }
+ user.RenderItem (ListItemType.Separator, index, this, writer);
+ if (isTable)
+ writer.RenderEndTag ();
+ }
+ rowsCount++;
+ if (rowsCount == total || index == (total - 1)) {
+ if (isTable)
+ writer.RenderEndTag ();
+ else if (rowsCount < total)
+ writer.WriteFullBeginTag ("br");
+ rowsCount = 0;
+ }
+ }
+
+ if (user.HasFooter){
+ if (isTable){
+ writer.RenderBeginTag (HtmlTextWriterTag.Tr);
+ if (colsCount != 1)
+ writer.AddAttribute (HtmlTextWriterAttribute.Colspan,
+ colSpan.ToString(NumberFormatInfo.InvariantInfo));
+
+ itemStyle = user.GetItemStyle (ListItemType.Footer, -1);
+ if(itemStyle != null)
+ itemStyle.AddAttributesToRender (writer);
+ writer.RenderBeginTag (HtmlTextWriterTag.Td);
+ }
+ user.RenderItem (ListItemType.Footer, -1, this, writer);
+ if (isTable){
+ writer.RenderEndTag ();
+ writer.RenderEndTag ();
+ }
+ }
+
+ if (ctrl != null)
+ ctrl.RenderEndTag(writer);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RepeatLayout.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RepeatLayout.cs
new file mode 100755
index 00000000000..de1e81530e0
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RepeatLayout.cs
@@ -0,0 +1,21 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: RepeatLayout
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum RepeatLayout
+ {
+ Table,
+ Flow
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Repeater.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Repeater.cs
new file mode 100644
index 00000000000..d5362c97fa7
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Repeater.cs
@@ -0,0 +1,377 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: Repeater
+ *
+ * Author: Gaurav Vaish, Gonzalo Paniagua (gonzalo@ximian.com)
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ * (c) 2002 Ximian, Inc. (http://www.ximian.com)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+using System.Web.Util;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("ItemCommand")]
+ [DefaultProperty("DataSource")]
+ //[Designer("??")]
+ [ParseChildren(true)]
+ [PersistChildren(false)]
+ public class Repeater : Control, INamingContainer
+ {
+ private static readonly object ItemCommandEvent = new object();
+ private static readonly object ItemCreatedEvent = new object();
+ private static readonly object ItemDataBoundEvent = new object();
+
+ private static readonly string ITEMCOUNT = "Repeater_Item_Count";
+
+ private ITemplate alternatingItemTemplate;
+ private ITemplate footerTemplate;
+ private ITemplate headerTemplate;
+ private ITemplate itemTemplate;
+ private ITemplate separatorTemplate;
+ private object dataSource;
+
+ private RepeaterItemCollection items;
+ private ArrayList itemsArrayList;
+
+ public Repeater(): base()
+ {
+ }
+
+ public event RepeaterCommandEventHandler ItemCommand
+ {
+ add
+ {
+ Events.AddHandler(ItemCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ItemCommandEvent, value);
+ }
+ }
+
+ public event RepeaterItemEventHandler ItemCreated
+ {
+ add
+ {
+ Events.AddHandler(ItemCreatedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ItemCreatedEvent, value);
+ }
+ }
+
+ public event RepeaterItemEventHandler ItemDataBound
+ {
+ add
+ {
+ Events.AddHandler(ItemDataBoundEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ItemDataBoundEvent, value);
+ }
+ }
+
+ public virtual ITemplate AlternatingItemTemplate
+ {
+ get
+ {
+ return alternatingItemTemplate;
+ }
+ set
+ {
+ alternatingItemTemplate = value;
+ }
+ }
+
+ public override ControlCollection Controls
+ {
+ get
+ {
+ EnsureChildControls();
+ return base.Controls;
+ }
+ }
+
+ public virtual string DataMember
+ {
+ get
+ {
+ object o = ViewState["DataMember"];
+ if(o != null)
+ {
+ return (string)o;
+ }
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["DataMember"] = value;
+ }
+ }
+
+ public virtual object DataSource
+ {
+ get
+ {
+ return dataSource;
+ }
+ set
+ {
+ dataSource = value;
+ }
+ }
+
+ public virtual ITemplate FooterTemplate
+ {
+ get
+ {
+ return footerTemplate;
+ }
+ set
+ {
+ footerTemplate = value;
+ }
+ }
+
+ public virtual ITemplate HeaderTemplate
+ {
+ get
+ {
+ return headerTemplate;
+ }
+ set
+ {
+ headerTemplate = value;
+ }
+ }
+
+ public virtual RepeaterItemCollection Items
+ {
+ get
+ {
+ if(items != null)
+ {
+ if(itemsArrayList != null)
+ {
+ EnsureChildControls();
+ }
+ items = new RepeaterItemCollection(itemsArrayList);
+ }
+ return items;
+ }
+ }
+
+ public virtual ITemplate ItemTemplate
+ {
+ get
+ {
+ return itemTemplate;
+ }
+ set
+ {
+ itemTemplate = value;
+ }
+ }
+
+ public virtual ITemplate SeparatorTemplate
+ {
+ get
+ {
+ return separatorTemplate;
+ }
+ set
+ {
+ separatorTemplate = value;
+ }
+ }
+
+ public override void DataBind()
+ {
+ OnDataBinding(EventArgs.Empty);
+ }
+
+ protected override void CreateChildControls()
+ {
+ Controls.Clear();
+ if(ViewState[ITEMCOUNT] != null)
+ {
+ CreateControlHierarchy(false);
+ } else
+ {
+ itemsArrayList = new ArrayList();
+ }
+ ClearChildViewState();
+ }
+
+ private RepeaterItem CreateItem (int itemIndex,
+ ListItemType itemType,
+ bool dataBind,
+ object dataItem)
+ {
+ RepeaterItem repeaterItem = new RepeaterItem (itemIndex, itemType);
+ RepeaterItemEventArgs repeaterEventArgs = new RepeaterItemEventArgs (repeaterItem);
+ InstantiateItem (repeaterItem);
+ if (dataBind)
+ repeaterItem.DataItem = dataItem;
+ OnItemCreated (repeaterEventArgs);
+ Controls.Add (repeaterItem);
+ if (dataBind) {
+ repeaterItem.DataBind ();
+ OnItemDataBound (repeaterEventArgs);
+ repeaterItem.DataItem = null;
+ }
+ return repeaterItem;
+ }
+
+ private void InstantiateItem (RepeaterItem item)
+ {
+ ITemplate template;
+ switch (item.ItemType) {
+ case ListItemType.Header:
+ template = this.headerTemplate;
+ break;
+ case ListItemType.Footer:
+ template = this.footerTemplate;
+ break;
+ case ListItemType.Item:
+ template = this.itemTemplate;
+ break;
+ case ListItemType.AlternatingItem:
+ template = this.alternatingItemTemplate;
+ break;
+ case ListItemType.Separator:
+ template = this.separatorTemplate;
+ break;
+ default:
+ throw new HttpException ("Unknown ListItemType: " + item.ItemType);
+ }
+
+ template.InstantiateIn (item);
+ }
+
+ protected virtual void CreateControlHierarchy (bool useDataSource)
+ {
+ ArrayList itemList = new ArrayList ();
+ items = new RepeaterItemCollection (itemList);
+ IEnumerable ds = null;
+ if (useDataSource)
+ ds = DataSourceHelper.GetResolvedDataSource (DataSource, DataMember);
+
+ if (!useDataSource) {
+ int itemCount = (int) ViewState [ITEMCOUNT];
+ if (itemCount != -1)
+ ds = new ArrayList (itemCount);
+ }
+
+ if (ds == null)
+ return;
+
+ if (headerTemplate != null)
+ CreateItem (-1, ListItemType.Header, useDataSource, null);
+
+ bool even = true;
+ int index = 0;
+ foreach (object item in ds){
+ if (separatorTemplate != null && index > 0)
+ CreateItem (index - 1, ListItemType.Separator, useDataSource, null);
+
+ RepeaterItem repeaterItem;
+ ListItemType lType;
+ if (!even && alternatingItemTemplate != null)
+ lType = ListItemType.AlternatingItem;
+ else
+ lType = ListItemType.Item;
+
+ repeaterItem = CreateItem (index, lType, useDataSource, item);
+ itemList.Add (repeaterItem);
+ index++;
+ even = !even;
+ }
+
+ if (footerTemplate != null)
+ CreateItem (-1, ListItemType.Footer, useDataSource, null);
+ }
+
+ protected override bool OnBubbleEvent(object sender, EventArgs e)
+ {
+ bool retVal = false;
+ if(e is RepeaterCommandEventArgs)
+ {
+ OnItemCommand((RepeaterCommandEventArgs)e);
+ retVal = true;
+ }
+ return retVal;
+ }
+
+ protected override void OnDataBinding(EventArgs e)
+ {
+ base.OnDataBinding(e);
+ Controls.Clear();
+ ClearChildViewState();
+ CreateControlHierarchy(true);
+ ChildControlsCreated = true;
+ }
+
+ protected virtual void OnItemCommand(RepeaterCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ RepeaterCommandEventHandler rceh = (RepeaterCommandEventHandler)
+ Events [ItemCommandEvent];
+ if(rceh != null)
+ {
+ rceh(this, e);
+ }
+ }
+ }
+
+ protected virtual void OnItemCreated(RepeaterItemEventArgs e)
+ {
+ if(Events != null)
+ {
+ RepeaterItemEventHandler rceh = (RepeaterItemEventHandler)
+ Events [ItemCreatedEvent];
+ if(rceh != null)
+ {
+ rceh(this, e);
+ }
+ }
+ }
+
+ protected virtual void OnItemDataBound(RepeaterItemEventArgs e)
+ {
+ if(Events != null)
+ {
+ RepeaterItemEventHandler rceh = (RepeaterItemEventHandler)
+ Events [ItemDataBoundEvent];
+ if(rceh != null)
+ {
+ rceh(this, e);
+ }
+ }
+ }
+
+ protected virtual RepeaterItem CreateItem (int itemIndex, ListItemType itemType)
+ {
+ return new RepeaterItem (itemIndex, itemType);
+ }
+
+ protected virtual void InitializeItem (RepeaterItem item)
+ {
+ InstantiateItem (item);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterCommandEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterCommandEventArgs.cs
new file mode 100644
index 00000000000..1d2e5c298ff
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterCommandEventArgs.cs
@@ -0,0 +1,46 @@
+/**
+* Namespace: System.Web.UI.WebControls
+* Class: RepeaterCommandEventArgs
+*
+* Author: Gaurav Vaish
+* Maintainer: gvaish@iitk.ac.in
+* Implementation: yes
+* Status: 100%
+*
+* (C) Gaurav Vaish (2001)
+*/
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class RepeaterCommandEventArgs: CommandEventArgs
+ {
+ private RepeaterItem rItem;
+ private object cmdSrc;
+
+ public RepeaterCommandEventArgs(RepeaterItem item, object commandSource, CommandEventArgs originalArgs): base(originalArgs)
+ {
+ rItem = item;
+ cmdSrc = commandSource;
+ }
+
+ public object CommandSource
+ {
+ get
+ {
+ return cmdSrc;
+ }
+ }
+
+ public RepeaterItem Item
+ {
+ get
+ {
+ return rItem;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterCommandEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterCommandEventHandler.cs
new file mode 100644
index 00000000000..1d93d3d8a67
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterCommandEventHandler.cs
@@ -0,0 +1,16 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void RepeaterCommandEventHandler(object sender, RepeaterCommandEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItem.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItem.cs
new file mode 100644
index 00000000000..69adc3bb369
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItem.cs
@@ -0,0 +1,72 @@
+/**
+* Namespace: System.Web.UI.WebControls
+* Class: RepeaterItem
+*
+* Author: Gaurav Vaish
+* Maintainer: gvaish@iitk.ac.in
+* Implementation: yes
+* Status: 100%
+*
+* (C) Gaurav Vaish (2001)
+*/
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [ToolboxItem(false)]
+ public class RepeaterItem: Control, INamingContainer
+ {
+ private int itemIndex;
+ private ListItemType itemType;
+ private object dataItem;
+
+ public RepeaterItem(int itemIndex, ListItemType itemType)
+ {
+ this.itemIndex = itemIndex;
+ this.itemType = itemType;
+ }
+
+ public virtual object DataItem
+ {
+ get
+ {
+ return dataItem;
+ }
+ set
+ {
+ dataItem = value;
+ }
+ }
+
+ public virtual int ItemIndex
+ {
+ get
+ {
+ return itemIndex;
+ }
+ }
+
+ public virtual ListItemType ItemType
+ {
+ get
+ {
+ return itemType;
+ }
+ }
+
+ protected override bool OnBubbleEvent(object source, EventArgs e)
+ {
+ if(e is CommandEventArgs)
+ {
+ RepeaterCommandEventArgs rcea = new RepeaterCommandEventArgs(this, source, (CommandEventArgs)e);
+ RaiseBubbleEvent(source, rcea);
+ return true;
+ }
+ return false;
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemCollection.cs
new file mode 100644
index 00000000000..a77a5549562
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemCollection.cs
@@ -0,0 +1,83 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: RepeaterItemCollection
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class RepeaterItemCollection : ICollection, IEnumerable
+ {
+ private ArrayList items;
+
+ public RepeaterItemCollection(ArrayList items)
+ {
+ this.items = items;
+ }
+
+ public int Count
+ {
+ get
+ {
+ return items.Count;
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public RepeaterItem this[int index]
+ {
+ get
+ {
+ return (RepeaterItem)(items[index]);
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ foreach(RepeaterItem current in this)
+ {
+ array.SetValue(current, index++);
+ }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return items.GetEnumerator();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemEventArgs.cs
new file mode 100644
index 00000000000..4ccd5dc1269
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemEventArgs.cs
@@ -0,0 +1,37 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: RepeaterItemEventArgs
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class RepeaterItemEventArgs : EventArgs
+ {
+ private RepeaterItem item;
+
+ public RepeaterItemEventArgs(RepeaterItem item)
+ {
+ this.item = item;
+ }
+
+ public RepeaterItem Item
+ {
+ get
+ {
+ return item;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemEventHandler.cs
new file mode 100644
index 00000000000..73f7913171c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RepeaterItemEventHandler.cs
@@ -0,0 +1,16 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void RepeaterItemEventHandler(object sender, RepeaterItemEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RequiredFieldValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RequiredFieldValidator.cs
new file mode 100644
index 00000000000..907d1ccc7b2
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/RequiredFieldValidator.cs
@@ -0,0 +1,60 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: RequiredFieldValidator
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ [ToolboxData("<{0}:RequiredFieldValidator runat=\"server\" "
+ + "ErrorMessage=\"RequiredFieldValidator\">"
+ + "</{0}:RequiredFieldValidator>")]
+ public class RequiredFieldValidator : BaseValidator
+ {
+ public RequiredFieldValidator(): base()
+ {
+ }
+
+ public string InitialValue
+ {
+ get
+ {
+ object o = ViewState["InitialValue"];
+ if(o != null)
+ return (String)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["InitialValue"] = value;
+ }
+ }
+
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender(writer);
+ if(RenderUplevel)
+ {
+ writer.AddAttribute("evaluationfunction", "RequiredFieldValidatorEvaluateIsValid");
+ writer.AddAttribute("initialvalue", InitialValue);
+ }
+ }
+
+ protected override bool EvaluateIsValid()
+ {
+ string val = GetControlValidationValue(ControlToValidate);
+ if(val != null)
+ {
+ return (val.Trim() != InitialValue.Trim());
+ }
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/SelectedDatesCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/SelectedDatesCollection.cs
new file mode 100644
index 00000000000..dc4f807dfdb
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/SelectedDatesCollection.cs
@@ -0,0 +1,125 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: SelectedDatesCollection
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class SelectedDatesCollection : ICollection, IEnumerable
+ {
+ ArrayList dateList;
+
+ public SelectedDatesCollection(ArrayList dateList)
+ {
+ this.dateList = dateList;
+ }
+
+ public int Count
+ {
+ get
+ {
+ return dateList.Count;
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public DateTime this[int index]
+ {
+ get
+ {
+ return (DateTime)(dateList[index]);
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public void Add(DateTime date)
+ {
+ dateList.Add(date);
+ }
+
+ public void Clear()
+ {
+ dateList.Clear();
+ }
+
+ public bool Contains(DateTime date)
+ {
+ return dateList.Contains(date);
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ foreach(DateTime current in this)
+ {
+ array.SetValue(current, index++);
+ }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return dateList.GetEnumerator();
+ }
+
+ public void Remove(DateTime date)
+ {
+ dateList.Remove(date);
+ }
+
+ public void SelectRange(DateTime fromDate, DateTime toDate)
+ {
+ dateList.Clear();
+ //FIXME: Probable bug in MS implementation. It SHOULD NOT
+ // clear the list if fromDate > toDate
+ if(fromDate > toDate)
+ {
+ return;
+ }
+ DateTime local = fromDate;
+ do
+ {
+ dateList.Add(local);
+ local = local.AddDays(1);
+ } while(local < toDate);
+ }
+
+ internal ArrayList GetDateList ()
+ {
+ return dateList;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ServerValidateEventArgs.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ServerValidateEventArgs.cs
new file mode 100644
index 00000000000..1bfd0aabfd0
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ServerValidateEventArgs.cs
@@ -0,0 +1,42 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: ServerValidateEventArgs
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class ServerValidateEventArgs : EventArgs
+ {
+ private bool isValid;
+ private string value;
+
+ public ServerValidateEventArgs(string value, bool isValid)
+ {
+ this.value = value;
+ this.isValid = isValid;
+ }
+
+ public bool IsValid
+ {
+ get { return isValid; }
+ set { isValid = value; }
+ }
+
+ public string Value
+ {
+ get { return value; }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ServerValidateEventHandler.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ServerValidateEventHandler.cs
new file mode 100644
index 00000000000..b37ffd5f26f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ServerValidateEventHandler.cs
@@ -0,0 +1,16 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public delegate void ServerValidateEventHandler(object sender, ServerValidateEventArgs e);
+} \ No newline at end of file
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs
new file mode 100644
index 00000000000..3aea32ef075
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs
@@ -0,0 +1,539 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: Style
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Text;
+using System.Collections;
+using System.Drawing;
+using System.Globalization;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [ToolboxItem(false)]
+ [TypeConverter(typeof(ExpandableObjectConverter))]
+ public class Style : Component , IStateManager
+ {
+ internal static int MARKED = (0x01 << 0);
+ internal static int BACKCOLOR = (0x01 << 1);
+ internal static int BORDERCOLOR = (0x01 << 2);
+ internal static int BORDERSTYLE = (0x01 << 3);
+ internal static int BORDERWIDTH = (0x01 << 4);
+ internal static int CSSCLASS = (0x01 << 5);
+ internal static int FORECOLOR = (0x01 << 6);
+ internal static int HEIGHT = (0x01 << 7);
+ internal static int WIDTH = (0x01 << 8);
+ internal static int FONT_BOLD = (0x01 << 9);
+ internal static int FONT_ITALIC = (0x01 << 10);
+ internal static int FONT_NAMES = (0x01 << 11);
+ internal static int FONT_SIZE = (0x01 << 12);
+ internal static int FONT_STRIKE = (0x01 << 13);
+ internal static int FONT_OLINE = (0x01 << 14);
+ internal static int FONT_ULINE = (0x01 << 15);
+
+ internal static string selectionBitString = "_SystemWebUIWebControlsStyle_SBS";
+
+ private StateBag viewState;
+ private int selectionBits;
+ private bool selfStateBag;
+
+ private FontInfo font;
+
+ public Style()
+ {
+ Initialize(null);
+ selfStateBag = true;
+ }
+
+ public Style(StateBag bag): base()
+ {
+ Initialize(bag);
+ selfStateBag = false;
+ }
+
+ private void Initialize(StateBag bag)
+ {
+ viewState = bag;
+ selectionBits = 0x00;
+ }
+
+ protected internal StateBag ViewState
+ {
+ get
+ {
+ if(viewState == null)
+ {
+ viewState = new StateBag(false);
+ if(IsTrackingViewState)
+ viewState.TrackViewState();
+ }
+ return viewState;
+ }
+ }
+
+ internal bool IsSet(int bit)
+ {
+ return ( (selectionBits & bit) != 0x00);
+ }
+
+ internal virtual void Set(int bit)
+ {
+ selectionBits |= bit;
+ if(IsTrackingViewState)
+ selectionBits |= MARKED;
+ }
+
+ public Color BackColor
+ {
+ get
+ {
+ if(IsSet(BACKCOLOR))
+ return (Color)ViewState["BackColor"];
+ return Color.Empty;
+ }
+ set
+ {
+ ViewState["BackColor"] = value;
+ Set(BACKCOLOR);
+ }
+ }
+
+ public Color BorderColor
+ {
+ get
+ {
+ if(IsSet(BORDERCOLOR))
+ return (Color)ViewState["BorderColor"];
+ return Color.Empty;
+ }
+ set
+ {
+ ViewState["BorderColor"] = value;
+ Set(BORDERCOLOR);
+ }
+ }
+
+ public BorderStyle BorderStyle
+ {
+ get
+ {
+ if(IsSet(BORDERSTYLE))
+ return (BorderStyle)ViewState["BorderStyle"];
+ return BorderStyle.NotSet;
+ }
+ set
+ {
+ ViewState["BorderStyle"] = value;
+ Set(BORDERSTYLE);
+ }
+ }
+
+ public Unit BorderWidth
+ {
+ get
+ {
+ if(IsSet(BORDERWIDTH))
+ return (Unit)ViewState["BorderWidth"];
+ return Unit.Empty;
+ }
+ set
+ {
+ ViewState["BorderWidth"] = value;
+ Set(BORDERWIDTH);
+ }
+ }
+
+ public string CssClass
+ {
+ get
+ {
+ if(IsSet(CSSCLASS))
+ return (string)ViewState["CssClass"];
+ return string.Empty;
+ }
+ set
+ {
+ ViewState["CssClass"] = value;
+ Set(CSSCLASS);
+ }
+ }
+
+ public Color ForeColor
+ {
+ get
+ {
+ if(IsSet(FORECOLOR))
+ return (Color)ViewState["ForeColor"];
+ return Color.Empty;
+ }
+ set
+ {
+ ViewState["ForeColor"] = value;
+ Set(FORECOLOR);
+ }
+ }
+
+ public Unit Height
+ {
+ get
+ {
+ if(IsSet(HEIGHT))
+ return (Unit)ViewState["Height"];
+ return Unit.Empty;
+ }
+ set
+ {
+ ViewState["Height"] = value;
+ Set(HEIGHT);
+ }
+ }
+
+ public Unit Width
+ {
+ get
+ {
+ if(IsSet(WIDTH))
+ return (Unit)ViewState["Width"];
+ return Unit.Empty;
+ }
+ set
+ {
+ ViewState["Width"] = value;
+ Set(WIDTH);
+ }
+ }
+
+ public FontInfo Font
+ {
+ get
+ {
+ if(font==null)
+ font = new FontInfo(this);
+ return font;
+ }
+ }
+
+ protected internal virtual bool IsEmpty
+ {
+ get { return (selectionBits == 0); }
+ }
+
+ private void AddColor(HtmlTextWriter writer, HtmlTextWriterStyle style, Color color)
+ {
+ if(!color.IsEmpty)
+ writer.AddStyleAttribute(style, ColorTranslator.ToHtml(color));
+ }
+
+ private static string StringArrayToString(string[] array, char separator)
+ {
+ if(array.Length == 0)
+ return String.Empty;
+ StringBuilder sb = new StringBuilder();
+ for(int i=0; i < array.Length; i++)
+ {
+ if(i==0)
+ {
+ sb.Append(array[0]);
+ } else
+ {
+ sb.Append(separator);
+ sb.Append(array[i]);
+ }
+ }
+ return sb.ToString();
+ }
+
+ public void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ AddAttributesToRender(writer, null);
+ }
+
+ public virtual void AddAttributesToRender(HtmlTextWriter writer, WebControl owner)
+ {
+ if(IsSet(BACKCOLOR))
+ {
+ AddColor(writer, HtmlTextWriterStyle.BackgroundColor, (Color)ViewState["BackColor"]);
+ }
+
+ if(IsSet(BORDERCOLOR))
+ {
+ AddColor(writer, HtmlTextWriterStyle.BorderColor, (Color)ViewState["BorderColor"]);
+ }
+
+ if(IsSet(FORECOLOR))
+ {
+ AddColor(writer, HtmlTextWriterStyle.Color, (Color)ViewState["ForeColor"]);
+ }
+
+ if(IsSet(CSSCLASS))
+ {
+ string cssClass = (string)ViewState["CssClass"];
+ if(cssClass.Length > 0)
+ writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
+ }
+
+ if(!BorderWidth.IsEmpty)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, BorderWidth.ToString(CultureInfo.InvariantCulture));
+ if(BorderStyle!=BorderStyle.NotSet)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, Enum.Format(typeof(BorderStyle), BorderStyle, "G"));
+ } else
+ {
+ if(BorderWidth.Value != 0.0)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid");
+ }
+ }
+ } else
+ {
+ if(BorderStyle!=BorderStyle.NotSet)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, Enum.Format(typeof(BorderStyle), BorderStyle, "G"));
+ }
+ }
+
+ if(Font.Names.Length > 0)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, StringArrayToString(Font.Names,','));
+ }
+
+ if(!Font.Size.IsEmpty)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, Font.Size.ToString(CultureInfo.InvariantCulture));
+ }
+
+ if(Font.Bold)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold");
+ }
+
+ if(Font.Italic)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.FontStyle, "italic");
+ }
+
+ string textDecoration = String.Empty;
+ if(Font.Strikeout)
+ {
+ textDecoration += " strikeout";
+ }
+ if(Font.Underline)
+ {
+ textDecoration += " underline";
+ }
+ if(Font.Overline)
+ {
+ textDecoration += " overline";
+ }
+ if(textDecoration.Length > 0)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, textDecoration);
+ }
+
+ Unit u = Unit.Empty;
+ if(IsSet(HEIGHT))
+ {
+ u = (Unit)ViewState["Height"];
+ writer.AddStyleAttribute(HtmlTextWriterStyle.Height, u.ToString(CultureInfo.InvariantCulture));
+ }
+ if(IsSet(WIDTH))
+ {
+ u = (Unit)ViewState["Width"];
+ writer.AddStyleAttribute(HtmlTextWriterStyle.Width, u.ToString(CultureInfo.InvariantCulture));
+ }
+ }
+
+ public virtual void CopyFrom(Style source)
+ {
+ if(source!=null && !source.IsEmpty)
+ {
+ Font.CopyFrom(source.Font);
+ if(source.Height!=Unit.Empty)
+ {
+ Height = source.Height;
+ }
+ if(source.Width!=Unit.Empty)
+ {
+ Width = source.Width;
+ }
+ if(source.BorderColor!=Color.Empty)
+ {
+ BorderColor = source.BorderColor;
+ }
+ if(source.BorderWidth!=Unit.Empty)
+ {
+ BorderWidth = source.BorderWidth;
+ }
+ if(source.BorderStyle!=BorderStyle.NotSet)
+ {
+ BorderStyle = source.BorderStyle;
+ }
+ if(source.BackColor!=Color.Empty)
+ {
+ BackColor = source.BackColor;
+ }
+ if(source.CssClass!=String.Empty)
+ {
+ CssClass = source.CssClass;
+ }
+ if(source.ForeColor!=Color.Empty)
+ {
+ ForeColor = source.ForeColor;
+ }
+ }
+ }
+
+ public virtual void MergeWith(Style with)
+ {
+ if(with!=null && !with.IsEmpty)
+ {
+ if(IsEmpty)
+ {
+ CopyFrom(with);
+ return;
+ }
+
+ Font.MergeWith(with.Font);
+ if(!IsSet(HEIGHT) && with.Height!=Unit.Empty)
+ {
+ Height = with.Height;
+ }
+ if(!IsSet(WIDTH) && with.Width!=Unit.Empty)
+ {
+ Width = with.Width;
+ }
+ if(!IsSet(BORDERCOLOR) && with.BorderColor!=Color.Empty)
+ {
+ BorderColor = with.BorderColor;
+ }
+ if(!IsSet(BORDERWIDTH) && with.BorderWidth!=Unit.Empty)
+ {
+ BorderWidth = with.BorderWidth;
+ }
+ if(!IsSet(BORDERSTYLE) && with.BorderStyle!=BorderStyle.NotSet)
+ {
+ BorderStyle = with.BorderStyle;
+ }
+ if(!IsSet(BACKCOLOR) && with.BackColor!=Color.Empty)
+ {
+ BackColor = with.BackColor;
+ }
+ if(!IsSet(CSSCLASS) && with.CssClass!=String.Empty)
+ {
+ CssClass = with.CssClass;
+ }
+ if(!IsSet(FORECOLOR) && with.ForeColor!=Color.Empty)
+ {
+ ForeColor = with.ForeColor;
+ }
+ }
+ }
+
+ public virtual void Reset()
+ {
+ if(IsSet(BACKCOLOR))
+ ViewState.Remove("BackColor");
+ if(IsSet(BORDERCOLOR))
+ ViewState.Remove("BorderColor");
+ if(IsSet(BORDERSTYLE))
+ ViewState.Remove("BorderStyle");
+ if(IsSet(BORDERWIDTH))
+ ViewState.Remove("BorderWidth");
+ if(IsSet(CSSCLASS))
+ ViewState.Remove("CssClass");
+ if(IsSet(FORECOLOR))
+ ViewState.Remove("ForeColor");
+ if(IsSet(HEIGHT))
+ ViewState.Remove("Height");
+ if(IsSet(WIDTH))
+ ViewState.Remove("Width");
+ if(font!=null)
+ font.Reset();
+ selectionBits = 0x00;
+ }
+
+ protected bool IsTrackingViewState
+ {
+ get
+ {
+ return ( (selectionBits & MARKED) != 0x00 );
+ }
+ }
+
+ protected internal virtual void TrackViewState()
+ {
+ if(viewState!=null)
+ ViewState.TrackViewState();
+ Set(MARKED);
+ }
+
+ protected internal virtual object SaveViewState()
+ {
+ if(viewState != null)
+ {
+ if(IsSet(MARKED))
+ {
+ ViewState[selectionBitString] = selectionBits;
+ }
+ if(selfStateBag)
+ {
+ return ViewState.SaveViewState();
+ }
+ }
+ return null;
+ }
+
+ protected internal void LoadViewState(object state)
+ {
+ if (state != null && selfStateBag)
+ ViewState.LoadViewState(state);
+
+ if (viewState != null) {
+ object o = ViewState[selectionBitString];
+ if (o != null)
+ selectionBits = (int) o;
+ }
+ }
+
+ void IStateManager.LoadViewState(object state)
+ {
+ LoadViewState(state);
+ }
+
+ object IStateManager.SaveViewState()
+ {
+ return SaveViewState();
+ }
+
+ void IStateManager.TrackViewState()
+ {
+ TrackViewState();
+ }
+
+ bool IStateManager.IsTrackingViewState
+ {
+ get
+ {
+ return IsTrackingViewState;
+ }
+ }
+
+ public override string ToString()
+ {
+ return String.Empty;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TODO b/mcs/class/System.Web/System.Web.UI.WebControls/TODO
new file mode 100755
index 00000000000..05abe9b822a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TODO
@@ -0,0 +1,156 @@
+All Classes, Interfaces, Structures, Delegates and Enumerations
+
+
+<attributesIssue>
+ Attributes may have to be supplied to the classes. Some of the attributes
+ include DefaultPropertyAttribute, ToolboxItemAttribute, ParseChildrenAttribute
+ (to be added to System.Web.UI) etc. Currently, I have not taken care of these
+ aspects. They are to be handled later on.
+</attributesIssue>
+
+<disposableItemsIssue>
+ I have not taken care of any disposing issues that may be involved. But I think
+ it will not be a problem since I am no where using unmanaged code.
+</disposableItemsIssue>
+
+<legends>
+*: Completed
+&: Work in progress. See <item-name>.cs file for maintainer's name
+</legends>
+
+* AdCreatedEventArgs
+* AdRotator
+* BaseCompareValidator
+* BaseDataList
+& BaseValidator
+& BoundColumn
+* Button
+* ButtonColumn
+& Calendar
+* CalendarDay
+* CheckBox
+* CheckBoxList
+* CommandEventArgs
+& CompareValidator
+* CustomValidator
+& DataGrid
+* DataGridColumn
+* DataGridColumnCollection
+* DataGridCommandEventArgs
+& DataGridItem
+* DataGridItemCollection
+* DataGridItemEventArgs
+* DataGridPageChangedEventArgs
+& DataGridPagerStyle
+* DataGridShortCommandEventArgs
+* DataKeyCollection
+& DataList
+* DataListCommandEventArgs
+& DataListItem
+* DataListItemCollecton
+* DataListItemEventArgs
+* DayRenderEventArgs
+* DropDownList
+& EditCommandColumn
+* FontInfo
+* FontNamesConverter
+& FontUnitConverter
+* HyperLink
+* HyperLinkColumn
+* HyperLinkControlBuilder
+* Image
+* ImageButton
+* Label
+* LabelControlBuilder
+* LinkButton
+* LinkButtonControlBuilder
+* ListBox
+* ListControl
+* ListItem
+* ListItemCollection
+* ListItemControlBuilder
+* Literal
+* LiteralControlBuilder
+* MonthChangedEventArgs
+* PagedDataSource
+* Panel
+* PlaceHolder
+* PlaceHolderControlBuilder
+* RadioButton
+& RadioButtonList
+* RangeValidator
+* RegularExpressionValidator
+& Repeater
+* RepeaterCommandEventArgs
+& RepeaterItem
+* RepeaterItemCollection
+* RepeaterItemEventArgs
+& RepeatInfo
+* RequiredFieldValidator
+* SelectedDatesCollection
+* ServerValidateEventArgs
+* Style
+* Table
+* TableCell
+* TableCellCollection
+* TableCellControlBuilder
+* TableHeaderCell
+* TableItemStyle
+* TableRow
+* TableRowCollection
+* TableStyle
+* TargetConverter
+* TemplateColumn
+& TextBox
+* TextBoxControlBuilder
+* UnitConverter
+* ValidatedControlConverter
+& ValidationSummary
+& WebColorConverter
+& WebControl
+& Xml
+
+* IRepeatInfoUser
+
+* FontUnit
+* Unit
+
+* AdCreatedEventHandler
+* CommandEventHandler
+* DataGridCommandEventHandler
+* DataGridItemEventHandler
+* DataGridPageChangedEventHandler
+* DataGridSortCommandEventHandler
+* DataListCommandEventHandler
+* DataListItemEventHandler
+* DayRenderEventHandler
+* MonthChangedEventHandler
+* RepeaterCommandEventHandler
+* RepeaterItemEventHandler
+* ServerValidateEventHandler
+
+* BorderStyle
+* ButtonColumnType
+* CalendarSelectionMode
+* DayNameFormat
+* FirstDayOfWeek
+* FontSize
+* GridLines
+* HorizontalAlign
+* ImageAlign
+* ListItemType
+* ListSelectionMode
+* NextPrevFormat
+* PagerMode
+* PagerPosition
+* RepeatDirection
+* RepeatLayout
+* TextAlign
+* TextBoxMode
+* TitleFormat
+* UnitType
+* ValidationCompareOperator
+* ValidationDataType
+* ValidationSummaryDisplayMode
+* ValidatorDisplay
+* VerticalAlign
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Table.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Table.cs
new file mode 100644
index 00000000000..16d1cf25f18
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Table.cs
@@ -0,0 +1,159 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: Table
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Drawing;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultProperty("Rows")]
+ //[Designer("??")]
+ [ParseChildren(true, "Rows")]
+ public class Table: WebControl
+ {
+ private TableRowCollection rows;
+
+ private class TableRowControlCollection : ControlCollection
+ {
+ public TableRowControlCollection (Control owner) : base (owner)
+ {
+ }
+
+ public override void Add (Control child)
+ {
+ if (!(child is TableRow))
+ throw new ArgumentException (HttpRuntime.FormatResourceString (
+ "Cannot_Have_Children_Of_Type",
+ "Table",
+ child.GetType ().Name.ToString ()));
+ base.Add (child);
+ }
+
+ public override void AddAt(int index, Control child)
+ {
+ if (!(child is TableRow))
+ throw new ArgumentException (HttpRuntime.FormatResourceString (
+ "Cannot_Have_Children_Of_Type",
+ "Table",
+ child.GetType ().Name.ToString ()));
+ base.AddAt (index, child);
+ }
+ }
+
+ public Table () : base (HtmlTextWriterTag.Table)
+ {
+ }
+
+ public virtual string BackImageUrl
+ {
+ get {
+ if (ControlStyleCreated)
+ return ((TableStyle) ControlStyle).BackImageUrl;
+ return String.Empty;
+ }
+
+ set { ((TableStyle) ControlStyle).BackImageUrl = value; }
+ }
+
+ public virtual int CellPadding
+ {
+ get {
+ if (ControlStyleCreated)
+ return ((TableStyle) ControlStyle).CellPadding;
+ return -1;
+ }
+
+ set { ((TableStyle) ControlStyle).CellPadding = value; }
+ }
+
+ public virtual int CellSpacing
+ {
+ get {
+ if (ControlStyleCreated)
+ return ((TableStyle) ControlStyle).CellSpacing;
+ return -1;
+ }
+
+ set { ((TableStyle) ControlStyle).CellSpacing = value; }
+ }
+
+ public virtual GridLines GridLines
+ {
+ get {
+ if (ControlStyleCreated)
+ return ((TableStyle) ControlStyle).GridLines;
+ return GridLines.None;
+ }
+
+ set { ((TableStyle) ControlStyle).GridLines = value; }
+ }
+
+ public virtual HorizontalAlign HorizontalAlign
+ {
+ get {
+ if (ControlStyleCreated)
+ return ((TableStyle) ControlStyle).HorizontalAlign;
+ return HorizontalAlign.NotSet;
+ }
+
+ set { ((TableStyle) ControlStyle).HorizontalAlign = value; }
+ }
+
+ public virtual TableRowCollection Rows
+ {
+ get {
+ if (rows == null)
+ rows = new TableRowCollection (this);
+ return rows;
+ }
+ }
+
+ protected override void AddAttributesToRender (HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender (writer);
+ if(!BorderColor.IsEmpty)
+ writer.AddAttribute (HtmlTextWriterAttribute.Bordercolor,
+ ColorTranslator.ToHtml (BorderColor));
+
+ Unit bw = BorderWidth;
+ if (GridLines == GridLines.None)
+ bw = Unit.Pixel (0);
+ else if (bw.IsEmpty || bw.Type == UnitType.Pixel)
+ bw = Unit.Pixel(1);
+
+ writer.AddAttribute (HtmlTextWriterAttribute.Border,
+ ((int) bw.Value).ToString (NumberFormatInfo.InvariantInfo));
+ }
+
+ protected override ControlCollection CreateControlCollection ()
+ {
+ return new TableRowControlCollection (this);
+ }
+
+ protected override Style CreateControlStyle ()
+ {
+ return new TableStyle (ViewState);
+ }
+
+ protected override void RenderContents (HtmlTextWriter writer)
+ {
+ foreach (TableRow current in Rows)
+ current.RenderControl (writer);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TableCell.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TableCell.cs
new file mode 100644
index 00000000000..cf8c19ae151
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TableCell.cs
@@ -0,0 +1,147 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TableCell
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultProperty("Text")]
+ [ToolboxItem(false)]
+ [ControlBuilder(typeof(TableCellControlBuilder))]
+ [ParseChildren(false)]
+ [PersistChildren(true)]
+ public class TableCell: WebControl
+ {
+ public TableCell () : base (HtmlTextWriterTag.Td)
+ {
+ PreventAutoID ();
+ }
+
+ internal TableCell (HtmlTextWriterTag tag) : base (tag)
+ {
+ PreventAutoID ();
+ }
+
+ public virtual int ColumnSpan
+ {
+ get {
+ object o = ViewState ["ColumnSpan"];
+ return (o == null) ? 0 : (int) o;
+ }
+
+ set { ViewState ["ColumnSpan"] = value; }
+ }
+
+ public virtual int RowSpan
+ {
+ get {
+ object o = ViewState ["RowSpan"];
+ return (o == null) ? 0 : (int) o;
+ }
+
+ set { ViewState ["RowSpan"] = value; }
+ }
+
+ public virtual string Text
+ {
+ get {
+ object o = ViewState ["Text"];
+ return (o == null) ? String.Empty : (string) o;
+ }
+
+ set { ViewState ["Text"] = value; }
+ }
+
+ public virtual HorizontalAlign HorizontalAlign
+ {
+ get {
+ if (ControlStyleCreated)
+ return ((TableItemStyle) ControlStyle).HorizontalAlign;
+ return HorizontalAlign.NotSet;
+ }
+ set { ((TableItemStyle) ControlStyle).HorizontalAlign = value; }
+ }
+
+ public virtual VerticalAlign VerticalAlign
+ {
+ get {
+ if (ControlStyleCreated)
+ return ((TableItemStyle) ControlStyle).VerticalAlign;
+ return VerticalAlign.NotSet;
+ }
+
+ set { ((TableItemStyle) ControlStyle).VerticalAlign = value; }
+ }
+
+ public virtual bool Wrap
+ {
+ get {
+ if (ControlStyleCreated)
+ return ((TableItemStyle) ControlStyle).Wrap;
+ return true;
+ }
+ set { ((TableItemStyle) ControlStyle).Wrap = value; }
+ }
+
+ protected override void AddAttributesToRender (HtmlTextWriter writer)
+ {
+ base.AddAttributesToRender (writer);
+ if (ColumnSpan > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Colspan,
+ ColumnSpan.ToString (NumberFormatInfo.InvariantInfo));
+
+ if (RowSpan > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Rowspan,
+ RowSpan.ToString (NumberFormatInfo.InvariantInfo));
+ }
+
+ protected override void AddParsedSubObject (object obj)
+ {
+ if (HasControls ()){
+ base.AddParsedSubObject (obj);
+ return;
+ }
+
+ if (obj is LiteralControl){
+ Text = ((LiteralControl) obj).Text;
+ return;
+ }
+
+ string text = Text;
+ if (text.Length > 0){
+ Text = String.Empty;
+ base.AddParsedSubObject (new LiteralControl (text));
+ }
+
+ base.AddParsedSubObject (obj);
+ }
+
+ protected override Style CreateControlStyle ()
+ {
+ return new TableItemStyle (ViewState);
+ }
+
+ protected override void RenderContents (HtmlTextWriter writer)
+ {
+ if (HasControls ())
+ base.RenderContents (writer);
+ else
+ writer.Write (Text);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TableCellCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TableCellCollection.cs
new file mode 100644
index 00000000000..c3b442b91de
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TableCellCollection.cs
@@ -0,0 +1,181 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TableCellCollection
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ //[Editor("??")]
+ public sealed class TableCellCollection: IList, ICollection, IEnumerable
+ {
+ private TableRow owner;
+
+ internal TableCellCollection(TableRow owner)
+ {
+ if(owner == null)
+ {
+ throw new ArgumentNullException();
+ }
+ this.owner = owner;
+ }
+
+ public int Count
+ {
+ get
+ {
+ return owner.Controls.Count;
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public TableCell this[int index]
+ {
+ get
+ {
+ return (TableCell)owner.Controls[index];
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public int Add(TableCell cell)
+ {
+ AddAt(-1, cell);
+ return owner.Controls.Count;
+ }
+
+ public void AddAt(int index, TableCell cell)
+ {
+ owner.Controls.AddAt(index, cell);
+ }
+
+ public void AddRange(TableCell[] cells)
+ {
+ foreach(TableCell cell in cells)
+ {
+ Add(cell);
+ }
+ }
+
+ public void Clear()
+ {
+ if(owner.HasControls())
+ {
+ owner.Controls.Clear();
+ }
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ foreach(object cell in this)
+ {
+ array.SetValue(cell, index++);
+ }
+ }
+
+ public int GetCellIndex(TableCell cell)
+ {
+ if(!owner.HasControls())
+ {
+ return -1;
+ }
+ return owner.Controls.IndexOf(cell);
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return owner.Controls.GetEnumerator();
+ }
+
+ public void Remove(TableCell cell)
+ {
+ owner.Controls.Remove(cell);
+ }
+
+ public void RemoveAt(int index)
+ {
+ owner.Controls.RemoveAt(index);
+ }
+
+ int IList.Add(object o)
+ {
+ return Add((TableCell)o);
+ }
+
+ bool IList.Contains(object o)
+ {
+ return owner.Controls.Contains((TableCell)o);
+ }
+
+ int IList.IndexOf(object o)
+ {
+ return owner.Controls.IndexOf((TableCell)o);
+ }
+
+ void IList.Insert(int index, object o)
+ {
+ owner.Controls.AddAt(index, (TableCell)o);
+ }
+
+ void IList.Remove(object o)
+ {
+ owner.Controls.Remove((TableCell)o);
+ }
+
+ bool IList.IsFixedSize
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ object IList.this[int index]
+ {
+ get
+ {
+ return this[index];
+ }
+ set
+ {
+ RemoveAt(index);
+ AddAt(index, (TableCell)value);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TableCellControlBuilder.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TableCellControlBuilder.cs
new file mode 100644
index 00000000000..6363462fa51
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TableCellControlBuilder.cs
@@ -0,0 +1,31 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TableCellControlBuilder
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class TableCellControlBuilder: ControlBuilder
+ {
+ public TableCellControlBuilder(): base()
+ {
+ }
+
+ public override bool AllowWhitespaceLiterals()
+ {
+ return false;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TableHeaderCell.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TableHeaderCell.cs
new file mode 100644
index 00000000000..e3ccb0c1a93
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TableHeaderCell.cs
@@ -0,0 +1,26 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TableHeaderCell
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class TableHeaderCell: TableCell
+ {
+ public TableHeaderCell(): base(HtmlTextWriterTag.Th)
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TableItemStyle.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TableItemStyle.cs
new file mode 100644
index 00000000000..cddc73434aa
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TableItemStyle.cs
@@ -0,0 +1,176 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TableItemStyle
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class TableItemStyle: Style
+ {
+ private static int H_ALIGN = (0x01 << 16);
+ private static int V_ALIGN = (0x01 << 17);
+ private static int WRAP = (0x01 << 18);
+
+ public TableItemStyle(): base()
+ {
+ }
+
+ public TableItemStyle(StateBag bag): base(bag)
+ {
+ }
+
+ [Bindable(true)]
+ [DefaultValue(HorizontalAlign.NotSet)]
+ [NotifyParentProperty(true)]
+ [WebCategory("Layout")]
+ [WebSysDescription("TableItemStyle_HorizontalAlign")]
+ public virtual HorizontalAlign HorizontalAlign
+ {
+ get
+ {
+ if(IsSet(H_ALIGN))
+ return (HorizontalAlign)ViewState["HorizontalAlign"];
+ return HorizontalAlign.NotSet;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(HorizontalAlign), value))
+ {
+ throw new ArgumentException();
+ }
+ ViewState["HorizontalAlign"] = value;
+ Set(H_ALIGN);
+ }
+ }
+
+ [Bindable(true)]
+ [DefaultValue(VerticalAlign.NotSet)]
+ [NotifyParentProperty(true)]
+ [WebCategory("Layout")]
+ [WebSysDescription("TableItemStyle_VerticalAlign")]
+ public virtual VerticalAlign VerticalAlign
+ {
+ get
+ {
+ if(IsSet(V_ALIGN))
+ return (VerticalAlign)ViewState["VerticalAlign"];
+ return VerticalAlign.NotSet;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(VerticalAlign), value))
+ {
+ throw new ArgumentException();
+ }
+ ViewState["VerticalAlign"] = value;
+ Set(V_ALIGN);
+ }
+ }
+
+ [Bindable(true)]
+ [DefaultValue(VerticalAlign.NotSet)]
+ [NotifyParentProperty(true)]
+ [WebCategory("Layout")]
+ [WebSysDescription("TableItemStyle_Wrap")]
+ public virtual bool Wrap
+ {
+ get
+ {
+ if(IsSet(WRAP))
+ return (bool)ViewState["Wrap"];
+ return true;
+ }
+ set
+ {
+ ViewState["Wrap"] = value;
+ }
+ }
+
+ public override void CopyFrom(Style s)
+ {
+ if(s!=null && s is TableItemStyle && !s.IsEmpty)
+ {
+ base.CopyFrom(s);
+ TableItemStyle from = (TableItemStyle)s;
+ if(from.IsSet(H_ALIGN))
+ {
+ HorizontalAlign = from.HorizontalAlign;
+ }
+ if(from.IsSet(V_ALIGN))
+ {
+ VerticalAlign = from.VerticalAlign;
+ }
+ if(from.IsSet(WRAP))
+ {
+ Wrap = from.Wrap;
+ }
+ }
+ }
+
+ public override void MergeWith(Style s)
+ {
+ if(s!=null && s is TableItemStyle && !s.IsEmpty)
+ {
+ base.MergeWith(s);
+ TableItemStyle with = (TableItemStyle)s;
+ if(with.IsSet(H_ALIGN) && !IsSet(H_ALIGN))
+ {
+ HorizontalAlign = with.HorizontalAlign;
+ }
+ if(with.IsSet(V_ALIGN) && !IsSet(V_ALIGN))
+ {
+ VerticalAlign = with.VerticalAlign;
+ }
+ if(with.IsSet(WRAP) && !IsSet(WRAP))
+ {
+ Wrap = with.Wrap;
+ }
+ }
+ }
+
+ public override void Reset()
+ {
+ if(IsSet(H_ALIGN))
+ ViewState.Remove("HorizontalAlign");
+ if(IsSet(V_ALIGN))
+ ViewState.Remove("VerticalAlign");
+ if(IsSet(WRAP))
+ ViewState.Remove("Wrap");
+ base.Reset();
+ }
+
+ public override void AddAttributesToRender(HtmlTextWriter writer, WebControl owner)
+ {
+ base.AddAttributesToRender(writer, owner);
+ if(!Wrap)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
+ }
+ if(HorizontalAlign != HorizontalAlign.NotSet)
+ {
+ // Temporarily commented out. I'm having problems in cygwin.
+ //writer.AddAttribute(HtmlTextWriterAttribute.Align, TypeDescriptor.GetConverter(typeof(HorizontalAlign)).ConvertToString(HorizontalAlign));
+ writer.AddAttribute(HtmlTextWriterAttribute.Align, HorizontalAlign.ToString ());
+ }
+ if(VerticalAlign != VerticalAlign.NotSet)
+ {
+ // Temporarily commented out. I'm having problems in cygwin.
+ //writer.AddAttribute(HtmlTextWriterAttribute.Valign, TypeDescriptor.GetConverter(typeof(VerticalAlign)).ConvertToString(VerticalAlign));
+ writer.AddAttribute(HtmlTextWriterAttribute.Valign, VerticalAlign.ToString ());
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TableRow.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TableRow.cs
new file mode 100644
index 00000000000..a0a1d82c922
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TableRow.cs
@@ -0,0 +1,99 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TableRow
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultProperty("Cells")]
+ [ParseChildren(true, "Cells")]
+ public class TableRow: WebControl
+ {
+ private TableCellCollection cells;
+
+ public TableRow() : base (HtmlTextWriterTag.Tr)
+ {
+ PreventAutoID ();
+ }
+
+ public virtual TableCellCollection Cells
+ {
+ get {
+ if (cells == null)
+ cells = new TableCellCollection (this);
+ return cells;
+ }
+ }
+
+ public virtual HorizontalAlign HorizontalAlign
+ {
+ get {
+ object o = ViewState ["HorizontalAlign"];
+ return (o == null) ? HorizontalAlign.NotSet : (HorizontalAlign) o;
+ }
+
+ set { ViewState ["HorizontalAlign"] = value; }
+ }
+
+ public virtual VerticalAlign VerticalAlign
+ {
+ get {
+ object o = ViewState ["VerticalAlign"];
+ return (o == null) ? VerticalAlign.NotSet : (VerticalAlign) o;
+ }
+
+ set { ViewState ["VerticalAlign"] = value; }
+ }
+
+ protected override Style CreateControlStyle ()
+ {
+ return new TableItemStyle (ViewState);
+ }
+
+ protected override ControlCollection CreateControlCollection ()
+ {
+ return new CellControlCollection (this);
+ }
+
+ protected class CellControlCollection : ControlCollection
+ {
+ internal CellControlCollection (Control owner) : base (owner)
+ {
+ }
+
+ public override void Add (Control child)
+ {
+ if (!(child is TableCell))
+ throw new ArgumentException (HttpRuntime.FormatResourceString (
+ "Cannot_Have_Children_Of_Type",
+ "TableRow",
+ GetType ().Name.ToString ()));
+ base.Add (child);
+ }
+
+ public override void AddAt(int index, Control child)
+ {
+ if (!(child is TableCell))
+ throw new ArgumentException (HttpRuntime.FormatResourceString (
+ "Cannot_Have_Children_Of_Type",
+ "TableRow",
+ GetType ().Name.ToString ()));
+ base.AddAt (index, child);
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TableRowCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TableRowCollection.cs
new file mode 100644
index 00000000000..b2db6123249
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TableRowCollection.cs
@@ -0,0 +1,179 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TableRowCollection
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Collections;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public sealed class TableRowCollection: IList, ICollection, IEnumerable
+ {
+ Table owner;
+
+ internal TableRowCollection(Table owner)
+ {
+ if(owner == null)
+ {
+ throw new ArgumentNullException();
+ }
+ this.owner = owner;
+ }
+
+ public int Count
+ {
+ get
+ {
+ return owner.Controls.Count;
+ }
+ }
+
+ public bool IsReadOnly
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsSynchronized
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public TableRow this[int index]
+ {
+ get
+ {
+ return (TableRow)owner.Controls[index];
+ }
+ }
+
+ public object SyncRoot
+ {
+ get
+ {
+ return this;
+ }
+ }
+
+ public int Add(TableRow row)
+ {
+ AddAt(-1, row);
+ return owner.Controls.Count;
+ }
+
+ public void AddAt(int index, TableRow row)
+ {
+ owner.Controls.AddAt(index, row);
+ }
+
+ public void AddRange(TableRow[] rows)
+ {
+ foreach(TableRow row in rows)
+ {
+ Add(row);
+ }
+ }
+
+ public void Clear()
+ {
+ if(owner.HasControls())
+ {
+ owner.Controls.Clear();
+ }
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ foreach(object current in this)
+ {
+ array.SetValue(current, index++);
+ }
+ }
+
+ public int GetRowIndex(TableRow row)
+ {
+ if(!owner.HasControls())
+ {
+ return -1;
+ }
+ return owner.Controls.IndexOf(row);
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return owner.Controls.GetEnumerator();
+ }
+
+ public void Remove(TableRow row)
+ {
+ owner.Controls.Remove(row);
+ }
+
+ public void RemoveAt(int index)
+ {
+ owner.Controls.RemoveAt(index);
+ }
+
+ int IList.Add(object o)
+ {
+ return Add((TableRow)o);
+ }
+
+ bool IList.Contains(object o)
+ {
+ return owner.Controls.Contains((TableRow)o);
+ }
+
+ int IList.IndexOf(object o)
+ {
+ return owner.Controls.IndexOf((TableRow)o);
+ }
+
+ void IList.Insert(int index, object o)
+ {
+ owner.Controls.AddAt(index, (TableRow)o);
+ }
+
+ void IList.Remove(object o)
+ {
+ owner.Controls.Remove((TableRow)o);
+ }
+
+ bool IList.IsFixedSize
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ object IList.this[int index]
+ {
+ get
+ {
+ return this[index];
+ }
+ set
+ {
+ RemoveAt(index);
+ AddAt(index, (TableRow)value);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TableStyle.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TableStyle.cs
new file mode 100644
index 00000000000..6b1e7cd1415
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TableStyle.cs
@@ -0,0 +1,229 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TableStyle
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class TableStyle : Style
+ {
+ private static int IMAGE_URL = (0x01 << 16);
+ private static int CELL_PADD = (0x01 << 17);
+ private static int CELL_SPAC = (0x01 << 18);
+ private static int GRID_LINE = (0x01 << 19);
+ private static int HOR_ALIGN = (0x01 << 20);
+
+ public TableStyle(): base()
+ {
+ }
+
+ public TableStyle(StateBag bag): base(bag)
+ {
+ }
+
+ public virtual string BackImageUrl
+ {
+ get
+ {
+ if(IsSet(IMAGE_URL))
+ return (string)(ViewState["BackImageUrl"]);
+ return String.Empty;
+ }
+ set
+ {
+ if(value == null)
+ throw new ArgumentNullException("BackImageUrl");
+ ViewState["BackImageUrl"] = value;
+ Set(IMAGE_URL);
+ }
+ }
+
+ public virtual int CellPadding
+ {
+ get
+ {
+ if(IsSet(CELL_PADD))
+ return (int)(ViewState["CellPadding"]);
+ return -1;
+ }
+ set
+ {
+ if(value < -1)
+ throw new ArgumentOutOfRangeException("CellPadding");
+ ViewState["CellPadding"] = value;
+ Set(CELL_PADD);
+ }
+ }
+
+ public virtual int CellSpacing
+ {
+ get
+ {
+ if(IsSet(CELL_SPAC))
+ return (int)(ViewState["CellSpacing"]);
+ return -1;
+ }
+ set
+ {
+ if(value < -1)
+ throw new ArgumentOutOfRangeException("CellSpacing");
+ ViewState["CellSpacing"] = value;
+ Set(CELL_SPAC);
+ }
+ }
+
+ public virtual GridLines GridLines
+ {
+ get
+ {
+ if(IsSet(GRID_LINE))
+ return (GridLines)(ViewState["GridLines"]);
+ return GridLines.None;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(GridLines), value))
+ throw new ArgumentException();
+ ViewState["GridLines"] = value;
+ Set(GRID_LINE);
+ }
+ }
+
+ public virtual HorizontalAlign HorizontalAlign
+ {
+ get
+ {
+ if(IsSet(HOR_ALIGN))
+ return (HorizontalAlign)(ViewState["HorizontalAlign"]);
+ return HorizontalAlign.NotSet;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(HorizontalAlign), value))
+ throw new ArgumentException();
+ ViewState["HorizontalAlign"] = value;
+ Set(HOR_ALIGN);
+ }
+ }
+
+ public override void AddAttributesToRender(HtmlTextWriter writer, WebControl owner)
+ {
+ base.AddAttributesToRender(writer, owner);
+ if(BackImageUrl.Length > 0)
+ {
+ writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundImage, "url(" + owner.ResolveUrl(BackImageUrl) + ")");
+ }
+ if(CellSpacing >= 0)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, CellSpacing.ToString(NumberFormatInfo.InvariantInfo));
+ }
+ if(CellPadding >= 0)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, CellPadding.ToString(NumberFormatInfo.InvariantInfo));
+ }
+ if(HorizontalAlign != HorizontalAlign.NotSet)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Align, Enum.Format(typeof(HorizontalAlign), HorizontalAlign, "G"));
+ }
+ string gd = "";
+ switch(GridLines)
+ {
+ case GridLines.None: gd = "";
+ break;
+ case GridLines.Horizontal: gd = "cols";
+ break;
+ case GridLines.Vertical: gd = "rows";
+ break;
+ case GridLines.Both: gd = "all";
+ break;
+ }
+ writer.AddAttribute(HtmlTextWriterAttribute.Rules, gd);
+ }
+
+ public override void CopyFrom(Style s)
+ {
+ if(s != null && s is TableStyle && !s.IsEmpty)
+ {
+ base.CopyFrom(s);
+ TableStyle from = (TableStyle)s;
+ if(from.IsSet(HOR_ALIGN))
+ {
+ HorizontalAlign = from.HorizontalAlign;
+ }
+ if(from.IsSet(IMAGE_URL))
+ {
+ BackImageUrl = from.BackImageUrl;
+ }
+ if(from.IsSet(CELL_PADD))
+ {
+ CellPadding = from.CellPadding;
+ }
+ if(from.IsSet(CELL_SPAC))
+ {
+ CellSpacing = from.CellSpacing;
+ }
+ if(from.IsSet(GRID_LINE))
+ {
+ GridLines = from.GridLines;
+ }
+ }
+ }
+
+ public override void MergeWith(Style s)
+ {
+ if(s != null && s is TableStyle && !s.IsEmpty)
+ {
+ base.MergeWith(s);
+ TableStyle with = (TableStyle)s;
+ if(with.IsSet(HOR_ALIGN) && IsSet(HOR_ALIGN))
+ {
+ HorizontalAlign = with.HorizontalAlign;
+ }
+ if(with.IsSet(IMAGE_URL) && IsSet(IMAGE_URL))
+ {
+ BackImageUrl = with.BackImageUrl;
+ }
+ if(with.IsSet(CELL_PADD) && IsSet(CELL_PADD))
+ {
+ CellPadding = with.CellPadding;
+ }
+ if(with.IsSet(CELL_SPAC) && IsSet(CELL_SPAC))
+ {
+ CellSpacing = with.CellSpacing;
+ }
+ if(with.IsSet(GRID_LINE) && IsSet(GRID_LINE))
+ {
+ GridLines = with.GridLines;
+ }
+ }
+ }
+
+ public override void Reset()
+ {
+ if(IsSet(IMAGE_URL))
+ ViewState.Remove("BackImageUrl");
+ if(IsSet(HOR_ALIGN))
+ ViewState.Remove("HorizontalAlign");
+ if(IsSet(CELL_PADD))
+ ViewState.Remove("CellPadding");
+ if(IsSet(CELL_SPAC))
+ ViewState.Remove("CellSpacing");
+ if(IsSet(GRID_LINE))
+ ViewState.Remove("GridLines");
+ base.Reset();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TargetConverter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TargetConverter.cs
new file mode 100644
index 00000000000..409dd35a9c0
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TargetConverter.cs
@@ -0,0 +1,55 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TargetConverter
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class TargetConverter : StringConverter
+ {
+ private StandardValuesCollection standardValues;
+ private string[] values = {
+ "_parent",
+ "_self",
+ "_blank",
+ "_search",
+ "_top"
+ };
+
+ public TargetConverter(): base()
+ {
+ }
+
+ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
+ {
+ if(standardValues == null)
+ {
+ standardValues = new StandardValuesCollection(values);
+ }
+ return standardValues;
+ }
+
+ public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
+ {
+ return false;
+ }
+
+ public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
+ {
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TemplateColumn.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TemplateColumn.cs
new file mode 100644
index 00000000000..b64b42bde50
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TemplateColumn.cs
@@ -0,0 +1,109 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TemplateColumn
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class TemplateColumn : DataGridColumn
+ {
+ private ITemplate editItemTemplate;
+ private ITemplate footerTemplate;
+ private ITemplate headerTemplate;
+ private ITemplate itemTemplate;
+
+ public TemplateColumn(): base()
+ {
+ }
+
+ public virtual ITemplate EditItemTemplate
+ {
+ get
+ {
+ return editItemTemplate;
+ }
+ set
+ {
+ editItemTemplate = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual ITemplate FooterTemplate
+ {
+ get
+ {
+ return footerTemplate;
+ }
+ set
+ {
+ footerTemplate = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual ITemplate HeaderTemplate
+ {
+ get
+ {
+ return headerTemplate;
+ }
+ set
+ {
+ headerTemplate = value;
+ OnColumnChanged();
+ }
+ }
+
+ public virtual ITemplate ItemTemplate
+ {
+ get
+ {
+ return itemTemplate;
+ }
+ set
+ {
+ itemTemplate = value;
+ OnColumnChanged();
+ }
+ }
+
+ public override void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
+ {
+ base.InitializeCell(cell, columnIndex, itemType);
+ ITemplate toRender = null;
+ switch(itemType)
+ {
+ case ListItemType.Header: toRender = headerTemplate;
+ break;
+ case ListItemType.Footer: toRender = footerTemplate;
+ break;
+ case ListItemType.Item: toRender = itemTemplate;
+ break;
+ case ListItemType.AlternatingItem: toRender = itemTemplate;
+ break;
+ case ListItemType.SelectedItem: toRender = editItemTemplate;
+ break;
+ default: toRender = editItemTemplate;
+ break;
+ }
+ if(toRender != null)
+ {
+ cell.Text = String.Empty;
+ toRender.InstantiateIn(cell);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TextAlign.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TextAlign.cs
new file mode 100755
index 00000000000..906bb73badd
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TextAlign.cs
@@ -0,0 +1,21 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: TextAlign
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum TextAlign
+ {
+ Left = 1,
+ Right
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs
new file mode 100644
index 00000000000..2e1b5a87795
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs
@@ -0,0 +1,236 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TextBox
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 80%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Globalization;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultEvent("TextChanged")]
+ [DefaultProperty("Text")]
+ [ParseChildren(false)]
+ [ValidationProperty("Text")]
+ public class TextBox : WebControl, IPostBackDataHandler
+ {
+ private static readonly object TextChangedEvent = new object ();
+
+ public TextBox() : base (HtmlTextWriterTag.Input)
+ {
+ }
+
+ public virtual bool AutoPostBack
+ {
+ get {
+ object o = ViewState ["AutoPostBack"];
+ return (o == null) ? false : (bool) o;
+ }
+
+ set { ViewState ["AutoPostBack"] = value; }
+ }
+
+ public virtual int Columns
+ {
+ get {
+ object o = ViewState ["Columns"];
+ return (o == null) ? 0 : (int) o;
+ }
+
+ set { ViewState ["Columns"] = value; }
+ }
+
+ public virtual int MaxLength
+ {
+ get
+ {
+ object o = ViewState ["MaxLength"];
+ return (o == null) ? 0 : (int) o;
+ }
+
+ set { ViewState ["MaxLength"] = value; }
+ }
+
+ public virtual bool ReadOnly
+ {
+ get
+ {
+ object o = ViewState ["ReadOnly"];
+ return (o == null) ? false : (bool) o;
+ }
+ set { ViewState ["ReadOnly"] = value; }
+ }
+
+ public virtual int Rows
+ {
+ get
+ {
+ object o = ViewState ["Rows"];
+ return (o == null) ? 0 : (int) o;
+ }
+
+ set { ViewState ["Rows"] = value; }
+ }
+
+ public virtual string Text
+ {
+ get {
+ object o = ViewState ["Text"];
+ return (o == null) ? String.Empty : (string) o;
+ }
+
+ set { ViewState ["Text"] = value; }
+ }
+
+ public virtual TextBoxMode TextMode
+ {
+ get {
+ object o = ViewState ["TextMode"];
+ return (o == null) ? TextBoxMode.SingleLine : (TextBoxMode) o;
+ }
+
+ set {
+ if(!Enum.IsDefined (typeof(TextBoxMode), value))
+ throw new ArgumentException ();
+ ViewState ["TextMode"] = value;
+ }
+ }
+
+ public virtual bool Wrap
+ {
+ get {
+ object o = ViewState ["Wrap"];
+ return (o == null) ? true : (bool) o;
+ }
+
+ set { ViewState ["Wrap"] = value; }
+ }
+
+ public event EventHandler TextChanged
+ {
+ add { Events.AddHandler (TextChangedEvent, value); }
+ remove { Events.RemoveHandler (TextChangedEvent, value); }
+ }
+
+ protected override HtmlTextWriterTag TagKey
+ {
+ get {
+ if(TextMode == TextBoxMode.MultiLine)
+ return HtmlTextWriterTag.Textarea;
+ return HtmlTextWriterTag.Input;
+ }
+ }
+
+ protected override void AddAttributesToRender (HtmlTextWriter writer)
+ {
+ if(Page != null)
+ Page.VerifyRenderingInServerForm (this);
+
+ writer.AddAttribute (HtmlTextWriterAttribute.Name, UniqueID);
+ if (TextMode == TextBoxMode.MultiLine){
+ if (Rows > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Rows,
+ Rows.ToString (
+ NumberFormatInfo.InvariantInfo));
+
+ if (Columns > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Cols,
+ Columns.ToString (
+ NumberFormatInfo.InvariantInfo));
+
+ if (!Wrap)
+ writer.AddAttribute(HtmlTextWriterAttribute.Wrap, "off");
+ } else {
+ string mode;
+ if (TextMode == TextBoxMode.Password)
+ mode = "password";
+ else {
+ mode = "text";
+ if (Text.Length > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Value, Text);
+ }
+
+ writer.AddAttribute (HtmlTextWriterAttribute.Type, mode);
+ if (MaxLength > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Maxlength,
+ MaxLength.ToString (NumberFormatInfo.InvariantInfo));
+
+ if (Columns > 0)
+ writer.AddAttribute (HtmlTextWriterAttribute.Size,
+ Columns.ToString (NumberFormatInfo.InvariantInfo));
+ }
+
+ if (ReadOnly)
+ writer.AddAttribute (HtmlTextWriterAttribute.ReadOnly, "readonly");
+
+ base.AddAttributesToRender (writer);
+
+ if (AutoPostBack && Page != null){
+ writer.AddAttribute (HtmlTextWriterAttribute.Onchange,
+ Page.GetPostBackClientEvent (this, ""));
+ writer.AddAttribute ("language", "javascript");
+ }
+ }
+
+ protected override void AddParsedSubObject(object obj)
+ {
+ if(!(obj is LiteralControl))
+ throw new HttpException (HttpRuntime.FormatResourceString (
+ "Cannot_Have_Children_Of_Type", "TextBox",
+ GetType ().Name.ToString ()));
+
+ Text = ((LiteralControl) obj).Text;
+ }
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender (e);
+ if (Events [TextChangedEvent] == null)
+ ViewState.SetItemDirty ("Text", false);
+ }
+
+ protected virtual void OnTextChanged (EventArgs e)
+ {
+ if(Events != null){
+ EventHandler eh = (EventHandler) (Events [TextChangedEvent]);
+ if(eh != null)
+ eh (this, e);
+ }
+ }
+
+ protected override void Render (HtmlTextWriter writer)
+ {
+ RenderBeginTag(writer);
+ if (TextMode == TextBoxMode.MultiLine)
+ HttpUtility.HtmlEncode (Text, writer);
+ RenderEndTag(writer);
+ }
+
+ bool IPostBackDataHandler.LoadPostData (string postDataKey,
+ NameValueCollection postCollection)
+ {
+ if (postCollection [postDataKey] != Text){
+ Text = postCollection [postDataKey];
+ return true;
+ }
+ return false;
+ }
+
+ void IPostBackDataHandler.RaisePostDataChangedEvent ()
+ {
+ OnTextChanged (EventArgs.Empty);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TextBoxControlBuilder.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TextBoxControlBuilder.cs
new file mode 100644
index 00000000000..7c26db6eaf3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TextBoxControlBuilder.cs
@@ -0,0 +1,36 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: TextBoxControlBuilder
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class TextBoxControlBuilder : ControlBuilder
+ {
+ public TextBoxControlBuilder(): base()
+ {
+ }
+
+ public override bool AllowWhitespaceLiterals()
+ {
+ return false;
+ }
+
+ public override bool HtmlDecodeLiterals()
+ {
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TextBoxMode.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TextBoxMode.cs
new file mode 100755
index 00000000000..47b903ec0f2
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TextBoxMode.cs
@@ -0,0 +1,22 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: TextBoxMode
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum TextBoxMode
+ {
+ SingleLine,
+ MultiLine,
+ Password
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TitleFormat.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TitleFormat.cs
new file mode 100755
index 00000000000..3cfb9a42f42
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/TitleFormat.cs
@@ -0,0 +1,21 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: TitleFormat
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum TitleFormat
+ {
+ Month,
+ MonthYear
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Unit.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Unit.cs
new file mode 100644
index 00000000000..550961bf513
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Unit.cs
@@ -0,0 +1,257 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Struct: Unit
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Globalization;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [TypeConverter(typeof(UnitConverter))]
+ public struct Unit
+ {
+ public static readonly Unit Empty = new Unit();
+
+ private static int Min = -32768;
+ private static int Max = +32767;
+
+ private UnitType type;
+ private double val;
+
+ public static Unit Parse(string s)
+ {
+ return new Unit(s);
+ }
+
+ public static Unit Parse(string s, CultureInfo culture)
+ {
+ return new Unit(s, culture);
+ }
+
+ public static Unit Percentage(double n)
+ {
+ return new Unit (n, UnitType.Percentage);
+ }
+
+ public static Unit Pixel(int n)
+ {
+ return new Unit (n, UnitType.Pixel);
+ }
+
+ public static Unit Point(int n)
+ {
+ return new Unit(n, UnitType.Point);
+ }
+
+ public static bool operator ==(Unit left, Unit right)
+ {
+ return (left.type == right.type && left.val == right.val);
+ }
+
+ public static bool operator !=(Unit left, Unit right)
+ {
+ return !(left == right);
+ }
+
+ public static implicit operator Unit(int n)
+ {
+ return new Unit(n);
+ }
+
+ public Unit(double value)
+ {
+ if(value < Min || value > Max)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ val = value;
+ type = UnitType.Pixel;
+ }
+
+ public Unit(int value)
+ {
+ if(value < Min || value > Max)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ val = value;
+ type = UnitType.Pixel;
+ }
+
+ public Unit(string value): this(value, CultureInfo.CurrentCulture)
+ {
+ }
+
+ public Unit(double value, UnitType type)
+ {
+ if(value < Min || value > Max)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ val = value;
+ this.type = type;
+ }
+
+ public Unit(string value, CultureInfo culture): this(value, culture, UnitType.Pixel)
+ {
+ }
+
+ internal Unit(string value, CultureInfo culture, UnitType defType)
+ {
+ string valueTrim;
+ if (value == null || (valueTrim = value.Trim ()).Length == 0) {
+ val = 0;
+ type = UnitType.Pixel;
+ return;
+ }
+
+ if (culture == null)
+ culture = CultureInfo.CurrentCulture;
+
+ string strVal = valueTrim.ToLower ();
+ int length = strVal.Length;
+ char c;
+ int start = -1;
+ for (int i = 0; i < length; i++) {
+ c = strVal [i];
+ if( (c >= '0' && c <= '9') || (c == '-' || c == '.' || c == ',') )
+ start = i;
+ }
+
+ if (start == -1)
+ throw new ArgumentException("No digits in 'value'");
+
+ start++;
+ if (start < length) {
+ type = GetTypeFromString (strVal.Substring (start).Trim ());
+ val = 0;
+ } else {
+ type = defType;
+ }
+
+ try {
+ string numbers = strVal.Substring (0, start);
+ if (type == UnitType.Pixel)
+ val = (double) Int32.Parse (numbers, culture);
+ else
+ val = (double) Single.Parse (numbers, culture);
+ } catch (Exception) {
+ throw new FormatException ("Error parsing " + value);
+ }
+
+ if (val < Min || val > Max)
+ throw new ArgumentOutOfRangeException ();
+ }
+
+ private static UnitType GetTypeFromString(string s)
+ {
+ if(s == null || s.Length == 0)
+ return UnitType.Pixel;
+ s = s.ToLower().Trim();
+ string[] uTypes = {
+ "px",
+ "pt",
+ "pc",
+ "in",
+ "mm",
+ "cm",
+ "%",
+ "em",
+ "ex"
+ };
+ int i = 0;
+ foreach(string cType in uTypes)
+ {
+ if(s == cType)
+ return (UnitType)Enum.ToObject(typeof(UnitType), (i + 1));
+ i++;
+ }
+ return UnitType.Pixel;
+ }
+
+ private string GetStringFromPixel(UnitType ut)
+ {
+ string[] uTypes = {
+ "px",
+ "pt",
+ "pc",
+ "in",
+ "mm",
+ "cm",
+ "%",
+ "em",
+ "ex"
+ };
+ if( !Enum.IsDefined(typeof(UnitType), ut) )
+ return "px";
+ return uTypes[(int)ut - 1];
+ }
+
+ public bool IsEmpty
+ {
+ get
+ {
+ return (type == 0);
+ }
+ }
+
+ public UnitType Type
+ {
+ get
+ {
+ if(IsEmpty)
+ return UnitType.Pixel;
+ return type;
+ }
+ }
+
+ public double Value
+ {
+ get
+ {
+ return val;
+ }
+ }
+
+ public override bool Equals(object obj)
+ {
+ if(obj != null && obj is Unit)
+ {
+ Unit that = (Unit)obj;
+ return ( this.type == that.type && this.val == that.val );
+ }
+ return false;
+ }
+
+ public override int GetHashCode()
+ {
+ return ( (type.GetHashCode() << 2) | (val.GetHashCode()) );
+ }
+
+ public override string ToString()
+ {
+ if(IsEmpty)
+ return String.Empty;
+ return ( val.ToString() + GetStringFromPixel(type) );
+ }
+
+ public string ToString(CultureInfo culture)
+ {
+ if(IsEmpty)
+ return String.Empty;
+ return ( val.ToString(culture) + GetStringFromPixel(type) );
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/UnitConverter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/UnitConverter.cs
new file mode 100644
index 00000000000..b3320bb39ce
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/UnitConverter.cs
@@ -0,0 +1,65 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: UnitConverter
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Globalization;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class UnitConverter : TypeConverter
+ {
+ public UnitConverter(): base()
+ {
+ }
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if(sourceType == typeof(string))
+ return true;
+ return CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ if(value == null)
+ return null;
+ if(value is string)
+ {
+ string val = ((string)value).Trim();
+ if(val.Length == 0)
+ {
+ return Unit.Empty;
+ }
+ return (culture == null ? Unit.Parse(val) : Unit.Parse(val, culture));
+ }
+ return ConvertFrom(context, culture, value);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if(destinationType == typeof(string))
+ {
+ Unit val = (Unit)value;
+ if(val == Unit.Empty)
+ {
+ return String.Empty;
+ }
+ return val.ToString(culture);
+ }
+ return ConvertTo(context, culture, value, destinationType);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/UnitType.cs b/mcs/class/System.Web/System.Web.UI.WebControls/UnitType.cs
new file mode 100755
index 00000000000..285c1cc7195
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/UnitType.cs
@@ -0,0 +1,28 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: UnitType
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum UnitType
+ {
+ Pixel = 1,
+ Point,
+ Pica,
+ Inch,
+ Mm,
+ Cm,
+ Percentage,
+ Em,
+ Ex
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ValidatedControlConverter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ValidatedControlConverter.cs
new file mode 100644
index 00000000000..883154a7429
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ValidatedControlConverter.cs
@@ -0,0 +1,76 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: ValidatedControlConverter
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class ValidatedControlConverter : StringConverter
+ {
+ public ValidatedControlConverter(): base()
+ {
+ }
+
+ private object[] GetValues(IContainer container)
+ {
+ ArrayList values = new ArrayList();
+ IEnumerator ie = container.Components.GetEnumerator();
+ try
+ {
+ foreach(IComponent current in container.Components)
+ {
+ Control ctrl = (Control)current;
+ if(ctrl == null || ctrl.ID == null || ctrl.ID.Length == 0)
+ continue;
+ ValidationPropertyAttribute attrib = (ValidationPropertyAttribute)((TypeDescriptor.GetAttributes(ctrl))[typeof(ValidationPropertyAttribute)]);
+ if(attrib == null || attrib.Name == null)
+ continue;
+ values.Add(String.Copy(ctrl.ID));
+ }
+ }finally
+ {
+ if(ie is IDisposable)
+ ((IDisposable)ie).Dispose();
+ }
+ values.Sort();
+ return values.ToArray();
+ }
+
+ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
+ {
+ if(context != null && context.Container != null)
+ {
+ object[] values = GetValues(context.Container);
+ if(values != null)
+ {
+ return new StandardValuesCollection(values);
+ }
+ }
+ return null;
+ }
+
+ public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
+ {
+ return false;
+ }
+
+ public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
+ {
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ValidationCompareOperator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationCompareOperator.cs
new file mode 100755
index 00000000000..a752aa1df5d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationCompareOperator.cs
@@ -0,0 +1,26 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: ValidationCompareOperator
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum ValidationCompareOperator
+ {
+ Equal,
+ NotEqual,
+ GreaterThan,
+ GreaterThanEqual,
+ LessThan,
+ LessThanEqual,
+ DataTypeCheck
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ValidationDataType.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationDataType.cs
new file mode 100755
index 00000000000..227133269e1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationDataType.cs
@@ -0,0 +1,24 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: ValidationDataType
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum ValidationDataType
+ {
+ String,
+ Integer,
+ Double,
+ Date,
+ Currency
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs
new file mode 100644
index 00000000000..a90ce3f20fe
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs
@@ -0,0 +1,142 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: ValidationSummary
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: ??%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Drawing;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class ValidationSummary : WebControl
+ {
+ private bool uplevelRender;
+
+ public ValidationSummary(): base(HtmlTextWriterTag.Div)
+ {
+ uplevelRender = false;
+ ForeColor = Color.Red;
+ }
+
+ public ValidationSummaryDisplayMode DisplayMode
+ {
+ get
+ {
+ object o = ViewState["DisplayMode"];
+ if(o != null)
+ return (ValidationSummaryDisplayMode)o;
+ return ValidationSummaryDisplayMode.BulletList;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(ValidationSummaryDisplayMode), value))
+ throw new ArgumentException();
+ ViewState["DisplayMode"] = value;
+ }
+ }
+
+ public bool EnableClientScript
+ {
+ get
+ {
+ object o = ViewState["EnableClientScript"];
+ if(o != null)
+ return (bool)o;
+ return true;
+ }
+ set
+ {
+ ViewState["EnableClientScript"] = value;
+ }
+ }
+
+ public override Color ForeColor
+ {
+ get
+ {
+ return ForeColor;
+ }
+ set
+ {
+ ForeColor = value;
+ }
+ }
+
+ public bool ShowMessageBox
+ {
+ get
+ {
+ object o = ViewState["ShowMessageBox"];
+ if(o != null)
+ return (bool)o;
+ return false;
+ }
+ set
+ {
+ ViewState["ShowMessageBox"] = value;
+ }
+ }
+
+ public bool ShowSummary
+ {
+ get
+ {
+ object o = ViewState["ShowSummary"];
+ if(o != null)
+ return (bool)o;
+ return true;
+ }
+ set
+ {
+ ViewState["ShowSummary"] = value;
+ }
+ }
+
+ public string HeaderText
+ {
+ get
+ {
+ object o = ViewState["HeaderText"];
+ if(o != null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["HeaderText"] = value;
+ }
+ }
+
+ [MonoTODO("FIXME_See_Comments")]
+ protected override void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ AddAttributesToRender(writer);
+ if(uplevelRender)
+ {
+ //FIXME: This is not the case always. I forgot the case when it is absent.
+ // something to do with the ID's value? or ClienID's value itself?
+ writer.AddAttribute("id", ClientID);
+ if(HeaderText.Length > 0)
+ writer.AddAttribute("headertext", HeaderText, true);
+ if(ShowMessageBox)
+ writer.AddAttribute("showmessagebox", "True");
+ if(!ShowSummary)
+ writer.AddAttribute("showsummary", "False");
+ if(DisplayMode != ValidationSummaryDisplayMode.BulletList)
+ {
+ writer.AddAttribute("displaymode", PropertyConverter.EnumToString(typeof(ValidationSummaryDisplayMode), DisplayMode));
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummaryDisplayMode.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummaryDisplayMode.cs
new file mode 100755
index 00000000000..c3cf718395c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummaryDisplayMode.cs
@@ -0,0 +1,22 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: ValidationSummaryDisplayMode
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum ValidationSummaryDisplayMode
+ {
+ List,
+ BulletList,
+ SingleParagraph
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ValidatorDisplay.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ValidatorDisplay.cs
new file mode 100755
index 00000000000..48086af18bc
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/ValidatorDisplay.cs
@@ -0,0 +1,22 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: ValidatorDisplay
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.UI.WebControls
+{
+ public enum ValidatorDisplay
+ {
+ None,
+ Static,
+ Dynamic
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/VerticalAlign.cs b/mcs/class/System.Web/System.Web.UI.WebControls/VerticalAlign.cs
new file mode 100755
index 00000000000..caaea9d7c7b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/VerticalAlign.cs
@@ -0,0 +1,26 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Enumeration: VerticalAlign
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System.ComponentModel;
+
+namespace System.Web.UI.WebControls
+{
+ [TypeConverter(typeof(VerticalAlignConverter))]
+ public enum VerticalAlign
+ {
+ NotSet,
+ Top,
+ Middle,
+ Bottom
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/VerticalAlignConverter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/VerticalAlignConverter.cs
new file mode 100644
index 00000000000..17bfe389b4e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/VerticalAlignConverter.cs
@@ -0,0 +1,51 @@
+//
+// System.Web.UI.WebControls.VerticalAlignConverter
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.ComponentModel;
+using System.Globalization;
+
+namespace System.Web.UI.WebControls
+{
+ class VerticalAlignConverter : EnumConverter
+ {
+ public VerticalAlignConverter () : base (typeof(VerticalAlign))
+ {
+ }
+
+ // The base class is enough to handle everything.
+ // The methods are here just to make the class status page happy.
+ // Add some optimizations?
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
+ {
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value)
+ {
+ return base.ConvertFrom (context, culture, value);
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
+ {
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value,
+ Type destinationType)
+ {
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/WebColorConverter.cs b/mcs/class/System.Web/System.Web.UI.WebControls/WebColorConverter.cs
new file mode 100644
index 00000000000..2b36327049a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/WebColorConverter.cs
@@ -0,0 +1,74 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: WebColorConverter
+ *
+ * Author: Gaurav Vaish, Gonzalo Paniagua Javier
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>, <gonzalo@ximian.com>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ * (c) 2002 Ximian, Inc. (http://www.ximian.com)
+ */
+
+using System;
+using System.Globalization;
+using System.ComponentModel;
+using System.Drawing;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ public class WebColorConverter : ColorConverter
+ {
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value)
+ {
+ if (value is string) {
+ string val = ((string) value).Trim ();
+ if(val == String.Empty || val.Length == 0)
+ return Color.Empty;
+
+ NumberStyles style = (val [0] == '#') ? NumberStyles.HexNumber :
+ NumberStyles.None;
+
+ try {
+ int n = Int32.Parse (val.Substring (1), style);
+ return Color.FromArgb (n);
+ } catch {
+ Color c = Color.FromName (val);
+ if (c.A != 0 || c.R != 0 || c.B != 0 || c.G != 0)
+ return c;
+ }
+ }
+
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value,
+ Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException ("destinationType");
+
+ if (destinationType == typeof (String) && value != null) {
+ Color c = (Color) value;
+ if (c == Color.Empty)
+ return String.Empty;
+
+ if (c.IsNamedColor || c.IsSystemColor)
+ return c.Name;
+
+ return String.Format ("#{0:X2}{1:X2}{2:X2}{3:X2}", c.A, c.R, c.G, c.B);
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs b/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs
new file mode 100755
index 00000000000..d7a84d0b541
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs
@@ -0,0 +1,451 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: WebControl
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 40%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+using System.Drawing;
+using System.Collections.Specialized;
+
+namespace System.Web.UI.WebControls
+{
+ [PersistChildrenAttribute(false)]
+ [ParseChildrenAttribute(true)]
+ public class WebControl : Control, IAttributeAccessor
+ {
+ //TODO: A list of private members may be incomplete
+
+ private HtmlTextWriterTag tagKey;
+ private string stringTag;
+ private AttributeCollection attributes;
+ private StateBag attributeState;
+ private Style controlStyle;
+ private bool enabled;
+ private string tagName;
+
+ // TODO: The constructors definitions
+ protected WebControl () : this (HtmlTextWriterTag.Span)
+ {
+ }
+
+ public WebControl(HtmlTextWriterTag tag): base()
+ {
+ //FIXME: am i right?
+ tagKey = tag;
+ //stringTag = null;
+ Initialize();
+ }
+
+ protected WebControl(string tag): base()
+ {
+ //FIXME: am i right?
+ stringTag = tag;
+ Initialize();
+ }
+
+ private void Initialize()
+ {
+ controlStyle = null;
+ enabled = true;
+ tagName = stringTag;
+ attributeState = null;
+ }
+
+ public virtual string AccessKey
+ {
+ get
+ {
+ object o = ViewState["AccessKey"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["AccessKey"] = value;
+ }
+ }
+
+ [MonoTODO("FIXME_Internal_method_calls")]
+ public AttributeCollection Attributes
+ {
+ get
+ {
+ if(attributes==null)
+ {
+ //FIXME: From where to get StateBag and how? I think this method is OK!
+ if(attributeState == null)
+ {
+ attributeState = new StateBag(true);
+ if(IsTrackingViewState)
+ {
+ attributeState.TrackViewState();
+ }
+ }
+ attributes = new AttributeCollection(attributeState);
+ }
+ return attributes;
+ }
+ }
+
+ public virtual Color BackColor
+ {
+ get {
+ if (!ControlStyleCreated)
+ return Color.Empty;
+ return ControlStyle.BackColor;
+ }
+
+ set {
+ ControlStyle.BackColor = value;
+ }
+ }
+
+ public virtual Color BorderColor
+ {
+ get {
+ if (!ControlStyleCreated)
+ return Color.Empty;
+ return ControlStyle.BorderColor;
+ }
+
+ set {
+ ControlStyle.BorderColor = value;
+ }
+ }
+
+ public virtual BorderStyle BorderStyle
+ {
+ get {
+ if (!ControlStyleCreated)
+ return BorderStyle.NotSet;
+ return ControlStyle.BorderStyle;
+ }
+
+ set {
+ ControlStyle.BorderStyle = value;
+ }
+ }
+
+ public virtual Unit BorderWidth
+ {
+ get {
+ if (!ControlStyleCreated)
+ return Unit.Empty;
+ return ControlStyle.BorderWidth;
+ }
+
+ set {
+ if (value.Value < 0)
+ throw new ArgumentException();
+ ControlStyle.BorderWidth = value;
+ }
+ }
+
+ public Style ControlStyle
+ {
+ get
+ {
+ if(controlStyle == null)
+ {
+ controlStyle = CreateControlStyle();
+ if(IsTrackingViewState)
+ {
+ controlStyle.TrackViewState();
+ }
+ controlStyle.LoadViewState(null);
+ }
+ return controlStyle;
+ }
+ }
+
+ public bool ControlStyleCreated
+ {
+ get
+ {
+ return (controlStyle!=null);
+ }
+ }
+
+ public virtual string CssClass
+ {
+ get
+ {
+ return ControlStyle.CssClass;
+ }
+ set
+ {
+ ControlStyle.CssClass = value;
+ }
+ }
+
+ public virtual bool Enabled
+ {
+ get
+ {
+ return enabled;
+ }
+ set
+ {
+ enabled = value;
+ }
+ }
+
+ public virtual FontInfo Font
+ {
+ get
+ {
+ return ControlStyle.Font;
+ }
+ }
+
+ public virtual Color ForeColor
+ {
+ get {
+ if (!ControlStyleCreated)
+ return Color.Empty;
+ return ControlStyle.ForeColor;
+ }
+
+ set {
+ ControlStyle.ForeColor = value;
+ }
+ }
+
+ public virtual Unit Height
+ {
+ get
+ {
+ return ControlStyle.Height;
+ }
+ set
+ {
+ ControlStyle.Height = value;
+ }
+ }
+
+ public CssStyleCollection Style
+ {
+ get
+ {
+ return Attributes.CssStyle;
+ }
+ }
+
+ public virtual short TabIndex
+ {
+ get
+ {
+ object o = ViewState["TabIndex"];
+ if(o!=null)
+ return (short)o;
+ return 0;
+ }
+ set
+ {
+ if(value < -32768 || value > 32767)
+ throw new ArgumentException();
+ ViewState["TabIndex"] = value;
+ }
+ }
+
+ public virtual string ToolTip
+ {
+ get
+ {
+ object o = ViewState["ToolTip"];
+ if(o!=null)
+ return (string)o;
+ return String.Empty;
+ }
+ set
+ {
+ ViewState["ToolTip"] = value;
+ }
+ }
+
+ public virtual Unit Width
+ {
+ get
+ {
+ return ControlStyle.Width;
+ }
+ set
+ {
+ ControlStyle.Width = value;
+ }
+ }
+
+ public void ApplyStyle(Style s)
+ {
+ if (s != null && !s.IsEmpty)
+ ControlStyle.CopyFrom (s);
+ }
+
+ public void CopyBaseAttributes(WebControl controlSrc)
+ {
+ /*
+ * AccessKey, Enabled, ToolTip, TabIndex, Attributes
+ */
+ AccessKey = controlSrc.AccessKey;
+ Enabled = controlSrc.Enabled;
+ ToolTip = controlSrc.ToolTip;
+ TabIndex = controlSrc.TabIndex;
+ attributes = controlSrc.Attributes;
+ AttributeCollection otherAtt = controlSrc.Attributes;
+ foreach (string key in controlSrc.Attributes.Keys)
+ Attributes [key] = otherAtt [key];
+ }
+
+ public void MergeStyle(Style s)
+ {
+ ControlStyle.MergeWith(s);
+ }
+
+ public virtual void RenderBeginTag(HtmlTextWriter writer)
+ {
+ AddAttributesToRender(writer);
+ writer.RenderBeginTag(TagName);
+ }
+
+ public virtual void RenderEndTag(HtmlTextWriter writer)
+ {
+ writer.RenderEndTag();
+ }
+
+ protected virtual HtmlTextWriterTag TagKey
+ {
+ get
+ {
+ return tagKey;
+ }
+ }
+
+ protected virtual string TagName
+ {
+ get
+ {
+ if(tagName == null && TagKey != 0)
+ {
+ tagName = Enum.Format(typeof(HtmlTextWriterTag), TagKey, "G").ToString();
+ }
+ // What if tagName is null and tagKey 0?
+ return tagName;
+ }
+ }
+
+ protected virtual void AddAttributesToRender(HtmlTextWriter writer)
+ {
+ if(ID!=null)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
+ }
+ if(AccessKey.Length>0)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, AccessKey);
+ }
+ if(!Enabled)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
+ }
+ if(ToolTip.Length>0)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Title, ToolTip);
+ }
+ if(TabIndex != 0)
+ {
+ writer.AddAttribute(HtmlTextWriterAttribute.Tabindex, TabIndex.ToString());
+ }
+ if(ControlStyleCreated)
+ {
+ if(!ControlStyle.IsEmpty)
+ {
+ ControlStyle.AddAttributesToRender(writer, this);
+ }
+ }
+ if(attributeState != null){
+ IEnumerator ie = Attributes.Keys.GetEnumerator ();
+ while (ie.MoveNext ()){
+ string key = (string) ie.Current;
+ writer.AddAttribute (key, Attributes [key]);
+ }
+ }
+ }
+
+ protected virtual Style CreateControlStyle()
+ {
+ return new Style(ViewState);
+ }
+
+ protected override void LoadViewState (object savedState)
+ {
+ if (savedState != null) {
+ Triplet saved = (Triplet) savedState;
+ base.LoadViewState (saved.First);
+ if (ControlStyleCreated)
+ ControlStyle.LoadViewState (saved.Second);
+ if (attributeState != null)
+ attributeState.LoadViewState (saved.Third);
+ }
+ }
+
+ protected override void Render(HtmlTextWriter writer)
+ {
+ RenderBeginTag(writer);
+ RenderContents(writer);
+ RenderEndTag(writer);
+ }
+
+ protected virtual void RenderContents(HtmlTextWriter writer)
+ {
+ base.Render(writer);
+ }
+
+ protected override object SaveViewState()
+ {
+ object baseView = base.SaveViewState ();
+ object controlView = null;
+ if (ControlStyleCreated)
+ controlView = ControlStyle.SaveViewState();
+
+ object attrView = null;
+ if (attributeState != null)
+ attrView = attributeState.SaveViewState();
+
+ return new Triplet (baseView, controlView, attrView);
+ }
+
+ protected override void TrackViewState()
+ {
+ base.TrackViewState();
+ if (ControlStyleCreated)
+ ControlStyle.TrackViewState ();
+ if (attributeState != null)
+ attributeState.TrackViewState ();
+ }
+
+ string IAttributeAccessor.GetAttribute(string key)
+ {
+ if(Attributes!=null)
+ return Attributes[key] as string;
+ return null;
+ }
+
+ void IAttributeAccessor.SetAttribute(string key, string value)
+ {
+ Attributes[key] = value;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs
new file mode 100644
index 00000000000..487dffbc599
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs
@@ -0,0 +1,224 @@
+/**
+ * Namespace: System.Web.UI.WebControls
+ * Class: Xml
+ *
+ * Author: Gaurav Vaish, Gonzalo Paniagua Javier
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>, <gonzalo@ximian.com>
+ * Implementation: yes
+ * Status: 95%
+ *
+ * (C) Gaurav Vaish (2002)
+ * (c) 2002 Ximian, Inc. (http://www.ximian.com)
+ */
+
+using System;
+using System.ComponentModel;
+using System.IO;
+using System.Xml;
+using System.Xml.Xsl;
+using System.Xml.XPath;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+ [DefaultProperty("DocumentSource")]
+ [PersistChildren(false)]
+ public class Xml : Control
+ {
+ private XmlDocument document;
+ private string documentContent;
+ private string documentSource;
+ private XslTransform transform;
+ private XsltArgumentList transformArgumentList;
+ private string transformSource;
+
+ private XPathDocument xpathDoc;
+
+ private static XslTransform defaultTransform;
+
+ static Xml()
+ {
+ XmlTextReader reader = new XmlTextReader(new StringReader("<xsl:stylesheet version='1.0' " +
+ "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>" +
+ "<xsl:template match=\"\">" +
+ "<xsl:copy-of select=\".\"/>" +
+ "</xsl:template>" +
+ "</xsl:stylesheet>"));
+ defaultTransform = new XslTransform();
+ defaultTransform.Load(reader);
+ }
+
+ public Xml(): base()
+ {
+ }
+
+ [MonoTODO("security")]
+ private void LoadXmlDoc ()
+ {
+ if (documentContent != null && documentContent.Length > 0) {
+ document = new XmlDocument();
+ document.LoadXml (documentContent);
+ return;
+ }
+
+ if (documentSource != null && documentSource.Length != 0) {
+ document = new XmlDocument();
+ document.Load (documentSource);
+ }
+ }
+
+ public XmlDocument Document
+ {
+ get
+ {
+ if(document == null)
+ LoadXmlDoc();
+ return document;
+ }
+ set
+ {
+ documentSource = null;
+ documentContent = null;
+ xpathDoc = null;
+ document = value;
+ }
+ }
+
+ public string DocumentContent
+ {
+ get
+ {
+ return String.Empty;
+ }
+ set
+ {
+ document = null;
+ xpathDoc = null;
+ documentContent = value;
+ }
+ }
+
+ public string DocumentSource
+ {
+ get
+ {
+ if(documentSource != null)
+ return documentSource;
+ return String.Empty;
+ }
+ set
+ {
+ document = null;
+ documentContent = null;
+ xpathDoc = null;
+ documentSource = value;
+ }
+ }
+
+ public XslTransform Transform
+ {
+ get
+ {
+ return transform;
+ }
+ set
+ {
+ transformSource = null;
+ transform = value;
+ }
+ }
+
+ public string TransformSource
+ {
+ get
+ {
+ if(transformSource != null)
+ return transformSource;
+ return String.Empty;
+ }
+ set
+ {
+ transform = null;
+ transformSource = value;
+ }
+ }
+
+ public XsltArgumentList TransformArgumentList
+ {
+ get
+ {
+ return transformArgumentList;
+ }
+ set
+ {
+ transformArgumentList = value;
+ }
+ }
+
+ protected override void AddParsedSubObject(object obj)
+ {
+ if(obj is LiteralControl)
+ {
+ DocumentContent = ((LiteralControl)obj).Text;
+ return;
+ }
+ throw new HttpException (HttpRuntime.FormatResourceString (
+ "Cannot_Have_Children_of_Type",
+ "Xml",
+ GetType().Name));
+ }
+
+ [MonoTODO("security")]
+ private void LoadXpathDoc ()
+ {
+ if(documentContent != null && documentContent.Length > 0) {
+ xpathDoc = new XPathDocument (new StringReader (documentContent));
+ return;
+ }
+
+ if (documentSource != null && documentSource.Length != 0) {
+ xpathDoc = new XPathDocument (MapPathSecure (documentSource));
+ return;
+ }
+ }
+
+ [MonoTODO("security")]
+ private void LoadTransform ()
+ {
+ if (transform != null)
+ return;
+
+ if (transformSource != null && transformSource.Length != 0) {
+ transform = new XslTransform ();
+ transform.Load (transformSource);
+ }
+ }
+
+ protected override void Render(HtmlTextWriter output)
+ {
+ if(document == null)
+ {
+ LoadXpathDoc();
+ }
+
+ LoadTransform();
+ if(document == null || xpathDoc == null)
+ {
+ return;
+ }
+ if(transform == null)
+ {
+ transform = defaultTransform;
+ }
+ if(document != null)
+ {
+ Transform.Transform(document, transformArgumentList, output);
+ return;
+ }
+ Transform.Transform(xpathDoc, transformArgumentList, output);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/ApplicationFileParser.cs b/mcs/class/System.Web/System.Web.UI/ApplicationFileParser.cs
new file mode 100644
index 00000000000..de9df55763b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ApplicationFileParser.cs
@@ -0,0 +1,46 @@
+//
+// System.Web.UI.ApplicationfileParser
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ internal sealed class ApplicationFileParser : TemplateParser
+ {
+ [MonoTODO]
+ protected override Type CompileIntoType ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ internal static Type GetCompiledApplicationType (string inputFile,
+ HttpContext context,
+ ref ApplicationFileParser parser)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override Type DefaultBaseType
+ {
+ get {
+ return typeof (HttpApplication);
+ }
+ }
+
+ protected override string DefaultDirectiveName
+ {
+ get {
+ return "application";
+ }
+ }
+ }
+
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/AttributeCollection.cs b/mcs/class/System.Web/System.Web.UI/AttributeCollection.cs
new file mode 100755
index 00000000000..be03b6c7ed0
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/AttributeCollection.cs
@@ -0,0 +1,82 @@
+//
+// System.Web.UI.AttributeCollection.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com
+//
+
+using System;
+using System.Collections;
+
+namespace System.Web.UI {
+
+ public sealed class AttributeCollection
+ {
+ private StateBag bag;
+ private CssStyleCollection styleCollection;
+
+ public AttributeCollection (StateBag bag)
+ {
+ this.bag = bag;
+ }
+
+ public int Count {
+ get { return bag.Count; }
+ }
+
+ public CssStyleCollection CssStyle {
+ get {
+ if (styleCollection == null)
+ styleCollection = new CssStyleCollection (bag);
+ return styleCollection;
+ }
+ }
+
+ public string this [string key] {
+ get { return bag [key] as string; }
+
+ set { bag.Add (key, value); }
+ }
+
+ public ICollection Keys {
+ get { return bag.Keys; }
+ }
+
+ public void Add (string key, string value)
+ {
+ if (styleCollection != null && 0 == String.Compare (key, "style", true))
+ styleCollection.FillStyle (value);
+ else
+ bag.Add (key, value);
+ }
+
+ public void AddAttributes (HtmlTextWriter writer)
+ {
+ foreach (string key in bag.Keys) {
+ string value = bag [key] as string;
+ writer.AddAttribute (key, value);
+ }
+ }
+
+ public void Clear ()
+ {
+ bag.Clear ();
+ }
+
+ public void Remove (string key)
+ {
+ bag.Remove (key);
+ }
+
+ public void Render (HtmlTextWriter writer)
+ {
+ foreach (string key in bag.Keys) {
+ string value = bag [key] as string;
+ writer.WriteAttribute (key, value);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/BaseParser.cs b/mcs/class/System.Web/System.Web.UI/BaseParser.cs
new file mode 100755
index 00000000000..480ef7501b3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/BaseParser.cs
@@ -0,0 +1,84 @@
+//
+// System.Web.UI.BaseParser.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System.IO;
+using System.Web;
+using System.Web.Util;
+
+namespace System.Web.UI
+{
+ public class BaseParser
+ {
+ private HttpContext context;
+ private string baseDir;
+ private string baseVDir;
+ private string vPath;
+
+ internal string MapPath (string path)
+ {
+ return MapPath (path, true);
+ }
+
+ internal string MapPath (string path, bool allowCrossAppMapping)
+ {
+ if (context == null)
+ throw new HttpException ("context is null!!");
+
+ return context.Request.MapPath (path, context.Request.ApplicationPath, allowCrossAppMapping);
+ }
+
+ internal string PhysicalPath (string path)
+ {
+ if (Path.DirectorySeparatorChar != '/')
+ path = path.Replace ('/', '\\');
+
+ return Path.Combine (BaseDir, path);
+ }
+
+ internal HttpContext Context
+ {
+ get {
+ return context;
+ }
+ set {
+ context = value;
+ }
+ }
+
+ internal string BaseDir
+ {
+ get {
+ if (baseDir == null)
+ baseDir = MapPath (BaseVirtualDir, false);
+
+ return baseDir;
+ }
+ }
+
+ internal string BaseVirtualDir
+ {
+ get {
+ if (baseVDir == null)
+ baseVDir = UrlUtils.GetDirectory (context.Request.FilePath);
+
+ return baseVDir;
+ }
+ }
+
+ internal string CurrentVirtualPath
+ {
+ get {
+ return vPath;
+ }
+ }
+ }
+
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/BuildMethod.cs b/mcs/class/System.Web/System.Web.UI/BuildMethod.cs
new file mode 100644
index 00000000000..d06a4024166
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/BuildMethod.cs
@@ -0,0 +1,16 @@
+//
+// System.Web.UI.BuildMethod.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public delegate Control BuildMethod();
+}
diff --git a/mcs/class/System.Web/System.Web.UI/BuildTemplateMethod.cs b/mcs/class/System.Web/System.Web.UI/BuildTemplateMethod.cs
new file mode 100644
index 00000000000..8d53ce41e2e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/BuildTemplateMethod.cs
@@ -0,0 +1,16 @@
+//
+// System.Web.UI.BuildTemplateMethod.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public delegate void BuildTemplateMethod(Control control);
+}
diff --git a/mcs/class/System.Web/System.Web.UI/ChangeLog b/mcs/class/System.Web/System.Web.UI/ChangeLog
new file mode 100644
index 00000000000..564d1459118
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ChangeLog
@@ -0,0 +1,673 @@
+2003-01-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: some more tweaks to naming containers stuff.
+ * DataBinder.cs: don't throw exception if the container is null.
+
+ * Page.cs: now we can render client scripts, startup scripts and hidden
+ fields. Only render __VIEWSTATE if there is someone that will take care
+ of it.
+ (RaisePostBackEvents): first try the last one that required raise event,
+ then try __EVENTTARGET.
+
+2003-01-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: fixes in UniqueID, FindControl, AddedControl,
+ UnloadRecursive, InitRecursive. Reduced the size of __VIEWSTATE. Made
+ FindControl work with NamingContainers.
+
+ * ControlCollection.cs: notify the parent when clearing the collection.
+
+ * LosFormatter.cs: Added debugging output and generate a valid
+ viewstate even for unknown types.
+
+ * Page.cs: GetPostBackEventReference now uses UniqueID. Reduced
+ viewstate.
+
+2003-01-10 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: make it fire the LoadData related events also for controls
+ such as ImageButton, whose variable(s) in the query string are of the
+ form ctrl_name.x and only fire them once per control.
+
+2003-01-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataBinder.cs:
+ (GetPropertyValue): don't try to get the property as indexed
+
+2003-01-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataBinder.cs: use TypeDescriptor to get the properties and their
+ values.
+
+2003-01-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs:
+ (AddedControl): take the children to the same state of the parent.
+ (InitRecursive): set the page of the children.
+
+ * Page.cs: removed one line (it's done a few lines above).
+
+ * UserControl.cs:
+ (OnInit): always call InitializeAsUserControl
+ (InitializeAsUserControl): sets the page for the control.
+
+2003-01-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: fixed bug #36037.
+
+2002-12-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * BaseParser.cs: a couple of path fixes to make it work
+ when the page is not in the root directory.
+
+2002-12-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: fixed PreRenderRecursiveInternal. Thanks to kojoadams for
+ reporting the bug.
+
+2002-12-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * BaseParser.cs: use MapPath and context to locate files.
+ * Control.cs: implemented MapPathSecure.
+ * TemplateControl.cs: use UrlUtils to generate the path.
+ * TemplateControlParser.cs: use the context and MapPath.
+ * UserControl.cs: implemented MapPath.
+ * UserControlParser.cs: added context parameter to constructor.
+
+2002-12-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: implemented MapPathSecure.
+ * Page.cs: fixed Server property.
+
+2002-12-15 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataBinder.cs: try the indexer if the property is not found in
+ GetPropertyValue ().
+
+2002-12-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: added AutoEventWireup internal property.
+
+ * Page.cs: removed page events wire up from here.
+
+ * TemplateControl.cs: new method WireupAutomaticEvents to hook up page
+ and user controls events.
+
+ * TemplateControlParser.cs: process the options that are applicable
+ once we have the instance of the control.
+
+ * TemplateParser.cs: also stores the options.
+
+ * UserControl.cs: hook up events before initializing the control.
+
+
+2002-12-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: new method to set bindingContainer value.
+ * TemplateControl.cs: added controls are not binding containers.
+
+2002-12-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: implemented TemplateSourceDirectory.
+ * TemplateControl.cs: implemented LoadControl and LoadTemplate.
+
+2002-11-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * UserControl.cs: fixed SetAttribute.
+ * UserControlParser.cs: set the correct base type.
+
+2002-11-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * TemplateParser.cs: fixed BaseType.
+ * UserControlParser.cs: helper class to compile user controls.
+
+2002-11-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * LosFormatter.cs: added DateTime to special types.
+
+2002-11-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * LosFormatter.cs: added array serialization support. Disabled binary
+ serialization and add some debugging code.
+
+ * StateBag.cs: the length of the list of value can be less than the
+ length if the list of keys when remaining values are null.
+
+2002-11-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: return something useful in GetPostBackClientEvent.
+
+2002-11-02 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: implemented FileDependecies and made it protected.
+
+2002-10-31 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: save control names instead of the controls
+ themselves to the ViewState.
+
+ * LosFormatter.cs: added support for serializing unknown
+ types. BinaryFormatter does not work so you better don't store anything
+ of unknown Type in ViewState.
+
+ * Page.cs: GetViewStateString works now using LosFormatter.
+ Complete "Control execution lifecycle" by unloading all the child
+ controls. Check for null in RaisePostBackEvents.
+ LoadPageViewStateFromPersistenceMedium uses LosFormatter too.
+
+2002-10-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataBinder.cs: implemented Eval and GetIndexedPropertyValue methods.
+
+2002-10-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * LosFormatter.cs: Use WebEncoding.Encoding.
+
+ * Control.cs:
+ * Page.cs: fixed namespace.
+
+2002-10-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: set the context in ProcessRequest. Added a few trace calls.
+ * Control.cs: added some trace information.
+
+2002-10-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * SimpleHandlerFactory.cs: new handler for .ashx files.
+
+2002-09-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.UI/PageHandlerFactory.cs: new file.
+ * System.Web.UI/PageParser.cs:
+ * System.Web.UI/TemplateControlParser.cs: we are now able to compile
+ pages and use HttpApplication, HttpRuntime and SimpleWorkerRequest.
+
+2002-09-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: implemented ObBubbleEvent.
+ * Page.cs: temporary workaround to make POST work with xsp server.
+
+2002-09-22 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: fixed InvokeEventMethod now that Type.GetMethod does not
+ return pvt methods.
+
+2002-09-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * SimpleWebHandlerParser.cs: New file.
+ * WebServiceParser.cs: New file.
+
+2002-08-22 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * LosFormatter.cs: almost fully implemented.
+
+2002-08-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * CompiledTemplateBuilder.cs: InstantiateIn is virtual.
+ * EmptyControlCollection.cs: throw correct exception.
+ * LosFormatter.cs: stubbed out.
+ * OutputCacheLocation.cs: little fix.
+
+2002-08-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.UI/ApplicationFileParser.cs:
+ * System.Web.UI/BaseParser.cs:
+ * System.Web.UI/PageParser.cs:
+ * System.Web.UI/TemplateControl.cs:
+ * System.Web.UI/TemplateControlParser.cs:
+ * System.Web.UI/TemplateParser.cs: first steps to move xsp into
+ System.Web.
+
+2002-07-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: request to render postback script can be after form started
+ rendering.
+
+2002-07-22 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: added more page events to invoke automagically if some
+ methods are defined.
+
+2002-07-22 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs:
+ (SaveViewState): save state even when control is not visible.
+ (SaveViewStateRecursive):
+ (LoadViewStateRecursive): made internal.
+
+2002-07-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: improved event raising to allow client postback for a wider
+ variety of actions (clicking an hyperlink, ...).
+
+2002-07-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * UserControl.cs: implemented Load/SaveViewState.
+
+2002-07-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AttributeCollection.cs:
+ (Add): handle 'style' through styleCollection.
+
+ * CssStyleCollection.cs:
+ (fillStyle): renamed to FillStyle and made it internal.
+
+ * Page.cs:
+ (GetViewStateString): fixed, broken after other recent changes.
+ (ProcessPostData): allow a second try for postback data after OnLoad.
+ (ProcessRequest): clear controls collection, removed call to
+ UnloadRecursive.
+
+2002-07-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: uncommented Dispose.
+
+ * Page.cs:
+ (DeterminePostBackMode): more checkings.
+ (GetPostBackClientHyperLink): implemented.
+ (GetPostBackEventReference): added some comments with the HTML that MS
+ generates for that.
+ (ProcessRequest): fixed processing order. The page is unloaded after
+ a request and regenerated from view state on subsequents posts.
+
+2002-07-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: fixed related to ViewState. Added RemovedControl.
+
+ * ControlCollection.cs: notify owner of control removal.
+
+ * CssStyleCollection.cs: almost rewritten to make it render the style
+ attribute after changes to it.
+
+ * Page.cs: follow the guidelines in 'Control execution lifecycle'.
+ Removed Xml code.
+
+ * StateBag.cs: don't use IDictionary.GetEnumerator on the
+ HybridDictionary: it makes the program give an InvalidCastException at
+ runtime. Why?
+
+2002-07-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: fire Init and Load events for all children.
+
+2002-07-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * UserControl.cs: New file.
+
+2002-07-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ControlBuilderAttribute.cs: finished implementation.
+
+2002-07-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ConstructorNeedsTagAttribute.cs: the default constructor sets the
+ property to false.
+
+2002-07-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.UI/AttributeCollection.cs: added CssStyleCollection.
+
+ * System.Web.UI/CssStyleCollection.cs: use a StateBag instead of a
+ Hashtable. Added internal .ctor.
+
+ * System.Web.UI/DataBinding.cs: propertyType is a Type. Implemented
+ Equals and GetHashCode.
+
+ * System.Web.UI/DataBoundLiteralControl.cs:
+ (LoadViewState):
+ (SaveViewState): implemented.
+
+ * System.Web.UI/Page.cs: FileDependencies is not public.
+
+ * System.Web.UI/ParseChildrenAttribute.cs: give a value to Default.
+ (GetHashCode):
+ (Equals):
+ (IsDefaultAttribute): implemented.
+
+2002-07-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: fixed Visible property.
+ * Page.cs: fixed GetViewStateString.
+
+2002-07-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.UI/Page.cs:
+ (GetViewStateString): new function to give the server access to the
+ generated view state string.
+ (Validate): d'oh!
+
+2002-07-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs:
+ (SaveViewstateRecursive): implemented.
+ (SaveViewState): fixed.
+ (IParserAccessor.AddParsedSubObject): don't use 'this'.
+
+ * Page.cs: added code to save view state to an xml file. It's not
+ being used right now.
+
+2002-06-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.UI/LiteralControl.cs:
+ Fixes based on class status page:
+
+ - Add attributes (DefaultEvent, ParseChildren).
+ - Fix declarations.
+ - Explicitly implement some interfaces (IPostBackDataHandler
+ and IPostBackEventHandler).
+ - Implemented some missing methods.
+
+2002-06-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: reimplemented FindControls.
+
+ * Page.cs:
+ (.ctor): set the page for this control.
+ (IsPostBack): return valid value.
+ (DeterminePostBackMode): finished.
+ (OnFormRender): render __VIEWSTATE (uses GetTypeHashCode()).
+ (ProcessPostData): implemented. Raises change and postback events.
+ (ProcessRequest): changed to support reuse of the instance.
+ (RegisterRequiresPostBack): implemented.
+
+ * ValidatorCollection.cs: implemented all methods.
+
+2002-06-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs:
+ * Page.cs: first attemp to save view state.
+
+ * HtmlForm.cs: don't render Action.
+
+2002-06-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: implemented more properties using information we already
+ have in Context.
+ (OnFormRender):
+ (OnFormPostRender):
+ (VerifyRenderingInServerForm): implemented.
+
+2002-06-22 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: changed InvokeEventMethod to use a GetMethod that works with
+ out runtime. Renamed Page_Init and Page_Load.
+
+ After this, we can load a dll and render HTML in linux.
+
+2002-06-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs:
+ (AddedControl): new function that is called whenever a control is
+ added to a collection of controls in a container. It sets the defaults
+ except for Page.
+
+ * ControlCollection.cs: call AddedControl in Add/AddAt.
+
+ * DataBoundLiteralControl.cs: implemented constructor, Text, Render,
+ SetStaticString and SetDataBoundString.
+
+ * Page.cs: removed SetDefaults.
+
+2002-06-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * CompiledTemplateBuilder.cs: new file. Used in the code generated
+ by xsp.
+
+ * Control.cs:
+ (BindingContainer): implemented.
+ (EnsureChildControls): avoid stack overflow.
+
+ * DataBinder.cs: implemented Eval and PropertyValue.
+
+2002-06-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HtmlTextWriter.cs: fixed style attributes rendering (almost the same
+ bug as in regular attributes).
+
+2002-06-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: implemented PreventAutoID.
+
+ * Page.cs:
+ (SetDefaults): don't set ID automatically if Control.PreventAutoID has
+ been called.
+
+2002-06-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs:
+ (Validators): if the collection is null, create one.
+ (GetPostBackEventReference 2): don't throw exception.
+ (GetPostBackClientEvent): return a string with containing the method
+ name, the control name and the argument.
+
+2002-06-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: SetPage is now called SetDefaults and also sets a default
+ ID for controls that don't have one yet.
+
+2002-06-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs:
+ (GetPostBackClient):
+ (RegisterRequiresPostBack): don't throw NotImplementedException to
+ keep going.
+ (ProcessRequest): set the current page as the Page property for *all*
+ the controls, not just the direct children of the page.
+
+2002-06-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * 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 <gonzalo@ximian.com>
+
+ * ControlCollection.cs:
+ (AddAt): if index is -1 behave as a plain Add.
+
+2002-06-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: for each child control to render, assign Control.Page.
+ Probably also needed in HtmlContainerControl derived classes.
+
+2002-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * AttributeCollection.cs: don't need a Hastable. StateBag now works
+ fine and takes care of the details.
+
+ * Control.cs: added HasChildren property.
+
+ * StateBag.cs: fixed a couple of nasty bugs.
+
+2002-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs: run OnInit, OnLoad y PreRender before rendering the page.
+ Invoke Page_Init and/or Page_Load if the user supplied them (though
+ this should depend on AutoEventWireUp attribute of Page directive).
+
+2002-06-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Control.cs: don't throw exception in ControlID. By now, it returns ID.
+
+ * Page.cs:
+ (ProcessRequest): implemented.
+
+2002-06-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web.UI/Page.cs: finished stubbing out. Implemented some
+ methods.
+
+2002-06-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Page.cs:
+ (FileDependencies): now is public public.
+ (EnableViewStateMAC): uncommented and made protected.
+ (GetTypeHashCode): added method.
+
+2002-05-24 Duncan Mak <duncan@ximian.com>
+
+ * TemplateControl.cs (SetStringResourcePointer): Fixed typo.
+
+ * StateBag.cs (Item): Changed the visibility level of the this
+ [object] indexer.
+
+ Misc. formatting edits, fixing some bugs introduced by the indentation.
+
+ * DataBinder.cs (Eval)
+ (GetIndexedPropertyValue)
+ (GetPropertyValue): Fixed return types.
+
+2002-05-21 Miguel de Icaza <miguel@ximian.com>
+
+ * HtmlTextWriter.cs: Use this to change the member instances.
+
+2002-05-17 Duncan Mak <duncan@ximian.com>
+
+ * AttributeCollection.cs:
+ * ControlCollection.cs:
+ * CssStyleCollection.cs:
+ * DataBindingCollection.cs:
+ * EmptyControlCollection.cs: Added missing Collection classes.
+
+2002-05-17 Duncan Mak <duncan@ximian.com>
+
+ * BaseParser.cs:
+ * TemplateParser.cs: Implemented. BaseParser is weird because
+ there is no documentation on what it does.
+
+ * ControlBuilder.cs:
+
+ * DataBinder.cs:
+ * DataBinding.cs: Added.
+
+ * DataBoundLiteralControl.cs:
+ * Triplet.cs: Added.
+
+ * RenderMethod.cs: Added this delegate for Control.cs
+
+2002-05-15 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ValidationPropertyAttribute.cs: a couple of fixes to make it compile.
+
+2002-05-14 Duncan Mak <duncan@ximian.com>
+
+ * ValidationPropertyAttribute.cs: Added to CVS.
+
+2002-05-10 Duncan Mak <duncan@ximian.com>
+
+ * ConstructorNeedsTagAttribute.cs:
+ * ControlBuilderAttribute.cs:
+ * ImageClickEventArgs.cs:
+ * ParseChildrenAttribute.cs:
+ * PartialCachingAttribute.cs:
+ * PersistChildrenAttribute.cs:
+ * PersistenceModeAttribute.cs:
+ * TemplateContainerAttribute.cs: Added to CVS.
+
+ * PersistanceMode.cs: Removed, fixed typo.
+ * PersistenceMode.cs: Replacing above.
+
+ * StateBag.cs (this): Fixed indexer, it takes a string as the
+ index, not an object.
+
+ * ValidatorCollection.cs: Fixed typo, ValidatedCollection to ValidatorCollection.
+
+ * Page.cs (Validators): return type should be ValidatorCollection,
+ not ValidatedCollection.
+
+ * TagPrefixAttribute.cs: Added to CVS.
+
+2002-05-07 Duncan Mak <duncan@ximian.com>
+
+ * Utils.cs (GetClientValidatedEvent): Uncommented the 'Page' argument.
+
+2002-03-26 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * DataBindingHandlerAttribute.cs
+ - Completed
+ * ToolboxDataAttribute.cs - Completed
+
+2002-01-03 Nick Drochak <ndrochak@gol.com>
+
+ * DesignTimeParseData.cs: initialze static member to avoid compile
+ error
+ * PropertyConverter.cs: remove uneeded exception variables from
+ catch blocks.
+
+2002-01-02 Nick Drochak <ndrochak@gol.com>
+
+ * DesignTimeParseData.cs: fix header to show correct class name
+
+2001-12-21 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * StateBag.cs - Completed
+
+2001-12-19 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * Pair.cs - Small undocumented class. Completed.
+
+2001-12-18 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * DesignTimeParseData.cs - Initial implementation
+ * StateBag.cs - Initial implementation
+
+2001-12-17 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * PropertyConverter.cs - Undocumented class. Completed.
+ * Utils.cs - Undocumented, private class.
+ Initial implementation
+
+2001-08-28 Bob Smith <bob@thestuff.net>
+ * Control.cs: Figured out some undocumented API.
+ * Added TODO.
+ * BuildMethod.cs: Initial implementation.
+ * BuildTemplateMethod.cs: Initial implementation.
+ * HtmlTextWriterAttribute.cs: Initial implementation.
+ * HtmlTextWriterStyle.cs: Initial implementation.
+ * HtmlTextWriterTag.cs: Initial implementation.
+ * IAttributeAccessor.cs: Initial implementation.
+ * IDataBindingsAccessor.cs: Initial implementation.
+ * ImageClickEventHandler.cs: Initial implementation.
+ * INamingContainer.cs: Initial implementation.
+ * IParserAccessor.cs: Initial implementation.
+ * IPostBackDataHandler.cs: Initial implementation.
+ * IPostBackEventHandler.cs: Initial implementation.
+ * IStateManager.cs: Initial implementation.
+ * ITagNameToTypeMapper.cs: Initial implementation.
+ * ITemplate.cs: Initial implementation.
+ * IValidator.cs: Initial implementation.
+ * OutputCacheLocation.cs: Initial implementation.
+ * PersistanceMode.cs: Initial implementation.
+ * StateItem.cs: Initial implementation.
+
+2001-08-27 Bob Smith <bob@thestuff.net>
+
+ * Control.cs: Bug fixes and implementations.
+
+2001-08-24 Bob Smith <bob@thestuff.net>
+
+ * Control.cs: Bug fixes.
+
+2001-08-23 Bob Smith <bob@thestuff.net>
+
+ * Control.cs: More implementation. Events reworked for performance.
+
+2001-08-22 Bob Smith <bob@thestuff.net>
+
+ * LiteralControl.cs: Implemented.
+ * Control.cs: Even more implementation (Events). What a beast.
+
+2001-08-20 Bob Smith <bob@thestuff.net>
+
+ * Control.cs: More implementation. Not done yet. Shutter.
+
+2001-08-17 Bob Smith <bob@thestuff.net>
+
+ * Control.cs: Partial implementation.
diff --git a/mcs/class/System.Web/System.Web.UI/CompiledTemplateBuilder.cs b/mcs/class/System.Web/System.Web.UI/CompiledTemplateBuilder.cs
new file mode 100644
index 00000000000..a3ad857a0d3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/CompiledTemplateBuilder.cs
@@ -0,0 +1,29 @@
+//
+// System.Web.UI.CompiledTemplateBuilder
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+// This is used in the generated C# code from MS and xsp does the same.
+// It just seems to be a container implementing an ITemplate interface.
+
+namespace System.Web.UI {
+
+public class CompiledTemplateBuilder : ITemplate
+{
+ private BuildTemplateMethod templateMethod;
+
+ public CompiledTemplateBuilder (BuildTemplateMethod templateMethod)
+ {
+ this.templateMethod = templateMethod;
+ }
+
+ public virtual void InstantiateIn (Control ctrl)
+ {
+ templateMethod (ctrl);
+ }
+}
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/ConstructorNeedsTagAttribute.cs b/mcs/class/System.Web/System.Web.UI/ConstructorNeedsTagAttribute.cs
new file mode 100755
index 00000000000..cacfe8da90a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ConstructorNeedsTagAttribute.cs
@@ -0,0 +1,31 @@
+//
+// System.Web.UI.ConstructorNeedsTagAttribute.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+
+using System;
+
+namespace System.Web.UI {
+
+ [AttributeUsage (AttributeTargets.Class)]
+ public sealed class ConstructorNeedsTagAttribute : Attribute
+ {
+ bool needsTag;
+
+ public ConstructorNeedsTagAttribute ()
+ {
+ needsTag = false;
+ }
+
+ public ConstructorNeedsTagAttribute (bool needsTag)
+ {
+ this.needsTag = needsTag;
+ }
+
+ public bool NeedsTag {
+ get { return needsTag; }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/Control.cs b/mcs/class/System.Web/System.Web.UI/Control.cs
new file mode 100644
index 00000000000..9e2720bab14
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/Control.cs
@@ -0,0 +1,867 @@
+//
+// System.Web.UI.Control.cs
+//
+// Authors:
+// Bob Smith <bob@thestuff.net>
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) Bob Smith
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+/*
+ * Maintainer: bob@thestuff.net, gvaish@iitk.ac.in
+ * (C) Bob Smith, Gaurav Vaish
+ */
+
+//notes: view state only tracks changes after OnInit method is executed for the page request. You can read from it at any time, but cant write to it during rendering.
+//even more notes: view state info in trackviewstate method description. read later.
+//Ok, enough notes: what the heck is different between enable view state, and track view state.
+//Well, maybe not. How does the ViewState know when to track changes? Does it look at the property
+//on the owning control, or does it have a method/property of its own that gets called?
+// I think this last question is solved in the Interface for it. Look into this.
+
+//cycle:
+//init is called when control is first created.
+//load view state ic called right after init to populate the view state.
+//loadpostdata is called if ipostbackdatahandler is implemented.
+//load is called when control is loaded into a page
+//raisepostdatachangedevent if ipostbackdatahandler is implemented.
+//raisepostbackevent if ipostbackeventhandler is implemented.
+//prerender is called when the server is about to render its page object
+//SaveViewState is called.
+//Unload then dispose it apears. :)
+
+//Naming Container MUST have some methods. What are they? No clue. Help? (updated: the doc says that it's just a marker interface)
+
+//read this later. http://gotdotnet.com/quickstart/aspplus/
+//This to: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguidnf/html/cpconattributesdesign-timesupport.asp
+//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguidnf/html/cpcontracefunctionality.asp
+
+// Isnt life grand? :)
+// See the undocumented methods? Gota love um. ;)
+// ASP.test4_aspx.Page_Load(Object Sender, EventArgs e) in \\genfs2\www24\bobsmith11\test4.aspx:6
+// System.Web.UI.Control.OnLoad(EventArgs e) +67
+// System.Web.UI.Control.LoadRecursive() +73
+// System.Web.UI.Page.ProcessRequestMain() +394
+
+// ASP.test4_aspx.Page_Unload(Object Sender, EventArgs e) in \\genfs2\www24\bobsmith11\test4.aspx:6
+// System.EventHandler.Invoke(Object sender, EventArgs e) +0
+// System.Web.UI.Control.OnUnload(EventArgs e) +67
+// System.Web.UI.Control.UnloadRecursive(Boolean dispose) +78
+// System.Web.UI.Page.ProcessRequest() +194
+// System.Web.UI.Page.ProcessRequest(HttpContext context) +18
+// System.Web.CallHandlerExecutionStep.Execute() +179
+// System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87
+
+
+// ASP.test4_aspx.Page_Unload(Object Sender, EventArgs e) in \\genfs2\www24\bobsmith11\test4.aspx:6
+// System.Web.UI.Control.OnUnload(EventArgs e) +67
+// System.Web.UI.Control.UnloadRecursive(Boolean dispose) +78
+// System.Web.UI.Page.ProcessRequest()
+
+// ASP.test4_aspx.Page_Kill(Object Sender, EventArgs e) in \\genfs2\www24\bobsmith11\test4.aspx:6
+// System.Web.UI.Control.OnPreRender(EventArgs e) +67
+// System.Web.UI.Control.PreRenderRecursiveInternal() +61
+// System.Web.UI.Page.ProcessRequestMain() +753
+
+// ASP.test4_aspx.OnInit(EventArgs e) in \\genfs2\www24\bobsmith11\test4.aspx:6
+// System.Web.UI.Control.InitRecursive(Control namingContainer) +202
+// System.Web.UI.Page.ProcessRequestMain() +120
+
+// ASP.test4_aspx.SaveViewState() in \\genfs2\www24\bobsmith11\test4.aspx:12
+// System.Web.UI.Control.SaveViewStateRecursive() +51
+// System.Web.UI.Page.SavePageViewState() +174
+// System.Web.UI.Page.ProcessRequestMain() +861
+
+// ASP.test_aspx.LoadViewState(Object t) +28
+// System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +125
+// System.Web.UI.Page.LoadPageViewState() +182
+// System.Web.UI.Page.ProcessRequestMain() +256
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Web;
+using System.Web.Util;
+
+namespace System.Web.UI
+{
+ public class Control : IComponent, IDisposable, IParserAccessor, IDataBindingsAccessor
+ {
+ private static readonly object DataBindingEvent = new object();
+ private static readonly object DisposedEvent = new object();
+ private static readonly object InitEvent = new object();
+ private static readonly object LoadEvent = new object();
+ private static readonly object PreRenderEvent = new object();
+ private static readonly object UnloadEvent = new object();
+ private string uniqueID;
+ private string _userId = null;
+ private string _cachedClientId = null;
+ private ControlCollection _controls = null;
+ private bool _enableViewState = true;
+ private IDictionary _childViewStates = null; //TODO: Not sure datatype. Placeholder guess.
+ private bool _isNamingContainer = false;
+ private Control _namingContainer = null;
+ private Page _page = null;
+ private Control _parent = null;
+ private ISite _site = null;
+ private bool _visible = true;
+ private HttpContext _context = null;
+ private bool _childControlsCreated = false;
+ private StateBag _viewState = null;
+ private bool _trackViewState = false;
+ private EventHandlerList _events = new EventHandlerList();
+ private RenderMethod _renderMethodDelegate = null;
+ private bool autoID = true;
+ private bool creatingControls = false;
+ private bool bindingContainer = true;
+ private bool autoEventWireup = true;
+
+ bool inited = false;
+ bool loaded = false;
+ bool prerendered = false;
+ int defaultNumberID = 0;
+
+ private DataBindingCollection dataBindings = null;
+
+ public Control()
+ {
+ if (this is INamingContainer) _isNamingContainer = true;
+ }
+
+ public Control BindingContainer
+ {
+ get {
+ Control container = NamingContainer;
+ if (!container.bindingContainer)
+ container = container.BindingContainer;
+ return container;
+ }
+ }
+
+ public virtual string ClientID {
+ get {
+ string client = UniqueID;
+
+ if (client != null)
+ client = client.Replace (':', '_');
+
+ return client;
+ }
+ }
+
+ public virtual ControlCollection Controls //DIT
+ {
+ get
+ {
+ if (_controls == null) _controls = CreateControlCollection();
+ return _controls;
+ }
+ }
+ public virtual bool EnableViewState //DIT
+ {
+ get
+ {
+ return _enableViewState;
+ }
+ set
+ {
+ _enableViewState = value;
+ }
+ }
+
+ public virtual string ID {
+ get {
+ return _userId;
+ }
+
+ set {
+ if (value == "")
+ value = null;
+
+ _userId = value;
+ NullifyUniqueID ();
+ }
+ }
+
+ public virtual Control NamingContainer //DIT
+ {
+ get
+ {
+ if (_namingContainer == null && _parent != null)
+ {
+ if (_parent._isNamingContainer == false)
+ _namingContainer = _parent.NamingContainer;
+ else
+ _namingContainer = _parent;
+ }
+ return _namingContainer;
+ }
+ }
+ public virtual Page Page //DIT
+ {
+ get
+ {
+ if (_page == null && _parent != null) _page = _parent.Page;
+ return _page;
+ }
+ set
+ {
+ _page = value;
+ }
+ }
+ public virtual Control Parent //DIT
+ {
+ get
+ {
+ return _parent;
+ }
+ }
+ public ISite Site //DIT
+ {
+ get
+ {
+ return _site;
+ }
+ set
+ {
+ _site = value;
+ }
+ }
+
+ public virtual string TemplateSourceDirectory {
+ get { return (_parent == null) ? String.Empty : _parent.TemplateSourceDirectory; }
+ }
+
+ 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;
+ }
+ }
+ public virtual bool Visible
+ {
+ get
+ {
+ if (_visible == false)
+ return false;
+
+ if (_parent != null)
+ return _parent.Visible;
+
+ return true;
+ }
+ set
+ {
+ _visible = value;
+ }
+ }
+ protected bool ChildControlsCreated //DIT
+ {
+ get
+ {
+ return _childControlsCreated;
+ }
+ set
+ {
+ if (value == false && _childControlsCreated == true)
+ _controls.Clear();
+ _childControlsCreated = value;
+ }
+ }
+ 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 //DIT
+ {
+ get
+ {
+ return _trackViewState;
+ }
+ }
+ protected virtual StateBag ViewState
+ {
+ get
+ {
+ if(_viewState == null)
+ _viewState = new StateBag (ViewStateIgnoresCase);
+
+ if (IsTrackingViewState)
+ _viewState.TrackViewState ();
+
+ return _viewState;
+ }
+ }
+
+ protected virtual bool ViewStateIgnoresCase
+ {
+ get {
+ return false;
+ }
+ }
+
+ internal bool AutoEventWireup {
+ get { return autoEventWireup; }
+ set { autoEventWireup = value; }
+ }
+
+ internal void SetBindingContainer (bool isBC)
+ {
+ bindingContainer = isBC;
+ }
+
+ internal void ResetChildNames ()
+ {
+ defaultNumberID = 0;
+ }
+
+ string GetDefaultName ()
+ {
+ return "_ctrl" + defaultNumberID++;
+ }
+
+ void NullifyUniqueID ()
+ {
+ uniqueID = null;
+ if (_controls == null)
+ return;
+
+ foreach (Control c in _controls)
+ c.NullifyUniqueID ();
+ }
+
+ 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);
+
+ control._parent = this;
+ control._page = Page;
+
+ if (_isNamingContainer) {
+ control._namingContainer = this;
+ if (control.AutoID == true && control._userId == null) {
+ control._userId = GetDefaultName ();
+ }
+ }
+
+ if (inited)
+ control.InitRecursive (_isNamingContainer ? this : null);
+
+ if (loaded)
+ control.LoadRecursive ();
+
+ if (prerendered)
+ control.PreRenderRecursiveInternal ();
+ }
+
+ protected virtual void AddParsedSubObject(object obj) //DIT
+ {
+ WebTrace.PushContext ("Control.AddParsedSubobject ()");
+ Control c = obj as Control;
+ WebTrace.WriteLine ("Start: {0} -> {1}", obj, (c != null) ? c.ID : String.Empty);
+ if (c != null) Controls.Add(c);
+ WebTrace.WriteLine ("End");
+ WebTrace.PopContext ();
+ }
+ protected void BuildProfileTree(string parentId, bool calcViewState)
+ {
+ //TODO
+ }
+ protected void ClearChildViewState()
+ {
+ //TODO
+ //Not quite sure about this. an example clears children then calls this, so I think
+ //view state is local to the current object, not children.
+ }
+ protected virtual void CreateChildControls() {} //DIT
+ protected virtual ControlCollection CreateControlCollection() //DIT
+ {
+ return new ControlCollection(this);
+ }
+
+ protected virtual void EnsureChildControls () //DIT
+ {
+ if (ChildControlsCreated == false && !creatingControls) {
+ creatingControls = true;
+ CreateChildControls();
+ ChildControlsCreated = true;
+ creatingControls = false;
+ }
+ }
+
+ public virtual Control FindControl (string id)
+ {
+ return FindControl (id, 0);
+ }
+
+ Control LookForControlByName (string id)
+ {
+ if (!HasChildren)
+ return null;
+
+ foreach (Control c in _controls) {
+ if (String.Compare (id, c._userId, true) == 0)
+ return c;
+
+ if (!c._isNamingContainer && c.HasChildren) {
+ Control child = c.LookForControlByName (id);
+ if (child != null)
+ return child;
+ }
+ }
+
+ return null;
+ }
+
+ protected virtual Control FindControl (string id, int pathOffset)
+ {
+ EnsureChildControls ();
+ if (_controls == null)
+ return null;
+
+ Control namingContainer = null;
+ if (!_isNamingContainer) {
+ namingContainer = NamingContainer;
+ if (namingContainer == null)
+ return null;
+
+ return namingContainer.FindControl (id, pathOffset);
+ }
+
+ 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)
+ {
+ if (savedState != null)
+ ViewState.LoadViewState (savedState);
+ }
+
+ [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
+ {
+ return false;
+ }
+ protected virtual void OnDataBinding(EventArgs e) //DIT
+ {
+ if (_events != null)
+ {
+ EventHandler eh = (EventHandler)(_events[DataBindingEvent]);
+ if (eh != null) eh(this, e);
+ }
+ }
+ protected virtual void OnInit(EventArgs e) //DIT
+ {
+ if (_events != null)
+ {
+ EventHandler eh = (EventHandler)(_events[InitEvent]);
+ if (eh != null) eh(this, e);
+ }
+ }
+ protected virtual void OnLoad(EventArgs e) //DIT
+ {
+ if (_events != null)
+ {
+ EventHandler eh = (EventHandler)(_events[LoadEvent]);
+ if (eh != null) eh(this, e);
+ }
+ }
+ protected virtual void OnPreRender(EventArgs e) //DIT
+ {
+ if (_events != null)
+ {
+ EventHandler eh = (EventHandler)(_events[PreRenderEvent]);
+ if (eh != null) eh(this, e);
+ }
+ }
+ protected virtual void OnUnload(EventArgs e) //DIT
+ {
+ if (_events != null)
+ {
+ EventHandler eh = (EventHandler)(_events[UnloadEvent]);
+ if (eh != null) eh(this, e);
+ }
+ }
+
+ protected void RaiseBubbleEvent(object source, EventArgs args)
+ {
+ Control c = Parent;
+ while (c != null) {
+ if (c.OnBubbleEvent (source, args))
+ break;
+ c = c.Parent;
+ }
+ }
+
+ protected virtual void Render(HtmlTextWriter writer) //DIT
+ {
+ RenderChildren(writer);
+ }
+
+ protected virtual void RenderChildren(HtmlTextWriter writer) //DIT
+ {
+ if (_renderMethodDelegate != null)
+ _renderMethodDelegate(writer, this);
+ else if (_controls != null)
+ foreach (Control c in _controls)
+ c.RenderControl(writer);
+ }
+
+ protected virtual object SaveViewState ()
+ {
+ if (_viewState == null)
+ return null;
+
+ return _viewState.SaveViewState ();
+ }
+
+ protected virtual void TrackViewState()
+ {
+ if (_viewState != null)
+ _viewState.TrackViewState ();
+ _trackViewState = true;
+ }
+
+ public virtual void Dispose()
+ {
+ if (_events != null)
+ {
+ EventHandler eh = (EventHandler) _events [DisposedEvent];
+ if (eh != null)
+ eh(this, EventArgs.Empty);
+ }
+ }
+
+ public bool HasChildren
+ {
+ get { return (_controls != null && _controls.Count > 0); }
+ }
+
+ public event EventHandler DataBinding //DIT
+ {
+ add
+ {
+ Events.AddHandler(DataBindingEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(DataBindingEvent, value);
+ }
+ }
+ public event EventHandler Disposed //DIT
+ {
+ add
+ {
+ Events.AddHandler(DisposedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(DisposedEvent, value);
+ }
+ }
+ public event EventHandler Init //DIT
+ {
+ add
+ {
+ Events.AddHandler(InitEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(InitEvent, value);
+ }
+ }
+ public event EventHandler Load //DIT
+ {
+ add
+ {
+ Events.AddHandler(LoadEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(LoadEvent, value);
+ }
+ }
+ public event EventHandler PreRender //DIT
+ {
+ add
+ {
+ Events.AddHandler(PreRenderEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(PreRenderEvent, value);
+ }
+ }
+ public event EventHandler Unload //DIT
+ {
+ add
+ {
+ Events.AddHandler(UnloadEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(UnloadEvent, value);
+ }
+ }
+
+ public virtual void DataBind() //DIT
+ {
+ OnDataBinding(EventArgs.Empty);
+ if (_controls != null)
+ foreach (Control c in _controls)
+ c.DataBind();
+ }
+
+ public virtual bool HasControls() //DIT
+ {
+ if (_controls != null && _controls.Count >0) return true;
+ return false;
+ }
+
+ public void RenderControl(HtmlTextWriter writer)
+ {
+ if (_visible)
+ {
+ //TODO: Something about tracing here.
+ Render(writer);
+ }
+ }
+
+ [MonoTODO]
+ public string ResolveUrl(string relativeUrl)
+ {
+ return relativeUrl;
+ }
+
+ public void SetRenderMethodDelegate(RenderMethod renderMethod) //DIT
+ {
+ WebTrace.PushContext ("Control.AddParsedSubobject ()");
+ WebTrace.WriteLine ("Start");
+ _renderMethodDelegate = renderMethod;
+ WebTrace.WriteLine ("End");
+ WebTrace.PopContext ();
+ }
+
+ protected void LoadRecursive()
+ {
+ OnLoad (EventArgs.Empty);
+ if (_controls != null) {
+ foreach (Control c in _controls)
+ c.LoadRecursive ();
+ }
+ loaded = true;
+ }
+
+ protected void UnloadRecursive(Boolean dispose)
+ {
+ if (_controls != null) {
+ foreach (Control c in _controls)
+ c.UnloadRecursive (dispose);
+ }
+
+ OnUnload (EventArgs.Empty);
+ if (dispose)
+ Dispose();
+ }
+
+ protected void PreRenderRecursiveInternal()
+ {
+ if (_visible) {
+ EnsureChildControls ();
+ OnPreRender (EventArgs.Empty);
+ if (_controls == null)
+ return;
+
+ foreach (Control c in _controls)
+ c.PreRenderRecursiveInternal ();
+ }
+ prerendered = true;
+ }
+
+ protected void InitRecursive(Control namingContainer)
+ {
+ if (_controls != null) {
+ if (_isNamingContainer)
+ namingContainer = this;
+
+ if (namingContainer != null &&
+ namingContainer._userId == null &&
+ namingContainer.autoID)
+ namingContainer._userId = namingContainer.GetDefaultName ();
+
+ foreach (Control c in _controls) {
+ c._page = Page;
+ c._namingContainer = namingContainer;
+ c.InitRecursive (namingContainer);
+ }
+ }
+
+ OnInit (EventArgs.Empty);
+ TrackViewState ();
+ inited = true;
+ }
+
+ internal object SaveViewStateRecursive ()
+ {
+ if (!EnableViewState)
+ return null;
+
+ ArrayList controlList = null;
+ ArrayList controlStates = null;
+
+ foreach (Control ctrl in Controls) {
+ object ctrlState = ctrl.SaveViewStateRecursive ();
+ if (ctrlState == null || ctrl.ID == null)
+ continue;
+
+ if (controlList == null) {
+ controlList = new ArrayList ();
+ controlStates = new ArrayList ();
+ }
+
+ controlList.Add (ctrl.ID);
+ controlStates.Add (ctrlState);
+ }
+
+ object thisState = SaveViewState ();
+ if (thisState == null && controlList == null && controlStates == null)
+ return null;
+
+ return new Triplet (thisState, controlList, controlStates);
+ }
+
+ internal void LoadViewStateRecursive (object savedState)
+ {
+ if (!EnableViewState || !Visible || savedState == null)
+ return;
+
+ Triplet savedInfo = (Triplet) savedState;
+ LoadViewState (savedInfo.First);
+
+ ArrayList controlList = savedInfo.Second as ArrayList;
+ if (controlList == null)
+ return;
+ ArrayList controlStates = savedInfo.Third as ArrayList;
+ int nControls = controlList.Count;
+ for (int i = 0; i < nControls; i++) {
+ Control c = FindControl ((string) controlList [i]);
+ if (c != null && controlStates != null)
+ c.LoadViewStateRecursive (controlStates [i]);
+ }
+ }
+
+ void IParserAccessor.AddParsedSubObject(object obj)
+ {
+ AddParsedSubObject(obj);
+ }
+
+ DataBindingCollection IDataBindingsAccessor.DataBindings
+ {
+ get
+ {
+ if(dataBindings == null)
+ dataBindings = new DataBindingCollection();
+ return dataBindings;
+ }
+ }
+
+ bool IDataBindingsAccessor.HasDataBindings
+ {
+ get
+ {
+ return (dataBindings!=null && dataBindings.Count>0);
+ }
+ }
+
+ internal bool AutoID
+ {
+ get { return autoID; }
+ set {
+ if (value == false && !_isNamingContainer)
+ return;
+
+ autoID = value;
+ }
+ }
+
+ internal void PreventAutoID()
+ {
+ AutoID = false;
+ }
+
+ protected internal virtual void RemovedControl (Control control)
+ {
+ control.UnloadRecursive (false);
+ control._parent = null;
+ control._page = null;
+ control._namingContainer = null;
+ }
+
+ //TODO: I think there are some needed Interface implementations to do here.
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/ControlBuilder.cs b/mcs/class/System.Web/System.Web.UI/ControlBuilder.cs
new file mode 100755
index 00000000000..7acb206a3a3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ControlBuilder.cs
@@ -0,0 +1,167 @@
+//
+// System.Web.UI.ControlBuilder.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.Web.UI {
+
+ public class ControlBuilder
+ {
+ TemplateParser parser;
+ ControlBuilder parentBuilder;
+ Type type;
+ string tagName;
+ string id;
+ IDictionary attribs;
+ int line;
+ string fileName;
+
+ public ControlBuilder ()
+ {
+ }
+
+
+ internal ControlBuilder (
+ TemplateParser parser, ControlBuilder parentBuilder,
+ Type type, string tagName, string id,
+ IDictionary attribs, int line, string sourceFileName)
+
+ {
+ this.parser = parser;
+ this.parentBuilder = parentBuilder;
+ this.type = type;
+ this.tagName = tagName;
+ this.id = id;
+ this.attribs = attribs;
+ this.line = line;
+ this.fileName = sourceFileName;
+ }
+
+ public Type ControlType {
+ get { return type; }
+ }
+
+ [MonoTODO]
+ public bool FChildrenAsProperties {
+ get { return false; }
+ }
+
+ [MonoTODO]
+ public bool FIsNonParserAccessor {
+ get { return false; }
+ }
+
+ [MonoTODO]
+ public bool HasAspCode {
+ get { return false; }
+ }
+
+ public string ID {
+ get { return id; }
+
+ set { id = value; }
+ }
+
+ [MonoTODO]
+ public bool InDesigner {
+ get { return false; }
+ }
+
+ [MonoTODO]
+ public Type NamingContainerType {
+ get { return null; }
+ }
+
+ protected TemplateParser Parser {
+ get { return parser; }
+ }
+
+ public string TagName {
+ get { return tagName; }
+ }
+
+ [MonoTODO]
+ public virtual bool AllowWhitespaceLiterals ()
+ {
+ return false;
+ }
+
+ [MonoTODO]
+ public virtual void AppendLiteralString (string s)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void AppendSubBuilder (ControlBuilder subBuilder)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void CloseControl ()
+ {
+ }
+
+ [MonoTODO]
+ public static ControlBuilder CreateBuilderFromType (
+ TemplateParser parser, ControlBuilder parentBuilder,
+ Type type, string tagName, string id,
+ IDictionary attribs, int line, string sourceFileName)
+ {
+ return new ControlBuilder (parser, parentBuilder, type,
+ tagName, id, attribs, line, sourceFileName);
+ }
+
+ [MonoTODO]
+ public virtual Type GetChildControlType (string tagName, IDictionary attribs)
+ {
+ return attribs [tagName] as Type;
+ }
+
+ [MonoTODO]
+ public virtual bool HasBody ()
+ {
+ return false;
+ }
+
+ [MonoTODO]
+ public virtual bool HtmlDecodeLiterals ()
+ {
+ return false;
+ }
+
+ [MonoTODO]
+ public virtual void Init (
+ TemplateParser parser, ControlBuilder parentBuilder,
+ Type type, string tagName, string id, IDictionary attribs)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual bool NeedsTagInnerText ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void OnAppendToParentBuilder ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual void SetTagInnerText (string text)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/ControlBuilderAttribute.cs b/mcs/class/System.Web/System.Web.UI/ControlBuilderAttribute.cs
new file mode 100755
index 00000000000..dfae94c445d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ControlBuilderAttribute.cs
@@ -0,0 +1,47 @@
+//
+// System.Web.UI.ControlBuilderAttribute.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com)
+
+using System;
+
+namespace System.Web.UI {
+
+ [AttributeUsage (AttributeTargets.Class)]
+ public sealed class ControlBuilderAttribute : Attribute
+ {
+ Type builderType;
+ public static readonly ControlBuilderAttribute Default = new ControlBuilderAttribute (null);
+
+ public ControlBuilderAttribute (Type builderType)
+ {
+ this.builderType = builderType;
+ }
+
+ public Type BuilderType {
+ get { return builderType; }
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (!(obj is ControlBuilderAttribute))
+ return false;
+ return ((ControlBuilderAttribute) obj).builderType == builderType;
+ }
+
+ public override int GetHashCode ()
+ {
+ return base.GetHashCode ();
+ }
+
+ public override bool IsDefaultAttribute ()
+ {
+ return Equals (Default);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/ControlCollection.cs b/mcs/class/System.Web/System.Web.UI/ControlCollection.cs
new file mode 100755
index 00000000000..225b55b10ce
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ControlCollection.cs
@@ -0,0 +1,124 @@
+//
+// System.Web.UI.ControlCollection.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.Web.UI {
+
+ public class ControlCollection : ICollection, IEnumerable
+ {
+ ArrayList list = new ArrayList ();
+ Control owner;
+
+ public ControlCollection (Control owner)
+ {
+ if (owner == null)
+ throw new ArgumentException ();
+
+ this.owner = owner;
+ }
+
+ public int Count {
+ get { return list.Count; }
+ }
+
+ public bool IsReadOnly {
+ get { return list.IsReadOnly; }
+ }
+
+ public bool IsSynchronized {
+ get { return list.IsSynchronized; }
+ }
+
+ public virtual Control this [int index] {
+ get { return list [index] as Control; }
+ }
+
+ protected Control Owner {
+ get { return owner; }
+ }
+
+ public object SyncRoot {
+ get { return list.SyncRoot; }
+ }
+
+ public virtual void Add (Control child)
+ {
+ if (child == null)
+ throw new ArgumentNullException ();
+ if (IsReadOnly)
+ throw new HttpException ();
+
+ list.Add (child);
+ owner.AddedControl (child, list.Count - 1);
+ }
+
+ public virtual void AddAt (int index, Control child)
+ {
+ if (child == null) // maybe we should check for ! (child is Control)?
+ throw new ArgumentNullException ();
+
+ if ((index < -1) || (index > Count))
+ throw new ArgumentOutOfRangeException ();
+
+ if (IsReadOnly)
+ throw new HttpException ();
+
+ if (index == -1){
+ Add (child);
+ } else {
+ list [index] = child;
+ owner.AddedControl (child, index);
+ }
+ }
+
+ public virtual void Clear ()
+ {
+ list.Clear ();
+ if (owner != null)
+ owner.ResetChildNames ();
+ }
+
+ public virtual bool Contains (Control c)
+ {
+ return list.Contains (c);
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ list.CopyTo (array, index);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ public virtual int IndexOf (Control c)
+ {
+ return list.IndexOf (c);
+ }
+
+ public virtual void Remove (Control value)
+ {
+ list.Remove (value);
+ owner.RemovedControl (value);
+ }
+
+ public virtual void RemoveAt (int index)
+ {
+ if (IsReadOnly)
+ throw new HttpException ();
+
+ Control value = (Control) list [index];
+ list.RemoveAt (index);
+ owner.RemovedControl (value);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/CssStyleCollection.cs b/mcs/class/System.Web/System.Web.UI/CssStyleCollection.cs
new file mode 100755
index 00000000000..8191228681c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/CssStyleCollection.cs
@@ -0,0 +1,106 @@
+//
+// System.Web.UI.CssStyleCollection.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.Text;
+
+namespace System.Web.UI {
+
+ public sealed class CssStyleCollection
+ {
+ private StateBag bag;
+ private StateBag style;
+
+ internal CssStyleCollection (StateBag bag)
+ {
+ this.bag = bag;
+ style = new StateBag ();
+ string st_string = bag ["style"] as string;
+ if (st_string != null)
+ FillStyle (st_string);
+ }
+
+ internal void FillStyle (string s)
+ {
+ int mark = s.IndexOf (':');
+ if (mark == -1)
+ return;
+ string key = s.Substring (0, mark). Trim ();
+ if (mark + 1 > s.Length)
+ return;
+
+ string fullValue = s.Substring (mark + 1);
+ if (fullValue == "")
+ return;
+
+ mark = fullValue.IndexOf (';');
+ string value;
+ if (mark == -1)
+ value = fullValue.Trim ();
+ else
+ value = fullValue.Substring (0, mark).Trim ();
+
+ style.Add (key, value);
+ if (mark + 1 > fullValue.Length)
+ return;
+ FillStyle (fullValue.Substring (mark + 1));
+ }
+
+ private string BagToString ()
+ {
+ StringBuilder sb = new StringBuilder ();
+ foreach (string k in style.Keys)
+ sb.AppendFormat ("{0}: {1}; ", k, style [k]);
+ return sb.ToString ();
+ }
+
+ public int Count
+ {
+ get { return style.Count; }
+ }
+
+ public string this [string key]
+ {
+ get {
+ return style [key] as string;
+ }
+
+ set {
+ Add (key, value);
+ }
+ }
+
+ public ICollection Keys {
+ get { return style.Keys; }
+ }
+
+ public void Add (string key, string value)
+ {
+ style [key] = value;
+ bag ["style"] = BagToString ();
+ }
+
+ public void Clear ()
+ {
+ bag.Remove ("style");
+ style.Clear ();
+ }
+
+ public void Remove (string key)
+ {
+ if (style [key] != null) {
+ style.Remove (key);
+ bag ["style"] = BagToString ();
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/DataBinder.cs b/mcs/class/System.Web/System.Web.UI/DataBinder.cs
new file mode 100755
index 00000000000..5ab388c6d89
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/DataBinder.cs
@@ -0,0 +1,158 @@
+//
+// System.Web.UI.DataBinder.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+using System.ComponentModel;
+using System.Reflection;
+
+namespace System.Web.UI {
+
+ public sealed class DataBinder
+ {
+ public DataBinder ()
+ {
+ }
+
+ private static string FormatResult (object result, string format)
+ {
+ if (result == null)
+ return String.Empty;
+
+ if (format == null)
+ return result.ToString ();
+
+ return String.Format (format, result);
+ }
+
+ public static object Eval (object container, string expression)
+ {
+ if (expression == null)
+ throw new ArgumentNullException ("expression");
+
+ object current = container;
+
+ while (current != null) {
+ int dot = expression.IndexOf ('.');
+ int size = (dot == -1) ? expression.Length : dot;
+ string prop = expression.Substring (0, size);
+ if (prop.IndexOf ('[') != -1)
+ current = GetIndexedPropertyValue (current, prop);
+ else
+ current = GetPropertyValue (current, prop);
+
+ if (dot == -1)
+ break;
+
+ expression = expression.Substring (prop.Length + 1);
+ }
+
+ return current;
+ }
+
+ public static string Eval (object container, string expression, string format)
+ {
+ object result = Eval (container, expression);
+ return FormatResult (result, format);
+ }
+
+ public static object GetIndexedPropertyValue (object container, string expr)
+ {
+ if (expr == null)
+ throw new ArgumentNullException ("expr");
+
+ int openIdx = expr.IndexOf ('[');
+ int closeIdx = expr.IndexOf (']'); // see the test case. MS ignores all after the first ]
+ if (openIdx < 0 || closeIdx < 0 || closeIdx - openIdx <= 1)
+ throw new ArgumentException (expr + " is not a valid indexed expression.");
+
+ string val = expr.Substring (openIdx + 1, closeIdx - openIdx - 1);
+ val = val.Trim ();
+ int valLength = val.Length;
+ if (valLength == 0)
+ throw new ArgumentException (expr + " is not a valid indexed expression.");
+
+ int intVal = 0;
+ bool is_string;
+ char first = val [0];
+ if (first >= '0' && first <= '9') {
+ is_string = false;
+ try {
+ intVal = Int32.Parse (val);
+ } catch {
+ throw new ArgumentException (expr + " is not a valid indexed expression.");
+ }
+
+ } else if (first == '"' && val [valLength - 1] == '"') {
+ is_string = true;
+ val = val.Substring (0, val.Length - 1).Substring (1);
+ } else {
+ throw new ArgumentException (expr + " is not a valid indexed expression.");
+ }
+
+ string property = null;
+ if (openIdx > 0) {
+ property = expr.Substring (0, openIdx);
+ if (property != null && property != String.Empty)
+ container = GetPropertyValue (container, property);
+ }
+
+ if (container == null)
+ return null;
+
+ Type t = container.GetType ();
+ // MS does not seem to look for any other than "Item"!!!
+ object [] atts = t.GetCustomAttributes (typeof (DefaultMemberAttribute), false);
+ if (atts.Length != 1)
+ throw new ArgumentException (expr + " indexer not found.");
+
+ property = ((DefaultMemberAttribute) atts [0]).MemberName;
+
+ Type [] argTypes = new Type [] { (is_string) ? typeof (string) : typeof (int) };
+ PropertyInfo prop = t.GetProperty (property, argTypes);
+ if (prop == null)
+ throw new ArgumentException (expr + " indexer not found.");
+
+ object [] args = new object [1];
+ if (is_string)
+ args [0] = val;
+ else
+ args [0] = intVal;
+
+ return prop.GetValue (container, args);
+ }
+
+ public static string GetIndexedPropertyValue (object container, string expr, string format)
+ {
+ object result = GetIndexedPropertyValue (container, expr);
+ return FormatResult (result, format);
+ }
+
+ public static object GetPropertyValue (object container, string propName)
+ {
+ if (propName == null)
+ throw new ArgumentNullException ("propName");
+
+ PropertyDescriptor prop = TypeDescriptor.GetProperties (container).Find (propName, true);
+ if (prop == null) {
+ throw new HttpException ("Property " + propName + " not found in " +
+ container.GetType ());
+ }
+
+ return prop.GetValue (container);
+ }
+
+ public static string GetPropertyValue (object container, string propName, string format)
+ {
+ object result = GetPropertyValue (container, propName);
+ return FormatResult (result, format);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/DataBinding.cs b/mcs/class/System.Web/System.Web.UI/DataBinding.cs
new file mode 100755
index 00000000000..cf0c8a07d49
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/DataBinding.cs
@@ -0,0 +1,60 @@
+//
+// System.Web.UI.DataBinding.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+
+namespace System.Web.UI {
+
+ public sealed class DataBinding
+ {
+ string propertyName;
+ Type propertyType;
+ string expression;
+
+ public DataBinding (string propertyName, Type propertyType,
+ string expression)
+ {
+ this.propertyName = propertyName;
+ this.propertyType = propertyType;
+ this.expression = expression;
+ }
+
+ public string Expression {
+ get { return expression; }
+ set { expression = value; }
+ }
+
+ public string PropertyName {
+ get { return propertyName; }
+ }
+
+ public Type PropertyType {
+ get { return propertyType; }
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (!(obj is DataBinding))
+ return false;
+
+ DataBinding o = (DataBinding) obj;
+ return (o.Expression == expression &&
+ o.PropertyName == propertyName &&
+ o.PropertyType == propertyType);
+ }
+
+ public override int GetHashCode ()
+ {
+ return propertyName.GetHashCode () +
+ (propertyType.GetHashCode () << 1) +
+ (expression.GetHashCode () << 2) ;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/DataBindingCollection.cs b/mcs/class/System.Web/System.Web.UI/DataBindingCollection.cs
new file mode 100755
index 00000000000..80e86454612
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/DataBindingCollection.cs
@@ -0,0 +1,92 @@
+//
+// System.Web.UI.DataBindingCollection.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.Web.UI {
+
+ public sealed class DataBindingCollection : ICollection, IEnumerable
+ {
+ Hashtable list;
+ ArrayList removed;
+
+ public DataBindingCollection ()
+ {
+ list = new Hashtable ();
+ removed = new ArrayList ();
+ }
+
+ public int Count {
+ get { return list.Count; }
+ }
+
+ public bool IsReadOnly {
+ get { return list.IsReadOnly; }
+ }
+
+ public bool IsSynchronized {
+ get { return list.IsSynchronized; }
+ }
+
+ public DataBinding this [string propertyName] {
+ get { return list [propertyName] as DataBinding; }
+ }
+
+ public string [] RemovedBindings {
+ get { return (string []) removed.ToArray (typeof (string)); }
+ }
+
+ public object SyncRoot {
+ get { return list.SyncRoot; }
+ }
+
+ public void Add (DataBinding binding)
+ {
+ list.Add (binding.PropertyName, binding);
+ }
+
+ public void Clear ()
+ {
+ list.Clear ();
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ list.CopyTo (array, index);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return list.GetEnumerator ();
+ }
+
+ public void Remove (DataBinding binding)
+ {
+ string key = binding.PropertyName;
+ Remove (key);
+ }
+
+ public void Remove (string propertyName)
+ {
+ removed.Add (propertyName);
+ list.Remove (propertyName);
+ }
+
+ public void Remove (string propertyName,
+ bool addToRemovedList)
+ {
+ if (addToRemovedList)
+ removed.Add (String.Empty); // LAMESPEC
+ else
+ removed.Add (propertyName);
+
+ list.Remove (propertyName);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/DataBindingHandlerAttribute.cs b/mcs/class/System.Web/System.Web.UI/DataBindingHandlerAttribute.cs
new file mode 100644
index 00000000000..65af373bc8c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/DataBindingHandlerAttribute.cs
@@ -0,0 +1,49 @@
+/**
+ * Namespace: System.Web.UI
+ * Class: DataBindingHandlerAttribute
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.Reflection;
+
+namespace System.Web.UI
+{
+ [AttributeUsage(AttributeTargets.Class)]
+ public sealed class DataBindingHandlerAttribute : Attribute
+ {
+ public static readonly DataBindingHandlerAttribute Default;
+
+ private string handlerTypeName;
+
+ public DataBindingHandlerAttribute()
+ {
+ handlerTypeName = String.Empty;
+ }
+
+ public DataBindingHandlerAttribute(string typeName)
+ {
+ handlerTypeName = typeName;
+ }
+
+ public DataBindingHandlerAttribute(Type type)
+ {
+ handlerTypeName = type.AssemblyQualifiedName;
+ }
+
+ public string HandlerTypeName
+ {
+ get
+ {
+ return handlerTypeName;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/DataBoundLiteralControl.cs b/mcs/class/System.Web/System.Web.UI/DataBoundLiteralControl.cs
new file mode 100755
index 00000000000..33374d4a0bc
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/DataBoundLiteralControl.cs
@@ -0,0 +1,80 @@
+//
+// System.Web.UI.DataBoundLiteralCOntrol.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+using System.Text;
+
+namespace System.Web.UI {
+
+ public sealed class DataBoundLiteralControl : Control
+ {
+ private string [] staticLiterals;
+ private string [] dataBoundLiterals;
+
+ public DataBoundLiteralControl (int staticLiteralsCount,
+ int dataBoundLiteralCount)
+ {
+ staticLiterals = new string [staticLiteralsCount];
+ dataBoundLiterals = new string [dataBoundLiteralCount];
+ PreventAutoID ();
+ }
+
+ public string Text {
+ get {
+ StringBuilder text = new StringBuilder ();
+ int stLength = staticLiterals.Length;
+ int dbLength = dataBoundLiterals.Length;
+ int max = (stLength > dbLength) ? stLength : dbLength;
+ for (int i = 0; i < max; i++){
+ if (i < stLength)
+ text.Append (staticLiterals [i]);
+ if (i < dbLength)
+ text.Append (dataBoundLiterals [i]);
+ }
+
+ return text.ToString ();
+ }
+ }
+
+ protected override ControlCollection CreateControlCollection ()
+ {
+ return new EmptyControlCollection (this);
+ }
+
+ protected override void LoadViewState (object savedState)
+ {
+ if (savedState != null)
+ dataBoundLiterals = (string []) savedState;
+ }
+
+ protected override void Render (HtmlTextWriter output)
+ {
+ output.Write (Text);
+ }
+
+ protected override object SaveViewState ()
+ {
+ if (dataBoundLiterals.Length == 0)
+ return null;
+ return dataBoundLiterals;
+ }
+
+ public void SetDataBoundString (int index, string s)
+ {
+ dataBoundLiterals [index] = s;
+ }
+
+ public void SetStaticString (int index, string s)
+ {
+ staticLiterals [index] = s;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/DesignTimeParseData.cs b/mcs/class/System.Web/System.Web.UI/DesignTimeParseData.cs
new file mode 100644
index 00000000000..901e0c4cb91
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/DesignTimeParseData.cs
@@ -0,0 +1,29 @@
+/**
+ * Namespace: System.Web.UI
+ * Class: DesignTimeParseData
+ *
+ * Author: Gaurav Vaish
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: ?%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public sealed class DesignTimeParseData
+ {
+ private static bool inDesigner = false;
+
+ internal static bool InDesigner
+ {
+ get
+ {
+ return inDesigner;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/EmptyControlCollection.cs b/mcs/class/System.Web/System.Web.UI/EmptyControlCollection.cs
new file mode 100755
index 00000000000..9d5a039625e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/EmptyControlCollection.cs
@@ -0,0 +1,30 @@
+//
+// System.Web.UI.EmptyControlCollection.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+
+namespace System.Web.UI {
+
+ public class EmptyControlCollection : ControlCollection
+ {
+ public EmptyControlCollection (Control owner)
+ : base (owner)
+ {
+ }
+
+ public override void Add (Control child)
+ {
+ throw new NotSupportedException ("Control " + Owner.ID + " does not allow children");
+ }
+
+ public override void AddAt (int index, Control child)
+ {
+ throw new NotSupportedException ("Control " + Owner.ID + " does not allow children");
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/HtmlTextWriter.cs b/mcs/class/System.Web/System.Web.UI/HtmlTextWriter.cs
new file mode 100644
index 00000000000..f78cffc1b6b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/HtmlTextWriter.cs
@@ -0,0 +1,1027 @@
+/* System.Web.UI
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI{
+
+public class HtmlTextWriter : System.IO.TextWriter {
+
+static HtmlTextWriter(){
+ HtmlTextWriter._tagKeyLookupTable = new Hashtable(97);
+ HtmlTextWriter._tagNameLookupArray = new TagInformation[97];
+ HtmlTextWriter.RegisterTag("", HtmlTextWriterTag.Unknown, TagType.Other);
+ HtmlTextWriter.RegisterTag("a", HtmlTextWriterTag.A, TagType.Inline);
+ HtmlTextWriter.RegisterTag("acronym", HtmlTextWriterTag.Acronym, TagType.Inline);
+ HtmlTextWriter.RegisterTag("address", HtmlTextWriterTag.Address, TagType.Other);
+ HtmlTextWriter.RegisterTag("area", HtmlTextWriterTag.Area, TagType.Other);
+ HtmlTextWriter.RegisterTag("b", HtmlTextWriterTag.B, TagType.Inline);
+ HtmlTextWriter.RegisterTag("base", HtmlTextWriterTag.Base, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("basefont", HtmlTextWriterTag.Basefont, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("bdo", HtmlTextWriterTag.Bdo, TagType.Inline);
+ HtmlTextWriter.RegisterTag("bgsound", HtmlTextWriterTag.Bgsound, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("big", HtmlTextWriterTag.Big, TagType.Inline);
+ HtmlTextWriter.RegisterTag("blockquote", HtmlTextWriterTag.Blockquote, TagType.Other);
+ HtmlTextWriter.RegisterTag("body", HtmlTextWriterTag.Body, TagType.Other);
+ HtmlTextWriter.RegisterTag("br", HtmlTextWriterTag.Br, TagType.Other);
+ HtmlTextWriter.RegisterTag("button", HtmlTextWriterTag.Button, TagType.Inline);
+ HtmlTextWriter.RegisterTag("caption", HtmlTextWriterTag.Caption, TagType.Other);
+ HtmlTextWriter.RegisterTag("center", HtmlTextWriterTag.Center, TagType.Other);
+ HtmlTextWriter.RegisterTag("cite", HtmlTextWriterTag.Cite, TagType.Inline);
+ HtmlTextWriter.RegisterTag("code", HtmlTextWriterTag.Code, TagType.Inline);
+ HtmlTextWriter.RegisterTag("col", HtmlTextWriterTag.Col, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("colgroup", HtmlTextWriterTag.Colgroup, TagType.Other);
+ HtmlTextWriter.RegisterTag("del", HtmlTextWriterTag.Del, TagType.Inline);
+ HtmlTextWriter.RegisterTag("dd", HtmlTextWriterTag.Dd, TagType.Inline);
+ HtmlTextWriter.RegisterTag("dfn", HtmlTextWriterTag.Dfn, TagType.Inline);
+ HtmlTextWriter.RegisterTag("dir", HtmlTextWriterTag.Dir, TagType.Other);
+ HtmlTextWriter.RegisterTag("div", HtmlTextWriterTag.Div, TagType.Other);
+ HtmlTextWriter.RegisterTag("dl", HtmlTextWriterTag.Dl, TagType.Other);
+ HtmlTextWriter.RegisterTag("dt", HtmlTextWriterTag.Dt, TagType.Inline);
+ HtmlTextWriter.RegisterTag("em", HtmlTextWriterTag.Em, TagType.Inline);
+ HtmlTextWriter.RegisterTag("embed", HtmlTextWriterTag.Embed, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("fieldset", HtmlTextWriterTag.Fieldset, TagType.Other);
+ HtmlTextWriter.RegisterTag("font", HtmlTextWriterTag.Font, TagType.Inline);
+ HtmlTextWriter.RegisterTag("form", HtmlTextWriterTag.Form, TagType.Other);
+ HtmlTextWriter.RegisterTag("frame", HtmlTextWriterTag.Frame, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("frameset", HtmlTextWriterTag.Frameset, TagType.Other);
+ HtmlTextWriter.RegisterTag("h1", HtmlTextWriterTag.H1, TagType.Other);
+ HtmlTextWriter.RegisterTag("h2", HtmlTextWriterTag.H2, TagType.Other);
+ HtmlTextWriter.RegisterTag("h3", HtmlTextWriterTag.H3, TagType.Other);
+ HtmlTextWriter.RegisterTag("h4", HtmlTextWriterTag.H4, TagType.Other);
+ HtmlTextWriter.RegisterTag("h5", HtmlTextWriterTag.H5, TagType.Other);
+ HtmlTextWriter.RegisterTag("h6", HtmlTextWriterTag.H6, TagType.Other);
+ HtmlTextWriter.RegisterTag("head", HtmlTextWriterTag.Head, TagType.Other);
+ HtmlTextWriter.RegisterTag("hr", HtmlTextWriterTag.Hr, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("html", HtmlTextWriterTag.Html, TagType.Other);
+ HtmlTextWriter.RegisterTag("i", HtmlTextWriterTag.I, TagType.Inline);
+ HtmlTextWriter.RegisterTag("iframe", HtmlTextWriterTag.Iframe, TagType.Other);
+ HtmlTextWriter.RegisterTag("img", HtmlTextWriterTag.Img, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("input", HtmlTextWriterTag.Input, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("ins", HtmlTextWriterTag.Ins, TagType.Inline);
+ HtmlTextWriter.RegisterTag("isindex", HtmlTextWriterTag.Isindex, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("kbd", HtmlTextWriterTag.Kbd, TagType.Inline);
+ HtmlTextWriter.RegisterTag("label", HtmlTextWriterTag.Label, TagType.Inline);
+ HtmlTextWriter.RegisterTag("legend", HtmlTextWriterTag.Legend, TagType.Other);
+ HtmlTextWriter.RegisterTag("li", HtmlTextWriterTag.Li, TagType.Inline);
+ HtmlTextWriter.RegisterTag("link", HtmlTextWriterTag.Link, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("map", HtmlTextWriterTag.Map, TagType.Other);
+ HtmlTextWriter.RegisterTag("marquee", HtmlTextWriterTag.Marquee, TagType.Other);
+ HtmlTextWriter.RegisterTag("menu", HtmlTextWriterTag.Menu, TagType.Other);
+ HtmlTextWriter.RegisterTag("meta", HtmlTextWriterTag.Meta, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("nobr", HtmlTextWriterTag.Nobr, TagType.Inline);
+ HtmlTextWriter.RegisterTag("noframes", HtmlTextWriterTag.Noframes, TagType.Other);
+ HtmlTextWriter.RegisterTag("noscript", HtmlTextWriterTag.Noscript, TagType.Other);
+ HtmlTextWriter.RegisterTag("object", HtmlTextWriterTag.Object, TagType.Other);
+ HtmlTextWriter.RegisterTag("ol", HtmlTextWriterTag.Ol, TagType.Other);
+ HtmlTextWriter.RegisterTag("option", HtmlTextWriterTag.Option, TagType.Other);
+ HtmlTextWriter.RegisterTag("p", HtmlTextWriterTag.P, TagType.Inline);
+ HtmlTextWriter.RegisterTag("param", HtmlTextWriterTag.Param, TagType.Other);
+ HtmlTextWriter.RegisterTag("pre", HtmlTextWriterTag.Pre, TagType.Other);
+ HtmlTextWriter.RegisterTag("q", HtmlTextWriterTag.Q, TagType.Inline);
+ HtmlTextWriter.RegisterTag("rt", HtmlTextWriterTag.Rt, TagType.Other);
+ HtmlTextWriter.RegisterTag("ruby", HtmlTextWriterTag.Ruby, TagType.Other);
+ HtmlTextWriter.RegisterTag("s", HtmlTextWriterTag.S, TagType.Inline);
+ HtmlTextWriter.RegisterTag("samp", HtmlTextWriterTag.Samp, TagType.Inline);
+ HtmlTextWriter.RegisterTag("script", HtmlTextWriterTag.Script, TagType.Other);
+ HtmlTextWriter.RegisterTag("select", HtmlTextWriterTag.Select, TagType.Other);
+ HtmlTextWriter.RegisterTag("small", HtmlTextWriterTag.Small, TagType.Other);
+ HtmlTextWriter.RegisterTag("span", HtmlTextWriterTag.Span, TagType.Inline);
+ HtmlTextWriter.RegisterTag("strike", HtmlTextWriterTag.Strike, TagType.Inline);
+ HtmlTextWriter.RegisterTag("strong", HtmlTextWriterTag.Strong, TagType.Inline);
+ HtmlTextWriter.RegisterTag("style", HtmlTextWriterTag.Style, TagType.Other);
+ HtmlTextWriter.RegisterTag("sub", HtmlTextWriterTag.Sub, TagType.Inline);
+ HtmlTextWriter.RegisterTag("sup", HtmlTextWriterTag.Sup, TagType.Inline);
+ HtmlTextWriter.RegisterTag("table", HtmlTextWriterTag.Table, TagType.Other);
+ HtmlTextWriter.RegisterTag("tbody", HtmlTextWriterTag.Tbody, TagType.Other);
+ HtmlTextWriter.RegisterTag("td", HtmlTextWriterTag.Td, TagType.Inline);
+ HtmlTextWriter.RegisterTag("textarea", HtmlTextWriterTag.Textarea, TagType.Inline);
+ HtmlTextWriter.RegisterTag("tfoot", HtmlTextWriterTag.Tfoot, TagType.Other);
+ HtmlTextWriter.RegisterTag("th", HtmlTextWriterTag.Th, TagType.Inline);
+ HtmlTextWriter.RegisterTag("thead", HtmlTextWriterTag.Thead, TagType.Other);
+ HtmlTextWriter.RegisterTag("title", HtmlTextWriterTag.Title, TagType.Other);
+ HtmlTextWriter.RegisterTag("tr", HtmlTextWriterTag.Tr, TagType.Other);
+ HtmlTextWriter.RegisterTag("tt", HtmlTextWriterTag.Tt, TagType.Inline);
+ HtmlTextWriter.RegisterTag("u", HtmlTextWriterTag.U, TagType.Inline);
+ HtmlTextWriter.RegisterTag("ul", HtmlTextWriterTag.Ul, TagType.Other);
+ HtmlTextWriter.RegisterTag("var", HtmlTextWriterTag.Var, TagType.Inline);
+ HtmlTextWriter.RegisterTag("wbr", HtmlTextWriterTag.Wbr, TagType.NonClosing);
+ HtmlTextWriter.RegisterTag("xml", HtmlTextWriterTag.Xml, TagType.Other);
+
+ HtmlTextWriter._attrKeyLookupTable = new Hashtable(40);
+ HtmlTextWriter._attrNameLookupArray = new AttributeInformation[40];
+ HtmlTextWriter.RegisterAttribute("accesskey", HtmlTextWriterAttribute.Accesskey, true);
+ HtmlTextWriter.RegisterAttribute("align", HtmlTextWriterAttribute.Align, false);
+ HtmlTextWriter.RegisterAttribute("alt", HtmlTextWriterAttribute.Alt, true);
+ HtmlTextWriter.RegisterAttribute("background", HtmlTextWriterAttribute.Background, true);
+ HtmlTextWriter.RegisterAttribute("bgcolor", HtmlTextWriterAttribute.Bgcolor, false);
+ HtmlTextWriter.RegisterAttribute("border", HtmlTextWriterAttribute.Border, false);
+ HtmlTextWriter.RegisterAttribute("bordercolor", HtmlTextWriterAttribute.Bordercolor, false);
+ HtmlTextWriter.RegisterAttribute("cellpadding", HtmlTextWriterAttribute.Cellpadding, false);
+ HtmlTextWriter.RegisterAttribute("cellspacing", HtmlTextWriterAttribute.Cellspacing, false);
+ HtmlTextWriter.RegisterAttribute("checked", HtmlTextWriterAttribute.Checked, false);
+ HtmlTextWriter.RegisterAttribute("class", HtmlTextWriterAttribute.Class, true);
+ HtmlTextWriter.RegisterAttribute("cols", HtmlTextWriterAttribute.Cols, false);
+ HtmlTextWriter.RegisterAttribute("colspan", HtmlTextWriterAttribute.Colspan, false);
+ HtmlTextWriter.RegisterAttribute("disabled", HtmlTextWriterAttribute.Disabled, false);
+ HtmlTextWriter.RegisterAttribute("for", HtmlTextWriterAttribute.For, false);
+ HtmlTextWriter.RegisterAttribute("height", HtmlTextWriterAttribute.Height, false);
+ HtmlTextWriter.RegisterAttribute("href", HtmlTextWriterAttribute.Href, true);
+ HtmlTextWriter.RegisterAttribute("id", HtmlTextWriterAttribute.Id, false);
+ HtmlTextWriter.RegisterAttribute("maxlength", HtmlTextWriterAttribute.Maxlength, false);
+ HtmlTextWriter.RegisterAttribute("multiple", HtmlTextWriterAttribute.Multiple, false);
+ HtmlTextWriter.RegisterAttribute("name", HtmlTextWriterAttribute.Name, false);
+ HtmlTextWriter.RegisterAttribute("nowrap", HtmlTextWriterAttribute.Nowrap, false);
+ HtmlTextWriter.RegisterAttribute("onchange", HtmlTextWriterAttribute.Onchange, true);
+ HtmlTextWriter.RegisterAttribute("onclick", HtmlTextWriterAttribute.Onclick, true);
+ HtmlTextWriter.RegisterAttribute("readonly", HtmlTextWriterAttribute.ReadOnly, false);
+ HtmlTextWriter.RegisterAttribute("rows", HtmlTextWriterAttribute.Rows, false);
+ HtmlTextWriter.RegisterAttribute("rowspan", HtmlTextWriterAttribute.Rowspan, false);
+ HtmlTextWriter.RegisterAttribute("rules", HtmlTextWriterAttribute.Rules, false);
+ HtmlTextWriter.RegisterAttribute("selected", HtmlTextWriterAttribute.Selected, false);
+ HtmlTextWriter.RegisterAttribute("size", HtmlTextWriterAttribute.Size, false);
+ HtmlTextWriter.RegisterAttribute("src", HtmlTextWriterAttribute.Src, true);
+ HtmlTextWriter.RegisterAttribute("style", HtmlTextWriterAttribute.Style, false);
+ HtmlTextWriter.RegisterAttribute("tabindex", HtmlTextWriterAttribute.Tabindex, false);
+ HtmlTextWriter.RegisterAttribute("target", HtmlTextWriterAttribute.Target, false);
+ HtmlTextWriter.RegisterAttribute("title", HtmlTextWriterAttribute.Title, true);
+ HtmlTextWriter.RegisterAttribute("type", HtmlTextWriterAttribute.Type, false);
+ HtmlTextWriter.RegisterAttribute("valign", HtmlTextWriterAttribute.Valign, false);
+ HtmlTextWriter.RegisterAttribute("value", HtmlTextWriterAttribute.Value, true);
+ HtmlTextWriter.RegisterAttribute("width", HtmlTextWriterAttribute.Width, false);
+ HtmlTextWriter.RegisterAttribute("wrap", HtmlTextWriterAttribute.Wrap, false);
+
+ HtmlTextWriter._styleKeyLookupTable = new Hashtable(14);
+ HtmlTextWriter._styleNameLookupArray = new String[14];
+ HtmlTextWriter.RegisterStyle("background-color", HtmlTextWriterStyle.BackgroundColor);
+ HtmlTextWriter.RegisterStyle("background-image", HtmlTextWriterStyle.BackgroundImage);
+ HtmlTextWriter.RegisterStyle("border-collapse", HtmlTextWriterStyle.BorderCollapse);
+ HtmlTextWriter.RegisterStyle("border-color", HtmlTextWriterStyle.BorderColor);
+ HtmlTextWriter.RegisterStyle("border-style", HtmlTextWriterStyle.BorderStyle);
+ HtmlTextWriter.RegisterStyle("border-width", HtmlTextWriterStyle.BorderWidth);
+ HtmlTextWriter.RegisterStyle("color", HtmlTextWriterStyle.Color);
+ HtmlTextWriter.RegisterStyle("font-family", HtmlTextWriterStyle.FontFamily);
+ HtmlTextWriter.RegisterStyle("font-size", HtmlTextWriterStyle.FontSize);
+ HtmlTextWriter.RegisterStyle("font-style", HtmlTextWriterStyle.FontStyle);
+ HtmlTextWriter.RegisterStyle("font-weight", HtmlTextWriterStyle.FontWeight);
+ HtmlTextWriter.RegisterStyle("height", HtmlTextWriterStyle.Height);
+ HtmlTextWriter.RegisterStyle("text-decoration", HtmlTextWriterStyle.TextDecoration);
+ HtmlTextWriter.RegisterStyle("width", HtmlTextWriterStyle.Width);
+}
+
+public HtmlTextWriter(TextWriter writer):this(writer, " "){}
+
+public HtmlTextWriter(TextWriter writer, string tabString) : base() {
+ this.writer = writer;
+ this.tabString = tabString;
+ indentLevel = 0;
+ tabsPending = false;
+ _httpWriter = writer as HttpWriter;
+ _isDescendant = GetType() == typeof(HtmlTextWriter) == false;
+ _attrList = new RenderAttribute[20];
+ _attrCount = 0;
+ _styleList = new RenderStyle[20];
+ _styleCount = 0;
+ _endTags = new TagStackEntry[16];
+ _endTagCount = 0;
+ _inlineCount = 0;
+}
+
+public virtual void AddAttribute(HtmlTextWriterAttribute key, string value){
+ if ((int) key >= 0 && (int) key < HtmlTextWriter._attrNameLookupArray.Length) {
+ AttributeInformation attrInfo = HtmlTextWriter._attrNameLookupArray[(int) key];
+ AddAttribute(attrInfo.name, value, key, attrInfo.encode);
+ }
+}
+
+public virtual void AddAttribute(HtmlTextWriterAttribute key, string value, bool fEncode){
+ if ((int) key >= 0 && (int) key < HtmlTextWriter._attrNameLookupArray.Length) {
+ AddAttribute(HtmlTextWriter._attrNameLookupArray[(int) key].name, value, key, fEncode);
+ }
+}
+
+public virtual void AddAttribute(string name, string value){
+ HtmlTextWriterAttribute attr = GetAttributeKey(name);
+ value = EncodeAttributeValue(GetAttributeKey(name), value);
+ AddAttribute(name, value, attr);
+}
+
+public virtual void AddAttribute(string name, string value, bool fEndode){
+ value = EncodeAttributeValue(value, fEndode);
+ AddAttribute(name, value, GetAttributeKey(name));
+}
+
+protected virtual void AddAttribute(string name, string value, HtmlTextWriterAttribute key){
+ AddAttribute(name, value, key, false);
+}
+
+private void AddAttribute(string name, string value, HtmlTextWriterAttribute key, bool encode){
+ if (_attrCount >= (int) _attrList.Length) {
+ RenderAttribute[] rAttrArr = new RenderAttribute[_attrList.Length * 2];
+ System.Array.Copy(_attrList, rAttrArr, (int) _attrList.Length);
+ _attrList = rAttrArr;
+ }
+ RenderAttribute rAttr;
+ rAttr.name = name;
+ rAttr.value = value;
+ rAttr.key = key;
+ rAttr.encode = encode;
+ _attrList [_attrCount++] = rAttr;
+}
+
+public virtual void AddStyleAttribute(HtmlTextWriterStyle key, string value){
+ AddStyleAttribute(GetStyleName(key), value, key);
+}
+
+public virtual void AddStyleAttribute(string name, string value){
+ AddStyleAttribute(name, value, GetStyleKey(name));
+}
+
+protected virtual void AddStyleAttribute(string name, string value, HtmlTextWriterStyle key){
+ RenderStyle[] tagRender;
+ RenderStyle beforeTag;
+
+ if (_styleCount >= (int) _styleList.Length) {
+ RenderStyle[] rAttrArr = new RenderStyle[_styleList.Length * 2];
+ System.Array.Copy(_styleList, rAttrArr, (int) _styleList.Length);
+ _styleList = rAttrArr;
+ }
+ RenderStyle rAttr;
+ rAttr.name = name;
+ rAttr.value = value;
+ rAttr.key = key;
+ _styleList [_styleCount++] = rAttr;
+}
+
+public override void Close(){
+ writer.Close();
+}
+
+protected virtual string EncodeAttributeValue(HtmlTextWriterAttribute attrKey, string value){
+ bool valid = true;
+ if (0 <= (int) attrKey && (int) attrKey < HtmlTextWriter._attrNameLookupArray.Length)
+ valid = HtmlTextWriter._attrNameLookupArray[(int) attrKey].encode;
+ return EncodeAttributeValue(value, valid);
+}
+
+protected string EncodeAttributeValue(string value, bool fEncode){
+ if (value == null)
+ return null;
+ if (!(fEncode))
+ return value;
+ return System.Web.HttpUtility.HtmlAttributeEncode(value);
+}
+
+protected string EncodeUrl(string url){
+ if (url.IndexOf(SpaceChar) < 0)
+ return url;
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ for(int i=0; i <= url.Length; i++){
+ char temp = url[i];
+ if (temp != 32)
+ sb.Append(temp);
+ else
+ sb.Append("%20");
+ }
+ return sb.ToString();
+}
+
+protected virtual void FilterAttributes(){
+ int count = 0;
+ for(int i=0; i < _styleCount; i++){
+ RenderStyle rStyle = _styleList[i];
+ if (OnStyleAttributeRender(rStyle.name, rStyle.value, rStyle.key)) {
+ count++;
+ }
+ }
+ _styleCount = count;
+ count = 0;
+ for(int i=0; i <= _attrCount; i++){
+ RenderAttribute rAttr = _attrList[i];
+ if (OnAttributeRender(rAttr.name, rAttr.value, rAttr.key)) {
+ count++;
+ }
+ }
+ _attrCount = count;
+}
+
+public override void Flush(){
+ writer.Flush();
+}
+
+protected HtmlTextWriterAttribute GetAttributeKey(string attrName){
+ if (attrName != null && attrName.Length > 0) {
+ object attr = HtmlTextWriter._attrKeyLookupTable[attrName.ToLower()];
+ if (attr != null)
+ return (HtmlTextWriterAttribute) attr;
+ }
+ return (HtmlTextWriterAttribute) (-1);
+}
+
+protected string GetAttributeName(HtmlTextWriterAttribute attrKey){
+ if ((int) attrKey >= 0 && (int) attrKey < HtmlTextWriter._attrNameLookupArray.Length)
+ return HtmlTextWriter._attrNameLookupArray[(int) attrKey].name;
+ return System.String.Empty;
+}
+
+protected HtmlTextWriterStyle GetStyleKey(string styleName){
+ if (styleName != null && styleName.Length > 0) {
+ object style = HtmlTextWriter._styleKeyLookupTable[styleName.ToLower()];
+ if (style != null)
+ return (HtmlTextWriterStyle) style;
+ }
+ return (HtmlTextWriterStyle) (-1);
+}
+
+protected string GetStyleName(HtmlTextWriterStyle styleKey){
+ if ((int) styleKey >= 0 && (int) styleKey < HtmlTextWriter._styleNameLookupArray.Length)
+ return HtmlTextWriter._styleNameLookupArray[(int) styleKey];
+ return System.String.Empty;
+}
+
+protected virtual HtmlTextWriterTag GetTagKey(string tagName){
+ if (tagName != null && tagName.Length > 0) {
+ object tag = HtmlTextWriter._tagKeyLookupTable[tagName.ToLower()];
+ if (tag != null)
+ return (HtmlTextWriterTag) tag;
+ }
+ return 0;
+}
+
+protected virtual string GetTagName(HtmlTextWriterTag tagKey){
+ if ((int) tagKey >= 0 && (int) tagKey < HtmlTextWriter._tagNameLookupArray.Length)
+ return HtmlTextWriter._tagNameLookupArray[(int) tagKey].name;
+ return System.String.Empty;
+}
+
+protected bool IsAttributeDefined(HtmlTextWriterAttribute key){
+ for (int i=0; i < _attrCount; i++) {
+ if (_attrList[i].key == key)
+ return true;
+ }
+ return false;
+}
+
+protected bool IsAttributeDefined(HtmlTextWriterAttribute key, ref string value){
+ value = null;
+ for (int i=0; i < _attrCount; i++) {
+ if (_attrList[i].key == key) {
+ value = _attrList[i].value;
+ return true;
+ }
+ }
+ return false;
+}
+
+protected bool IsStyleAttributeDefined(HtmlTextWriterStyle key){
+ for (int i= 0; i < _styleCount; i++) {
+ if (_styleList[i].key == key)
+ return true;
+ }
+ return false;
+}
+
+protected bool IsStyleAttributeDefined(HtmlTextWriterStyle key, ref string value){
+ value = null;
+ for( int i=0; i < _styleCount; i++) {
+ if (_styleList[i].key == key) {
+ value = _styleList[i].value;
+ return true;
+ }
+ }
+ 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 (tabsPending) {
+ for(int i=0; i <= indentLevel; i++) {
+ writer.Write(tabString);
+ }
+ tabsPending = false;
+ }
+}
+
+protected string PopEndTag(){
+ if (_endTagCount <= 0)
+ throw new InvalidOperationException("A PopEndTag was called without a corresponding PushEndTag");
+ _endTagCount--;
+ TagKey = _endTags[_endTagCount].tagKey;
+ return _endTags[_endTagCount].endTagText;
+}
+
+protected void PushEndTag(string endTag){
+ if (_endTagCount >= (int) _endTags.Length) {
+ TagStackEntry[] temp = new TagStackEntry[(int) _endTags.Length * 2];
+ System.Array.Copy(_endTags, temp, (int) _endTags.Length);
+ _endTags = temp;
+ }
+ _endTags[_endTagCount].tagKey = _tagKey;
+ _endTags[_endTagCount].endTagText = endTag;
+ _endTagCount++;
+}
+
+protected static void RegisterAttribute(string name, HtmlTextWriterAttribute key){
+ HtmlTextWriter.RegisterAttribute(name, key, false);
+}
+
+private static void RegisterAttribute(string name, HtmlTextWriterAttribute key, bool fEncode){
+ name = name.ToLower();
+ HtmlTextWriter._attrKeyLookupTable.Add(name, key);
+ if ((int) key < (int) HtmlTextWriter._attrNameLookupArray.Length)
+ HtmlTextWriter._attrNameLookupArray[(int) key] = new AttributeInformation(name, fEncode);
+}
+
+protected static void RegisterStyle(string name, HtmlTextWriterStyle key){
+ name = name.ToLower();
+ HtmlTextWriter._styleKeyLookupTable.Add(name, key);
+ if ((int) key < (int) HtmlTextWriter._styleNameLookupArray.Length)
+ HtmlTextWriter._styleNameLookupArray[(int) key] = name;
+}
+
+protected static void RegisterTag(string name, HtmlTextWriterTag key){
+ HtmlTextWriter.RegisterTag(name, key, TagType.Other);
+}
+
+private static void RegisterTag(string name, HtmlTextWriterTag key, TagType type){
+ name = name.ToLower();
+ HtmlTextWriter._tagKeyLookupTable.Add(name, key);
+ string fullTag = null;
+ if ((int) type != 1 && (int) key != 0) {
+ fullTag = EndTagLeftChars + name + TagRightChar;
+ }
+ if ((int) key < HtmlTextWriter._tagNameLookupArray.Length)
+ HtmlTextWriter._tagNameLookupArray[(int) key] = new TagInformation(name, type, fullTag);
+}
+
+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(HtmlTextWriterTag tagKey){
+ TagKey = tagKey;
+ bool tagRendered = true;
+ bool tagRender = true;
+ if (_isDescendant) {
+ tagRender = OnTagRender(_tagName, _tagKey);
+ FilterAttributes();
+ string beforeTag = RenderBeforeTag();
+ if (beforeTag != null) {
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(beforeTag);
+ }
+ }
+ TagInformation currentTag = HtmlTextWriter._tagNameLookupArray[_tagIndex];
+ 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++) {
+ rAttr = _attrList[i];
+ if (rAttr.key == HtmlTextWriterAttribute.Style)
+ rAttrValue = rAttr.value;
+ else {
+ writer.Write(SpaceChar);
+ writer.Write(rAttr.name);
+ if (rAttr.value != null) {
+ writer.Write(EqualsChar);
+ writer.Write(DoubleQuoteChar);
+ if (rAttr.encode) {
+ if (_httpWriter == null) {
+ System.Web.HttpUtility.HtmlAttributeEncode(rAttr.value, writer);
+ }
+ else {
+ System.Web.HttpUtility.HtmlAttributeEncode(rAttr.value, (TextWriter) _httpWriter);
+ }
+ }
+ else {
+ writer.Write(rAttr.value);
+ }
+ writer.Write(DoubleQuoteChar);
+ }
+ }
+ }
+ if (_styleCount > 0 || rAttrValue != null) {
+ writer.Write(SpaceChar);
+ writer.Write("style");
+ writer.Write(EqualsChar);
+ writer.Write(DoubleQuoteChar);
+ RenderStyle rStyle;
+ for (int i=0; i < _styleCount; i++) {
+ rStyle = _styleList[i];
+ writer.Write(rStyle.name);
+ writer.Write(StyleEqualsChar);
+ writer.Write(rStyle.value);
+ writer.Write(SemicolonChar);
+ }
+ if (rAttrValue != null)
+ writer.Write(rAttrValue);
+ writer.Write(DoubleQuoteChar);
+ }
+ if (currentTag.tagType == TagType.NonClosing) {
+ writer.Write(SpaceChar);
+ writer.Write(SlashChar);
+ writer.Write(TagRightChar);
+ }
+ else
+ writer.Write(TagRightChar);
+ }
+ string beforeContent = RenderBeforeContent();
+ if (beforeContent != null) {
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(beforeContent);
+ }
+ if (tagRendered) {
+ if (currentTag.tagType == TagType.Inline)
+ _inlineCount++;
+ else {
+ WriteLine();
+ Indent++;
+ }
+ if (currentTag.closingTag == null) {
+ currentTag.closingTag = EndTagLeftChars + _tagName + TagRightChar;
+ }
+ }
+ if (_isDescendant) {
+ string afterContent = RenderAfterContent();
+ if (afterContent != null) {
+ if (currentTag.closingTag != null)
+ currentTag.closingTag = afterContent;
+ }
+ string afterTag = RenderAfterTag();
+ if (afterTag != null) {
+ if (currentTag.closingTag != null)
+ currentTag.closingTag = afterTag;
+ }
+ }
+ PushEndTag(currentTag.closingTag);
+ _attrCount = 0;
+ _styleCount = 0;
+}
+
+public virtual void RenderBeginTag(string tagName){
+ TagName = tagName;
+ RenderBeginTag(_tagKey);
+}
+
+public virtual void RenderEndTag(){
+ string endTagText = PopEndTag();
+ if (endTagText != null) {
+ if (HtmlTextWriter._tagNameLookupArray[_tagIndex].tagType == 0) {
+ _inlineCount--;
+ Write(endTagText);
+ }
+ else{
+ WriteLine();
+ Indent--;
+ Write(endTagText);
+ }
+ }
+}
+
+public override void Write(bool value){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(value);
+}
+
+public override void Write(char value){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(value);
+}
+
+public override void Write(char[] buffer){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(buffer);
+}
+
+public override void Write(char[] buffer, int index, int count){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(buffer, index, count);
+}
+
+public override void Write(double value){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(value);
+}
+
+public override void Write(int value){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(value);
+}
+
+public override void Write(long value){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(value);
+}
+
+public override void Write(object value){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(value);
+}
+
+public override void Write(float value){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(value);
+}
+
+public override void Write(string s){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(s);
+}
+
+public override void Write(string format, object arg0){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(format, arg0);
+}
+
+public override void Write(string format, object arg0, object arg1){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(format, arg0, arg1);
+}
+
+public override void Write(string format, params object[] arg){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(format, arg);
+}
+
+public virtual void WriteAttribute(string name, string value){
+ WriteAttribute(name, value, false);
+}
+
+public virtual void WriteAttribute(string name, string value, bool fEncode){
+ writer.Write(SpaceChar);
+ writer.Write(name);
+ if (value != null) {
+ writer.Write(EqualsChar);
+ writer.Write(DoubleQuoteChar);
+ if (fEncode) {
+ if (_httpWriter == null) {
+ System.Web.HttpUtility.HtmlAttributeEncode(value, writer);
+ }
+ else{
+ System.Web.HttpUtility.HtmlAttributeEncode(value, (TextWriter) _httpWriter);
+ }
+ }
+ else{
+ writer.Write(value);
+ }
+ writer.Write(DoubleQuoteChar);
+ }
+}
+
+public virtual void WriteBeginTag(string tagName){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(TagLeftChar);
+ writer.Write(tagName);
+}
+
+public virtual void WriteEndTag(string tagName){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(TagLeftChar);
+ writer.Write(SlashChar);
+ writer.Write(tagName);
+ writer.Write(TagRightChar);
+}
+
+public virtual void WriteFullBeginTag(string tagName){
+ if (tabsPending)
+ OutputTabs();
+ writer.Write(TagLeftChar);
+ writer.Write(tagName);
+ writer.Write(TagRightChar);
+}
+
+public override void WriteLine(){
+ writer.WriteLine();
+ tabsPending = true;
+}
+
+public override void WriteLine(bool value){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(value);
+ tabsPending = true;
+}
+
+public override void WriteLine(char value){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(value);
+ tabsPending = true;
+}
+
+public override void WriteLine(char[] buffer){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(buffer);
+ tabsPending = true;
+}
+
+public override void WriteLine(char[] buffer, int index, int count){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(buffer, index, count);
+ tabsPending = true;
+}
+
+public override void WriteLine(double value){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(value);
+ tabsPending = true;
+}
+
+public override void WriteLine(int value){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(value);
+ tabsPending = true;
+}
+
+public override void WriteLine(long value){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(value);
+ tabsPending = true;
+}
+
+public override void WriteLine(object value){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(value);
+ tabsPending = true;
+}
+
+public override void WriteLine(float value){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(value);
+ tabsPending = true;
+}
+
+public override void WriteLine(string s){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(s);
+ tabsPending = true;
+}
+
+public override void WriteLine(string format, object arg0){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(format, arg0);
+ tabsPending = true;
+}
+
+public override void WriteLine(string format, object arg0, object arg1){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(format, arg0, arg1);
+ tabsPending = true;
+}
+
+public override void WriteLine(string format, params object[] arg){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(format, arg);
+ tabsPending = true;
+}
+
+[CLSCompliant(false)]
+public override void WriteLine(uint value){
+ if (tabsPending)
+ OutputTabs();
+ writer.WriteLine(value);
+ tabsPending = true;
+}
+
+public void WriteLineNoTabs(string s){
+ writer.WriteLine(s);
+}
+
+public virtual void WriteStyleAttribute(string name, string value){
+ WriteStyleAttribute(name, value, false);
+}
+
+public virtual void WriteStyleAttribute(string name, string value, bool fEncode){
+ writer.Write(name);
+ writer.Write(StyleEqualsChar);
+ if (fEncode) {
+ if (_httpWriter == null) {
+ System.Web.HttpUtility.HtmlAttributeEncode(value, writer);
+ }
+ else{
+ System.Web.HttpUtility.HtmlAttributeEncode(value, (TextWriter) _httpWriter);
+ }
+ }
+ else {
+ writer.Write(value);
+ }
+ writer.Write(SemicolonChar);
+}
+
+public override System.Text.Encoding Encoding {
+ get{
+ return writer.Encoding;
+ }
+}
+
+public int Indent {
+ get{
+ return indentLevel;
+ }
+ set{
+ if (value < 0)
+ value = 0;
+ indentLevel = value;
+ }
+}
+
+public TextWriter InnerWriter {
+ get{
+ return writer;
+ }
+ set{
+ writer = value;
+ _httpWriter = value as HttpWriter;
+ }
+}
+
+public override string NewLine {
+ get{
+ return writer.NewLine;
+ }
+ set{
+ writer.NewLine = value;
+ }
+}
+
+protected HtmlTextWriterTag TagKey {
+ get{
+ return _tagKey;
+ }
+ set{
+ _tagIndex = (int) value;
+ if (_tagIndex < 0 || _tagIndex >= (int) HtmlTextWriter._tagNameLookupArray.Length)
+ throw new ArgumentOutOfRangeException("value");
+ _tagKey = value;
+ if (value != 0)
+ _tagName = HtmlTextWriter._tagNameLookupArray[_tagIndex].name;
+ }
+}
+
+protected string TagName {
+ get{
+ return _tagName;
+ }
+ set{
+ _tagName = value;
+ _tagKey = GetTagKey(_tagName);
+ _tagIndex = (int) _tagKey;
+ }
+}
+
+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 = '>';
+
+private int _attrCount;
+private int _endTagCount;
+private int _styleCount;
+private int indentLevel;
+private int _inlineCount;
+private int _tagIndex;
+
+private bool _isDescendant;
+private bool tabsPending;
+
+private HtmlTextWriterTag _tagKey;
+private TextWriter writer;
+private HttpWriter _httpWriter;
+
+private static Hashtable _attrKeyLookupTable;
+private static Hashtable _styleKeyLookupTable;
+private static Hashtable _tagKeyLookupTable;
+
+private string _tagName;
+private string tabString;
+private static string[] _styleNameLookupArray;
+
+private RenderAttribute[] _attrList;
+private static AttributeInformation[] _attrNameLookupArray;
+private static TagInformation[] _tagNameLookupArray;
+private TagStackEntry[] _endTags;
+private RenderStyle[] _styleList;
+
+} //HtmlTextWriter
+
+struct AttributeInformation {
+ public bool encode;
+ public string name;
+
+ public AttributeInformation(string name, bool encode){
+ this.encode = encode;
+ this.name = name;
+ }
+}
+
+struct RenderAttribute {
+ public bool encode;
+ public HtmlTextWriterAttribute key;
+ public string name;
+ public string value;
+}
+
+struct RenderStyle {
+ public HtmlTextWriterStyle key;
+ public string name;
+ public string value;
+}
+
+struct TagInformation {
+ public string closingTag;
+ public string name;
+ public TagType tagType;
+
+ public TagInformation(string name, TagType tagType, string closingTag){
+ this.name = name;
+ this.tagType = tagType;
+ this.closingTag = closingTag;
+ }
+}
+
+struct TagStackEntry {
+ public string endTagText;
+ public HtmlTextWriterTag tagKey;
+}
+
+enum TagType {
+ Inline,
+ NonClosing,
+ Other
+}
+
+
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI/HtmlTextWriterAttribute.cs b/mcs/class/System.Web/System.Web.UI/HtmlTextWriterAttribute.cs
new file mode 100644
index 00000000000..5b82723c5c3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/HtmlTextWriterAttribute.cs
@@ -0,0 +1,54 @@
+/* System.Web.UI
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+
+namespace System.Web.UI{
+
+public enum HtmlTextWriterAttribute {
+Accesskey,
+Align,
+Alt,
+Background,
+Bgcolor,
+Border,
+Bordercolor,
+Cellpadding,
+Cellspacing,
+Checked,
+Class,
+Cols,
+Colspan,
+Disabled,
+For,
+Height,
+Href,
+Id,
+Maxlength,
+Multiple,
+Name,
+Nowrap,
+Onchange,
+Onclick,
+ReadOnly,
+Rows,
+Rowspan,
+Rules,
+Selected,
+Size,
+Src,
+Style,
+Tabindex,
+Target,
+Title,
+Type,
+Valign,
+Value,
+Width,
+Wrap,
+}
+
+
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI/HtmlTextWriterStyle.cs b/mcs/class/System.Web/System.Web.UI/HtmlTextWriterStyle.cs
new file mode 100644
index 00000000000..4955422d668
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/HtmlTextWriterStyle.cs
@@ -0,0 +1,28 @@
+/* System.Web.UI
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+
+namespace System.Web.UI{
+
+public enum HtmlTextWriterStyle {
+BackgroundColor,
+BackgroundImage,
+BorderCollapse,
+BorderColor,
+BorderStyle,
+BorderWidth,
+Color,
+FontFamily,
+FontSize,
+FontStyle,
+FontWeight,
+Height,
+TextDecoration,
+Width
+}
+
+
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI/HtmlTextWriterTag.cs b/mcs/class/System.Web/System.Web.UI/HtmlTextWriterTag.cs
new file mode 100644
index 00000000000..f248979246a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/HtmlTextWriterTag.cs
@@ -0,0 +1,111 @@
+/* System.Web.UI
+* Authors
+* Leen Toelen (toelen@hotmail.com)
+*/
+
+
+namespace System.Web.UI{
+
+public enum HtmlTextWriterTag {
+Unknown,
+A,
+Acronym,
+Address,
+Area,
+B,
+Base,
+Basefont,
+Bdo,
+Bgsound,
+Big,
+Blockquote,
+Body,
+Br,
+Button,
+Caption,
+Center,
+Cite,
+Code,
+Col,
+Colgroup,
+Dd,
+Del,
+Dfn,
+Dir,
+Div,
+Dl,
+Dt,
+Em,
+Embed,
+Fieldset,
+Font,
+Form,
+Frame,
+Frameset,
+H1,
+H2,
+H3,
+H4,
+H5,
+H6,
+Head,
+Hr,
+Html,
+I,
+Iframe,
+Img,
+Input,
+Ins,
+Isindex,
+Kbd,
+Label,
+Legend,
+Li,
+Link,
+Map,
+Marquee,
+Menu,
+Meta,
+Nobr,
+Noframes,
+Noscript,
+Object,
+Ol,
+Option,
+P,
+Param,
+Pre,
+Q,
+Rt,
+Ruby,
+S,
+Samp,
+Script,
+Select,
+Small,
+Span,
+Strike,
+Strong,
+Style,
+Sub,
+Sup,
+Table,
+Tbody,
+Td,
+Textarea,
+Tfoot,
+Th,
+Thead,
+Title,
+Tr,
+Tt,
+U,
+Ul,
+Var,
+Wbr,
+Xml
+}
+
+
+} // namespace System.Web.UI.HtmlControls
+
diff --git a/mcs/class/System.Web/System.Web.UI/IAttributeAccessor.cs b/mcs/class/System.Web/System.Web.UI/IAttributeAccessor.cs
new file mode 100644
index 00000000000..be0984b2c8b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/IAttributeAccessor.cs
@@ -0,0 +1,20 @@
+//
+// System.Web.UI.IAttributeAccessor.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public interface IAttributeAccessor
+ {
+ string GetAttribute(string key);
+ void SetAttribute(string key, string value);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/IDataBindingsAccessor.cs b/mcs/class/System.Web/System.Web.UI/IDataBindingsAccessor.cs
new file mode 100644
index 00000000000..5ff7f00b2da
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/IDataBindingsAccessor.cs
@@ -0,0 +1,20 @@
+//
+// System.Web.UI.IDataBindingsAccessor.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public interface IDataBindingsAccessor
+ {
+ DataBindingCollection DataBindings {get;}
+ bool HasDataBindings {get;}
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/INamingContainer.cs b/mcs/class/System.Web/System.Web.UI/INamingContainer.cs
new file mode 100644
index 00000000000..659c5b60bed
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/INamingContainer.cs
@@ -0,0 +1,18 @@
+//
+// System.Web.UI.INamingContainer.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public interface INamingContainer
+ {
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/IParserAccessor.cs b/mcs/class/System.Web/System.Web.UI/IParserAccessor.cs
new file mode 100644
index 00000000000..cad22017e9d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/IParserAccessor.cs
@@ -0,0 +1,19 @@
+//
+// System.Web.UI.IParserAccessor.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public interface IParserAccessor
+ {
+ void AddParsedSubObject(object obj);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/IPostBackDataHandler.cs b/mcs/class/System.Web/System.Web.UI/IPostBackDataHandler.cs
new file mode 100644
index 00000000000..7d105cb7476
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/IPostBackDataHandler.cs
@@ -0,0 +1,21 @@
+//
+// System.Web.UI.IPostBackDataHandler.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+using System.Collections.Specialized;
+
+namespace System.Web.UI
+{
+ public interface IPostBackDataHandler
+ {
+ bool LoadPostData(string postDataKey, NameValueCollection postCollection);
+ void RaisePostDataChangedEvent();
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/IPostBackEventHandler.cs b/mcs/class/System.Web/System.Web.UI/IPostBackEventHandler.cs
new file mode 100644
index 00000000000..daa6f70160c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/IPostBackEventHandler.cs
@@ -0,0 +1,19 @@
+//
+// System.Web.UI.IPostBackEventHandler.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public interface IPostBackEventHandler
+ {
+ void RaisePostBackEvent(string eventArgument);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/IStateManager.cs b/mcs/class/System.Web/System.Web.UI/IStateManager.cs
new file mode 100644
index 00000000000..4bcb6b8deb0
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/IStateManager.cs
@@ -0,0 +1,22 @@
+//
+// System.Web.UI.IStateManager.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public interface IStateManager
+ {
+ void LoadViewState(object state);
+ object SaveViewState();
+ void TrackViewState();
+ bool IsTrackingViewState { get; }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/ITagNameToTypeMapper.cs b/mcs/class/System.Web/System.Web.UI/ITagNameToTypeMapper.cs
new file mode 100644
index 00000000000..da35c6b0ee8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ITagNameToTypeMapper.cs
@@ -0,0 +1,20 @@
+//
+// System.Web.UI.ITagNameToTypeMapper.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+using System.Collections;
+
+namespace System.Web.UI
+{
+ public interface ITagNameToTypeMapper
+ {
+ Type GetControlType(string tagName, IDictionary attribs);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/ITemplate.cs b/mcs/class/System.Web/System.Web.UI/ITemplate.cs
new file mode 100644
index 00000000000..c9981859b37
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ITemplate.cs
@@ -0,0 +1,19 @@
+//
+// System.Web.UI.ITemplate.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public interface ITemplate
+ {
+ void InstantiateIn(Control container);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/IValidator.cs b/mcs/class/System.Web/System.Web.UI/IValidator.cs
new file mode 100644
index 00000000000..47b418aee39
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/IValidator.cs
@@ -0,0 +1,21 @@
+//
+// System.Web.UI.IValidator.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public interface IValidator
+ {
+ void Validate();
+ string ErrorMessage {get; set;}
+ bool IsValid {get; set;}
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/ImageClickEventArgs.cs b/mcs/class/System.Web/System.Web.UI/ImageClickEventArgs.cs
new file mode 100755
index 00000000000..d2330bb6615
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ImageClickEventArgs.cs
@@ -0,0 +1,25 @@
+//
+// System.Web.UI.ImageClickEventArgs.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+
+namespace System.Web.UI {
+ public sealed class ImageClickEventArgs : EventArgs
+ {
+ public ImageClickEventArgs (int x, int y)
+ {
+ X = x;
+ Y = y;
+ }
+
+ public int X;
+ public int Y;
+ }
+}
+
+
diff --git a/mcs/class/System.Web/System.Web.UI/ImageClickEventHandler.cs b/mcs/class/System.Web/System.Web.UI/ImageClickEventHandler.cs
new file mode 100644
index 00000000000..2bcc75881df
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ImageClickEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// System.Web.UI.ImageClickEventHandler.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public delegate void ImageClickEventHandler(object sender, ImageClickEventArgs e);
+}
diff --git a/mcs/class/System.Web/System.Web.UI/LiteralControl.cs b/mcs/class/System.Web/System.Web.UI/LiteralControl.cs
new file mode 100644
index 00000000000..7a3ef1d0a7a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/LiteralControl.cs
@@ -0,0 +1,44 @@
+//
+// System.Web.UI.LiteralControl.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public class LiteralControl : Control
+ {
+ private string _text = String.Empty;
+ public LiteralControl() {}
+ public LiteralControl(string text)
+ {
+ _text = text;
+ }
+ public virtual string Text
+ {
+ get
+ {
+ return _text;
+ }
+ set
+ {
+ _text = value;
+ }
+ }
+ protected override void Render(HtmlTextWriter writer)
+ {
+ writer.Write(_text);
+ }
+
+ protected override ControlCollection CreateControlCollection ()
+ {
+ return new EmptyControlCollection (this);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/LosFormatter.cs b/mcs/class/System.Web/System.Web.UI/LosFormatter.cs
new file mode 100644
index 00000000000..fc06c921206
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/LosFormatter.cs
@@ -0,0 +1,487 @@
+//
+// System.Web.UI.LosFormatter
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Text;
+using System.Web.UI;
+using System.Web.Util;
+
+namespace System.Web.UI
+{
+ public sealed class LosFormatter
+ {
+ delegate void WriteObject (LosFormatter formatter, TextWriter writer, object value);
+ static char [] specialChars = new char [] {'<', '>', ';'};
+
+ const char booleanID = 'o';
+ const char stringID = 's';
+ const char charID = 'c';
+ const char int16ID = 'i';
+ const char int32ID = 'I';
+ const char int64ID = 'l';
+ const char colorID = 'C';
+ const char pairID = 'p';
+ const char tripletID = 't';
+ const char arrayListID = 'L';
+ const char hashtableID = 'h';
+ const char binaryID = 'b';
+ const char arrayID = 'a';
+ const char dateTimeID = 'd';
+
+ static Hashtable specialTypes;
+ static Hashtable idToType;
+
+ static LosFormatter ()
+ {
+ specialTypes = new Hashtable ();
+ specialTypes.Add (typeof (Boolean), new WriteObject (WriteBoolean));
+ specialTypes.Add (typeof (Pair), new WriteObject (WritePair));
+ specialTypes.Add (typeof (Triplet), new WriteObject (WriteTriplet));
+ specialTypes.Add (typeof (Color), new WriteObject (WriteColor));
+ specialTypes.Add (typeof (ArrayList), new WriteObject (WriteArrayList));
+ specialTypes.Add (typeof (Hashtable), new WriteObject (WriteHashtable));
+ specialTypes.Add (typeof (Array), new WriteObject (WriteArray));
+ specialTypes.Add (typeof (DateTime), new WriteObject (WriteDateTime));
+
+ idToType = new Hashtable ();
+ idToType.Add (typeof (string), stringID);
+ idToType.Add (typeof (char), charID);
+ idToType.Add (typeof (Int16), int16ID);
+ idToType.Add (typeof (Int32), int32ID);
+ idToType.Add (typeof (Int64), int64ID);
+ idToType.Add (typeof (Boolean), booleanID);
+ idToType.Add (typeof (Pair), pairID);
+ idToType.Add (typeof (Triplet), tripletID);
+ idToType.Add (typeof (Color), colorID);
+ idToType.Add (typeof (ArrayList), arrayListID);
+ idToType.Add (typeof (Hashtable), hashtableID);
+ idToType.Add (typeof (Array), arrayID);
+ }
+
+ public object Deserialize (Stream stream)
+ {
+ if (stream == null)
+ throw new ArgumentNullException ("stream");
+
+ return Deserialize (new StreamReader (stream));
+ }
+
+ public object Deserialize (TextReader input)
+ {
+ if (input == null)
+ throw new ArgumentNullException ("input");
+
+ return Deserialize (input.ReadToEnd ());
+ }
+
+ public object Deserialize (string input)
+ {
+ if (input == null)
+ throw new ArgumentNullException ("input");
+
+ string real_input = WebEncoding.Encoding.GetString (Convert.FromBase64String (input));
+ return DeserializeObject (real_input);
+ }
+
+ private static string UnEscapeSpecialChars (string str)
+ {
+ if (str.IndexOf ('\\') == -1)
+ return str;
+
+ string result = str.Replace ("\\;", ";");
+ result = result.Replace ("\\>", ">");
+ result = result.Replace ("\\<", "<");
+ result = result.Replace ("\\\\", "\\");
+ return result;
+ }
+
+ private static string GetEnclosedString (string input)
+ {
+ if (input [0] != '<')
+ throw new ArgumentException (input);
+
+ int count = 1;
+ bool escaped = false;
+ StringBuilder result = new StringBuilder ();
+ for (int i = 1; count != 0 && i < input.Length; i++) {
+ char c = input [i];
+ if (escaped)
+ escaped = false;
+ else if (c == '\\')
+ escaped = true;
+ else if (c == '<')
+ count++;
+ else if (c == '>')
+ count--;
+
+ result.Append (c);
+ }
+
+ result.Length--;
+ return result.ToString ();
+ }
+
+ private static string [] GetStringValues (string input)
+ {
+ if (input == null || input.Length == 0)
+ return new string [0];
+
+ int length = input.Length;
+ bool escaped = false;
+ int opened = 0;
+ ArrayList list = new ArrayList ();
+ StringBuilder builder = new StringBuilder ();
+ for (int i = 0; i < length; i++) {
+ char c = input [i];
+ if (escaped)
+ escaped = false;
+ else if (c == '\\')
+ escaped = true;
+ else if (c == '<')
+ opened++;
+ else if (c == '>')
+ opened--;
+ else if (c == ';' && opened == 0) {
+ list.Add (builder.ToString ());
+ builder = new StringBuilder ();
+ continue;
+ }
+
+ builder.Append (c);
+ }
+
+ list.Add (builder.ToString ());
+
+ string [] result = new string [list.Count];
+ list.CopyTo (result, 0);
+ return result;
+ }
+
+ private object DeserializeObject (string input)
+ {
+ if (input == null || input.Length < 2)
+ return null;
+
+ object obj;
+ string enclosed = GetEnclosedString (input.Substring (1));
+ string [] splitted;
+
+ switch (input [0]) {
+ case booleanID:
+ obj = enclosed.Length == 1;
+ break;
+ case stringID:
+ obj = UnEscapeSpecialChars (enclosed);
+ break;
+ case int16ID:
+ obj = Int16.Parse (enclosed);
+ break;
+ case int32ID:
+ obj = Int32.Parse (enclosed);
+ break;
+ case int64ID:
+ obj = Int64.Parse (enclosed);
+ break;
+ case colorID:
+ obj = Color.FromArgb (Int32.Parse (enclosed));
+ break;
+ case pairID:
+ Pair pair = new Pair ();
+ obj = pair;
+ splitted = GetStringValues (enclosed);
+ if (splitted.Length > 0) {
+ pair.First = DeserializeObject (splitted [0]);
+ if (splitted.Length > 1)
+ pair.Second = DeserializeObject (splitted [1]);
+ }
+ break;
+ case tripletID:
+ Triplet triplet = new Triplet ();
+ obj = triplet;
+ splitted = GetStringValues (enclosed);
+ if (splitted.Length == 0)
+ break;
+ triplet.First = DeserializeObject (splitted [0]);
+ if (splitted.Length < 1)
+ break;
+ triplet.Second = DeserializeObject (splitted [1]);
+ if (splitted.Length < 2)
+ break;
+ triplet.Third = DeserializeObject (splitted [2]);
+ break;
+ case arrayListID:
+ case arrayID:
+ ArrayList list = new ArrayList ();
+ obj = list;
+ splitted = GetStringValues (enclosed);
+ foreach (string s in splitted) {
+ object o = DeserializeObject (s);
+ list.Add (o);
+ }
+
+ if (input [0] == arrayID)
+ obj = list.ToArray (typeof (object));
+
+ break;
+ case hashtableID:
+ object key;
+ object value;
+ Hashtable hash = new Hashtable ();
+ obj = hash;
+ splitted = GetStringValues (enclosed);
+ int length = splitted.Length;
+ for (int i = 0; i < length; i++) {
+ key = DeserializeObject (splitted [i++]);
+ if (i < length)
+ value = DeserializeObject (splitted [i]);
+ else
+ value = null;
+
+ hash.Add (key, value);
+ }
+ break;
+ case binaryID:
+ byte [] buffer = WebEncoding.Encoding.GetBytes (enclosed);
+ MemoryStream ms = new MemoryStream (buffer);
+ BinaryFormatter fmt = new BinaryFormatter ();
+ obj = fmt.Deserialize (ms);
+ break;
+ case dateTimeID:
+ obj = new DateTime (Int64.Parse (enclosed));
+ break;
+ default:
+ throw new ArgumentException ("input");
+ }
+
+ return obj;
+ }
+
+ public void Serialize (Stream stream, object value)
+ {
+ if (stream == null)
+ throw new ArgumentNullException ("stream");
+
+ if (value == null)
+ throw new ArgumentNullException ("value");
+
+ StreamWriter writer = new StreamWriter (stream);
+ Serialize (writer, value);
+ writer.Flush ();
+ }
+
+ public void Serialize (TextWriter output, object value)
+ {
+ if (value == null)
+ return;
+
+ if (output == null)
+ throw new ArgumentNullException ("output");
+
+ StringBuilder builder = new StringBuilder ();
+ StringWriter writer = new StringWriter (builder);
+ SerializeObject (writer, value);
+ byte [] bytes = WebEncoding.Encoding.GetBytes (builder.ToString ());
+ output.Write (Convert.ToBase64String (bytes));
+ }
+
+ private static void WriteBoolean (LosFormatter formatter, TextWriter output, object value)
+ {
+ if (value == null)
+ return;
+
+ output.Write (booleanID);
+ bool b = (bool) value;
+ output.Write (b ? "<t>" : "<>");
+ }
+
+ private static void WritePair (LosFormatter formatter, TextWriter output, object value)
+ {
+ if (value == null)
+ return;
+
+ output.Write (pairID);
+ Pair pair = (Pair) value;
+ output.Write ('<');
+ formatter.SerializeObject (output, pair.First);
+ output.Write (';');
+ formatter.SerializeObject (output, pair.Second);
+ output.Write ('>');
+ }
+
+ private static void WriteTriplet (LosFormatter formatter, TextWriter output, object value)
+ {
+ if (value == null)
+ return;
+
+ output.Write (tripletID);
+ Triplet triplet = (Triplet) value;
+ output.Write ('<');
+ formatter.SerializeObject (output, triplet.First);
+ output.Write (';');
+ formatter.SerializeObject (output, triplet.Second);
+ output.Write (';');
+ formatter.SerializeObject (output, triplet.Third);
+ output.Write ('>');
+ }
+
+ private static void WriteColor (LosFormatter formatter, TextWriter output, object value)
+ {
+ if (value == null)
+ return;
+
+ Color c = (Color) value;
+ output.Write (String.Format ("{0}<{1}>", colorID, c.ToArgb ()));
+ }
+
+ private static void WriteArrayList (LosFormatter formatter, TextWriter output, object value)
+ {
+ if (value == null)
+ return;
+
+ output.Write (arrayListID);
+ output.Write ('<');
+ ArrayList list = (ArrayList) value;
+ for (int i = 0; i < list.Count; i++) {
+ formatter.SerializeObject (output, list [i]);
+ if (i != list.Count - 1)
+ output.Write (';');
+ }
+ output.Write('>');
+ }
+
+ private static void WriteArray (LosFormatter formatter, TextWriter output, object value)
+ {
+ if (value == null)
+ return;
+
+ output.Write (arrayID);
+ output.Write ('<');
+ Array array = (Array) value;
+ for (int i = 0; i < array.Length; i++) {
+ formatter.SerializeObject (output, array.GetValue (i));
+ if (i != array.Length - 1)
+ output.Write (';');
+ }
+ output.Write('>');
+ }
+
+ private static void WriteHashtable (LosFormatter formatter, TextWriter output, object value)
+ {
+ if (value == null)
+ return;
+
+ output.Write (hashtableID);
+ output.Write ('<');
+ Hashtable hash = (Hashtable) value;
+ int i = 0;
+ foreach (DictionaryEntry entry in hash) {
+ formatter.SerializeObject (output, entry.Key);
+ output.Write (';');
+ formatter.SerializeObject (output, entry.Value);
+ if (i != hash.Count - 1)
+ output.Write (';');
+ i++;
+ }
+ output.Write('>');
+ }
+
+ private static void WriteDateTime (LosFormatter formatter, TextWriter output, object value)
+ {
+ if (value == null)
+ return;
+
+ output.Write (dateTimeID);
+ output.Write ('<');
+ output.Write (((DateTime) value).Ticks);
+ output.Write('>');
+ }
+
+ private static string EscapeSpecialChars (string str)
+ {
+ if (str.IndexOfAny (specialChars) == -1)
+ return str;
+
+ string result = str.Replace ("\\", "\\\\");
+ result = result.Replace ("<", "\\<");
+ result = result.Replace (">", "\\>");
+ result = result.Replace (";", "\\;");
+ return result;
+ }
+
+ private void SerializeBinary (TextWriter output, object value)
+ {
+ WebTrace.PushContext ("LosFormatter.SerializeBinary");
+ Console.WriteLine ("not serializing value type: " + value.GetType ());
+ output.Write ("<>");
+ /* This is just for debugging purposes */
+ /*if (value is Array) {
+ Array array = (Array) value;
+ for (int i = 0; i < array.Length; i++) {
+ object o = array.GetValue (i);
+ if (o == null)
+ WebTrace.WriteLine ("\t{0} is null", i);
+ else
+ WebTrace.WriteLine ("\t{0} {1} {2}", i, o.GetType (), o);
+ }
+ }
+ */
+ /*
+ BinaryFormatter fmt = new BinaryFormatter ();
+ MemoryStream stream = new MemoryStream ();
+
+ fmt.Serialize (stream, value);
+ output.Write (binaryID);
+ output.Write ('<');
+ byte [] buffer = stream.GetBuffer ();
+ output.Write (Convert.ToBase64String (stream.GetBuffer ()));
+ output.Write ('>');
+ */
+ WebTrace.PopContext ();
+ }
+
+ private void SerializeObject (TextWriter output, object value)
+ {
+ WebTrace.PushContext ("LosFormatter.SerializeObject");
+ if (value == null) {
+ WebTrace.WriteLine ("value is null");
+ WebTrace.PopContext ();
+ return;
+ }
+
+ Type t = value.GetType ();
+ if (t.IsArray)
+ t = typeof (Array);
+
+ if (specialTypes.Contains (t)) {
+ WriteObject w = (WriteObject) specialTypes [t];
+ w (this, output, value);
+ WebTrace.WriteLine ("special type: {0}", value.GetType ());
+ WebTrace.PopContext ();
+ return;
+ }
+
+ if (idToType.Contains (t)) {
+ char c = (char) idToType [t];
+ string s = EscapeSpecialChars (value.ToString ());
+ output.Write (String.Format ("{0}<{1}>", c, value.ToString ()));
+ WebTrace.WriteLine ("regular type: {0}", value.GetType ());
+ WebTrace.PopContext ();
+ return;
+ }
+
+ SerializeBinary (output, value);
+ WebTrace.PopContext ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/OutputCacheLocation.cs b/mcs/class/System.Web/System.Web.UI/OutputCacheLocation.cs
new file mode 100644
index 00000000000..173654504c0
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/OutputCacheLocation.cs
@@ -0,0 +1,23 @@
+//
+// System.Web.UI.OutputCacheLocation.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public enum OutputCacheLocation
+ {
+ Any,
+ Client,
+ Downstream,
+ Server,
+ None
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/Page.cs b/mcs/class/System.Web/System.Web.UI/Page.cs
new file mode 100755
index 00000000000..af39217060c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/Page.cs
@@ -0,0 +1,706 @@
+//
+// System.Web.UI.Page
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.IO;
+using System.Security.Principal;
+using System.Text;
+using System.Web;
+using System.Web.Caching;
+using System.Web.SessionState;
+using System.Web.Util;
+
+namespace System.Web.UI
+{
+
+public class Page : TemplateControl, IHttpHandler
+{
+ private string _culture;
+ private bool _viewState = true;
+ private bool _viewStateMac = false;
+ private string _errorPage;
+ private string _ID;
+ private bool _isValid;
+ private bool _smartNavigation = false;
+ private TraceContext _trace;
+ private bool _traceEnabled;
+ private TraceMode _traceModeValue;
+ private int _transactionMode;
+ private string _UICulture;
+ private HttpContext _context;
+ private ValidatorCollection _validators;
+ private bool renderingForm;
+ private object _savedViewState;
+ private ArrayList _requiresPostBack;
+ private ArrayList requiresPostDataChanged;
+ private IPostBackEventHandler requiresRaiseEvent;
+ private NameValueCollection secondPostData;
+ private bool requiresPostBackScript = false;
+ private bool postBackScriptRendered = false;
+ Hashtable clientScriptBlocks;
+ Hashtable startupScriptBlocks;
+ Hashtable hiddenFields;
+ bool handleViewState;
+
+ protected const string postEventArgumentID = "__EVENTARGUMENT";
+ protected const string postEventSourceID = "__EVENTTARGET";
+
+ #region Constructor
+ public Page ()
+ {
+ Page = this;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public HttpApplicationState Application
+ {
+ get { return _context.Application; }
+ }
+
+ bool AspCompatMode
+ {
+ set { throw new NotImplementedException (); }
+ }
+
+ bool Buffer
+ {
+ set { Response.BufferOutput = value; }
+ }
+
+ public Cache Cache
+ {
+ get { return _context.Cache; }
+ }
+
+ [MonoTODO]
+ public string ClientTarget
+ {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ int CodePage
+ {
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ string ContentType
+ {
+ set { throw new NotImplementedException (); }
+ }
+
+ protected override HttpContext Context
+ {
+ get { return _context; }
+ }
+
+ string Culture
+ {
+ set { _culture = value; }
+ }
+
+ public override bool EnableViewState
+ {
+ get { return _viewState; }
+ set { _viewState = value; }
+ }
+
+ protected bool EnableViewStateMac
+ {
+ get { return _viewStateMac; }
+ set { _viewStateMac = value; }
+ }
+
+ public string ErrorPage
+ {
+ get { return _errorPage; }
+ set { _errorPage = value; }
+ }
+
+ protected ArrayList FileDependencies
+ {
+ set {
+ if (Response != null)
+ Response.AddFileDependencies (value);
+ }
+ }
+
+ public override string ID
+ {
+ get { return _ID; }
+ set { _ID = value; }
+ }
+
+ public bool IsPostBack
+ {
+ get {
+ return (0 == String.Compare (Request.HttpMethod, "POST", true));
+ }
+ }
+
+ public bool IsReusable {
+ get { return false; }
+ }
+
+ public bool IsValid
+ {
+ get { return _isValid; }
+ }
+
+ [MonoTODO]
+ int LCID {
+ set { throw new NotImplementedException (); }
+ }
+
+ public HttpRequest Request
+ {
+ get { return _context.Request; }
+ }
+
+ public HttpResponse Response
+ {
+ get { return _context.Response; }
+ }
+
+ string ResponseEncoding
+ {
+ set { Response.ContentEncoding = Encoding.GetEncoding (value); }
+ }
+
+ public HttpServerUtility Server
+ {
+ get {
+ return Context.Server;
+ }
+ }
+
+ public virtual HttpSessionState Session
+ {
+ get { return _context.Session; }
+ }
+
+ public bool SmartNavigation
+ {
+ get { return _smartNavigation; }
+ set { _smartNavigation = value; }
+ }
+
+ public TraceContext Trace
+ {
+ get { return _trace; }
+ }
+
+ bool TraceEnabled
+ {
+ set { _traceEnabled = value; }
+ }
+
+ TraceMode TraceModeValue
+ {
+ set { _traceModeValue = value; }
+ }
+
+ int TransactionMode
+ {
+ set { _transactionMode = value; }
+ }
+
+ string UICulture
+ {
+ set { _UICulture = value; }
+ }
+
+ public IPrincipal User
+ {
+ get { return _context.User; }
+ }
+
+ public ValidatorCollection Validators
+ {
+ get {
+ if (_validators == null)
+ _validators = new ValidatorCollection ();
+ return _validators;
+ }
+ }
+
+ public override bool Visible
+ {
+ get { return base.Visible; }
+ set { base.Visible = value; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ [MonoTODO]
+ protected IAsyncResult AspCompatBeginProcessRequest (HttpContext context,
+ AsyncCallback cb,
+ object extraData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected void AspcompatEndProcessRequest (IAsyncResult result)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected virtual HtmlTextWriter CreateHtmlTextWriter (TextWriter tw)
+ {
+ return new HtmlTextWriter (tw);
+ }
+
+ [MonoTODO]
+ public void DesignerInitialize ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected virtual NameValueCollection DeterminePostBackMode ()
+ {
+ if (_context == null)
+ return null;
+
+ HttpRequest req = _context.Request;
+ if (req == null)
+ return null;
+
+ NameValueCollection coll = null;
+ if (IsPostBack)
+ coll = req.Form;
+ else
+ coll = req.QueryString;
+
+
+ if (coll == null || coll ["__VIEWSTATE"] == null)
+ return null;
+
+ return coll;
+ }
+
+ public string GetPostBackClientEvent (Control control, string argument)
+ {
+ return GetPostBackEventReference (control, argument);
+ }
+
+ public string GetPostBackClientHyperlink (Control control, string argument)
+ {
+ return "javascript:" + GetPostBackEventReference (control, argument);
+ }
+
+ public string GetPostBackEventReference (Control control)
+ {
+ return GetPostBackEventReference (control, "");
+ }
+
+ public string GetPostBackEventReference (Control control, string argument)
+ {
+ RequiresPostBackScript ();
+ return String.Format ("__doPostBack ('{0}', '{1}')", control.UniqueID, argument);
+ }
+
+ internal void RequiresPostBackScript ()
+ {
+ requiresPostBackScript = true;
+ }
+
+ public virtual int GetTypeHashCode ()
+ {
+ return 0;
+ }
+
+ [MonoTODO]
+ protected virtual void InitOutputCache (int duration,
+ string varyByHeader,
+ string varyByCustom,
+ OutputCacheLocation location,
+ string varyByParam)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool IsClientScriptBlockRegistered (string key)
+ {
+ if (clientScriptBlocks == null)
+ return false;
+
+ return clientScriptBlocks.ContainsKey (key);
+ }
+
+ public bool IsStartupScriptRegistered (string key)
+ {
+ if (startupScriptBlocks == null)
+ return false;
+
+ return startupScriptBlocks.ContainsKey (key);
+ }
+
+ public string MapPath (string virtualPath)
+ {
+ return Request.MapPath (virtualPath);
+ }
+
+ private void RenderPostBackScript (HtmlTextWriter writer, string formUniqueID)
+ {
+ writer.WriteLine ("<input type=\"hidden\" name=\"{0}\" value=\"\" />", postEventSourceID);
+ writer.WriteLine ("<input type=\"hidden\" name=\"{0}\" value=\"\" />", postEventArgumentID);
+ writer.WriteLine ();
+ writer.WriteLine ("<script language=\"javascript\">");
+ writer.WriteLine ("<!--");
+ writer.WriteLine ("\tfunction __doPostBack(eventTarget, eventArgument) {");
+ writer.WriteLine ("\t\tvar theform = document.{0};", formUniqueID);
+ writer.WriteLine ("\t\ttheform.{0}.value = eventTarget;", postEventSourceID);
+ writer.WriteLine ("\t\ttheform.{0}.value = eventArgument;", postEventArgumentID);
+ writer.WriteLine ("\t\ttheform.submit();");
+ writer.WriteLine ("\t}");
+ writer.WriteLine ("// -->");
+ writer.WriteLine ("</script>");
+ }
+
+ static void WriteScripts (HtmlTextWriter writer, Hashtable scripts)
+ {
+ if (scripts == null)
+ return;
+
+ foreach (string key in scripts.Values)
+ writer.WriteLine (key);
+ }
+
+ void WriteHiddenFields (HtmlTextWriter writer)
+ {
+ if (hiddenFields == null)
+ return;
+
+ foreach (string key in hiddenFields.Keys) {
+ string value = hiddenFields [key] as string;
+ writer.WriteLine ("\n<input type=\"hidden\" name=\"{0}\" value=\"{1}\" />", key, value);
+ }
+
+ hiddenFields = null;
+ }
+
+ internal void OnFormRender (HtmlTextWriter writer, string formUniqueID)
+ {
+ if (renderingForm)
+ throw new HttpException ("Only 1 HtmlForm is allowed per page.");
+
+ renderingForm = true;
+ writer.WriteLine ();
+ WriteHiddenFields (writer);
+ if (requiresPostBackScript) {
+ RenderPostBackScript (writer, formUniqueID);
+ postBackScriptRendered = true;
+ }
+
+ if (handleViewState) {
+ writer.Write ("<input type=\"hidden\" name=\"__VIEWSTATE\" ");
+ writer.WriteLine ("value=\"{0}\" />", GetViewStateString ());
+ }
+
+ WriteScripts (writer, clientScriptBlocks);
+ }
+
+ internal string GetViewStateString ()
+ {
+ StringWriter sr = new StringWriter ();
+ LosFormatter fmt = new LosFormatter ();
+ fmt.Serialize (sr, _savedViewState);
+ return sr.GetStringBuilder ().ToString ();
+ }
+
+ internal void OnFormPostRender (HtmlTextWriter writer, string formUniqueID)
+ {
+ if (!postBackScriptRendered && requiresPostBackScript)
+ RenderPostBackScript (writer, formUniqueID);
+
+ WriteHiddenFields (writer);
+ WriteScripts (writer, startupScriptBlocks);
+ renderingForm = false;
+ postBackScriptRendered = false;
+ }
+
+ private void ProcessPostData (NameValueCollection data, bool second)
+ {
+ if (data == null)
+ return;
+
+ Hashtable used = new Hashtable ();
+ foreach (string id in data.AllKeys){
+ if (id == "__VIEWSTATE" || id == postEventSourceID || id == postEventArgumentID)
+ continue;
+
+ string real_id = id;
+ int dot = real_id.IndexOf ('.');
+ if (dot >= 1)
+ real_id = real_id.Substring (0, dot);
+
+ if (real_id == null || used.ContainsKey (real_id))
+ continue;
+
+ used.Add (real_id, real_id);
+
+ Control ctrl = FindControl (real_id);
+ if (ctrl != null){
+ IPostBackDataHandler pbdh = ctrl as IPostBackDataHandler;
+ IPostBackEventHandler pbeh = ctrl as IPostBackEventHandler;
+
+ if (pbdh == null) {
+ if (pbeh != null)
+ RegisterRequiresRaiseEvent (pbeh);
+ continue;
+ }
+
+ if (pbdh.LoadPostData (real_id, data) == true) {
+ if (requiresPostDataChanged == null)
+ requiresPostDataChanged = new ArrayList ();
+ requiresPostDataChanged.Add (pbdh);
+ }
+ } else if (!second) {
+ if (secondPostData == null)
+ secondPostData = new NameValueCollection ();
+ secondPostData.Add (real_id, null);
+ }
+ }
+ }
+
+ public void ProcessRequest (HttpContext context)
+ {
+ _context = context;
+ WebTrace.PushContext ("Page.ProcessRequest ()");
+ WebTrace.WriteLine ("Entering");
+ WireupAutomaticEvents ();
+ WebTrace.WriteLine ("Finished hookup");
+ //-- Control execution lifecycle in the docs
+ WebTrace.WriteLine ("FrameworkInitialize");
+ FrameworkInitialize ();
+ WebTrace.WriteLine ("InitRecursive");
+ InitRecursive (null);
+ renderingForm = false;
+ if (IsPostBack) {
+ LoadPageViewState ();
+ ProcessPostData (DeterminePostBackMode (), false);
+ }
+
+ WebTrace.WriteLine ("LoadRecursive");
+ LoadRecursive ();
+ if (IsPostBack) {
+ ProcessPostData (secondPostData, true);
+ RaiseChangedEvents ();
+ RaisePostBackEvents ();
+ }
+ WebTrace.WriteLine ("PreRenderRecursiveInternal");
+ PreRenderRecursiveInternal ();
+
+ WebTrace.WriteLine ("SavePageViewState");
+ SavePageViewState ();
+ //--
+ HtmlTextWriter output = new HtmlTextWriter (context.Response.Output);
+ WebTrace.WriteLine ("RenderControl");
+ RenderControl (output);
+ _context = null;
+ WebTrace.WriteLine ("UnloadRecursive");
+ UnloadRecursive (true);
+ WebTrace.WriteLine ("End");
+ WebTrace.PopContext ();
+ }
+
+ internal void RaisePostBackEvents ()
+ {
+ if (requiresRaiseEvent != null) {
+ RaisePostBackEvent (requiresRaiseEvent, null);
+ return;
+ }
+
+ NameValueCollection postdata = DeterminePostBackMode ();
+ if (postdata == null)
+ return;
+
+ string eventTarget = postdata [postEventSourceID];
+ if (eventTarget == null || eventTarget.Length == 0)
+ return;
+
+ IPostBackEventHandler target = FindControl (eventTarget) as IPostBackEventHandler;
+ if (target == null)
+ return;
+
+ string eventArgument = postdata [postEventArgumentID];
+ RaisePostBackEvent (target, eventArgument);
+ }
+
+ internal void RaiseChangedEvents ()
+ {
+ if (requiresPostDataChanged == null)
+ return;
+
+ foreach (IPostBackDataHandler ipdh in requiresPostDataChanged)
+ ipdh.RaisePostDataChangedEvent ();
+
+ requiresPostDataChanged.Clear ();
+ }
+
+ protected virtual void RaisePostBackEvent (IPostBackEventHandler sourceControl, string eventArgument)
+ {
+ sourceControl.RaisePostBackEvent (eventArgument);
+ }
+
+ [MonoTODO]
+ public void RegisterArrayDeclaration (string arrayName, string arrayValue)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual void RegisterClientScriptBlock (string key, string script)
+ {
+ if (IsClientScriptBlockRegistered (key))
+ return;
+
+ if (clientScriptBlocks == null)
+ clientScriptBlocks = new Hashtable ();
+
+ clientScriptBlocks.Add (key, script);
+ }
+
+ public virtual void RegisterHiddenField (string hiddenFieldName, string hiddenFieldInitialValue)
+ {
+ if (hiddenFields == null)
+ hiddenFields = new Hashtable ();
+
+ if (!hiddenFields.ContainsKey (hiddenFieldName))
+ hiddenFields.Add (hiddenFieldName, hiddenFieldInitialValue);
+ }
+
+ [MonoTODO]
+ public void RegisterClientScriptFile (string a, string b, string c)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void RegisterOnSubmitStatement (string key, string script)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void RegisterRequiresPostBack (Control control)
+ {
+ if (_requiresPostBack == null)
+ _requiresPostBack = new ArrayList ();
+
+ _requiresPostBack.Add (control.ID);
+ }
+
+ public virtual void RegisterRequiresRaiseEvent (IPostBackEventHandler control)
+ {
+ requiresRaiseEvent = control;
+ }
+
+ public virtual void RegisterStartupScript (string key, string script)
+ {
+ if (IsStartupScriptRegistered (key))
+ return;
+
+ if (startupScriptBlocks == null)
+ startupScriptBlocks = new Hashtable ();
+
+ startupScriptBlocks.Add (key, script);
+ }
+
+ public void RegisterViewStateHandler ()
+ {
+ handleViewState = true;
+ }
+
+ protected virtual void SavePageStateToPersistenceMedium (object viewState)
+ {
+ _savedViewState = viewState;
+ }
+
+ protected virtual object LoadPageStateFromPersistenceMedium ()
+ {
+ NameValueCollection postdata = DeterminePostBackMode ();
+ string view_state;
+ if (postdata == null || (view_state = postdata ["__VIEWSTATE"]) == null)
+ return null;
+
+ _savedViewState = null;
+ LosFormatter fmt = new LosFormatter ();
+
+ try {
+ _savedViewState = fmt.Deserialize (view_state);
+ } catch (Exception e) {
+ throw new HttpException ("Error restoring page viewstate.\n{0}", e);
+ }
+
+ return _savedViewState;
+ }
+
+ internal void LoadPageViewState()
+ {
+ WebTrace.PushContext ("LoadPageViewState");
+ object sState = LoadPageStateFromPersistenceMedium ();
+ WebTrace.WriteLine ("sState = '{0}'", sState);
+ if (sState != null) {
+ Pair pair = (Pair) sState;
+ LoadViewStateRecursive (pair.First);
+ _requiresPostBack = pair.Second as ArrayList;
+ }
+ WebTrace.PopContext ();
+ }
+
+ internal void SavePageViewState ()
+ {
+ if (!handleViewState)
+ return;
+
+ Pair pair = new Pair ();
+ pair.First = SaveViewStateRecursive ();
+ if (_requiresPostBack != null && _requiresPostBack.Count > 0)
+ pair.Second = _requiresPostBack;
+ SavePageStateToPersistenceMedium (pair);
+ }
+
+ public virtual void Validate ()
+ {
+ if (_validators == null || _validators.Count == 0){
+ _isValid = true;
+ return;
+ }
+
+ bool all_valid = true;
+ foreach (IValidator v in _validators){
+ v.Validate ();
+ if (v.IsValid == false)
+ all_valid = false;
+ }
+
+ if (all_valid)
+ _isValid = true;
+ }
+
+ public virtual void VerifyRenderingInServerForm (Control control)
+ {
+ if (!renderingForm)
+ throw new HttpException ("Control '" + control.ClientID + " " + control.GetType () +
+ "' must be rendered within a HtmlForm");
+ }
+
+ #endregion
+}
+}
diff --git a/mcs/class/System.Web/System.Web.UI/PageHandlerFactory.cs b/mcs/class/System.Web/System.Web.UI/PageHandlerFactory.cs
new file mode 100644
index 00000000000..db9238b254f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/PageHandlerFactory.cs
@@ -0,0 +1,27 @@
+//
+// System.Web.UI.PageHandlerFactory
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Web;
+using System.Web.Compilation;
+
+namespace System.Web.UI
+{
+ class PageHandlerFactory : IHttpHandlerFactory
+ {
+ public virtual IHttpHandler GetHandler (HttpContext context, string requestType, string url, string path)
+ {
+ return PageParser.GetCompiledPageInstance (url, path, context);
+ }
+
+ public virtual void ReleaseHandler (IHttpHandler handler)
+ {
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/PageParser.cs b/mcs/class/System.Web/System.Web.UI/PageParser.cs
new file mode 100644
index 00000000000..a0c49e7c31c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/PageParser.cs
@@ -0,0 +1,46 @@
+//
+// System.Web.UI.PageParser
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Web;
+using System.Web.Compilation;
+
+namespace System.Web.UI
+{
+ public sealed class PageParser : TemplateControlParser
+ {
+ public static IHttpHandler GetCompiledPageInstance (string virtualPath,
+ string inputFile,
+ HttpContext context)
+ {
+ PageParser pp = new PageParser ();
+ IHttpHandler h = (IHttpHandler) pp.GetCompiledInstance (virtualPath, inputFile, context);
+ return h;
+ }
+
+ protected override Type CompileIntoType ()
+ {
+ return PageCompiler.CompilePageType (this);
+ }
+
+ protected override Type DefaultBaseType
+ {
+ get {
+ return typeof (Page);
+ }
+ }
+
+ protected override string DefaultDirectiveName
+ {
+ get {
+ return "page";
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/Pair.cs b/mcs/class/System.Web/System.Web.UI/Pair.cs
new file mode 100644
index 00000000000..bf13fabdce8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/Pair.cs
@@ -0,0 +1,36 @@
+/**
+ * Namespace: System.Web.UI
+ * Class: Pair
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace System.Web.UI
+{
+ public class Pair
+ {
+ public object First;
+ public object Second;
+
+ public Pair(object first, object second)
+ {
+ First = first;
+ Second = second;
+ }
+
+ public Pair()
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/ParseChildrenAttribute.cs b/mcs/class/System.Web/System.Web.UI/ParseChildrenAttribute.cs
new file mode 100755
index 00000000000..95b621a8015
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ParseChildrenAttribute.cs
@@ -0,0 +1,80 @@
+//
+// System.Web.UI.ParseChildrenAttribute.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com
+//
+
+using System;
+
+namespace System.Web.UI {
+
+ [AttributeUsage (AttributeTargets.Class)]
+ public sealed class ParseChildrenAttribute : Attribute
+ {
+ bool childrenAsProperties;
+ string defaultProperty;
+ public static readonly ParseChildrenAttribute Default = new ParseChildrenAttribute ();
+
+ // LAMESPEC
+ public ParseChildrenAttribute ()
+ {
+ childrenAsProperties = false;
+ defaultProperty = "";
+ }
+
+ public ParseChildrenAttribute (bool childrenAsProperties)
+ {
+ this.childrenAsProperties = childrenAsProperties;
+ this.defaultProperty = "";
+ }
+
+ public ParseChildrenAttribute (bool childrenAsProperties,
+ string defaultProperty)
+ {
+ this.childrenAsProperties = childrenAsProperties;
+ if (childrenAsProperties)
+ this.defaultProperty = defaultProperty;
+ }
+
+ public bool ChildrenAsProperties {
+
+ get { return childrenAsProperties; }
+
+ set { childrenAsProperties = value; }
+ }
+
+ public string DefaultProperty {
+ get { return defaultProperty; }
+
+ set { defaultProperty = value; }
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (!(obj is ParseChildrenAttribute))
+ return false;
+
+ ParseChildrenAttribute o = (ParseChildrenAttribute) obj;
+ if (childrenAsProperties == o.childrenAsProperties){
+ if (childrenAsProperties == false)
+ return true;
+ return (defaultProperty == o.DefaultProperty);
+ }
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return base.GetHashCode ();
+ }
+
+ public override bool IsDefaultAttribute ()
+ {
+ return Equals (Default);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/PartialCachingAttribute.cs b/mcs/class/System.Web/System.Web.UI/PartialCachingAttribute.cs
new file mode 100755
index 00000000000..be490317e8b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/PartialCachingAttribute.cs
@@ -0,0 +1,51 @@
+//
+// System.Web.UI.PartialCachingAttribute.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+
+namespace System.Web.UI {
+
+ [AttributeUsage (AttributeTargets.Class)]
+ public sealed class PartialCachingAttribute : Attribute
+ {
+ int duration;
+ string varyByControls;
+ string varyByCustom;
+ string varyByParams;
+
+ public PartialCachingAttribute (int duration)
+ {
+ this.duration = duration;
+ }
+
+ public PartialCachingAttribute (int duration, string varyByParams,
+ string varyByControls, string varyByCustom)
+ {
+ this.duration = duration;
+ this.varyByParams = varyByParams;
+ this.varyByControls = varyByControls;
+ this.varyByCustom = varyByCustom;
+ }
+
+ public int Duration {
+ get { return duration; }
+ }
+
+ public string VaryByParams {
+ get { return varyByParams; }
+ }
+
+ public string VaryByControls {
+ get { return varyByControls; }
+ }
+
+ public string VaryByCustom {
+ get { return varyByCustom; }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/PersistChildrenAttribute.cs b/mcs/class/System.Web/System.Web.UI/PersistChildrenAttribute.cs
new file mode 100755
index 00000000000..a38d49c817f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/PersistChildrenAttribute.cs
@@ -0,0 +1,50 @@
+//
+// System.Web.UI.PersistChildrenAttribute.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+
+namespace System.Web.UI {
+
+ [AttributeUsage (AttributeTargets.Class)]
+ public sealed class PersistChildrenAttribute : Attribute
+ {
+ bool persist;
+
+ public PersistChildrenAttribute (bool persist)
+ {
+ this.persist = persist;
+ }
+
+ public static readonly PersistChildrenAttribute Default;
+ public static readonly PersistChildrenAttribute Yes;
+ public static readonly PersistChildrenAttribute No;
+
+ public bool Persist {
+ get { return persist; }
+ }
+
+ [MonoTODO]
+ public override bool Equals (object obj)
+ {
+ return false;
+ }
+
+ [MonoTODO]
+ public override int GetHashCode ()
+ {
+ return 42;
+ }
+
+ [MonoTODO]
+ public override bool IsDefaultAttribute ()
+ {
+ return false;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/PersistenceMode.cs b/mcs/class/System.Web/System.Web.UI/PersistenceMode.cs
new file mode 100755
index 00000000000..e58f2847489
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/PersistenceMode.cs
@@ -0,0 +1,22 @@
+//
+// System.Web.UI.PersistenceMode.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+using System;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public enum PersistenceMode
+ {
+ Attribute = 0,
+ InnerProperty = 1,
+ InnerDefaultProperty = 2,
+ EncodedInnerDefaultProperty = 3,
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/PersistenceModeAttribute.cs b/mcs/class/System.Web/System.Web.UI/PersistenceModeAttribute.cs
new file mode 100755
index 00000000000..1f878f6ef2b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/PersistenceModeAttribute.cs
@@ -0,0 +1,52 @@
+//
+// System.Web.UI.PersistenceModeAttribute.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+
+namespace System.Web.UI {
+
+ [AttributeUsage (AttributeTargets.Class)]
+ public sealed class PersistenceModeAttribute : Attribute
+ {
+ PersistenceMode mode;
+
+ public PersistenceModeAttribute (PersistenceMode mode)
+ {
+ this.mode = mode;
+ }
+
+ public static readonly PersistenceModeAttribute Attribute;
+ public static readonly PersistenceModeAttribute Default;
+ public static readonly PersistenceModeAttribute EncodedInnerDefaultProperty;
+ public static readonly PersistenceModeAttribute InnerDefaultProperty;
+ public static readonly PersistenceModeAttribute InnerProperty;
+
+ public PersistenceMode Mode {
+ get { return mode; }
+ }
+
+ [MonoTODO]
+ public override bool Equals (object obj)
+ {
+ return false;
+ }
+
+ [MonoTODO]
+ public override int GetHashCode ()
+ {
+ return 42;
+ }
+
+ [MonoTODO]
+ public override bool IsDefaultAttribute ()
+ {
+ return false;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/PropertyConverter.cs b/mcs/class/System.Web/System.Web.UI/PropertyConverter.cs
new file mode 100644
index 00000000000..d98e80f912a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/PropertyConverter.cs
@@ -0,0 +1,124 @@
+/**
+ * Namespace: System.Web.UI
+ * Class: PropertyConverter
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Reflection;
+
+namespace System.Web.UI
+{
+ public sealed class PropertyConverter
+ {
+ private static Type[] parseMethodTypes;
+ private static Type[] parseMethodTypesWithSOP;
+
+ static PropertyConverter()
+ {
+ parseMethodTypes = new Type[1];
+ parseMethodTypes[0] = typeof(string);
+ parseMethodTypesWithSOP = new Type[2];
+ parseMethodTypesWithSOP[0] = typeof(string);
+ parseMethodTypesWithSOP[1] = typeof(IServiceProvider);
+ }
+
+ private PropertyConverter()
+ {
+ // Prevent any instance
+ }
+
+ public static object EnumFromString(Type enumType, string enumValue)
+ {
+ object retVal = null;
+ try
+ {
+ retVal = Enum.Parse(enumType, enumValue, true);
+ } catch
+ {
+ retVal = null;
+ }
+ return retVal;
+ }
+
+ public static string EnumToString(Type enumType, object enumValue)
+ {
+ string retVal = Enum.Format(enumType, enumValue, "G");
+ return retVal.Replace('_','-');
+ }
+
+ public static object ObjectFromString(Type objType, MemberInfo propertyInfo, string objValue)
+ {
+ if(objValue == null)
+ return null;
+ if(! (!objType.Equals(typeof(Boolean)) || objValue.Length > 0) )
+ {
+ return null;
+ }
+ if(objType.IsEnum)
+ {
+ return EnumFromString(objType, objValue);
+ }
+ if(objType.Equals(typeof(string)))
+ {
+ return objValue;
+ }
+ PropertyDescriptor pc = null;
+ if(propertyInfo != null)
+ {
+ pc = (TypeDescriptor.GetProperties(propertyInfo.ReflectedType))[propertyInfo.Name];
+ }
+ if(pc != null)
+ {
+ TypeConverter converter = pc.Converter;
+ if(converter!=null && converter.CanConvertFrom(typeof(string)))
+ {
+ return converter.ConvertFromInvariantString(objValue);
+ }
+ }
+ MethodInfo mi = objType.GetMethod("Parse", parseMethodTypesWithSOP);
+ object o = null;
+ if(mi != null)
+ {
+ object[] parameters = new object[2];
+ parameters[0] = objValue;
+ parameters[1] = CultureInfo.InvariantCulture;
+ try
+ {
+ o = Utils.InvokeMethod(mi, null, parameters);
+ } catch
+ {
+ }
+ }
+ if(o == null)
+ {
+ mi = objType.GetMethod("Parse", parseMethodTypes);
+ if(mi!=null)
+ {
+ object[] parameters = new object[1];
+ parameters[0] = objValue;
+ try
+ {
+ o = Utils.InvokeMethod(mi, null, parameters);
+ } catch
+ {
+ }
+ }
+ }
+ if(o == null)
+ {
+ throw new HttpException(/*HttpRuntime.FormatResourceString(*/"Type_not_creatable_from_string"/*, objType.FullName, objValue, propertyInfo.Name)*/);
+ }
+ return o;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/RenderMethod.cs b/mcs/class/System.Web/System.Web.UI/RenderMethod.cs
new file mode 100755
index 00000000000..8f2db742cdb
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/RenderMethod.cs
@@ -0,0 +1,13 @@
+//
+//
+// System.Web.UI.RenderMethod.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+namespace System.Web.UI {
+
+ public delegate void RenderMethod (HtmlTextWriter output, Control container);
+}
diff --git a/mcs/class/System.Web/System.Web.UI/SimpleHandlerFactory.cs b/mcs/class/System.Web/System.Web.UI/SimpleHandlerFactory.cs
new file mode 100644
index 00000000000..5d0da1df6d6
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/SimpleHandlerFactory.cs
@@ -0,0 +1,31 @@
+//
+// System.Web.UI.SimpleHandlerFactory
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Web;
+
+namespace System.Web.UI
+{
+ class SimpleHandlerFactory : IHttpHandlerFactory
+ {
+ [MonoTODO]
+ public virtual IHttpHandler GetHandler (HttpContext context,
+ string requestType,
+ string virtualPath,
+ string path)
+ {
+ // This should handle *.ashx files
+ throw new NotImplementedException ();
+ }
+
+ public virtual void ReleaseHandler (System.Web.IHttpHandler handler)
+ {
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs b/mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs
new file mode 100644
index 00000000000..bb3bc6732ac
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs
@@ -0,0 +1,186 @@
+//
+// System.Web.UI.SimpleWebHandlerParser
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+using System.Web;
+using System.Web.Compilation;
+using System.Web.Util;
+
+namespace System.Web.UI
+{
+ public abstract class SimpleWebHandlerParser
+ {
+ HttpContext context;
+ string vPath;
+ string physPath;
+ string className;
+ string codeBehind;
+ bool debug;
+ string language;
+ string program;
+
+ protected SimpleWebHandlerParser (HttpContext context, string virtualPath, string physicalPath)
+ {
+ this.context = context;
+ this.vPath = virtualPath;
+ this.physPath = physicalPath;
+ GetDirectiveAndContent ();
+ }
+
+ private void GetDirectiveAndContent ()
+ {
+ StreamReader reader = new StreamReader (File.OpenRead (physPath));
+ string line;
+ bool directiveFound = false;
+ StringBuilder content = new StringBuilder ();
+
+ while ((line = reader.ReadLine ()) != null) {
+ string trimmed = line.Trim ();
+ if (!directiveFound && trimmed != String.Empty)
+ continue;
+
+ if (!directiveFound) {
+ ParseDirective (trimmed);
+ directiveFound = true;
+ continue;
+ }
+
+ content.Append (line + "\n");
+ content.Append (reader.ReadToEnd ());
+ }
+
+ this.program = content.ToString ();
+ reader.Close ();
+ }
+
+ private void ParseDirective (string line)
+ {
+ MemoryStream st = new MemoryStream (WebEncoding.Encoding.GetBytes (line));
+ AspParser parser = new AspParser (physPath, st);
+ parser.Parse ();
+ ArrayList elems = parser.Elements;
+ if (elems.Count != 1)
+ throw new ApplicationException ("Error looking for WebService directive.");
+
+ Directive directive = elems [0] as Directive;
+ if (directive == null)
+ throw new ApplicationException ("Error looking for WebService directive.");
+
+ if (0 != String.Compare (directive.TagID, DefaultDirectiveName, false))
+ throw new ApplicationException ("Expecting @WebService. Got: " +
+ directive.TagID);
+
+ TagAttributes ta = directive.Attributes;
+ className = ta ["class"] as string;
+ if (className == null)
+ throw new ApplicationException ("No Class attribute found.");
+
+ string d = ta ["debug"] as string;
+ if (d != null)
+ debug = Convert.ToBoolean (d);
+
+ language = ta ["language"] as string;
+ if (language != null) {
+ if (0 != String.Compare (language, "C#", false))
+ throw new ApplicationException ("Only C# language is supported.");
+ }
+
+ codeBehind = ta ["codebehind"] as string;
+ if (codeBehind != null) {
+ string ext = Path.GetExtension (codeBehind);
+ if (0 != String.Compare (ext, "cs", false) &&
+ 0 != String.Compare (ext, "dll", false))
+ throw new ApplicationException ("Unknown file type in CodeBehind.");
+
+ }
+ }
+
+ protected abstract string DefaultDirectiveName { get; }
+
+ internal HttpContext Context
+ {
+ get {
+ return context;
+ }
+ }
+
+ internal string VirtualPath
+ {
+ get {
+ return vPath;
+ }
+ }
+
+ internal string PhysicalPath
+ {
+ get {
+ return physPath;
+ }
+ }
+
+ internal string ClassName
+ {
+ get {
+ return className;
+ }
+
+ set {
+ className = value;
+ }
+ }
+
+ internal string CodeBehind
+ {
+ get {
+ return codeBehind;
+ }
+
+ set {
+ codeBehind = value;
+ }
+ }
+
+ internal bool Debug
+ {
+ get {
+ return debug;
+ }
+
+ set {
+ debug = value;
+ }
+ }
+
+ internal string Language
+ {
+ get {
+ return language;
+ }
+
+ set {
+ language = value;
+ }
+ }
+
+ internal string Program
+ {
+ get {
+ return program;
+ }
+
+ set {
+ program = value;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/StateBag.cs b/mcs/class/System.Web/System.Web.UI/StateBag.cs
new file mode 100644
index 00000000000..925e5722e4d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/StateBag.cs
@@ -0,0 +1,249 @@
+/**
+ * Namespace: System.Web.UI
+ * Class: StateBag
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Web;
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace System.Web.UI
+{
+ public sealed class StateBag : IStateManager, IDictionary, ICollection, IEnumerable
+ {
+ private bool ignoreCase;
+ private bool marked;
+ private HybridDictionary bag;
+
+ public StateBag (bool ignoreCase)
+ {
+ Initialize (ignoreCase);
+ }
+
+ public StateBag ()
+ {
+ Initialize (false);
+ }
+
+ private void Initialize (bool ignoreCase)
+ {
+ this.ignoreCase = ignoreCase;
+ marked = false;
+ bag = new HybridDictionary (ignoreCase);
+ }
+
+ public int Count {
+ get { return bag.Count; }
+ }
+
+
+ public object this [string key] {
+ get {
+ if (key == null || key.Length == 0)
+ throw new ArgumentException (HttpRuntime.FormatResourceString ("Key_Cannot_Be_Null"));
+
+ object val = bag [key];
+
+ if (val is StateItem)
+ return ((StateItem) val).Value;
+
+ return null; //
+ }
+
+ set { Add (key, value); }
+ }
+
+ object IDictionary.this [object key] {
+ get { return this [(string) key] as object; }
+
+ set { Add ((string) key, value); }
+ }
+
+ public ICollection Keys {
+ get { return bag.Keys; }
+ }
+
+ public ICollection Values {
+ get { return bag.Values; }
+ }
+
+ public StateItem Add (string key, object value)
+ {
+ if (key == null || key.Length == 0)
+ throw new ArgumentException (HttpRuntime.FormatResourceString ("Key_Cannot_Be_Null"));
+
+ StateItem val = bag [key] as StateItem; //don't throw exception when null
+ if(val == null) {
+ if(value != null || marked) {
+ val = new StateItem (value);
+ bag.Add (key, val);
+ }
+ }
+ else if (value == null && !marked)
+ bag.Remove (key);
+ else
+ val.Value = value;
+
+ if (val != null && marked) {
+ val.IsDirty = true;
+ }
+
+ return val;
+ }
+
+ public void Clear ()
+ {
+ bag.Clear ();
+ }
+
+ public IDictionaryEnumerator GetEnumerator ()
+ {
+ return bag.GetEnumerator ();
+ }
+
+ public bool IsItemDirty (string key)
+ {
+ object o = bag [key];
+
+ if (o is StateItem)
+ return ((StateItem) o).IsDirty;
+
+ return false;
+ }
+
+ public void Remove (string key)
+ {
+ bag.Remove (key);
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ public void SetItemDirty (string key, bool dirty)
+ {
+ if (bag [key] is StateItem)
+ ((StateItem) bag [key]).IsDirty = dirty;
+ }
+
+ internal bool IsTrackingViewState {
+ get { return marked; }
+ }
+
+ internal void LoadViewState (object state)
+ {
+ if(state!=null) {
+ Pair pair = (Pair) state;
+ ArrayList keyList = (ArrayList) (pair.First);
+ ArrayList valList = (ArrayList) (pair.Second);
+
+ int valCount = valList.Count;
+ for(int i = 0; i < keyList.Count; i++) {
+ if (i < valCount)
+ Add ((string) keyList [i], valList [i]);
+ else
+ Add ((string) keyList [i], null);
+ }
+ }
+ }
+
+ internal object SaveViewState ()
+ {
+ if(bag.Count > 0) {
+ ArrayList keyList = null, valList = null;
+
+ foreach (string key in bag.Keys) {
+ StateItem item = (StateItem) bag [key];
+
+ if (item.IsDirty) {
+ if (keyList == null) {
+ keyList = new ArrayList ();
+ valList = new ArrayList ();
+ }
+
+ keyList.Add (key);
+ valList.Add (item.Value);
+ }
+ }
+
+ if (keyList!=null)
+ return new Pair (keyList, valList);
+ }
+ return null;
+ }
+
+ internal void TrackViewState()
+ {
+ marked = true;
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+
+ void IStateManager.LoadViewState (object savedState)
+ {
+ LoadViewState (savedState);
+ }
+
+ object IStateManager.SaveViewState ()
+ {
+ return SaveViewState ();
+ }
+
+ void IStateManager.TrackViewState ()
+ {
+ TrackViewState ();
+ }
+
+ bool IStateManager.IsTrackingViewState {
+ get { return IsTrackingViewState; }
+ }
+
+ void ICollection.CopyTo (Array array, int index)
+ {
+ Values.CopyTo (array, index);
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ object ICollection.SyncRoot
+ {
+ get { return this; }
+ }
+
+ void IDictionary.Add (object key, object value)
+ {
+ Add ((string) key, value);
+ }
+
+ void IDictionary.Remove (object key)
+ {
+ Remove ((string) key);
+ }
+
+ bool IDictionary.Contains (object key)
+ {
+ return bag.Contains ((string) key);
+ }
+
+ bool IDictionary.IsFixedSize {
+ get { return false; }
+ }
+
+ bool IDictionary.IsReadOnly {
+ get { return false; }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/StateItem.cs b/mcs/class/System.Web/System.Web.UI/StateItem.cs
new file mode 100644
index 00000000000..81a425bbaac
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/StateItem.cs
@@ -0,0 +1,47 @@
+//
+// 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;
+ }
+ }
+ private StateItem() {}
+ internal StateItem(Object value)
+ {
+ _value = value;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/TODO b/mcs/class/System.Web/System.Web.UI/TODO
new file mode 100644
index 00000000000..de529b87f86
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/TODO
@@ -0,0 +1,42 @@
+AttributeCollection
+BaseParser
+BasePartialCachingControl
+CompiledTemplateBuilder
+ConstructorNeedsTagAttribute
+ControlBuilder
+ControlBuilderAttribute
+ControlCollection
+CssStyleCollection
+DataBinder
+DataBinding
+DataBindingCollection
+DataBindingHandlerAttribute
+DataBoundLiteralControl
+DesignTimeParseData
+DesignTimeTemplateParser
+EmptyControlCollection
+Html32TextWriter
+HtmlTextWriter
+ImageClickEventArgs
+LosFormatter
+Page
+PageParser
+ParseChildrenAttribute
+PartialCachingAttribute
+PartialCachingControl
+PersistChildrenAttribute
+PersistanceModeAttribute
+RootBuilder
+SimpleWebHandlerParser
+StateBag
+StaticPartialCachingControl
+TagPrefixAttribute
+TemplateBuilder
+TemplateContainerAttribute
+TemplateControl
+TemplateControlParser
+ToolboxDataAttribute
+UserControl
+ValidationPropertyAttribute
+ValidatorCollection
+WebServiceProvider
diff --git a/mcs/class/System.Web/System.Web.UI/TagPrefixAttribute.cs b/mcs/class/System.Web/System.Web.UI/TagPrefixAttribute.cs
new file mode 100755
index 00000000000..0dc56d241f5
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/TagPrefixAttribute.cs
@@ -0,0 +1,37 @@
+//
+// System.Web.UI.TagPrefixAttribute.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+
+namespace System.Web.UI {
+
+ [AttributeUsage (AttributeTargets.Assembly)]
+ public sealed class TagPrefixAttribute : Attribute
+ {
+ string namespaceName;
+ string tagPrefix;
+
+ public TagPrefixAttribute (string namespaceName,
+ string tagPrefix)
+ {
+ if (namespaceName == null || tagPrefix == null)
+ throw new ArgumentNullException ();
+
+ this.namespaceName = namespaceName;
+ this.tagPrefix = tagPrefix;
+ }
+
+ public string NamespaceName {
+ get { return namespaceName; }
+ }
+
+ public string TagPrefix {
+ get { return tagPrefix; }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/TemplateContainerAttribute.cs b/mcs/class/System.Web/System.Web.UI/TemplateContainerAttribute.cs
new file mode 100755
index 00000000000..854bcf1419e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/TemplateContainerAttribute.cs
@@ -0,0 +1,27 @@
+//
+// System.Web.UI.TemplateContainerAttribute.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+
+namespace System.Web.UI {
+
+ [AttributeUsage (AttributeTargets.Property)]
+ public sealed class TemplateContainerAttribute : Attribute
+ {
+ Type containerType;
+
+ public TemplateContainerAttribute (Type containerType)
+ {
+ this.containerType = containerType;
+ }
+
+ public Type ContainerType {
+ get { return containerType; }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/TemplateControl.cs b/mcs/class/System.Web/System.Web.UI/TemplateControl.cs
new file mode 100755
index 00000000000..c5498d5d977
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/TemplateControl.cs
@@ -0,0 +1,217 @@
+//
+// System.Web.UI.TemplateControl.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Web.Compilation;
+using System.Web.Util;
+
+namespace System.Web.UI {
+
+ public abstract class TemplateControl : Control, INamingContainer
+ {
+ static object abortTransaction = new object ();
+ static object commitTransaction = new object ();
+ static object error = new object ();
+ static string [] methodNames = { "Page_Init",
+ "Page_Load",
+ "Page_DataBind",
+ "Page_PreRender",
+ "Page_Dispose",
+ "Page_Error" };
+
+ const BindingFlags bflags = BindingFlags.Public |
+ BindingFlags.NonPublic |
+ BindingFlags.DeclaredOnly |
+ BindingFlags.Static |
+ BindingFlags.Instance;
+
+ #region Constructor
+ protected TemplateControl ()
+ {
+ Construct ();
+ }
+
+ #endregion
+
+ #region Properties
+
+ protected virtual int AutoHandlers {
+ get { return 0; }
+ set { }
+ }
+
+ protected virtual bool SupportAutoEvents {
+ get { return true; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ protected virtual void Construct ()
+ {
+ }
+
+ [MonoTODO]
+ protected virtual LiteralControl CreateResourceBasedLiteralControl (int offset,
+ int size,
+ bool fAsciiOnly)
+ {
+ return null;
+ }
+
+ internal void WireupAutomaticEvents ()
+ {
+ if (!SupportAutoEvents || !AutoEventWireup)
+ return;
+
+ Type type = GetType ();
+ foreach (MethodInfo method in type.GetMethods (bflags)) {
+ int pos = Array.IndexOf (methodNames, method.Name);
+ if (pos == -1)
+ continue;
+
+ string name = methodNames [pos];
+ pos = name.IndexOf ("_");
+ if (pos == -1 || pos + 1 == name.Length)
+ continue;
+
+ if (method.ReturnType != typeof (void))
+ continue;
+
+ ParameterInfo [] parms = method.GetParameters ();
+ if (parms.Length != 2 ||
+ parms [0].ParameterType != typeof (object) ||
+ parms [1].ParameterType != typeof (EventArgs))
+ continue;
+
+ string eventName = name.Substring (pos + 1);
+ EventInfo evt = type.GetEvent (eventName);
+ if (evt == null)
+ continue;
+
+ evt.AddEventHandler (this, Delegate.CreateDelegate (typeof (EventHandler), method));
+ }
+ }
+
+ protected virtual void FrameworkInitialize ()
+ {
+ }
+
+ Type GetTypeFromControlPath (string virtualPath)
+ {
+ if (virtualPath == null)
+ throw new ArgumentNullException ("virtualPath");
+
+ string vpath = UrlUtils.Combine (TemplateSourceDirectory, virtualPath);
+ return UserControlCompiler.CompileUserControlType (new UserControlParser (vpath, Context));
+ }
+
+ public Control LoadControl (string virtualPath)
+ {
+ object control = Activator.CreateInstance (GetTypeFromControlPath (virtualPath));
+ if (control is UserControl)
+ ((UserControl) control).InitializeAsUserControl (Page);
+
+ return (Control) control;
+ }
+
+ public ITemplate LoadTemplate (string virtualPath)
+ {
+ Type t = GetTypeFromControlPath (virtualPath);
+ return new SimpleTemplate (t);
+ }
+
+ protected virtual void OnAbortTransaction (EventArgs e)
+ {
+ EventHandler eh = Events [error] as EventHandler;
+ if (eh != null)
+ eh.Invoke (this, e);
+ }
+
+ protected virtual void OnCommitTransaction (EventArgs e)
+ {
+ EventHandler eh = Events [commitTransaction] as EventHandler;
+ if (eh != null)
+ eh.Invoke (this, e);
+ }
+
+ protected virtual void OnError (EventArgs e)
+ {
+ EventHandler eh = Events [abortTransaction] as EventHandler;
+ if (eh != null)
+ eh.Invoke (this, e);
+ }
+
+ [MonoTODO]
+ public Control ParseControl (string content)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ public static object ReadStringResource (Type t)
+ {
+ return null;
+ }
+
+ [MonoTODO]
+ protected void SetStringResourcePointer (object stringResourcePointer,
+ int maxResourceOffset)
+ {
+ }
+
+ [MonoTODO]
+ protected void WriteUTF8ResourceString (HtmlTextWriter output, int offset,
+ int size, bool fAsciiOnly)
+ {
+ }
+
+ #endregion
+
+ #region Events
+
+ public event EventHandler AbortTransaction {
+ add { Events.AddHandler (abortTransaction, value); }
+ remove { Events.RemoveHandler (abortTransaction, value); }
+ }
+
+ public event EventHandler CommitTransaction {
+ add { Events.AddHandler (commitTransaction, value); }
+ remove { Events.RemoveHandler (commitTransaction, value); }
+ }
+
+ public event EventHandler Error {
+ add { Events.AddHandler (error, value); }
+ remove { Events.RemoveHandler (error, value); }
+ }
+
+ #endregion
+
+ class SimpleTemplate : ITemplate
+ {
+ Type type;
+
+ public SimpleTemplate (Type type)
+ {
+ this.type = type;
+ }
+
+ public void InstantiateIn (Control control)
+ {
+ Control template = Activator.CreateInstance (type) as Control;
+ template.SetBindingContainer (false);
+ control.Controls.Add (template);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs b/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs
new file mode 100644
index 00000000000..33f05b48bb5
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs
@@ -0,0 +1,47 @@
+//
+// System.Web.UI.TemplateControlParser
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.IO;
+using System.Web.Compilation;
+using System.Web.Util;
+
+namespace System.Web.UI
+{
+ public abstract class TemplateControlParser : TemplateParser
+ {
+ internal object GetCompiledInstance (string virtualPath, string inputFile, HttpContext context)
+ {
+ Context = context;
+ InputFile = MapPath (virtualPath);
+ Type type = CompileIntoType ();
+ if (type == null)
+ return null;
+
+ object ctrl = Activator.CreateInstance (type);
+ if (ctrl == null)
+ return null;
+
+ HandleOptions (ctrl);
+ return ctrl;
+ }
+
+ protected override void HandleOptions (object obj)
+ {
+ Control ctrl = obj as Control;
+ Hashtable options = Options;
+ if (options == null)
+ return;
+
+ if (options ["AutoEventWireup"] != null)
+ ctrl.AutoEventWireup = (bool) options ["AutoEventWireup"];
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/TemplateParser.cs b/mcs/class/System.Web/System.Web.UI/TemplateParser.cs
new file mode 100755
index 00000000000..b52d2f46719
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/TemplateParser.cs
@@ -0,0 +1,55 @@
+//
+// System.Web.UI.TemplateParser
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.Web;
+
+namespace System.Web.UI
+{
+ public abstract class TemplateParser : BaseParser
+ {
+ string inputFile;
+ string text;
+ Hashtable options;
+
+ protected abstract Type CompileIntoType ();
+
+ protected virtual void HandleOptions (object obj)
+ {
+ }
+
+ protected abstract Type DefaultBaseType { get; }
+
+ protected abstract string DefaultDirectiveName { get; }
+
+ internal string InputFile
+ {
+ get { return inputFile; }
+ set { inputFile = value; }
+ }
+
+ internal string Text
+ {
+ get { return text; }
+ set { text = value; }
+ }
+
+ internal Type BaseType
+ {
+ get { return DefaultBaseType; }
+ }
+
+ internal Hashtable Options {
+ get { return options; }
+ set { options = value; }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/ToolboxDataAttribute.cs b/mcs/class/System.Web/System.Web.UI/ToolboxDataAttribute.cs
new file mode 100644
index 00000000000..88bdd66227f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ToolboxDataAttribute.cs
@@ -0,0 +1,58 @@
+/**
+ * Namespace: System.Web.UI
+ * Class: ToolboxDataAttribute
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+
+namespace System.Web.UI
+{
+ [AttributeUsage(AttributeTargets.Class)]
+ public sealed class ToolboxDataAttribute : Attribute
+ {
+ public static readonly ToolboxDataAttribute Default = new ToolboxDataAttribute("");
+
+ private string data;
+
+ public ToolboxDataAttribute(string data)
+ {
+ this.data = data;
+ }
+
+ public string Data
+ {
+ get
+ {
+ return data;
+ }
+ }
+
+ public override bool IsDefaultAttribute()
+ {
+ return Default.Equals(this);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if(obj != null && obj is ToolboxDataAttribute)
+ {
+ ToolboxDataAttribute tda = (ToolboxDataAttribute)obj;
+ return (tda.Data == Data);
+ }
+ return false;
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/Triplet.cs b/mcs/class/System.Web/System.Web.UI/Triplet.cs
new file mode 100755
index 00000000000..28c8546c762
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/Triplet.cs
@@ -0,0 +1,36 @@
+//
+// System.Web.UI.Triplet.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+
+namespace System.Web.UI {
+
+ public class Triplet
+ {
+ public object First;
+ public object Second;
+ public object Third;
+
+ public Triplet ()
+ {
+ }
+
+ public Triplet (object x, object y)
+ {
+ First = x;
+ Second = y;
+ }
+
+ public Triplet (object x, object y, object z)
+ {
+ First = x;
+ Second = y;
+ Third = z;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/UserControl.cs b/mcs/class/System.Web/System.Web.UI/UserControl.cs
new file mode 100644
index 00000000000..50ef9362fab
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/UserControl.cs
@@ -0,0 +1,189 @@
+//
+// System.Web.UI.UserControl
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Web.Caching;
+using System.Web.SessionState;
+
+namespace System.Web.UI
+{
+ public class UserControl : TemplateControl, IAttributeAccessor
+ {
+ private bool initialized;
+ private AttributeCollection attributes;
+ private StateBag attrBag;
+
+ public UserControl ()
+ {
+ //??
+ }
+
+ public HttpApplicationState Application
+ {
+ get {
+ Page p = Page;
+ if (p == null)
+ return null;
+ return p.Application;
+ }
+ }
+
+ private void EnsureAttributes ()
+ {
+ if (attributes == null) {
+ attrBag = new StateBag (true);
+ if (IsTrackingViewState)
+ attrBag.TrackViewState ();
+ attributes = new AttributeCollection (attrBag);
+ }
+ }
+
+ public AttributeCollection Attributes
+ {
+ get {
+ return attributes;
+ }
+ }
+
+ public Cache Cache
+ {
+ get {
+ Page p = Page;
+ if (p == null)
+ return null;
+ return p.Cache;
+ }
+ }
+
+ public bool IsPostBack
+ {
+ get {
+ Page p = Page;
+ if (p == null)
+ return false;
+ return p.IsPostBack;
+ }
+ }
+
+ public HttpRequest Request
+ {
+ get {
+ Page p = Page;
+ if (p == null)
+ return null;
+ return p.Request;
+ }
+ }
+
+ public HttpResponse Response
+ {
+ get {
+ Page p = Page;
+ if (p == null)
+ return null;
+ return p.Response;
+ }
+ }
+
+ public HttpServerUtility Server
+ {
+ get {
+ Page p = Page;
+ if (p == null)
+ return null;
+ return p.Server;
+ }
+ }
+
+ public HttpSessionState Session
+ {
+ get {
+ Page p = Page;
+ if (p == null)
+ return null;
+ return p.Session;
+ }
+ }
+
+ public TraceContext Trace
+ {
+ get {
+ Page p = Page;
+ if (p == null)
+ return null;
+ return p.Trace;
+ }
+ }
+
+ [MonoTODO]
+ public void DesignerInitialize ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void InitializeAsUserControl (Page page)
+ {
+ if (initialized)
+ return;
+ initialized = true;
+ this.Page = page;
+ WireupAutomaticEvents ();
+ FrameworkInitialize ();
+ }
+
+ public string MapPath (string virtualPath)
+ {
+ return Request.MapPath (virtualPath, TemplateSourceDirectory, true);
+ }
+
+ protected override void LoadViewState (object savedState)
+ {
+ if (savedState != null) {
+ Pair p = (Pair) savedState;
+ base.LoadViewState (p.First);
+ if (p.Second != null) {
+ EnsureAttributes ();
+ attrBag.LoadViewState (p.Second);
+ }
+ }
+
+ }
+
+ protected override void OnInit (EventArgs e)
+ {
+ InitializeAsUserControl (Page);
+
+ base.OnInit(e);
+ }
+
+ protected override object SaveViewState ()
+ {
+ object baseState = base.SaveViewState();
+ object attrState = null;
+ if (attributes != null)
+ attrState = attrBag.SaveViewState ();
+ if (baseState == null && attrState == null)
+ return null;
+ return new Pair (baseState, attrState);
+ }
+
+ string IAttributeAccessor.GetAttribute (string name)
+ {
+ if (attributes == null)
+ return null;
+ return attributes [name];
+ }
+
+ void IAttributeAccessor.SetAttribute (string name, string value)
+ {
+ EnsureAttributes ();
+ Attributes [name] = value;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/UserControlParser.cs b/mcs/class/System.Web/System.Web.UI/UserControlParser.cs
new file mode 100644
index 00000000000..16253a6533d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/UserControlParser.cs
@@ -0,0 +1,50 @@
+//
+// System.Web.UI.UserControlParser
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Web;
+using System.Web.Compilation;
+
+namespace System.Web.UI
+{
+ public sealed class UserControlParser : TemplateControlParser
+ {
+ internal UserControlParser (string inputFile, HttpContext context)
+ {
+ Context = context;
+ InputFile = context.Request.MapPath (inputFile);
+ }
+
+ public static Type GetCompiledType (string virtualPath, string inputFile, HttpContext context)
+ {
+ UserControlParser ucp = new UserControlParser (inputFile, context);
+ Type t = ucp.CompileIntoType ();
+ return t;
+ }
+
+ protected override Type CompileIntoType ()
+ {
+ return UserControlCompiler.CompileUserControlType (this);
+ }
+
+ protected override Type DefaultBaseType
+ {
+ get {
+ return typeof (UserControl);
+ }
+ }
+
+ protected override string DefaultDirectiveName
+ {
+ get {
+ return "control";
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/Utils.cs b/mcs/class/System.Web/System.Web.UI/Utils.cs
new file mode 100644
index 00000000000..5efb7a7919a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/Utils.cs
@@ -0,0 +1,46 @@
+/**
+ * Namespace: System.Web.UI
+ * Class: Utils
+ *
+ * Author: Gaurav Vaish
+ * Maintainer-> gvaish@iitk.ac.in
+ * Implementation: yes
+ * Contact: <gvaish@iitk.ac.in>
+ * Status: ??%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Reflection;
+
+namespace System.Web.UI
+{
+ internal class Utils
+ {
+ internal static object InvokeMethod(MethodInfo info, object obj, object[] parameters)
+ {
+ object retVal = null;
+ try
+ {
+ retVal = info.Invoke(obj, parameters);
+ } catch(TargetInvocationException tie)
+ {
+ throw tie.InnerException;
+ }
+ return retVal;
+ }
+
+ internal static string GetClientValidatedEvent(Page page)
+ {
+ return "if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate();";
+ }
+
+ internal static string GetClientValidatedPostBack(Control control)
+ {
+ return (" { if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate()) " +
+ control.Page.GetPostBackEventReference(control) +
+ " } " );
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/ValidationPropertyAttribute.cs b/mcs/class/System.Web/System.Web.UI/ValidationPropertyAttribute.cs
new file mode 100644
index 00000000000..01281a6f002
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ValidationPropertyAttribute.cs
@@ -0,0 +1,27 @@
+//
+// System.Web.UI.ValidationPropertyAttribute.cs
+//
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+
+namespace System.Web.UI {
+ [AttributeUsage (AttributeTargets.Class)]
+ public sealed class ValidationPropertyAttribute : Attribute
+ {
+ string name;
+
+ public ValidationPropertyAttribute (string name)
+ {
+ this.name = name;
+ }
+
+ public string Name {
+ get { return name; }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.UI/ValidatorCollection.cs b/mcs/class/System.Web/System.Web.UI/ValidatorCollection.cs
new file mode 100755
index 00000000000..eef684a96ab
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/ValidatorCollection.cs
@@ -0,0 +1,69 @@
+//
+// System.Web.UI.ValidatorCollection.cs
+//
+// Authors:
+// Duncan Mak (duncan@ximian.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc. (http://www.ximian.com)
+
+using System;
+using System.Collections;
+
+namespace System.Web.UI {
+
+ public sealed class ValidatorCollection : ICollection, IEnumerable
+ {
+ private ArrayList _validators;
+
+ public ValidatorCollection ()
+ {
+ _validators = new ArrayList ();
+ }
+
+ public int Count {
+ get { return _validators.Count; }
+ }
+
+ public bool IsReadOnly {
+ get { return _validators.IsReadOnly; }
+ }
+
+ public bool IsSynchronized {
+ get { return _validators.IsSynchronized; }
+ }
+
+ public IValidator this [int index] {
+ get { return (IValidator) _validators [index]; }
+ }
+
+ public object SyncRoot {
+ get { return this; }
+ }
+
+ public void Add (IValidator validator)
+ {
+ _validators.Add (validator);
+ }
+
+ public bool Contains (IValidator validator)
+ {
+ return _validators.Contains (validator);
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ _validators.CopyTo (array, index);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return _validators.GetEnumerator ();
+ }
+
+ public void Remove (IValidator validator)
+ {
+ _validators.Remove (validator);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.UI/WebServiceParser.cs b/mcs/class/System.Web/System.Web.UI/WebServiceParser.cs
new file mode 100644
index 00000000000..c107c729871
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.UI/WebServiceParser.cs
@@ -0,0 +1,36 @@
+//
+// System.Web.UI.WebServiceParser
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Web;
+using System.Web.Compilation;
+
+namespace System.Web.UI
+{
+ public class WebServiceParser : SimpleWebHandlerParser
+ {
+ private WebServiceParser (HttpContext context, string virtualPath, string physicalPath)
+ : base (context, virtualPath, physicalPath)
+ {
+ }
+
+ public static Type GetCompiledType (string inputFile, HttpContext context)
+ {
+ WebServiceParser parser = new WebServiceParser (context, null, inputFile);
+ return WebServiceCompiler.CompileIntoType (parser);
+ }
+
+ protected override string DefaultDirectiveName
+ {
+ get {
+ return "webservice";
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Util/.cvsignore b/mcs/class/System.Web/System.Web.Util/.cvsignore
new file mode 100644
index 00000000000..04bc145deea
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/.cvsignore
@@ -0,0 +1 @@
+_*
diff --git a/mcs/class/System.Web/System.Web.Util/ApacheVersionInfo.cs b/mcs/class/System.Web/System.Web.Util/ApacheVersionInfo.cs
new file mode 100644
index 00000000000..229104aa271
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/ApacheVersionInfo.cs
@@ -0,0 +1,31 @@
+/**
+ * Namespace: System.Web.Util
+ * Class: ApacheVersionInfo
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: ??%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.Util
+{
+ /// <summary>
+ /// Versions of the modules related to Apache
+ /// </summary>
+ /// <remarks>
+ /// At present I don't know what modules are to be loaded and how
+ /// </remarks>
+ /// <see>
+ /// System.Web.Util.IISVersionInfo
+ /// </see>
+ internal class ApacheVersionInfo
+ {
+ public ApacheVersionInfo()
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Util/ChangeLog b/mcs/class/System.Web/System.Web.Util/ChangeLog
new file mode 100644
index 00000000000..15f40d2ebc6
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/ChangeLog
@@ -0,0 +1,84 @@
+2002-12-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * UrlUtils.cs: fixed IsRelativeUrl and IsRootUrl.
+
+2002-12-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * PathUtil.cs: removed.
+ * UrlUtils.cs: fixed Combine to handle '~'.
+
+2002-12-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * PathUtil.cs: some path handling methods that are not available in
+ System.IO.Path.
+
+2002-10-28 Gaurav Vaish <gvaish_mono@lycos.com>
+
+ * DataSourceHelper.cs : Fresh implementation. Moved from
+ System.Web.UI.WebControls.DataGrid
+ ::ResolveData(object, string).
+
+2002-10-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * WebTrace.cs: fixed namespace.
+
+ * WebEncoding.cs: new class that holds the default encoding for
+ System.Web.
+
+2002-01-03 Nick Drochak <ndrochak@gol.com>
+
+ * FileChangesMonitor.cs: remove redundant using statement; use int
+ for MAXLEN; capitalize correctly 'WebHashCodeProvider';
+ fix typo rsLock -> rwLock; Change IsRooted to IsPathRooted;
+ set out parameter value where needed
+ * FilePathParser.cs: qualify method GetPathRoot() with 'Path.'
+ * IISVersionInfo.cs: initialize static member to avoid compile error.
+ * WebEqualComparer.cs: static member defC shouldn't be readonly;
+ the string comparer had some typos (fixed)
+ * WebHashCodeProvider.cs: needed System.Globalization; static member
+ defHcp shouldn't be readonly; remove double equal typo.
+
+2002-01-02 Nick Drochak <ndrochak@gol.com>
+
+ * FileAction.cs: Use 0x7FFFFFFF as enum value for error. 0xFFFFFFFF
+ is too big for Int32.
+ * FileChangeEventHandler.cs: put missing 'void' return type on delegate
+ FileChangeEventHandler()
+ * FileChangedEventArgs.cs: ditto for FileChangedEvent()
+ * NativeFileChangeEventHandler.cs: ditto for NativeFileChangeEventHandler()
+ * FileChangesMonitor.cs: add needed namespaces and comment out imcomplete
+ code.
+
+2001-12-21 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * ApacheVersionInfo.cs - Dummy class, for later use.
+ * FileAction.cs:
+ * FileChangeEventHandler.cs:
+ * FileChangeEventArgs.cs:
+ * FileChangesMonitor.cs:
+ * NativeFileChangeEventHandler.cs
+ - To be used in System.Web/Http* classes.
+ Initially needed for HttpRuntime
+ * IISVersionInfo.cs - Some useful methods
+
+
+2001-12-17 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * UrlUtils.cs - Added functions Combine and Reduce
+
+2001-12-16 Miguel de Icaza <miguel@ximian.com>
+
+ * DataSourceHelper.cs, UrlUtils.cs: Set the correct namespace.
+
+2001-11-30
+ Gaurav Vaish <gvaish@iitk.ac.in>
+ * DataSourceHelper.cs - Resolving DataSource objects
+
+2001-11-09
+ Gaurav Vaish <gvaish@iitk.ac.in>
+ * UrlUtil.cs - Some basic functions
+
+2001-11-08
+ Gaurav Vaish <gvaish@iitk.ac.in>
+ * Namespace - Created the namespace for commonly used,
+ otherwise not available functions
diff --git a/mcs/class/System.Web/System.Web.Util/DataSourceHelper.cs b/mcs/class/System.Web/System.Web.Util/DataSourceHelper.cs
new file mode 100644
index 00000000000..d5519e6234a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/DataSourceHelper.cs
@@ -0,0 +1,67 @@
+/**
+ * Namespace: System.Web.UI.Util
+ * Class: DataSourceHelper
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Status: 10%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+namespace System.Web.Util
+{
+ internal class DataSourceHelper
+ {
+ public static IEnumerable GetResolvedDataSource(object source, string member)
+ {
+ if(source != null && source is IListSource)
+ {
+ IListSource src = (IListSource)source;
+ IList list = src.GetList();
+ if(!src.ContainsListCollection)
+ {
+ return list;
+ }
+ if(list != null && list is ITypedList)
+ {
+ ITypedList tlist = (ITypedList)list;
+ PropertyDescriptorCollection pdc = tlist.GetItemProperties(new PropertyDescriptor[0]);
+ if(pdc != null && pdc.Count > 0)
+ {
+ PropertyDescriptor pd = null;
+ if(member != null && member.Length > 0)
+ {
+ pd = pdc.Find(member, true);
+ } else
+ {
+ pd = pdc[0];
+ }
+ if(pd != null)
+ {
+ object rv = pd.GetValue(list[0]);
+ if(rv != null && rv is IEnumerable)
+ {
+ return (IEnumerable)rv;
+ }
+ }
+ throw new HttpException(
+ HttpRuntime.FormatResourceString("ListSource_Missing_DataMember", member));
+ }
+ throw new HttpException(
+ HttpRuntime.FormatResourceString("ListSource_Without_DataMembers"));
+ }
+ }
+ if(source is IEnumerable)
+ {
+ return (IEnumerable)source;
+ }
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Util/FileAction.cs b/mcs/class/System.Web/System.Web.Util/FileAction.cs
new file mode 100644
index 00000000000..1a727011e25
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/FileAction.cs
@@ -0,0 +1,26 @@
+/**
+ * Namespace: System.Web.Util
+ * Class: FileAction
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: ??%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.Util
+{
+ public enum FileAction
+ {
+ Overwhleming,
+ Added,
+ Removed,
+ Modifiled,
+ RenamedOldName,
+ RenamedNewName,
+ Error = 0x7FFFFFFF
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Util/FileChangeEventHandler.cs b/mcs/class/System.Web/System.Web.Util/FileChangeEventHandler.cs
new file mode 100644
index 00000000000..88bcf46e99b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/FileChangeEventHandler.cs
@@ -0,0 +1,17 @@
+/**
+ * Namespace: System.Web.Util
+ * Class: FileChangeEventHandler
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.Util
+{
+ public delegate void FileChangeEventHandler(object sender, int method);
+}
diff --git a/mcs/class/System.Web/System.Web.Util/FileChangedEventArgs.cs b/mcs/class/System.Web/System.Web.Util/FileChangedEventArgs.cs
new file mode 100644
index 00000000000..69bc9818f4a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/FileChangedEventArgs.cs
@@ -0,0 +1,43 @@
+/**
+ * Namespace: System.Web.Util
+ * Class: FileChangedEventArgs
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: ??%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.Util
+{
+ internal class FileChangedEventArgs : EventArgs
+ {
+ private string filename;
+ private FileAction action;
+
+ public void FileChangedEvent(FileAction action, string file)
+ {
+ this.action = action;
+ this.filename = file;
+ }
+
+ public string FileName
+ {
+ get
+ {
+ return filename;
+ }
+ }
+
+ public FileAction Action
+ {
+ get
+ {
+ return action;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Util/FileChangesMonitor.cs b/mcs/class/System.Web/System.Web.Util/FileChangesMonitor.cs
new file mode 100644
index 00000000000..069d2a4f385
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/FileChangesMonitor.cs
@@ -0,0 +1,62 @@
+/**
+ *
+ * Namespace: System.Web.Util
+ * Class: FileChangesMonitor
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: ??%
+ *
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.IO;
+using System.Web;
+using System.Runtime.InteropServices;
+using System.Collections;
+using System.Threading;
+
+namespace System.Web.Util
+{
+ internal class FileChangesMonitor
+ {
+ private static string BIN = "bin";
+ private static string BINDIR = "bin/";
+ private static int MAXLEN = 260;
+
+ private FileChangeEventHandler cbRename;
+ private NativeFileChangeEventHandler cbSubDirs;
+
+ private int monitoredSubdirs;
+ private string rootDir;
+ private Hashtable allDirs;
+ private GCHandle rootcbSubDirs;
+
+ private ReaderWriterLock rwLock;
+
+ public FileChangesMonitor()
+ {
+ allDirs = new Hashtable(WebHashCodeProvider.Default, WebEqualComparer.Default);
+ rwLock = new ReaderWriterLock();
+ }
+
+ /// <param name="file">Name of the file</param>
+ /// <param name="mTime">Last modification date</param>
+ /// <param name="length">Legnth of the file</param>
+ [MonoTODO]
+ public void GetFileAttributes(string file, out DateTime mTime, long length)
+ {
+ if(!Path.IsPathRooted(file))
+ {
+ throw new HttpException(HttpRuntime.FormatResourceString("Path_must_be_rooted"));
+ }
+ // TODO: finish this
+ mTime = DateTime.Now;
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Util/FilePathParser.cs b/mcs/class/System.Web/System.Web.Util/FilePathParser.cs
new file mode 100644
index 00000000000..625ac056d03
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/FilePathParser.cs
@@ -0,0 +1,82 @@
+/**
+ * Namespace: System.Web.Util
+ * Class: FilePathParser
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: ??%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+using System.IO;
+
+namespace System.Web.Util
+{
+ internal class FilePathParser
+ {
+ private static char[] pathSeparators = {
+ Path.DirectorySeparatorChar,
+ Path.AltDirectorySeparatorChar
+ };
+
+ private string dirName;
+ private string fileName;
+ private string shortDirName;
+ private string shortFileName;
+
+ private bool exists;
+
+ [MonoTODO]
+ public FilePathParser(string path, bool isFile, bool getShortNames)
+ {
+ path = path.Trim();
+ if(Path.GetPathRoot(path).Length < path.Length)
+ {
+ path = path.TrimEnd(pathSeparators);
+ }
+ if(!isFile)
+ {
+ dirName = GetBaseDirOrRoot(path);
+ } else
+ {
+ dirName = path;
+ }
+ if(getShortNames)
+ {
+ if(!Directory.Exists(dirName))
+ {
+ dirName = null;
+ return;
+ }
+ shortDirName = GetShortPathName(dirName);
+ if(shortDirName==null)
+ {
+ dirName = null;
+ return;
+ }
+ if(shortDirName == dirName)
+ {
+ shortDirName = null;
+ } else
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+
+ public static string GetBaseDirOrRoot(string file)
+ {
+ string bDir = Path.GetDirectoryName(file);
+ return ( bDir!=null ? bDir : Path.GetPathRoot(file));
+ }
+
+ [MonoTODO("Native_Call_Required")]
+ public static string GetShortPathName(string path)
+ {
+ //TODO: Native calls required, it's in kernel32.dll for windows
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Util/IISVersionInfo.cs b/mcs/class/System.Web/System.Web.Util/IISVersionInfo.cs
new file mode 100644
index 00000000000..68f252531d3
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/IISVersionInfo.cs
@@ -0,0 +1,109 @@
+/**
+
+ * Namespace: System.Web.Util
+ * Class: IISVersionInfo
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: ??%
+
+ *
+
+ * (C) Gaurav Vaish (2001)
+
+ */
+
+
+using System;
+using System.Diagnostics;
+using System.Web;
+
+namespace System.Web.Util
+{
+ //FIXME: This is highly Windows/IIS specific code. What about Apache related stuff?
+ internal class IISVersionInfo
+ {
+ private static string isapiVersion;
+ private static string mscoreeVersion;
+ private static string systemWebVersion;
+
+ private static readonly object lockObj = null;
+
+ public IISVersionInfo()
+ {
+ }
+
+ internal static string IsapiVersion
+ {
+ get
+ {
+ if(isapiVersion==null)
+ {
+ lock(lockObj)
+ {
+ // Recheck - another thread may have set the value
+ // before entering lock / exiting previous lock
+ if(isapiVersion==null)
+ {
+ //FIXME: What about Apache? What dll/shared-object to be loaded?
+ isapiVersion = GetLoadedModuleVersion("aspnet_isapi.dll");
+ }
+ }
+ }
+ return isapiVersion;
+ }
+ }
+
+ internal static string ClrVersion
+ {
+ get
+ {
+ if(mscoreeVersion==null)
+ {
+ lock(lockObj)
+ {
+ if(mscoreeVersion==null)
+ {
+ mscoreeVersion = GetLoadedModuleVersion("mscorlib.dll");
+ }
+ }
+ }
+ return mscoreeVersion;
+ }
+ }
+
+ internal static string SystemWebVersion
+ {
+ get
+ {
+ if(systemWebVersion == null)
+ {
+ lock(lockObj)
+ {
+ if(systemWebVersion==null)
+ {
+ systemWebVersion = (FileVersionInfo.GetVersionInfo((typeof(HttpRuntime)).Module.FullyQualifiedName)).FileVersion;
+ }
+ }
+ }
+ return systemWebVersion;
+ }
+ }
+
+ [MonoTODO]
+ internal static string GetLoadedModuleVersion(string modulename)
+ {
+ //TODO: Load the version information from the module
+ // Needs native calls - which ones, since the module will not be .Net aware
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ internal static string GetLoadedModuleFilename(string modulename)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Util/NativeFileChangeEventHandler.cs b/mcs/class/System.Web/System.Web.Util/NativeFileChangeEventHandler.cs
new file mode 100644
index 00000000000..13a88dc0c1e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/NativeFileChangeEventHandler.cs
@@ -0,0 +1,17 @@
+/**
+ * Namespace: System.Web.Util
+ * Class: NativeFileChangeEventHandler
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 100%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+namespace System.Web.Util
+{
+ public delegate void NativeFileChangeEventHandler(object sender, int method);
+}
diff --git a/mcs/class/System.Web/System.Web.Util/UrlUtils.cs b/mcs/class/System.Web/System.Web.Util/UrlUtils.cs
new file mode 100644
index 00000000000..4068a9b6f61
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/UrlUtils.cs
@@ -0,0 +1,290 @@
+/**
+ * Namespace: System.Web.UI.Util
+ * Class: UrlUtils
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Status: ??%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Collections;
+using System.Text;
+
+namespace System.Web.Util
+{
+ internal class UrlUtils
+ {
+ /*
+ * I could not find these functions in the class System.Uri
+ * Besides, an instance of Uri will not be formed until and unless the address is of
+ * the form protocol://[user:pass]host[:port]/[fullpath]
+ * ie, a protocol, and that too without any blanks before,
+ * is a must which may not be the case here.
+ * Important: Escaped URL is assumed here. nothing like .aspx?path=/something
+ * It should be .aspx?path=%2Fsomething
+ */
+ public static string GetProtocol(string url)
+ {
+ //Taking code from Java Class java.net.URL
+ if(url!=null)
+ {
+ if(url.Length>0)
+ {
+
+ int i, start = 0, limit;
+ limit = url.Length;
+ char c;
+ bool aRef = false;
+ while( (limit > 0) && (url[limit-1] <= ' '))
+ {
+ limit --;
+ }
+ while( (start < limit) && (url[start] <= ' '))
+ {
+ start++;
+ }
+ if(RegionMatches(true, url, start, "url:", 0, 4))
+ {
+ start += 4;
+ }
+ if(start < url.Length && url[start]=='#')
+ {
+ aRef = true;
+ }
+ for(i = start; !aRef && (i < limit) && ((c=url[i]) != '/'); i++)
+ {
+ if(c==':')
+ {
+ return url.Substring(start, i - start);
+ }
+ }
+ }
+ }
+ return String.Empty;
+ }
+
+ public static bool IsRelativeUrl(string url)
+ {
+ if (url.IndexOf(':') == -1)
+ return !IsRooted(url);
+
+ return false;
+ }
+
+ public static bool IsRootUrl(string url)
+ {
+ if(url!=null)
+ {
+ if(url.Length>0)
+ {
+ return IsValidProtocol(GetProtocol(url).ToLower());
+ }
+ }
+ return true;
+ }
+
+ public static bool IsRooted(string path)
+ {
+ if(path!=null && path.Length > 0)
+ {
+ return (path[0]=='/' || path[0]=='\\');
+ }
+ return true;
+ }
+
+ public static void FailIfPhysicalPath(string path)
+ {
+ if(path!= null && path.Length > 1)
+ {
+ if(path[1]==':' || path.StartsWith(@"\\"))
+ throw new HttpException(HttpRuntime.FormatResourceString("Physical_path_not_allowed", path));
+ }
+ }
+
+ public static string Combine (string basePath, string relPath)
+ {
+ FailIfPhysicalPath (relPath);
+ if (IsRootUrl (relPath)) {
+ if (relPath != null && relPath.Length > 0)
+ return Reduce (relPath);
+
+ return String.Empty;
+ }
+
+ if (relPath.Length < 3 || relPath [0] != '~' || relPath [0] == '/' || relPath [0] == '\\') {
+ if (basePath == null || basePath.Length == 1 || basePath [0] == '/')
+ basePath = String.Empty;
+
+ return Reduce (basePath + "/" + relPath);
+ }
+
+ string vPath = HttpRuntime.AppDomainAppVirtualPath;
+ if (vPath.Length <= 1)
+ vPath = String.Empty;
+
+ return Reduce (vPath + "/" + relPath.Substring (2));
+ }
+
+ public static bool IsValidProtocol(string protocol)
+ {
+ if(protocol.Length < 1)
+ return false;
+ char c = protocol[0];
+ if(!Char.IsLetter(c))
+ {
+ return false;
+ }
+ for(int i=1; i < protocol.Length; i++)
+ {
+ c = protocol[i];
+ if(!Char.IsLetterOrDigit(c) && c!='.' && c!='+' && c!='-')
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /*
+ * MakeRelative("http://www.foo.com/bar1/bar2/file","http://www.foo.com/bar1")
+ * will return "bar2/file"
+ * while MakeRelative("http://www.foo.com/bar1/...","http://www.anotherfoo.com")
+ * return 'null' and so does the call
+ * MakeRelative("http://www.foo.com/bar1/bar2","http://www.foo.com/bar")
+ */
+ public static string MakeRelative(string fullUrl, string relativeTo)
+ {
+ if(fullUrl==relativeTo)
+ {
+ return String.Empty;
+ }
+ if(fullUrl.IndexOf(relativeTo)!=0)
+ {
+ return null;
+ }
+ string leftOver = fullUrl.Substring(relativeTo.Length);
+ if(!fullUrl.EndsWith("/") && !leftOver.StartsWith("/"))
+ {
+ return null;
+ }
+ if(leftOver.StartsWith("/"))
+ {
+ leftOver = leftOver.Substring(1);
+ }
+ return leftOver;
+ }
+
+ /*
+ * Check JavaDocs for java.lang.String#RegionMatches(bool, int, String, int, int)
+ * Could not find anything similar in the System.String class
+ */
+ public static bool RegionMatches(bool ignoreCase, string source, int start, string match, int offset, int len)
+ {
+ if(source!=null || match!=null)
+ {
+ if(source.Length>0 && match.Length>0)
+ {
+ char[] ta = source.ToCharArray();
+ char[] pa = match.ToCharArray();
+ if((offset < 0) || (start < 0) || (start > (source.Length - len)) || (offset > (match.Length - len)))
+ {
+ return false;
+ }
+ while(len-- > 0)
+ {
+ char c1 = ta[start++];
+ char c2 = pa[offset++];
+ if(c1==c2)
+ continue;
+ if(ignoreCase)
+ {
+ if(Char.ToUpper(c1)==Char.ToUpper(c2))
+ continue;
+ // Check for Gregorian Calendar where the above may not hold good
+ if(Char.ToLower(c1)==Char.ToLower(c2))
+ continue;
+ }
+ return false;
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static string Reduce(string path)
+ {
+ int len = path.Length;
+ int dotIndex = -1;
+ path = path.Replace('\\','/');
+ while(true)
+ {
+ dotIndex++;
+ dotIndex = path.IndexOf('.', dotIndex);
+ if(dotIndex < 0)
+ {
+ return path;
+ }
+ if(dotIndex != 0 && path[dotIndex -1]=='/')
+ continue;
+ if(dotIndex+1 == len || path[dotIndex+1]=='/')
+ break;
+ if(path[dotIndex+1]=='.')
+ continue;
+ if(dotIndex+2 == len || path[dotIndex+2]=='/')
+ break;
+ }
+ ArrayList list = new ArrayList();
+ StringBuilder sb = new StringBuilder();
+ dotIndex = 0;
+ int temp;
+ do
+ {
+ temp = dotIndex;
+ dotIndex = path.IndexOf('/', temp + 1);
+ if(dotIndex < 0)
+ dotIndex = len;
+ if( (dotIndex - temp) <= 3 && (dotIndex < 1 || path[dotIndex - 1]== '.') && ( (temp+1) >= len || path[temp+1]=='.') )
+ {
+ if(dotIndex - temp == 3)
+ continue;
+ if(list.Count == 0)
+ throw new System.Web.HttpException(System.Web.HttpRuntime.FormatResourceString("Cannot_exit_up_top_directory"));
+ sb.Length = (int) list[list.Count - 1];
+ list.RemoveRange(list.Count - 1, 1);
+ continue;
+ }
+ list.Add(sb.Length);
+ sb.Append(path, temp, dotIndex - temp);
+ } while(dotIndex != len);
+ return sb.ToString();
+ }
+
+ public static string GetDirectory(string url)
+ {
+ if(url==null)
+ {
+ return null;
+ }
+ if(url.Length==0)
+ {
+ return String.Empty;
+ }
+ url.Replace('\\','/');
+
+ string baseDir = "";
+ int last = url.LastIndexOf ('/');
+ if (last > 0)
+ baseDir = url.Substring(0, url.LastIndexOf('/'));
+
+ if(baseDir.Length==0)
+ {
+ baseDir = "/";
+ }
+ return baseDir;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Util/WebEncoding.cs b/mcs/class/System.Web/System.Web.Util/WebEncoding.cs
new file mode 100644
index 00000000000..5966bd0405f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/WebEncoding.cs
@@ -0,0 +1,24 @@
+//
+// System.Web.Util.WebEncoding
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Text;
+
+namespace System.Web.Util
+{
+ internal class WebEncoding
+ {
+ static Encoding encoding = new UTF8Encoding (false);
+
+ static public Encoding Encoding
+ {
+ get { return encoding; }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.Util/WebEqualComparer.cs b/mcs/class/System.Web/System.Web.Util/WebEqualComparer.cs
new file mode 100644
index 00000000000..9ab223bcbd4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/WebEqualComparer.cs
@@ -0,0 +1,107 @@
+/**
+ * Namespace: System.Web.Util
+ * Class: WebEqualComparer
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: ??%
+ *
+ * (C) Gaurav Vaish (2001)
+ */
+
+using System;
+using System.Globalization;
+using System.Collections;
+
+namespace System.Web.Util
+{
+ public class WebEqualComparer : IComparer
+ {
+ private static IComparer defC;
+
+ public WebEqualComparer()
+ {
+ }
+
+ public static IComparer Default
+ {
+ get
+ {
+ if(defC == null)
+ {
+ defC = new WebEqualComparer();
+ }
+ return defC;
+ }
+ }
+
+ /// <summary>
+ /// To compare two strings
+ /// </summary>
+ /// <remarks>
+ /// Cannot apply String.Compare(..) since I am at web
+ /// </remarks>
+ int IComparer.Compare(object left, object right)
+ {
+ string leftStr, rightStr;
+ leftStr = null;
+ rightStr = null;
+ if(left is string)
+ {
+ leftStr = (string)left;
+ }
+ if(right is string)
+ {
+ rightStr = (string)right;
+ }
+
+ if(leftStr==null || rightStr==null)
+ {
+ throw new ArgumentException();
+ }
+
+ int ll = leftStr.Length;
+ int lr = rightStr.Length;
+ if(ll==0 && lr==0)
+ {
+ return 0;
+ }
+
+ if(ll==0 || lr==0)
+ {
+ return ( (ll > 0) ? 1 : -1);
+ }
+
+ char cl,cr;
+ int i=0;
+ for(i=0; i < leftStr.Length; i++)
+ {
+ if(i==lr)
+ {
+ return 1;
+ }
+ cl = leftStr[i];
+ cr = leftStr[i];
+ if(cl==cr)
+ {
+ continue;
+ }
+ UnicodeCategory ucl = Char.GetUnicodeCategory(cl);
+ UnicodeCategory ucr = Char.GetUnicodeCategory(cr);
+ if(ucl==ucr)
+ {
+ return ( (cl > cr) ? 1 : -1 );
+ }
+ cl = Char.ToLower(cl);
+ cr = Char.ToLower(cr);
+ if(cl!=cr)
+ {
+ return ( (cl > cr) ? 1 : -1);
+ }
+ }
+ return ( (i==lr) ? 0 : -1 );
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Util/WebHashCodeProvider.cs b/mcs/class/System.Web/System.Web.Util/WebHashCodeProvider.cs
new file mode 100644
index 00000000000..57ddd4dd632
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/WebHashCodeProvider.cs
@@ -0,0 +1,54 @@
+/**
+
+ * Namespace: System.Web.Util
+ * Class: WebHashCodeProvider
+ *
+
+ * Author: Gaurav Vaish
+
+ * Maintainer: gvaish@iitk.ac.in
+
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+
+ * Implementation: yes
+
+ * Status: ??%
+
+ *
+
+ * (C) Gaurav Vaish (2001)
+
+ */
+
+
+using System.Collections;
+using System.Globalization;
+
+namespace System.Web.Util
+{
+ public class WebHashCodeProvider : IHashCodeProvider
+ {
+ private static IHashCodeProvider defHcp;
+
+ public WebHashCodeProvider()
+ {
+ }
+
+ int IHashCodeProvider.GetHashCode(object key)
+ {
+ return Default.GetHashCode(key);
+ }
+
+ public static IHashCodeProvider Default
+ {
+ get
+ {
+ if(defHcp==null)
+ {
+ defHcp = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture);
+ }
+ return defHcp;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web.Util/WebTrace.cs b/mcs/class/System.Web/System.Web.Util/WebTrace.cs
new file mode 100644
index 00000000000..53b96402f4b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.Util/WebTrace.cs
@@ -0,0 +1,98 @@
+//
+// System.Web.Util.WebTrace
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Collections;
+using System.Diagnostics;
+
+namespace System.Web.Util
+{
+ internal class WebTrace
+ {
+ static Stack ctxStack;
+ static bool trace;
+
+ static WebTrace ()
+ {
+ ctxStack = new Stack ();
+ }
+
+ [Conditional("WEBTRACE")]
+ static public void PushContext (string context)
+ {
+ ctxStack.Push (context);
+ Trace.Indent ();
+ }
+
+ [Conditional("WEBTRACE")]
+ static public void PopContext ()
+ {
+ if (ctxStack.Count == 0)
+ return;
+
+ Trace.Unindent ();
+ ctxStack.Pop ();
+ }
+
+ static public string Context
+ {
+ get {
+ if (ctxStack.Count == 0)
+ return "No context";
+
+ return (string) ctxStack.Peek ();
+ }
+ }
+
+ static public bool StackTrace
+ {
+ get { return trace; }
+
+ set { trace = value; }
+ }
+
+ [Conditional("WEBTRACE")]
+ static public void WriteLine (string msg)
+ {
+ Trace.WriteLine (Format (msg));
+ }
+
+ [Conditional("WEBTRACE")]
+ static public void WriteLine (string msg, object arg)
+ {
+ Trace.WriteLine (Format (String.Format (msg, arg)));
+ }
+
+ [Conditional("WEBTRACE")]
+ static public void WriteLine (string msg, object arg1, object arg2)
+ {
+ Trace.WriteLine (Format (String.Format (msg, arg1, arg2)));
+ }
+
+ [Conditional("WEBTRACE")]
+ static public void WriteLine (string msg, object arg1, object arg2, object arg3)
+ {
+ Trace.WriteLine (Format (String.Format (msg, arg1, arg2, arg3)));
+ }
+
+ [Conditional("WEBTRACE")]
+ static public void WriteLine (string msg, params object [] args)
+ {
+ Trace.WriteLine (Format (String.Format (msg, args)));
+ }
+
+ static string Format (string msg)
+ {
+ if (trace)
+ return String.Format ("{0}: {1}\n{2}", Context, msg, Environment.StackTrace);
+ else
+ return String.Format ("{0}: {1}", Context, msg);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web.build b/mcs/class/System.Web/System.Web.build
new file mode 100644
index 00000000000..419f237efcf
--- /dev/null
+++ b/mcs/class/System.Web/System.Web.build
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<!-- NAnt build file for System.Web.dll -->
+
+<project name="System" default="build">
+ <property name="debug" value="false"/>
+
+ <target name="build">
+ <mkdir dir="../lib"/>
+ <csc target="library" output="../lib/System.Web.dll" debug="${debug}">
+ <arg value="/nowarn:1595"/>
+ <arg value="/nowarn:0169"/>
+ <arg value="/nowarn:0649"/> <!-- always default value -->
+ <arg value="/nowarn:0067"/> <!-- event never used -->
+ <arg value="/nowarn:0679"/> <!-- internal virual -->
+ <arg value="/nowarn:0168"/> <!-- never used variable -->
+ <arg value="/nowarn:0162"/> <!-- unreachable code -->
+ <arg value="/unsafe"/>
+ <arg value="/noconfig"/>
+ <arg value="/debug"/>
+ <arg value="/r:System.dll"/>
+ <arg value="/r:System.Drawing.dll"/>
+ <arg value="/r:System.Xml.dll"/>
+ <sources>
+ <includes name="**/*.cs"/>
+ <excludes name="Test/**"/>
+ </sources>
+ </csc>
+ </target>
+ <target name="trace">
+ <mkdir dir="../lib"/>
+ <csc target="library" output="../lib/System.Web.dll" debug="${debug}">
+ <arg value="/d:TRACE"/>
+ <arg value="/d:WEBTRACE"/>
+ <arg value="/nowarn:1595"/>
+ <arg value="/nowarn:0169"/>
+ <arg value="/nowarn:0649"/> <!-- always default value -->
+ <arg value="/nowarn:0067"/> <!-- event never used -->
+ <arg value="/nowarn:0679"/> <!-- internal virual -->
+ <arg value="/nowarn:0168"/> <!-- never used variable -->
+ <arg value="/nowarn:0162"/> <!-- unreachable code -->
+ <arg value="/unsafe"/>
+ <arg value="/noconfig"/>
+ <arg value="/debug"/>
+ <arg value="/r:System.dll"/>
+ <arg value="/r:System.Drawing.dll"/>
+ <arg value="/r:System.Xml.dll"/>
+ <sources>
+ <includes name="**/*.cs"/>
+ <excludes name="Test/**"/>
+ </sources>
+ </csc>
+ </target>
+ <target name="clean">
+ <delete file="../lib/System.Web.dll" failonerror="false"/>
+ <delete file="../lib/System.Web.pdb" failonerror="false"/>
+ </target>
+</project>
diff --git a/mcs/class/System.Web/System.Web/.cvsignore b/mcs/class/System.Web/System.Web/.cvsignore
new file mode 100644
index 00000000000..04bc145deea
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/.cvsignore
@@ -0,0 +1 @@
+_*
diff --git a/mcs/class/System.Web/System.Web/BeginEventHandler.cs b/mcs/class/System.Web/System.Web/BeginEventHandler.cs
new file mode 100644
index 00000000000..c2bd1ac2782
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/BeginEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// System.Web.BeginEventHandler.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+namespace System.Web
+{
+ public delegate IAsyncResult BeginEventHandler(object sender,
+ EventArgs e,
+ AsyncCallback cb,
+ object extraData);
+}
diff --git a/mcs/class/System.Web/System.Web/ChangeLog b/mcs/class/System.Web/System.Web/ChangeLog
new file mode 100644
index 00000000000..ba33cb3caf9
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/ChangeLog
@@ -0,0 +1,536 @@
+2003-01-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpRequest.cs: implemented CurrentExecutionFilePath.
+
+2003-01-10 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs: keep _lasterror if no context. Attach
+ application events *after* modules initialization (if not, User is not
+ set when the user handler is called).
+
+ * HttpApplicationFactory.cs: made all methods related to
+ AttachEvents static. I will fix OnStart/OnEnd for application and
+ session later.
+
+ * HttpRequest.cs: don't initialize cookies twice.
+
+2003-01-10 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpResponse.cs:
+ (ApplyAppPathModifiers): return the root directory for "".
+
+2003-01-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpUtility.cs: fixed HtmlDecode to avoid ArgumentOutOfRangeException.
+
+2003-01-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs: added new state to handle default authentication.
+
+2003-01-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpContext.cs: removed hack to get the User.
+
+2003-01-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpUtility.cs: fixed bug #36038. Thanks to juancri@tagnet.org for
+ reporting the bug and how to fix it.
+
+2002-12-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpCookie.cs: send 'expires' in the header.
+
+2002-12-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpValueCollection.cs: patch from Botjan Vizin
+ <bostjan.vizin@siol.net> that implements ToString (bool).
+
+2002-12-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplicationFactory.cs: add the context as parameter when building
+ the application Type.
+
+ * HttpCookie.cs: new internal constructor.
+ * HttpCookieCollection.cs: new internal method to make a cookie expire.
+
+ * HttpRequest.cs: MapPath fixes.
+ * HttpResponse.cs: implemented ApplyAppPathModifier.
+ * HttpRuntime.cs: fixed typo in AppDomainAppVirtualPath.
+
+2002-12-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpContext.cs: hack to create a default user when there's no one.
+ Implemented GetConfig (string).
+
+ * HttpRequest.cs: fixes to MapPath (string).
+
+2002-12-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpRuntime.cs: avoid nulls and exception when getting resource
+ format strings.
+
+ * StaticFileHandler.cs: added file name to error message.
+
+2002-12-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpResponse.cs: avoid sending chunked content for HTTP/1.1.
+
+2002-12-02 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplicationFactory.cs: get the events from the application class,
+ fire Application/Session Start/End and add the others as application
+ events.
+
+2002-11-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplicationFactory.cs: compile global.asax file if it exists.
+
+2002-11-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpRequest.cs: provide a default Browser until we detect it.
+ * HttpResponse.cs:
+ (End): do not close the connection here.
+ (Flush (bool)): send the headers when, for example, Redirect () is
+ called.
+
+2002-11-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpException.cs: simple error output.
+
+2002-11-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs: style.
+ * HttpException.cs: style.
+ * HttpRuntime.cs: only flush the response if there are no errors.
+ Otherwise, write an error output.
+ * HttpWriter.cs: change Unicode to UTF8.
+
+2002-11-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs: don't begin the request using ExecuteNextAsync
+ (it fails to work on NetServ).
+
+ * HttpWorkerRequest.cs: typo.
+
+2002-11-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpValueCollection.cs: the value may contain trailing '=' as it is
+ UrlEncoded. Don't split name=value based on '='.
+
+2002-11-02 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpCookie.cs: made GetCookieHeader internal.
+
+ * HttpRequest.cs: get cookies from request.
+
+ * HttpResponse.cs: send cookies. Implemented
+ AddFileDependencies (). Added check for _Writer == null in Flush
+ (Patrik ;-). Clear the content if HEAD or SupressContent == true.
+ Removed redirect hack used in old server.
+
+2002-10-31 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpRequest.cs: fixed GetRawContent (). Now it only tries to read at
+ most ContentLength bytes.
+
+ * HttpResponse.cs: now it sends the headers. Added
+ X-Powered-By header :-).
+
+ * HttpRuntime.cs: fixed typo.
+
+ * HttpValueCollection.cs: cosmetic changes.
+
+2002-10-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs: reenabled a few lines of code
+ (ThreadPool already fixed).
+
+ * HttpRequest.cs:
+ * HttpResponse.cs:
+ * HttpUtility.cs:
+ * HttpValueCollection.cs:
+ * HttpWriter.cs: Use WebEncoding.Encoding.
+
+2002-10-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpWriter.cs: changed encoding of the writer from Unicode to UTF8.
+ This fixes sending bytes and allows mixing byte with chars.
+
+2002-10-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpResponse.cs: implemented WriteFile methods.
+ * MimeTypes.cs: removed duplicated entries.
+
+2002-10-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpResponse.cs: don't throw exception in a couple of
+ methods not yet implemented.
+
+2002-10-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs: fixed type and handle factories when creating
+ IHttpHandler for a request.
+
+2002-10-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs: use handlers from configuration.
+ * HttpContext.cs: get handlers from ConfigurationSettings.
+
+2002-10-02 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpMethodNotAllowedHandler.cs:
+ * HttpRuntime.cs:
+ * StaticFileHandler.cs: Modified file.
+
+ * HttpUtility.cs: implemented all missing methods.
+
+
+2002-09-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web/HttpApplication.cs: use the static file handler.
+ * System.Web/HttpForbiddenHandler.cs: handler to forbid access.
+ * System.Web/HttpMethodNotAllowedHandler.cs: handler for method not
+ allowed.
+
+ * System.Web/HttpUtility.cs: finished all UrlDecode methods.
+ * System.Web/MimeTypes.cs: map from file extension to MIME type.
+ * System.Web/StaticFileHandler.cs: serves static files
+
+2002-09-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web/HttpApplication.cs:
+ * System.Web/HttpApplicationFactory.cs:
+ * System.Web/HttpRequest.cs:
+ * System.Web/HttpRuntime.cs: we are now able to compile pages and use
+ HttpApplication, HttpRuntime and SimpleWorkerRequest.
+
+2002-09-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs: added some missing methods.
+ * HttpApplicationFactory.cs: get event handlers for the application.
+ * HttpAsyncResult.cs: little fixes.
+ * HttpRequest.cs: make Encoding work even with no worker request.
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpWorkerRequest.cs: mcs doesn't go crazy. It's just me, that forgot
+ to add HttpMapPath to the list file...
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpWorkerRequest.cs: fixes compilation with mcs. I will add a bug
+ report when i get a test case.
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplicationFactory.cs:
+ * HttpCachePolicy.cs:
+ * HttpResponseHeader.cs:
+ * HttpResponseStream.cs:
+ * HttpResponseStreamProxy.cs:
+ * HttpValueCollection.cs: misc. fixes based on class status page.
+
+ * IHttpMapPath.cs: New file.
+
+ * HttpRequest.cs: implemented ContentEncoding.
+ * HttpWorkerRequest.cs: mono-stylized and implemented
+ SendResponseFromMemory.
+
+2002-08-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpContext.cs: reformatted.
+ * HttpStaticObjectsCollection.cs: implemented GetEnumertor, CopyTo and
+ the indexer.
+
+2002-08-05 Patrik Torstensson <ptorsten@hotmail.com>
+
+ * HttpApplication.cs: Implemented a state machine to allow handling of
+ HttpModules and HttpHandlers. Implementation of async handlers.
+
+ * HttpApplicationFactory.cs: Factory for creating HttpApplication
+ instances, including caching.
+
+ * HttpRuntime.cs: Usage of the new HttpApplicationFactory to get a
+ application instance to execute requests in and implementation of
+ request execution (still no request queue).
+
+ * HttpAsyncResult.cs: New file to handle async module results.
+
+ * HttpRequest.cs: Change signature of Dispose
+ * HttpResponse.cs: new internal method allowing filtering to happen
+ during the request flow in the state machine.
+
+2002-07-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs: events were not being initialized.
+
+2002-07-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ProcessModelInfo.cs: fixed compilation.
+
+2002-07-25 Tim Coleman <tim@timcoleman.com>
+ * ProcessModelInfo.cs:
+ New class added
+ * HttpParseException.cs:
+ * HttpCompileException.cs:
+ * HttpUnhandledException.cs:
+ Internal constructors added to these
+
+2002-07-24 Tim Coleman <tim@timcoleman.com>
+ * ProcessInfo.cs:
+ Fix constructor, reference to shutdownreason.
+
+2002-07-24 Tim Coleman <tim@timcoleman.com>
+ * HttpCachePolicy.cs:
+ Added stubbs to this class.
+ * HttpCacheability.cs:
+ * HttpCacheRevalidation.cs:
+ * HttpValidationStatus.cs:
+ * ProcessShutdownReason.cs:
+ * ProcessStatus.cs:
+ * TraceMode.cs:
+ Reorder the enumerations (and in some cases make
+ one-based) in order to agree with the .NET
+ implementation, based on the class status page.
+ * ProcessInfo.cs:
+ Implementation of this class.
+
+2002-07-23 Tim Coleman <tim@timcoleman.com>
+ * HttpCompileException.cs:
+ * HttpParseException.cs:
+ * HttpUnhandledException.cs:
+ New stubbs created.
+ * HttpApplication.cs:
+ * HttpBrowserCapabilities.cs:
+ Added missing methods stubbs and attributes based
+ on the class status page. Also reformatted some
+ source for consistency.
+
+2002-07-23 Tim Coleman <tim@timcoleman.com>
+ * HttpUtility.cs: Moved entities hashtable into main
+ class as a static object, so we don't instantiate
+ a new one every time. Also put the hashtable
+ building into a lock block.
+
+2002-07-22 Tim Coleman <tim@timcoleman.com>
+ * HttpUtility.cs: Cleanup of the code, implementation
+ of HtmlDecode/HtmlEncode functions
+
+2002-07-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpResponse.cs: quick&dirty hack to make redirection work. Should
+ be out of there once we have SimpleWorkerRequest.
+
+2002-07-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpUtility.cs: little typo, big headache.
+
+2002-07-10 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpRuntime.cs: don't throw NotImplemented in a couple of methods.
+
+2002-06-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.Web/HttpResponse.cs:
+
+ Fixes based on class status page:
+
+ - Add attributes (DefaultEvent, ParseChildren).
+ - Fix declarations.
+ - Explicitly implement some interfaces (IPostBackDataHandler
+ and IPostBackEventHandler).
+ - Implemented some missing methods.
+
+2002-06-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpContext.cs:
+ (Session): return null instead of throwing an exception.
+
+ * HttpRequest.cs:
+ (HttpMethod): return RequestType if not set.
+ (GetRawContent): return QueryString if we don't have a
+ HttpWorkerRequest.
+
+ * HttpUtility.cs: fixed Decode and Encode.
+
+2002-06-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpApplication.cs:
+ * HttpContext.cs: added System.Web.SessionState namespace.
+
+ * HttpSessionState.cs: removed. It is under
+ System.Web.SessionState.
+
+2002-06-10 Duncan Mak <duncan@ximian.com>
+
+ * HttpBrowserCapabilities.cs (BackgroundSounds): Fixed typo.
+
+2002-06-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpRequest.cs: implemented Browser property.
+
+2002-06-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * HttpBrowserCapabilities.cs: stubbed out.
+
+2002-05-18 Miguel de Icaza <miguel@ximian.com>
+
+ * HttpRuntime.cs: Reformat file.
+
+2002-05-07 Duncan Mak <duncan@ximian.com>
+
+ * HttpBrowserCapabilities.cs: Added, replacing
+ HttpBrowserCapabilites because of typo.
+
+ * HttpBrowserCapabilites.cs: Removed, replaced by above.
+
+ * HttpRequest.cs (Browser): Fixed typo.
+
+2002-04-12 Patrik Torstensson <patrik.torstensson@labs2.com>
+
+ * HttpApplication.cs: Minor updates
+ * HttpApplicationState.cs: Ready.
+ * HttpClientCertificate.cs: Signature updates
+ * HttpValueCollection.cs: ready
+ * HttpStaticObjectsCollection.cs: ready
+ * HttpResponseHeader.cs: made internal only
+ * HttpResponse.cs: Signature updates
+ * HttpPostedFile.cs: ready
+ * HttpCacheVaryByHeaders.cs: ready (except communication to policy)
+ * HttpCacheVaryByParams.cs: ready (except communication to policy)
+
+ System.Web is now over 60% ready..
+
+2002-04-11 Patrik Torstensson <patrik.torstensson@labs2.com>
+
+ * HttpException.cs: 95% ready, only windows dependent code left
+ * HttpFileCollection.cs: Finished.
+ * HttpRequest.cs: Minor fixes and fixed signature problems
+ * HttpResponse.cs: Implementation of missing methods and signature problems
+ * HttpResponseHeader.cs: Fixed signature problems
+ * HttpRuntime.cs: Fixed signature problems
+ * HttpServerUtility.cs: Added support for HttpApplication
+ * HttpSessionState.cs: Fixed signature issues
+ * HttpUtility.cs: fixed signature issues
+ * HttpValueCollection.cs: Support for cookie parsing and fixed signature issues
+ * HttpWorkerRequest.cs: Fixed small signature issue
+ * HttpWriter.cs: Fixed signature issue
+ * HttpApplication.cs: Basic implementation
+ * HttpApplicationState.cs: Small fixes to support major change comming up
+ * HttpBrowserCapabilities.cs: Added Type method
+ * HttpClientCertificate.cs: Almost ready, needs to parse certificate.
+ * HttpContext.cs: Fixed signature issues and added last methods.
+ * HttpCookie.cs: Full implementation
+ * HttpCookieCollection.cs: Full implementation
+ * TraceContext.cs: Methods implemented.
+ * HttpPostedFile.cs: Placeholder
+ * HttpStaticObjectsCollection.cs: Placeholder
+ * HttpModuleCollection.cs: Ready, will be used during the major revamp.
+
+ * Fixed a number of other small signature problems also (class status page)
+
+
+2002-04-10 Patrik Torstensson <patrik.torstensson@labs2.com>
+
+ * HttpWorkerRequest.EndOfSendNotification.cs Removed (included in WorkerRequest)
+ * Checkin of all new files (noted in last changenote)
+
+2002-04-10 Patrik Torstensson <patrik.torstensson@labs2.com>
+
+ * HttpContext.cs: First implementation (basic support, few methods left to impl)
+ * HttpException.cs: Partial implementation (basic support)
+ * HttpHelper.cs: Header parse helper, used by runtime (non public)
+ * HttpRequest.cs: Implementation (all methods there, not all fully impl)
+ * HttpRequestStream.cs: Full implementation
+ * HttpResponse.cs: Partial implementation(almost all methods)
+ * HttpResponseHeader.cs: Header helper
+ * HttpResponseStream.cs: Full implementation - Response stream support
+ * HttpResponseStreamProxy.cs: Implementation - filter support
+ * HttpRuntime.cs: Rewrite to support one IHttpModule (use for testing the runtime)
+ * HttpServerUtility.cs: Implemented usage of HttpContext for methods
+ and moved encoding functions to HttpUtility.
+
+ * HttpUtility.cs: Added encoding/decoding functions from HttpServerUtility and
+ added the Attribute encoding functions.
+
+ * HttpValueCollection.cs: Implementation.
+ * HttpWorkerRequest.cs: Rewrite and implementation of all methods (ready)
+ * HttpWriter.cs: Implementation (with filter support)
+
+ * HttpFileCollection: Added dummy class (placeholder)
+ * HttpApplication.cs: Added dummy class (placeholder)
+ * HttpApplicationState.cs: Added dummy class (placeholder)
+ * HttpBrowserCapabilities.cs: Added dummy class (placeholder)
+ * HtttpCachePolicy.cs: Added dummy class (placeholder)
+ * HttpClientCertificate.cs: Added dummy class (placeholder)
+ * HttpSessionState.cs: Added dummy class (placeholder)
+ * TraceContext.cs: Added dummy class (placeholder)
+
+
+2002/04/10 Nick Drochak <ndrochak@gol.com>
+
+ * HttpServerUtility.cs: Fix build breaker.
+
+2002-03-28 Wictor Wilén <wictor@iBizkit.se>
+
+ * HttpServerUtils.cs : Added some more functionality
+
+2002-03-28 Martin Baulig <martin@gnome.org>
+
+ * HttpServerUtils.cs (UrlDecode): You cannot implicitly cast a
+ char to a string, use ToString() instead.
+
+2002-03-16 Gaurav Vaish <gavish@iitk.ac.in>
+
+ * WebCategoryAttribute.cs
+ : Added private attribute.
+
+2002-03-16 Gaurav Vaish <gavish@iitk.ac.in>
+
+ * HttpRuntime.cs : Stubbed methods for
+ FormatStringResource(...) in agreement with the various
+ overloads available at String.Format(...)
+
+2002-01-08 Gaurav Vaish <gavish@iitk.ac.in>
+
+ * TODOAttribute.cs : Added, as an internal class to the assembly
+
+2002-01-03 Nick Drochak <ndrochak@gol.com>
+
+ * HttpRuntime.cs: remove uneeded exception variable from catch and
+ initialize remaining instance members to avoid compile warnings
+
+2002-01-02 Nick Drochak <ndrochak@gol.com>
+
+ * HttpRuntime.cs: fix spelling error/variable name change.
+
+2001-12-18 Gaurav Vaish <gvaish@iitk.ac.in>
+
+ * HttpRuntime.cs : Initial implementation
+
+2001-08-29 Bob Smith <bob@thestuff.net>
+
+ * HttpWorkerRequest.cs: Partial Implementation.
+
+2001-08-16 Bob Smith <bob@thestuff.net>
+
+ * HttpCookieCollection.cs, HttpCookie.cs: Bug fixes.
+
+2001-08-09 Bob Smith <bob@thestuff.net>
+
+ * BeginEventHandler.cs: Implemented.
+ * EndEventHandler.cs: Implemented.
+ * HttpCacheability.cs: Implemented.
+ * HttpCacheRevalidation.cs: Implemented.
+ * HttpCacheValidateHandler.cs: Implemented.
+ * HttpCookieCollection.cs: Implemented.
+ * HttpCookie.cs: Implemented.
+ * HttpValidationStatus.cs: Implemented.
+ * HttpWorkerRequest.EndOfSendNotification.cs: Implemented.
+ * IHttpAsyncHandler.cs: Implemented.
+ * IHttpHandler.cs: Implemented.
+ * IHttpHandlerFactory.cs: Implemented.
+ * IHttpModule.cs: Implemented.
+ * ProcessShutdownReason.cs: Implemented.
+ * ProcessStatus.cs: Implemented.
+ * TraceMode.cs: Implemented.
diff --git a/mcs/class/System.Web/System.Web/EndEventHandler.cs b/mcs/class/System.Web/System.Web/EndEventHandler.cs
new file mode 100644
index 00000000000..cd7a51c222a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/EndEventHandler.cs
@@ -0,0 +1,13 @@
+//
+// System.Web.EndEventHandler.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+namespace System.Web
+{
+ public delegate void EndEventHandler(IAsyncResult ar);
+}
diff --git a/mcs/class/System.Web/System.Web/HttpApplication.cs b/mcs/class/System.Web/System.Web/HttpApplication.cs
new file mode 100644
index 00000000000..044e1d1c7ac
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpApplication.cs
@@ -0,0 +1,1037 @@
+//
+// System.Web.HttpApplication
+//
+// Authors:
+// Patrik Torstensson (ptorsten@hotmail.com)
+// Tim Coleman (tim@timcoleman.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Threading;
+using System.Security.Principal;
+using System.Runtime.Remoting.Messaging;
+using System.Web.UI;
+using System.Web.Configuration;
+using System.Web.SessionState;
+
+namespace System.Web
+{
+
+ [ToolboxItem(true)]
+ public class HttpApplication : IHttpAsyncHandler, IHttpHandler, IComponent, IDisposable
+ {
+
+#region Event Handlers
+
+ // Async event holders
+ AsyncEvents _acquireRequestStateAsync;
+ AsyncEvents _authenticateRequestAsync;
+ AsyncEvents _endRequestAsync;
+ AsyncEvents _beginRequestAsync;
+ AsyncEvents _authorizeRequestAsync;
+ AsyncEvents _updateRequestCacheAsync;
+ AsyncEvents _resolveRequestCacheAsync;
+ AsyncEvents _releaseRequestStateAsync;
+ AsyncEvents _preRequestHandlerExecuteAsync;
+ AsyncEvents _postRequestHandlerExecuteAsync;
+
+ // ID objects used to indentify the event
+ static object AcquireRequestStateId = new Object ();
+ static object AuthenticateRequestId = new Object ();
+ static object DefaultAuthenticationId = new Object ();
+ static object EndRequestId = new Object ();
+ static object DisposedId = new Object ();
+ static object BeginRequestId = new Object ();
+ static object AuthorizeRequestId = new Object ();
+ static object UpdateRequestCacheId = new Object ();
+ static object ResolveRequestCacheId = new Object ();
+ static object ReleaseRequestStateId = new Object ();
+ static object PreSendRequestContentId = new Object ();
+ static object PreSendRequestHeadersId = new Object ();
+ static object PreRequestHandlerExecuteId = new Object ();
+ static object PostRequestHandlerExecuteId = new Object ();
+ static object ErrorId = new Object ();
+
+ // List of events
+ private EventHandlerList _Events;
+
+ public event EventHandler AcquireRequestState {
+ add { Events.AddHandler (AcquireRequestStateId, value); }
+ remove { Events.RemoveHandler (AcquireRequestStateId, value); }
+ }
+
+ public event EventHandler AuthenticateRequest {
+ add { Events.AddHandler (AuthenticateRequestId, value); }
+ remove { Events.RemoveHandler (AuthenticateRequestId, value); }
+ }
+
+ public event EventHandler AuthorizeRequest {
+ add { Events.AddHandler (AuthorizeRequestId, value); }
+ remove { Events.RemoveHandler (AuthorizeRequestId, value); }
+ }
+
+ public event EventHandler BeginRequest {
+ add { Events.AddHandler (BeginRequestId, value); }
+ remove { Events.RemoveHandler (BeginRequestId, value); }
+ }
+
+ public event EventHandler Disposed {
+ add { Events.AddHandler (DisposedId, value); }
+ remove { Events.RemoveHandler (DisposedId, value); }
+ }
+
+ public event EventHandler EndRequest {
+ add { Events.AddHandler (EndRequestId, value); }
+ remove { Events.RemoveHandler (EndRequestId, value); }
+ }
+
+ public event EventHandler Error {
+ add { Events.AddHandler (ErrorId, value); }
+ remove { Events.RemoveHandler (ErrorId, value); }
+ }
+
+ public event EventHandler PostRequestHandlerExecute {
+ add { Events.AddHandler (PostRequestHandlerExecuteId, value); }
+ remove { Events.RemoveHandler (PostRequestHandlerExecuteId, value); }
+ }
+
+ public event EventHandler PreRequestHandlerExecute {
+ add { Events.AddHandler (PreRequestHandlerExecuteId, value); }
+ remove { Events.RemoveHandler (PreRequestHandlerExecuteId, value); }
+ }
+
+ public event EventHandler PreSendRequestContent {
+ add { Events.AddHandler (PreSendRequestContentId, value); }
+ remove { Events.RemoveHandler (PreSendRequestContentId, value); }
+ }
+
+ public event EventHandler ReleaseRequestState {
+ add { Events.AddHandler (ReleaseRequestStateId, value); }
+ remove { Events.RemoveHandler (ReleaseRequestStateId, value); }
+ }
+
+ public event EventHandler ResolveRequestCache
+ {
+ add { Events.AddHandler (ResolveRequestCacheId, value); }
+ remove { Events.RemoveHandler (ResolveRequestCacheId, value); }
+ }
+
+ public event EventHandler UpdateRequestCache {
+ add { Events.AddHandler (UpdateRequestCacheId, value); }
+ remove { Events.RemoveHandler (UpdateRequestCacheId, value); }
+ }
+
+ public event EventHandler PreSendRequestHeaders {
+ add { Events.AddHandler (PreSendRequestHeadersId, value); }
+ remove { Events.RemoveHandler (PreSendRequestHeadersId, value); }
+ }
+
+ internal event EventHandler DefaultAuthentication {
+ add { Events.AddHandler (DefaultAuthenticationId, value); }
+ remove { Events.RemoveHandler (DefaultAuthenticationId, value); }
+ }
+
+ public void AddOnAcquireRequestStateAsync (BeginEventHandler beg, EndEventHandler end)
+ {
+ if (null == _acquireRequestStateAsync)
+ _acquireRequestStateAsync = new AsyncEvents ();
+
+ _acquireRequestStateAsync.Add (beg, end);
+ }
+
+ public void AddOnAuthenticateRequestAsync(BeginEventHandler beg, EndEventHandler end)
+ {
+ if (null == _authenticateRequestAsync)
+ _authenticateRequestAsync = new AsyncEvents ();
+
+ _authenticateRequestAsync.Add (beg, end);
+ }
+
+ public void AddOnAuthorizeRequestAsync (BeginEventHandler beg, EndEventHandler end)
+ {
+ if (null == _authorizeRequestAsync)
+ _authorizeRequestAsync = new AsyncEvents ();
+
+ _authorizeRequestAsync.Add (beg, end);
+ }
+
+ public void AddOnBeginRequestAsync (BeginEventHandler beg, EndEventHandler end)
+ {
+ if (null == _beginRequestAsync)
+ _beginRequestAsync = new AsyncEvents ();
+
+ _beginRequestAsync.Add (beg, end);
+ }
+
+ public void AddOnEndRequestAsync (BeginEventHandler beg, EndEventHandler end)
+ {
+ if (null == _endRequestAsync)
+ _endRequestAsync = new AsyncEvents ();
+
+ _endRequestAsync.Add (beg, end);
+ }
+
+ public void AddOnPostRequestHandlerExecuteAsync (BeginEventHandler beg, EndEventHandler end)
+ {
+ if (null == _postRequestHandlerExecuteAsync)
+ _postRequestHandlerExecuteAsync = new AsyncEvents ();
+
+ _postRequestHandlerExecuteAsync.Add (beg, end);
+ }
+
+ public void AddOnPreRequestHandlerExecuteAsync (BeginEventHandler beg, EndEventHandler end)
+ {
+ if (null == _preRequestHandlerExecuteAsync)
+ _preRequestHandlerExecuteAsync = new AsyncEvents ();
+
+ _preRequestHandlerExecuteAsync.Add (beg, end);
+ }
+
+ public void AddOnReleaseRequestStateAsync (BeginEventHandler beg, EndEventHandler end)
+ {
+ if (null == _releaseRequestStateAsync)
+ _releaseRequestStateAsync = new AsyncEvents ();
+
+ _releaseRequestStateAsync.Add (beg, end);
+ }
+
+ public void AddOnResolveRequestCacheAsync (BeginEventHandler beg, EndEventHandler end)
+ {
+ if (null == _resolveRequestCacheAsync)
+ _resolveRequestCacheAsync = new AsyncEvents ();
+
+ _resolveRequestCacheAsync.Add (beg, end);
+ }
+
+ public void AddOnUpdateRequestCacheAsync (BeginEventHandler beg, EndEventHandler end)
+ {
+ if (null == _updateRequestCacheAsync)
+ _updateRequestCacheAsync = new AsyncEvents ();
+
+ _updateRequestCacheAsync.Add (beg, end);
+ }
+
+#endregion
+
+#region State Machine
+
+ interface IStateHandler
+ {
+ void Execute();
+ bool CompletedSynchronously { get; }
+ bool PossibleToTimeout { get; }
+ }
+
+ class EventState : IStateHandler
+ {
+ HttpApplication _app;
+ EventHandler _event;
+
+ public EventState (HttpApplication app, EventHandler evt)
+ {
+ _app = app;
+ _event = evt;
+ }
+
+ public void Execute ()
+ {
+ if (null != _event)
+ _event (_app, EventArgs.Empty);
+ }
+
+ public bool CompletedSynchronously {
+ get { return true; }
+ }
+
+ public bool PossibleToTimeout {
+ get { return true; }
+ }
+ }
+
+ class AsyncEventState : IStateHandler
+ {
+ HttpApplication _app;
+ BeginEventHandler _begin;
+ EndEventHandler _end;
+ AsyncCallback _callback;
+ bool _async;
+
+ public AsyncEventState (HttpApplication app,
+ BeginEventHandler begin,
+ EndEventHandler end)
+ {
+ _async = false;
+ _app = app;
+ _begin = begin;
+ _end = end;
+ _callback = new AsyncCallback (OnAsyncReady);
+ }
+
+ public void Execute ()
+ {
+ _async = true;
+ IAsyncResult ar = _begin (_app, EventArgs.Empty, _callback, null);
+ if (ar.CompletedSynchronously) {
+ _async = false;
+ _end (ar);
+ }
+ }
+
+ public bool CompletedSynchronously {
+ get { return !_async; }
+ }
+
+ public bool PossibleToTimeout {
+ get {
+ // We can't cancel a async event
+ return false;
+ }
+ }
+
+ private void OnAsyncReady (IAsyncResult ar)
+ {
+ if (ar.CompletedSynchronously)
+ return;
+
+ Exception error = null;
+
+ try {
+ // Invoke end handler
+ _end(ar);
+ } catch (Exception exc) {
+ // Flow this error to the next state (handle during state execution)
+ error = exc;
+ }
+
+ _app._state.ExecuteNextAsync (error);
+ }
+ }
+
+ class AsyncEvents
+ {
+ ArrayList _events;
+ class EventRecord {
+ public EventRecord(BeginEventHandler beg, EndEventHandler end)
+ {
+ Begin = beg;
+ End = end;
+ }
+
+ public BeginEventHandler Begin;
+ public EndEventHandler End;
+ }
+
+ public AsyncEvents ()
+ {
+ _events = new ArrayList ();
+ }
+
+ public void Add (BeginEventHandler begin, EndEventHandler end)
+ {
+ _events.Add (new EventRecord (begin, end));
+ }
+
+ public void GetAsStates (HttpApplication app, ArrayList states)
+ {
+ foreach (object obj in _events)
+ states.Add (new AsyncEventState (app,
+ ((EventRecord) obj).Begin,
+ ((EventRecord) obj).End));
+ }
+ }
+
+
+ class ExecuteHandlerState : IStateHandler
+ {
+ HttpApplication _app;
+ AsyncCallback _callback;
+ IHttpAsyncHandler _handler;
+ bool _async;
+
+ public ExecuteHandlerState (HttpApplication app)
+ {
+ _app = app;
+ _callback = new AsyncCallback (OnAsyncReady);
+ }
+
+ private void OnAsyncReady (IAsyncResult ar)
+ {
+ if (ar.CompletedSynchronously)
+ return;
+
+ Exception error = null;
+
+ try {
+ // Invoke end handler
+ _handler.EndProcessRequest(ar);
+ } catch (Exception exc) {
+ // Flow this error to the next state (handle during state execution)
+ error = exc;
+ }
+
+ _handler = null;
+ _app._state.ExecuteNextAsync (error);
+ }
+
+ public void Execute ()
+ {
+ IHttpHandler handler = _app.Context.Handler;
+ if (handler == null)
+ return;
+
+ // Check if we can execute async
+ if (handler is IHttpAsyncHandler) {
+ _async = true;
+ _handler = (IHttpAsyncHandler) handler;
+
+ IAsyncResult ar = _handler.BeginProcessRequest (_app.Context,
+ _callback,
+ null);
+
+ if (ar.CompletedSynchronously) {
+ _async = false;
+ _handler = null;
+ ((IHttpAsyncHandler) handler).EndProcessRequest (ar);
+ }
+ } else {
+ _async = false;
+
+ // Sync handler
+ handler.ProcessRequest (_app.Context);
+ }
+ }
+
+ public bool CompletedSynchronously {
+ get { return !_async; }
+ }
+
+ public bool PossibleToTimeout {
+ get {
+ if (_app.Context.Handler is IHttpAsyncHandler)
+ return false;
+
+ return true;
+ }
+ }
+ }
+
+ class CreateHandlerState : IStateHandler
+ {
+ HttpApplication _app;
+
+ public CreateHandlerState (HttpApplication app)
+ {
+ _app = app;
+ }
+
+ public void Execute ()
+ {
+ _app.Context.Handler = _app.CreateHttpHandler ( _app.Context,
+ _app.Request.RequestType,
+ _app.Request.FilePath,
+ _app.Request.PhysicalPath);
+ }
+
+ public bool CompletedSynchronously {
+ get { return true; }
+ }
+
+ public bool PossibleToTimeout {
+ get { return false; }
+ }
+ }
+
+ class FilterHandlerState : IStateHandler
+ {
+ HttpApplication _app;
+
+ public FilterHandlerState (HttpApplication app)
+ {
+ _app = app;
+ }
+
+ public void Execute ()
+ {
+ _app.Context.Response.DoFilter ();
+ }
+
+ public bool CompletedSynchronously {
+ get { return true; }
+ }
+
+ public bool PossibleToTimeout {
+ get { return true; }
+ }
+ }
+
+ class StateMachine
+ {
+ HttpApplication _app;
+ WaitCallback _asynchandler;
+
+ IStateHandler [] _handlers;
+ int _currentStateIdx;
+ int _endStateIdx;
+ int _countSteps;
+ int _countSyncSteps;
+
+ // Helper to create the states for a normal event
+ private void GetAsStates (object Event, ArrayList states)
+ {
+ // Get list of clients for the sync events
+ Delegate evnt = _app.Events [Event];
+ if (evnt == null)
+ return;
+
+ System.Delegate [] clients = evnt.GetInvocationList();
+ foreach (Delegate client in clients)
+ states.Add (new EventState (_app, (EventHandler) client));
+ }
+
+ internal StateMachine (HttpApplication app)
+ {
+ _app = app;
+ }
+
+ internal void Init ()
+ {
+ _asynchandler = new WaitCallback (OnAsyncCallback);
+
+ // Create a arraylist of states to execute
+ ArrayList states = new ArrayList ();
+
+ // BeginRequest
+ if (null != _app._beginRequestAsync)
+ _app._beginRequestAsync.GetAsStates (_app, states);
+ GetAsStates (HttpApplication.BeginRequestId, states);
+
+ // AuthenticateRequest
+ if (null != _app._authenticateRequestAsync)
+ _app._authenticateRequestAsync.GetAsStates (_app, states);
+ GetAsStates (HttpApplication.AuthenticateRequestId, states);
+
+ // DefaultAuthentication
+ EventHandler defaultAuthHandler = (EventHandler) _app.Events [HttpApplication.DefaultAuthenticationId];
+ states.Add (new EventState (_app, defaultAuthHandler));
+
+ // AuthorizeRequest
+ if (null != _app._authorizeRequestAsync)
+ _app._authorizeRequestAsync.GetAsStates (_app, states);
+ GetAsStates (HttpApplication.AuthorizeRequestId, states);
+
+ // ResolveRequestCache
+ if (null != _app._resolveRequestCacheAsync)
+ _app._resolveRequestCacheAsync.GetAsStates (_app, states);
+ GetAsStates (HttpApplication.ResolveRequestCacheId, states);
+
+ // [A handler (a page corresponding to the request URL) is created at this point.]
+ states.Add (new CreateHandlerState (_app));
+
+ // AcquireRequestState
+ if (null != _app._acquireRequestStateAsync)
+ _app._acquireRequestStateAsync.GetAsStates (_app, states);
+ GetAsStates (HttpApplication.AcquireRequestStateId, states);
+
+ // PreRequestHandlerExecute
+ if (null != _app._preRequestHandlerExecuteAsync)
+ _app._preRequestHandlerExecuteAsync.GetAsStates (_app, states);
+ GetAsStates (HttpApplication.PreRequestHandlerExecuteId, states);
+
+ // [The handler is executed.]
+ states.Add (new ExecuteHandlerState (_app));
+
+ // PostRequestHandlerExecute
+ if (null != _app._postRequestHandlerExecuteAsync)
+ _app._postRequestHandlerExecuteAsync.GetAsStates (_app, states);
+ GetAsStates (HttpApplication.PostRequestHandlerExecuteId, states);
+
+ // ReleaseRequestState
+ if (null != _app._releaseRequestStateAsync)
+ _app._releaseRequestStateAsync.GetAsStates (_app, states);
+ GetAsStates (HttpApplication.ReleaseRequestStateId, states);
+
+ // [Response filters, if any, filter the output.]
+ states.Add (new FilterHandlerState (_app));
+
+ // UpdateRequestCache
+ if (null != _app._updateRequestCacheAsync)
+ _app._updateRequestCacheAsync.GetAsStates (_app, states);
+ GetAsStates (HttpApplication.UpdateRequestCacheId, states);
+
+ // EndRequest
+ if (null != _app._updateRequestCacheAsync)
+ _app._updateRequestCacheAsync.GetAsStates (_app, states);
+ GetAsStates (HttpApplication.EndRequestId, states);
+
+ // Make list ready to execute
+ _handlers = new IStateHandler [states.Count];
+ states.CopyTo (_handlers);
+ }
+
+
+ internal void Reset ()
+ {
+ _countSyncSteps = 0;
+ _countSteps = 0;
+ _currentStateIdx = -1;
+ _endStateIdx = _handlers.Length - 1;
+ }
+
+ internal void Start ()
+ {
+ Reset ();
+ ExecuteNextAsync (null);
+ }
+
+ internal void ExecuteNextAsync (Exception lasterror)
+ {
+ if (!Thread.CurrentThread.IsThreadPoolThread)
+ ThreadPool.QueueUserWorkItem (_asynchandler, lasterror);
+ else
+ ExecuteNext (lasterror);
+ }
+
+ internal void ExecuteNext (Exception lasterror)
+ {
+ bool ready_sync = false;
+ IStateHandler handler;
+
+ lock (_app) {
+ _app.OnStateExecuteEnter ();
+ try {
+ do {
+ if (null != lasterror) {
+ _app.HandleError (lasterror);
+ lasterror = null;
+ }
+
+ // Check if request flow is to be stopped
+ if (_app._CompleteRequest)
+ _currentStateIdx = _endStateIdx;
+
+ // Get next state handler
+ if (_currentStateIdx < _endStateIdx) {
+ _currentStateIdx++;
+ handler = _handlers [_currentStateIdx];
+
+ _countSteps++;
+ lasterror = ExecuteState (handler,
+ ref ready_sync);
+
+ if (ready_sync)
+ _countSyncSteps++;
+ }
+ } while (ready_sync && _currentStateIdx < _endStateIdx);
+ } finally {
+ _app.OnStateExecuteLeave ();
+ }
+ }
+
+ // Finish the request off..
+ if (_currentStateIdx == _endStateIdx) {
+ _app._asyncWebResult.Complete ((_countSyncSteps == _countSteps),
+ null,
+ null);
+
+ _app.Context.Handler = null;
+ _app.Context.ApplicationInstance = null;
+ _app.RecycleHandlers ();
+ _app._asyncWebResult = null;
+
+ HttpApplicationFactory.RecycleInstance (_app);
+ }
+ }
+
+ private void OnAsyncCallback (object obj)
+ {
+ ExecuteNext ((Exception) obj);
+ }
+
+ [MonoTODO()]
+ private Exception ExecuteState (IStateHandler state, ref bool readysync)
+ {
+ Exception lasterror = null;
+ try {
+
+ if (state.PossibleToTimeout) {
+ // TODO: Start timeout possible
+ try {
+ state.Execute ();
+ } finally {
+ // TODO: end timeout possible
+ }
+
+ // Check if we have a timeout and wait for the exception.
+ } else {
+ state.Execute ();
+ }
+
+ if (state.CompletedSynchronously)
+ readysync = true;
+ else
+ readysync = false;
+
+ } catch (ThreadAbortException obj) {
+ obj = obj;
+ // TODO!
+ // handle request timeout and return timeout httpexception
+ } catch (Exception obj) {
+ lasterror = obj;
+ }
+
+ return lasterror;
+ }
+ }
+
+#endregion
+
+#region Fields
+
+ StateMachine _state;
+
+ bool _CompleteRequest;
+ HttpContext _Context;
+ Exception _lastError;
+
+ HttpContext _savedContext;
+ IPrincipal _savedUser;
+ HttpAsyncResult _asyncWebResult;
+
+ ISite _Site;
+ HttpModuleCollection _ModuleCollection;
+ HttpSessionState _Session;
+ HttpApplicationState _appState;
+
+ bool _InPreRequestResponseMode;
+#endregion
+
+#region Constructor
+
+ public HttpApplication ()
+ {
+ }
+
+#endregion
+
+#region Methods
+ private IHttpHandler CreateHttpHandler (HttpContext context,
+ string type,
+ string file,
+ string path)
+ {
+ HandlerFactoryConfiguration handler =
+ HttpContext.GetAppConfig ("system.web/httpHandlers")
+ as HandlerFactoryConfiguration;
+
+ if (handler == null)
+ throw new HttpException ("Cannot get system.web/httpHandlers handler.");
+
+ object result = handler.FindHandler (type, path).Create ();
+ if (result is IHttpHandler)
+ return (IHttpHandler) result;
+
+ if (result is IHttpHandlerFactory) {
+ IHttpHandlerFactory factory = (IHttpHandlerFactory) result;
+ return factory.GetHandler (context, type, file, path);
+ }
+
+ return null;
+ }
+
+ [MonoTODO()]
+ internal void RecycleHandlers ()
+ {
+ // TODO: Recycle the created handlers (via factory?)
+ }
+
+ internal void InitModules ()
+ {
+ ModulesConfiguration modules;
+
+ modules = (ModulesConfiguration) HttpContext.GetAppConfig ("system.web/httpModules");
+ if (null == modules)
+ throw new HttpException (
+ HttpRuntime.FormatResourceString ("missing_modules_config"));
+
+ _ModuleCollection = modules.CreateCollection ();
+ if (_ModuleCollection == null)
+ return;
+
+ int pos, count;
+
+ count = _ModuleCollection.Count;
+ for (pos = 0; pos != count; pos++)
+ ((IHttpModule) _ModuleCollection.Get (pos)).Init (this);
+ }
+
+ internal void InitCulture ()
+ {
+ // TODO: Read culture info from globalization from config
+ }
+
+ internal void OnStateExecuteEnter ()
+ {
+ // TODO: Set correct culture for the thread
+ // TODO: Register in timeout manager
+
+ _savedContext = HttpContext.Context;
+ HttpContext.Context = _Context;
+
+ _savedUser = Thread.CurrentPrincipal;
+ Thread.CurrentPrincipal = Context.User;
+ }
+
+ internal void OnStateExecuteLeave ()
+ {
+ // TODO: Restore culture for the thread
+ // TODO: Remove from timeout manager
+
+ HttpContext.Context = _savedContext;
+ if (null != _savedUser) {
+ Thread.CurrentPrincipal = _savedUser;
+ _savedUser = null;
+ }
+ }
+
+ internal void ClearError ()
+ {
+ _lastError = null;
+ }
+
+ internal void HandleError (Exception obj)
+ {
+ EventHandler handler;
+ bool fire = true;
+
+ if (null != _Context) {
+ if (null != _Context.Error)
+ fire = false;
+
+ _Context.AddError (obj);
+ } else {
+ if (null != _lastError)
+ fire = false;
+
+ _lastError = obj;
+ }
+
+ if (!fire)
+ return;
+
+ // Fire OnError event here
+ handler = (EventHandler) Events [HttpApplication.ErrorId];
+ if (null != handler) {
+ try {
+ handler (this, EventArgs.Empty);
+ } catch (Exception excp) {
+ if (null != _Context)
+ _Context.AddError (excp);
+ }
+ }
+ }
+
+ [MonoTODO]
+ internal void Startup (HttpContext context, HttpApplicationState state)
+ {
+ // TODO: Need to attach methods in global.asax to correct events
+ _Context = context;
+
+ _appState = state;
+ _state = new StateMachine (this);
+
+ // Initialize all IHttpModule(s)
+ InitModules ();
+ HttpApplicationFactory.AttachEvents (this);
+
+ // Initialize custom application
+ _InPreRequestResponseMode = true;
+ try {
+ Init ();
+ } catch (Exception obj) {
+ HandleError (obj);
+ }
+
+ _InPreRequestResponseMode = false;
+
+ _state.Init ();
+ }
+
+ internal void Cleanup ()
+ {
+ try {
+ Dispose ();
+ } catch (Exception obj) {
+ HandleError (obj);
+ }
+
+ if (null != _ModuleCollection) {
+ int pos;
+ int count = _ModuleCollection.Count;
+
+ for (pos = 0; pos != count; pos++)
+ ((IHttpModule) _ModuleCollection.Get (pos)).Dispose ();
+
+ _ModuleCollection = null;
+ }
+
+ _state = null;
+ }
+
+ public void CompleteRequest ()
+ {
+ _CompleteRequest = true;
+ }
+
+ public virtual void Dispose ()
+ {
+ _Site = null;
+ EventHandler disposed = (EventHandler) Events [HttpApplication.DisposedId];
+ if (null != disposed)
+ disposed (this, EventArgs.Empty);
+ }
+
+ public virtual void Init ()
+ {
+ }
+
+ public virtual string GetVaryByCustomString (HttpContext context, string custom)
+ {
+ if (custom.ToLower () == "browser")
+ return context.Request.Browser.Type;
+
+ return null;
+ }
+
+ IAsyncResult IHttpAsyncHandler.BeginProcessRequest (HttpContext context,
+ AsyncCallback cb,
+ object extraData)
+ {
+ _Context = context;
+ Context.ApplicationInstance = this;
+ _CompleteRequest = false;
+
+ _asyncWebResult = new HttpAsyncResult (cb, extraData);
+
+ _state.Reset ();
+ _state.ExecuteNext (null);
+
+ return _asyncWebResult;
+ }
+
+ void IHttpAsyncHandler.EndProcessRequest (IAsyncResult result)
+ {
+ HttpAsyncResult ar = (HttpAsyncResult) result;
+
+ if (null != ar.Error)
+ throw ar.Error;
+ }
+
+ void IHttpHandler.ProcessRequest (HttpContext context)
+ {
+ throw new NotSupportedException (HttpRuntime.FormatResourceString("sync_not_supported"));
+ }
+
+ bool IHttpHandler.IsReusable {
+ get { return true; }
+ }
+#endregion
+
+#region Properties
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public HttpApplicationState Application {
+ get { return HttpApplicationFactory.ApplicationState; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public HttpContext Context {
+ get { return _Context; }
+ }
+
+ protected EventHandlerList Events {
+ get {
+ if (null == _Events)
+ _Events = new EventHandlerList ();
+
+ return _Events;
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public HttpModuleCollection Modules {
+ get {
+ if (null == _ModuleCollection)
+ _ModuleCollection = new HttpModuleCollection ();
+
+ return _ModuleCollection;
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public HttpRequest Request {
+ get {
+ if (null != _Context && (!_InPreRequestResponseMode))
+ return _Context.Request;
+
+ throw new HttpException ("Can't get request object");
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public HttpResponse Response {
+ get {
+ if (null != _Context && (!_InPreRequestResponseMode))
+ return _Context.Response;
+
+ throw new HttpException ("Can't get response object");
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public HttpServerUtility Server {
+ get {
+ if (null != _Context)
+ return _Context.Server;
+
+ return new HttpServerUtility (this);
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public HttpSessionState Session {
+ get {
+ if (null != _Session)
+ return _Session;
+
+ if (null != _Context && null != _Context.Session)
+ return _Context.Session;
+
+ throw new HttpException ("Failed to get session object");
+ }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public IPrincipal User {
+ get { return _Context.User; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public ISite Site {
+ get { return _Site; }
+ set { _Site = value; }
+ }
+#endregion Properties
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs b/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
new file mode 100644
index 00000000000..c290aae5789
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs
@@ -0,0 +1,321 @@
+//
+// System.Web.HttpApplicationFactory
+//
+// Author:
+// Patrik Torstensson (ptorsten@hotmail.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Web;
+using System.Web.Compilation;
+using System.Web.SessionState;
+
+namespace System.Web {
+ /// <summary>
+ /// TODO: We need to compile the global.asax into a type inherited from HttpApplication
+ /// </summary>
+ [MonoTODO]
+ class HttpApplicationFactory {
+ private string _appFilename;
+ private Type _appType;
+
+ private bool _appInitialized;
+ private bool _appFiredEnd;
+
+ private Stack _appFreePublicList;
+ private int _appFreePublicInstances;
+ static private int _appMaxFreePublicInstances = 32;
+
+ private HttpApplicationState _state;
+ static Hashtable appEventNames;
+
+ static IHttpHandler custApplication;
+
+ static private HttpApplicationFactory s_Factory = new HttpApplicationFactory();
+
+ static HttpApplicationFactory ()
+ {
+ appEventNames = new Hashtable ();
+ appEventNames.Add ("Application_BeginRequest", null);
+ appEventNames.Add ("Application_AuthenticateRequest", null);
+ appEventNames.Add ("Application_AuthorizeRequest", null);
+ appEventNames.Add ("Application_ResolveRequestCache", null);
+ appEventNames.Add ("Application_AcquireRequestState", null);
+ appEventNames.Add ("Application_PreRequestHandlerExecute", null);
+ appEventNames.Add ("Application_PostRequestHandlerExecute", null);
+ appEventNames.Add ("Application_ReleaseRequestState", null);
+ appEventNames.Add ("Application_UpdateRequestCache", null);
+ appEventNames.Add ("Application_EndRequest", null);
+ appEventNames.Add ("Application_PreSendRequestHeaders", null);
+ appEventNames.Add ("Application_PreSendRequestContent", null);
+ appEventNames.Add ("Application_Disposed", null);
+ appEventNames.Add ("Application_Error", null);
+ }
+
+ public HttpApplicationFactory() {
+ _appInitialized = false;
+ _appFiredEnd = false;
+
+ _appFreePublicList = new Stack();
+ _appFreePublicInstances = 0;
+ }
+
+ static private string GetAppFilename(HttpContext context) {
+ return Path.Combine(context.Request.PhysicalApplicationPath, "global.asax");
+ }
+
+ private void CompileApp(HttpContext context) {
+ if (File.Exists(_appFilename)) {
+ // Setup filemonitor for all filedepend also. CacheDependency?
+
+ _appType = GlobalAsaxCompiler.CompileApplicationType (_appFilename, context);
+ if (_appType == null)
+ throw new ApplicationException ("Error compiling application file (global.asax).");
+ } else {
+ _appType = typeof (System.Web.HttpApplication);
+ _state = new HttpApplicationState ();
+ }
+ }
+
+ static bool IsEventHandler (MethodInfo m)
+ {
+ if (m.ReturnType != typeof (void))
+ return false;
+
+ ParameterInfo [] pi = m.GetParameters ();
+ if (pi.Length != 2)
+ return false;
+
+ if (pi [0].ParameterType != typeof (object) ||
+ pi [1].ParameterType != typeof (EventArgs))
+ return false;
+
+ return appEventNames.ContainsKey (m.Name);
+ }
+
+ static void AddEvent (MethodInfo method, Hashtable appTypeEventHandlers)
+ {
+ string name = method.Name;
+ ArrayList list;
+ list = appTypeEventHandlers [name] as ArrayList;
+ if (list == null) {
+ list = new ArrayList ();
+ appTypeEventHandlers [name] = list;
+ }
+ list.Add (method);
+ }
+
+ static Hashtable GetApplicationTypeEvents (HttpApplication app)
+ {
+ Type appType = app.GetType ();
+ Hashtable appTypeEventHandlers = new Hashtable ();
+ ArrayList evtMethods = new ArrayList ();
+ BindingFlags flags = BindingFlags.Public |
+ BindingFlags.NonPublic |
+ BindingFlags.DeclaredOnly |
+ BindingFlags.Instance |
+ BindingFlags.Static;
+
+ MethodInfo [] methods = appType.GetMethods (flags);
+ foreach (MethodInfo m in methods) {
+ if (IsEventHandler (m))
+ AddEvent (m, appTypeEventHandlers);
+ }
+
+ Type baseType = appType.BaseType;
+ if (baseType == typeof (HttpApplication))
+ return appTypeEventHandlers;
+
+ flags = BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
+
+ methods = appType.GetMethods (flags);
+ foreach (MethodInfo m in methods) {
+ if (IsEventHandler (m))
+ AddEvent (m, appTypeEventHandlers);
+ }
+
+ return appTypeEventHandlers;
+ }
+
+ void FireEvents (string method_name, object state_context, object [] args)
+ {
+ /*
+ if (methods == null || methods.Count == 0)
+ return;
+
+ foreach (MethodInfo method in methods)
+ method.Invoke (this, args);
+ */
+ }
+
+ void FireOnAppStart (HttpContext context)
+ {
+ FireEvents ("Application_OnStart", context, new object [] {this, EventArgs.Empty});
+ }
+
+ void FireOnAppEnd ()
+ {
+ FireEvents ("Application_OnEnd", null, new object [] {this, EventArgs.Empty});
+ }
+
+ void FireOnSessionStart (HttpSessionState state, object source, EventArgs args)
+ {
+ FireEvents ("Session_OnStart", state, new object [] {source, args});
+ }
+
+ void FireOnSessionEnd (HttpSessionState state, object source, EventArgs args)
+ {
+ FireEvents ("Session_OnEnd", state, new object [] {source, args});
+ }
+
+ private void InitializeFactory(HttpContext context) {
+ // TODO: Should we be impersonating here? We are reading a app file.. security issue?
+
+ _appFilename = GetAppFilename(context);
+
+ CompileApp(context);
+ FireOnAppStart(context);
+ }
+
+ private void Dispose() {
+ ArrayList torelease = new ArrayList();
+ lock (_appFreePublicList) {
+ do {
+ torelease.Add(_appFreePublicList.Pop());
+ } while (_appFreePublicList.Count > 0);
+ }
+
+ if (torelease.Count > 0) {
+ foreach (Object obj in torelease) {
+ ((HttpApplication) obj).Cleanup();
+ }
+ }
+
+ if (!_appFiredEnd) {
+ lock (this) {
+ if (!_appFiredEnd) {
+ FireOnAppEnd();
+ _appFiredEnd = true;
+ }
+ }
+ }
+ }
+
+ internal static IHttpHandler GetInstance(HttpContext context)
+ {
+ if (custApplication != null)
+ return custApplication;
+
+ if (!s_Factory._appInitialized) {
+ lock (s_Factory) {
+ if (!s_Factory._appInitialized) {
+ s_Factory.InitializeFactory(context);
+ s_Factory._appInitialized = true;
+ }
+ }
+ }
+
+ return s_Factory.GetPublicInstance(context);
+ }
+
+ internal static void RecycleInstance(HttpApplication app) {
+ if (!s_Factory._appInitialized)
+ throw new InvalidOperationException("Factory not intialized");
+
+ s_Factory.RecyclePublicInstance(app);
+ }
+
+ internal static void AttachEvents (HttpApplication app)
+ {
+ Type appType = app.GetType ();
+ Hashtable appTypeEventHandlers = GetApplicationTypeEvents (app);
+ foreach (string key in appTypeEventHandlers.Keys) {
+ if (key == "Application_OnStart" || key == "Application_OnEnd" ||
+ key == "Session_OnStart" || key == "Session_OnEnd")
+ continue;
+
+ int pos = key.IndexOf ('_');
+ if (pos == -1 || key.Length <= pos + 1)
+ continue;
+
+ EventInfo evt = appType.GetEvent (key.Substring (pos + 1));
+ if (evt == null)
+ continue;
+
+ ArrayList list = appTypeEventHandlers [key] as ArrayList;
+ if (list == null || list.Count == 0)
+ continue;
+
+ foreach (MethodInfo method in list)
+ evt.AddEventHandler (app, Delegate.CreateDelegate (typeof (EventHandler), method));
+ }
+ }
+
+ private IHttpHandler GetPublicInstance(HttpContext context) {
+ HttpApplication app = null;
+
+ lock (_appFreePublicList) {
+ if (_appFreePublicInstances > 0) {
+ app = (HttpApplication) _appFreePublicList.Pop();
+ _appFreePublicInstances--;
+ }
+ }
+
+ if (app == null) {
+ // Create non-public object
+ app = (HttpApplication) HttpRuntime.CreateInternalObject(_appType);
+
+ app.Startup(context, HttpApplicationFactory.ApplicationState);
+ }
+
+ return (IHttpHandler) app;
+ }
+
+ internal void RecyclePublicInstance(HttpApplication app) {
+ lock (_appFreePublicList) {
+ if (_appFreePublicInstances < _appMaxFreePublicInstances) {
+ _appFreePublicList.Push(app);
+ _appFreePublicInstances++;
+
+ app = null;
+ }
+ }
+
+ if (app != null) {
+ app.Cleanup();
+ }
+ }
+
+ static internal HttpApplicationState ApplicationState {
+ get {
+ if (null == s_Factory._state) {
+ s_Factory._state = new HttpApplicationState();
+ }
+
+ return s_Factory._state;
+ }
+ }
+
+ internal static void EndApplication() {
+ s_Factory.Dispose();
+ }
+
+ internal static void StartSession(HttpSessionState state, object source, EventArgs args) {
+ s_Factory.FireOnSessionStart(state, source, args);
+ }
+
+ static void EndSession(HttpSessionState state, object source, EventArgs args) {
+ s_Factory.FireOnSessionEnd(state, source, args);
+ }
+
+ public static void SetCustomApplication (IHttpHandler customApplication)
+ {
+ custApplication = customApplication;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpApplicationState.cs b/mcs/class/System.Web/System.Web/HttpApplicationState.cs
new file mode 100644
index 00000000000..6131f07c776
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpApplicationState.cs
@@ -0,0 +1,232 @@
+//
+// System.Web.HttpApplicationState
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Threading;
+using System.Web;
+using System.Collections.Specialized;
+
+namespace System.Web {
+
+ [MonoTODO("Performance - Use SWMR lock here")]
+ public sealed class HttpApplicationState : NameObjectCollectionBase {
+ private HttpStaticObjectsCollection _AppObjects;
+ private HttpStaticObjectsCollection _SessionObjects;
+
+ // TODO : Change to ReadWriteLock when ready
+ private Mutex _Lock;
+
+ private void LockRead() {
+ Monitor.Enter(this);
+ }
+
+ private void LockWrite() {
+ Monitor.Enter(this);
+ }
+
+ private void UnlockRead() {
+ Monitor.Exit(this);
+ }
+
+ private void UnlockWrite() {
+ Monitor.Exit(this);
+ }
+
+ internal HttpApplicationState() {
+ _AppObjects = new HttpStaticObjectsCollection();
+ _SessionObjects = new HttpStaticObjectsCollection();
+ _Lock = new Mutex();
+ }
+
+ internal HttpApplicationState(HttpStaticObjectsCollection AppObj, HttpStaticObjectsCollection SessionObj) {
+ if (null != AppObj) {
+ _AppObjects = AppObj;
+ } else {
+ _AppObjects = new HttpStaticObjectsCollection();
+ }
+
+ if (null != SessionObj) {
+ _SessionObjects = SessionObj;
+ } else {
+ _SessionObjects = new HttpStaticObjectsCollection();
+ }
+ _Lock = new Mutex();
+ }
+
+ public void Add(string name, object value) {
+
+ LockWrite();
+ try {
+ BaseAdd(name, value);
+ }
+ finally {
+ UnlockWrite();
+ }
+ }
+
+ public void Clear() {
+
+ LockWrite();
+ try {
+ BaseClear();
+ }
+ finally {
+ UnlockWrite();
+ }
+ }
+
+ public object Get(string name) {
+ object ret = null;
+
+ LockRead();
+ try {
+ ret = BaseGet(name);
+ }
+ finally {
+ UnlockRead();
+ }
+
+ return ret;
+ }
+
+ public object Get(int index) {
+ object ret = null;
+
+ LockRead();
+ try {
+ ret = BaseGet(index);
+ }
+ finally {
+ UnlockRead();
+ }
+
+ return ret;
+ }
+
+ public string GetKey(int index) {
+ string ret = null;
+
+ LockRead();
+ try {
+ ret = BaseGetKey(index);
+ }
+ finally {
+ UnlockRead();
+ }
+
+ return ret;
+ }
+
+ public void Lock() {
+ LockWrite();
+ }
+
+ public void Remove(string name) {
+ LockWrite();
+ try {
+ BaseRemove(name);
+ }
+ finally {
+ UnlockWrite();
+ }
+ }
+
+ public void RemoveAll() {
+ Clear();
+ }
+
+ public void RemoveAt(int index) {
+ LockWrite();
+ try {
+ BaseRemoveAt(index);
+ }
+ finally {
+ UnlockWrite();
+ }
+ }
+
+ public void Set(string name, object value) {
+ LockWrite();
+ try {
+ BaseSet(name, value);
+ }
+ finally {
+ UnlockWrite();
+ }
+ }
+
+ public void UnLock() {
+ UnlockWrite();
+ }
+
+ public string [] AllKeys {
+ get {
+ string [] ret = null;
+
+ LockRead();
+ try {
+ ret = BaseGetAllKeys();
+ }
+ finally {
+ UnlockRead();
+ }
+
+ return ret;
+ }
+ }
+
+ public HttpApplicationState Contents {
+ get {
+ return this;
+ }
+ }
+
+ override public int Count {
+ get {
+ int ret = 0;
+
+ LockRead();
+ try {
+ ret = base.Count;
+ }
+ finally {
+ UnlockRead();
+ }
+
+ return ret;
+ }
+ }
+
+ public object this[string name] {
+ get {
+ return Get(name);
+ }
+ set {
+ Set(name, value);
+ }
+ }
+
+ public object this[int index] {
+ get {
+ return Get(index);
+ }
+ }
+
+ // ASP Session based objects
+ internal HttpStaticObjectsCollection SessionObjects {
+ get {
+ return _SessionObjects;
+ }
+ }
+
+ // ASP App based objects
+ public HttpStaticObjectsCollection StaticObjects {
+ get {
+ return _AppObjects;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpAsyncResult.cs b/mcs/class/System.Web/System.Web/HttpAsyncResult.cs
new file mode 100644
index 00000000000..87340a616b4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpAsyncResult.cs
@@ -0,0 +1,73 @@
+//
+// System.Web.HttpAsyncResult
+//
+// Author:
+// Patrik Torstensson (ptorsten@hotmail.com)
+//
+using System;
+using System.Threading;
+
+namespace System.Web
+{
+ internal class HttpAsyncResult : IAsyncResult
+ {
+ private object _result;
+ private object _asyncState;
+ private AsyncCallback _callback;
+ private Exception _error;
+
+ private bool _ready;
+ private bool _readySync;
+
+ internal HttpAsyncResult(AsyncCallback callback, object state) {
+ _callback = callback;
+ _asyncState = state;
+ }
+
+ internal void Complete(bool sync, object result, Exception error) {
+ _ready = true;
+ _readySync = sync;
+ _result = result;
+ _error = error;
+ if (null != _callback) {
+ _callback(this);
+ }
+ }
+
+ internal Exception Error {
+ get {
+ return null;
+ }
+ }
+
+ public object AsyncState {
+ get {
+ return _asyncState;
+ }
+ }
+
+ public object AsyncObject {
+ get {
+ return null;
+ }
+ }
+
+ public WaitHandle AsyncWaitHandle {
+ get {
+ return null;
+ }
+ }
+
+ public bool CompletedSynchronously {
+ get {
+ return _readySync;
+ }
+ }
+
+ public bool IsCompleted {
+ get {
+ return _ready;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpBrowserCapabilities.cs b/mcs/class/System.Web/System.Web/HttpBrowserCapabilities.cs
new file mode 100755
index 00000000000..a4c095c7f6d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpBrowserCapabilities.cs
@@ -0,0 +1,143 @@
+//
+// System.Web.HttpBrowserCapabilities
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+using System;
+using System.Web.Configuration;
+
+namespace System.Web {
+public class HttpBrowserCapabilities : HttpCapabilitiesBase
+{
+ public HttpBrowserCapabilities()
+ {
+ }
+
+ public bool ActiveXControls {
+ get { return false; }
+ }
+
+ [MonoTODO()]
+ public bool AOL {
+ get { return false; }
+ }
+
+ [MonoTODO()]
+ public bool BackgroundSounds {
+ get { return false; }
+ }
+
+ [MonoTODO()]
+ public bool Beta {
+ get { return false; }
+ }
+
+ [MonoTODO()]
+ public string Browser {
+ get { return "Not Implemented"; }
+ }
+
+ [MonoTODO()]
+ public bool CDF {
+ get { return false; }
+ }
+
+ [MonoTODO()]
+ public Version ClrVersion {
+ get { return new Version (0, 0); }
+ }
+
+ [MonoTODO()]
+ public bool Cookies {
+ get { return true; }
+ }
+
+ [MonoTODO()]
+ public bool Crawler {
+ get { return false; }
+ }
+
+ [MonoTODO()]
+ public Version EcmaScriptVersion {
+ get { return new Version (0, 0); }
+ }
+
+ [MonoTODO()]
+ public bool Frames {
+ get { return true; }
+ }
+
+ [MonoTODO()]
+ public bool JavaApplets {
+ get { return false; }
+ }
+
+ [MonoTODO()]
+ public bool JavaScript {
+ get { return true; }
+ }
+
+ [MonoTODO()]
+ public int MajorVersion {
+ get { return 0; }
+ }
+
+ [MonoTODO()]
+ public double MinorVersion {
+ get { return 0.0; }
+ }
+
+ [MonoTODO()]
+ public Version MSDomVersion {
+ get { return new Version (0, 0); }
+ }
+
+ [MonoTODO()]
+ public string Platform {
+ get { return "mono::"; }
+ }
+
+ [MonoTODO()]
+ public bool Tables {
+ get { return true; }
+ }
+
+ [MonoTODO()]
+ public Type TagWriter {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO()]
+ public string Type {
+ get { return "4"; }
+ }
+
+ [MonoTODO()]
+ public bool VBScript {
+ get { return false; }
+ }
+
+ [MonoTODO()]
+ public string Version {
+ get { return "4.0"; }
+ }
+
+ [MonoTODO()]
+ public Version W3CDomVersion {
+ get { return new Version (0, 0); }
+ }
+
+ [MonoTODO()]
+ public bool Win16 {
+ get { return false; }
+ }
+
+ [MonoTODO()]
+ public bool Win32 {
+ get { return true; }
+ }
+
+}
+}
diff --git a/mcs/class/System.Web/System.Web/HttpCachePolicy.cs b/mcs/class/System.Web/System.Web/HttpCachePolicy.cs
new file mode 100644
index 00000000000..d3a6cf445cb
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpCachePolicy.cs
@@ -0,0 +1,148 @@
+//
+// System.Web.HttpCachePolicy
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Tim Coleman (tim@timcoleman.com)
+//
+using System;
+
+namespace System.Web {
+ public sealed class HttpCachePolicy {
+
+ internal HttpCachePolicy ()
+ {
+ }
+
+ #region Fields
+
+ HttpCacheVaryByHeaders varyByHeaders;
+ HttpCacheVaryByParams varyByParams;
+
+ #endregion
+
+ #region Properties
+
+ public HttpCacheVaryByHeaders VaryByHeaders {
+ get { return varyByHeaders; }
+ }
+
+ public HttpCacheVaryByParams VaryByParams {
+ get { return varyByParams; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void AddValidationCallback (HttpCacheValidateHandler handler, object data)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void AppendCacheExtension (string extension)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetCacheability (HttpCacheability cacheability)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetCacheability (HttpCacheability cacheability, string field)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetETag (string etag)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetETagFromFileDependencies ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetExpires (DateTime date)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetLastModified (DateTime date)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetLastModifiedFromFileDependencies ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetMaxAge (TimeSpan date)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetNoServerCaching ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetNoStore ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetNoTransforms ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetProxyMaxAge (TimeSpan delta)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetRevalidation (HttpCacheRevalidation revalidation)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetSlidingExpiration (bool slide)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetValidUntilExpires (bool validUntilExpires)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetVaryByCustom (string custom)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpCacheRevalidation.cs b/mcs/class/System.Web/System.Web/HttpCacheRevalidation.cs
new file mode 100644
index 00000000000..dfe83e605b1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpCacheRevalidation.cs
@@ -0,0 +1,17 @@
+//
+// System.Web.HttpCacheRevalidation.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+namespace System.Web {
+ [Serializable]
+ public enum HttpCacheRevalidation {
+ AllCaches = 0x1,
+ ProxyCaches,
+ None,
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpCacheValidateHandler.cs b/mcs/class/System.Web/System.Web/HttpCacheValidateHandler.cs
new file mode 100644
index 00000000000..032aea39f6f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpCacheValidateHandler.cs
@@ -0,0 +1,16 @@
+//
+// System.Web.HttpCacheValidateHandler.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+namespace System.Web
+{
+ public delegate void HttpCacheValidateHandler(
+ HttpContext context,
+ object data,
+ ref HttpValidationStatus validationStatus);
+}
diff --git a/mcs/class/System.Web/System.Web/HttpCacheVaryByHeaders.cs b/mcs/class/System.Web/System.Web/HttpCacheVaryByHeaders.cs
new file mode 100644
index 00000000000..93ee07a0afe
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpCacheVaryByHeaders.cs
@@ -0,0 +1,110 @@
+//
+// System.Web.HttpCacheVaryByHeaders
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Collections;
+
+namespace System.Web {
+ public sealed class HttpCacheVaryByHeaders {
+ private Hashtable _Items;
+ private bool _Dirty;
+ private bool _Wildcard;
+
+ // TODO: We need internal methods here to communicate with CachePolicy
+
+ internal HttpCacheVaryByHeaders() {
+ }
+
+ public void VaryByUnspecifiedParameters() {
+ _Dirty = true;
+ _Wildcard = true;
+ _Items = null;
+ }
+
+ public bool AcceptTypes {
+ get {
+ return this["Accept"];
+ }
+
+ set {
+ this["Accept"] = value;
+ }
+ }
+
+ public bool this[string header] {
+ get {
+ if (null == header) {
+ throw new ArgumentNullException("header");
+ }
+
+ if (header == "*") {
+ return _Wildcard;
+ }
+
+ if (null != _Items) {
+ return _Items.ContainsKey(header);
+ }
+
+ return false;
+ }
+
+ set {
+ if (null == header) {
+ throw new ArgumentNullException("header");
+ }
+
+ if (!(value)) {
+ return;
+ }
+
+ _Dirty = true;
+
+ if (header == "*") {
+ VaryByUnspecifiedParameters();
+ return;
+ }
+
+ if (!_Wildcard) {
+ if (null == _Items) {
+ _Items = new Hashtable();
+ }
+
+ _Items[header] = true;
+ }
+ }
+ }
+
+ public bool UserAgent {
+ get {
+ return this["User-Agent"];
+ }
+
+ set {
+ this["User-Agent"] = value;
+ }
+ }
+
+ public bool UserCharSet {
+ get {
+ return this["Accept-Charset"];
+ }
+
+ set {
+ this["Accept-Charset"] = value;
+ }
+ }
+
+ public bool UserLanguage {
+ get {
+ return this["Accept-Language"];
+ }
+
+ set {
+ this["Accept-Language"] = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpCacheVaryByParams.cs b/mcs/class/System.Web/System.Web/HttpCacheVaryByParams.cs
new file mode 100644
index 00000000000..057ae081d7e
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpCacheVaryByParams.cs
@@ -0,0 +1,81 @@
+//
+// System.Web.HttpCacheVaryByParams
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Collections;
+
+namespace System.Web {
+ public sealed class HttpCacheVaryByParams {
+ private Hashtable _Items;
+ private bool _IgnoreParams;
+ private bool _Wildcard;
+ private bool _Dirty;
+
+ // TODO: We need internal methods here to communicate with CachePolicy
+
+ internal HttpCacheVaryByParams() {
+ }
+
+ public bool IgnoreParams {
+ get {
+ return _IgnoreParams;
+ }
+
+ set {
+ if (_Wildcard || null != _Items) {
+ return;
+ }
+
+ _Dirty = true;
+ _IgnoreParams = value;
+ }
+ }
+
+ public bool this[string header] {
+ get {
+ if (null == header) {
+ throw new ArgumentNullException("header");
+ }
+
+ if (header == "*") {
+ return _Wildcard;
+ }
+
+ if (null != _Items) {
+ return _Items.ContainsKey(header);
+ }
+
+ return false;
+ }
+
+ set {
+ if (null == header) {
+ throw new ArgumentNullException("header");
+ }
+
+ if (!(value)) {
+ return;
+ }
+
+ _Dirty = true;
+
+ if (header == "*") {
+ _Wildcard = true;
+ _Items = null;
+ return;
+ }
+
+ if (!_Wildcard) {
+ if (null == _Items) {
+ _Items = new Hashtable();
+ }
+
+ _Items[header] = true;
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpCacheability.cs b/mcs/class/System.Web/System.Web/HttpCacheability.cs
new file mode 100644
index 00000000000..448996473c4
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpCacheability.cs
@@ -0,0 +1,18 @@
+//
+// System.Web.HttpCacheability.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+namespace System.Web {
+ [Serializable]
+ public enum HttpCacheability {
+ NoCache = 0x1,
+ Private,
+ Server,
+ Public,
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpClientCertificate.cs b/mcs/class/System.Web/System.Web/HttpClientCertificate.cs
new file mode 100644
index 00000000000..4ffc12c0cd8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpClientCertificate.cs
@@ -0,0 +1,147 @@
+//
+// System.Web.HttpClientCertificate
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Web;
+using System.Collections.Specialized;
+
+namespace System.Web {
+ [MonoTODO()]
+ public class HttpClientCertificate : NameValueCollection {
+ private HttpContext _Context;
+ private byte [] _BinaryIssuer;
+ private int _CertEncoding;
+ private byte [] _Certificate;
+ private string _Cookie;
+ private int _Flags;
+ private string _Issuer;
+ private int _KeySize;
+ private byte [] _PublicKey;
+ private int _SecretKeySize;
+ private string _SerialNumber;
+ private string _ServerIssuer;
+ private string _ServerSubject;
+ private string _Subject;
+
+ private DateTime _ValidFrom;
+ private DateTime _ValidTo;
+
+ [MonoTODO("Decode ceritificate from Server variables.. CGI standard?")]
+ internal HttpClientCertificate(HttpContext Context) {
+ _Context = Context;
+ _Flags = 0;
+ }
+
+ public byte [] BinaryIssuer {
+ get {
+ return _BinaryIssuer;
+ }
+ }
+
+ public int CertEncoding {
+ get {
+ return _CertEncoding;
+ }
+ }
+
+ public byte [] Certificate {
+ get {
+ return _Certificate;
+ }
+ }
+
+ public string Cookie {
+ get {
+ return _Cookie;
+ }
+ }
+
+ public int Flags {
+ get {
+ return _Flags;
+ }
+ }
+
+ [MonoTODO()]
+ public bool IsPresent {
+ get {
+ return false;
+ }
+ }
+
+ public string Issuer {
+ get {
+ return _Issuer;
+ }
+ }
+
+ [MonoTODO()]
+ public bool IsValid {
+ get {
+ return false;
+ }
+ }
+
+ public int KeySize {
+ get {
+ return _KeySize;
+ }
+ }
+
+ public byte [] PublicKey {
+ get {
+ return _PublicKey;
+ }
+ }
+
+ public int SecretKeySize {
+ get {
+ return _SecretKeySize;
+ }
+ }
+
+ public string SerialNumber {
+ get {
+ return _SerialNumber;
+ }
+ }
+
+ public string ServerIssuer {
+ get {
+ return _ServerIssuer;
+ }
+ }
+
+ public string ServerSubject {
+ get {
+ return _ServerSubject;
+ }
+ }
+
+ public string Subject {
+ get {
+ return _Subject;
+ }
+ }
+
+ public DateTime ValidFrom {
+ get {
+ return _ValidFrom;
+ }
+ }
+
+ public DateTime ValidUntil {
+ get {
+ return ValidUntil;
+ }
+ }
+
+ [MonoTODO()]
+ public override string Get(string s) {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpCompileException.cs b/mcs/class/System.Web/System.Web/HttpCompileException.cs
new file mode 100644
index 00000000000..d320ea4a631
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpCompileException.cs
@@ -0,0 +1,45 @@
+//
+// System.Web.HttpCompileException.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.CodeDom.Compiler;
+
+namespace System.Web {
+ public sealed class HttpCompileException : HttpException {
+
+ #region Fields
+
+ CompilerResults results;
+ string sourceCode;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ internal HttpCompileException (CompilerResults results, string sourceCode)
+ : base ()
+ {
+ this.results = results;
+ this.sourceCode = sourceCode;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public CompilerResults Results {
+ get { return results; }
+ }
+
+ public string SourceCode {
+ get { return sourceCode; }
+ }
+
+ #endregion // Properties
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpContext.cs b/mcs/class/System.Web/System.Web/HttpContext.cs
new file mode 100644
index 00000000000..a776acd5e14
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpContext.cs
@@ -0,0 +1,299 @@
+//
+// System.Web.HttpContext
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Collections;
+using System.Configuration;
+using System.Security.Principal;
+using System.Web.Caching;
+using System.Web.Configuration;
+using System.Web.SessionState;
+using System.Threading;
+
+namespace System.Web
+{
+ public sealed class HttpContext : IServiceProvider
+ {
+ private ArrayList _arrExceptions;
+
+ private HttpResponse _oResponse;
+ private HttpRequest _oRequest;
+ private HttpServerUtility _Server;
+ private HttpApplication _oApplication;
+ private HttpWorkerRequest _oWorkerRequest;
+ private IHttpHandler _Handler;
+ private IHttpAsyncHandler _AsyncHandler;
+ private IPrincipal _User;
+
+ private bool _skipauth;
+ private Hashtable _oItems;
+ private DateTime _oTimestamp;
+
+ public HttpContext (HttpRequest Request, HttpResponse Response)
+ {
+ Context = this;
+
+ _arrExceptions = null;
+ _oItems = null;
+ _oTimestamp = DateTime.Now;
+ _oRequest = Request;
+ _oResponse = Response;
+ }
+
+ public HttpContext (HttpWorkerRequest WorkerRequest)
+ {
+ Context = this;
+
+ _arrExceptions = null;
+ _oItems = null;
+ _oTimestamp = DateTime.Now;
+ _oRequest = new HttpRequest (WorkerRequest, this);
+ _oResponse = new HttpResponse (WorkerRequest, this);
+ _oWorkerRequest = WorkerRequest;
+ }
+
+ internal HttpWorkerRequest WorkerRequest
+ {
+ get {
+ return _oWorkerRequest;
+ }
+ }
+
+ [MonoTODO("Context - Use System.Remoting.Messaging.CallContext instead of Thread storage")]
+ internal static HttpContext Context
+ {
+ get {
+ return (HttpContext) Thread.GetData (Thread.GetNamedDataSlot ("Context"));
+ }
+
+ set {
+ Thread.SetData (Thread.GetNamedDataSlot ("Context"), value);
+ }
+ }
+
+ public Exception [] AllErrors
+ {
+ get {
+ if (_arrExceptions == null || _arrExceptions.Count == 0)
+ return null;
+
+ return (Exception []) _arrExceptions.ToArray (typeof (Exception));;
+ }
+ }
+
+ public HttpApplicationState Application
+ {
+ get {
+ return HttpApplicationFactory.ApplicationState;
+ }
+ }
+
+ public HttpApplication ApplicationInstance
+ {
+ get {
+ return _oApplication;
+ }
+ set {
+ _oApplication = value;
+ }
+ }
+
+ public Cache Cache
+ {
+ get {
+ return HttpRuntime.Cache;
+ }
+ }
+
+ public static HttpContext Current
+ {
+ get {
+ return Context;
+ }
+ }
+
+ public Exception Error
+ {
+ get {
+ if (_arrExceptions == null || _arrExceptions.Count == 0)
+ return null;
+
+ return (Exception) _arrExceptions [0];
+ }
+ }
+
+ public IHttpHandler Handler
+ {
+ get {
+ return _Handler;
+ }
+
+ set {
+ _Handler = value;
+ }
+ }
+
+ internal IHttpAsyncHandler AsyncHandler
+ {
+ get {
+ return _AsyncHandler;
+ }
+
+ set {
+ _AsyncHandler = value;
+ }
+ }
+
+ [MonoTODO("bool IsCustomErrorEnabled")]
+ public bool IsCustomErrorEnabled
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO("bool IsDebuggingEnabled")]
+ public bool IsDebuggingEnabled
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public IDictionary Items
+ {
+ get {
+ if (_oItems == null)
+ _oItems = new Hashtable ();
+
+ return _oItems;
+ }
+ }
+
+ public HttpRequest Request
+ {
+ get {
+ return _oRequest;
+ }
+ }
+
+ public HttpResponse Response
+ {
+ get {
+ return _oResponse;
+ }
+ }
+
+ public HttpServerUtility Server
+ {
+ get {
+ if (null == _Server)
+ _Server = new HttpServerUtility (this);
+
+ return _Server;
+ }
+ }
+
+ public HttpSessionState Session
+ {
+ get {
+ return (HttpSessionState) Items ["sessionstate"];
+ }
+ }
+
+ public bool SkipAuthorization
+ {
+ get {
+ return _skipauth;
+ }
+
+ set {
+ _skipauth = value;
+ }
+ }
+
+ public DateTime Timestamp
+ {
+ get {
+ return _oTimestamp;
+ }
+ }
+
+ [MonoTODO("TraceContext Trace")]
+ public TraceContext Trace
+ {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ public IPrincipal User
+ {
+ get {
+ return _User;
+ }
+ set {
+ _User = value;
+ }
+ }
+
+ public void AddError (Exception errorInfo)
+ {
+ if (_arrExceptions == null)
+ _arrExceptions = new ArrayList ();
+
+ _arrExceptions.Add (errorInfo);
+ }
+
+ public void ClearError ()
+ {
+ _arrExceptions = null;
+ }
+
+ public object GetConfig (string name)
+ {
+ return ConfigurationSettings.GetConfig (name);
+ }
+
+ public static object GetAppConfig (string name)
+ {
+ return ConfigurationSettings.GetConfig (name);
+ }
+
+ object IServiceProvider.GetService (Type service)
+ {
+ if (service == typeof (HttpWorkerRequest))
+ return _oWorkerRequest;
+
+ if (service == typeof (HttpRequest))
+ return Request;
+
+ if (service == typeof (HttpResponse))
+ return Response;
+
+ if (service == typeof (HttpApplication))
+ return ApplicationInstance;
+
+ if (service == typeof (HttpApplicationState))
+ return Application;
+
+ if (service == typeof (HttpSessionState))
+ return Session;
+
+ if (service == typeof (HttpServerUtility))
+ return Server;
+
+ return null;
+ }
+
+ [MonoTODO("void RewritePath(string path)")]
+ public void RewritePath (string Path)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/HttpCookie.cs b/mcs/class/System.Web/System.Web/HttpCookie.cs
new file mode 100644
index 00000000000..507244a1976
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpCookie.cs
@@ -0,0 +1,183 @@
+//
+// System.Web.HttpCookie
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Text;
+using System.Web;
+using System.Collections.Specialized;
+
+namespace System.Web
+{
+ public sealed class HttpCookie
+ {
+ string _Name;
+ string _Value;
+ string _Domain;
+ DateTime _Expires;
+ bool _ExpiresSet;
+ string _Path;
+ bool _Secure = false;
+
+ HttpValueCollection _Values;
+
+ internal HttpCookie ()
+ {
+ _Path = "/";
+ }
+
+ public HttpCookie (string name)
+ {
+ _Path = "/";
+ _Name = name;
+ }
+
+ public HttpCookie (string name, string value)
+ {
+ _Name = name;
+ _Value = value;
+ _Path = "/";
+ }
+
+ internal HttpCookie (string name, string value, string path, DateTime expires)
+ {
+ _Name = name;
+ _Value = value;
+ _Path = path;
+ if (expires != DateTime.MinValue)
+ Expires = expires;
+ }
+
+ internal HttpResponseHeader GetCookieHeader ()
+ {
+ StringBuilder oSetCookie = new StringBuilder ();
+
+ if (null != _Name && _Name.Length > 0) {
+ oSetCookie.Append (_Name);
+ oSetCookie.Append ("=");
+ }
+
+ if (null != _Values) {
+ oSetCookie.Append (_Values.ToString (false));
+ } else if (null != _Value) {
+ oSetCookie.Append (_Value);
+ }
+
+ if (null != _Domain && _Domain.Length > 0) {
+ oSetCookie.Append ("; domain=");
+ oSetCookie.Append (_Domain);
+ }
+
+ if (null != _Path && Path.Length > 0) {
+ oSetCookie.Append ("; path=");
+ oSetCookie.Append (_Path);
+ }
+
+ if (_ExpiresSet && _Expires != DateTime.MinValue) {
+ oSetCookie.Append ("; expires=");
+ oSetCookie.Append (_Expires.ToUniversalTime ().ToString ("ddd, dd-MMM-yyyy HH':'mm':'ss '+0000'"));
+ }
+
+ if (_Secure)
+ oSetCookie.Append ("; secure");
+
+ return new HttpResponseHeader (HttpWorkerRequest.HeaderSetCookie, oSetCookie.ToString());
+ }
+
+ public string Domain
+ {
+ get { return _Domain; }
+ set { _Domain = value; }
+ }
+
+ public DateTime Expires
+ {
+ get {
+ if (!_ExpiresSet)
+ return DateTime.MinValue;
+
+ return _Expires;
+ }
+
+ set {
+ _ExpiresSet = true;
+ _Expires = value;
+ }
+ }
+
+ public bool HasKeys
+ {
+ get {
+ return Values.HasKeys ();
+ }
+ }
+
+ public string this [string key]
+ {
+ get { return Values [key]; }
+ set { Values [key] = value; }
+ }
+
+ public string Name
+ {
+ get { return _Name; }
+ set { _Name = value; }
+ }
+
+ public string Path
+ {
+ get { return _Path; }
+ set { _Path = value; }
+ }
+
+ public bool Secure
+ {
+ get { return _Secure; }
+ set { _Secure = value; }
+ }
+
+ public string Value
+ {
+ get {
+ if (null != _Values)
+ return _Values.ToString (false);
+
+ return _Value;
+ }
+
+ set {
+ if (null != _Values) {
+ _Values.Reset ();
+ _Values.Add (null, value);
+ return;
+ }
+
+ _Value = value;
+ }
+ }
+
+ public NameValueCollection Values
+ {
+ get {
+ if (null == _Values) {
+ _Values = new HttpValueCollection ();
+ if (null != _Value) {
+ // Do we have multiple keys
+ if (_Value.IndexOf ("&") >= 0 || _Value.IndexOf ("=") >= 0) {
+ _Values.FillFromCookieString (_Value);
+ } else {
+ _Values.Add (null, _Value);
+ }
+
+ _Value = null;
+ }
+ }
+
+ return _Values;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/HttpCookieCollection.cs b/mcs/class/System.Web/System.Web/HttpCookieCollection.cs
new file mode 100644
index 00000000000..e9872411813
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpCookieCollection.cs
@@ -0,0 +1,147 @@
+//
+// System.Web.HttpCookieCollection
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// (First impl Bob Smith <bob@thestuff.net>)
+//
+
+using System;
+using System.Web;
+using System.Collections.Specialized;
+
+namespace System.Web
+{
+ public sealed class HttpCookieCollection : NameObjectCollectionBase
+ {
+ HttpCookie [] _AllCookies;
+ string [] _AllKeys;
+
+ HttpResponse _Response;
+
+ internal HttpCookieCollection(HttpResponse Response, bool ReadOnly) : base()
+ {
+ _Response = Response;
+ IsReadOnly = ReadOnly;
+ }
+
+ public HttpCookieCollection () { }
+
+ public string [] AllKeys
+ {
+ get {
+ if (null == _AllKeys)
+ _AllKeys = BaseGetAllKeys ();
+
+ return _AllKeys;
+ }
+ }
+
+ public HttpCookie this [int index]
+ {
+ get { return Get (index); }
+ }
+
+ public HttpCookie this [string name]
+ {
+ get { return Get (name); }
+ }
+
+ public void Add (HttpCookie cookie)
+ {
+ if (null != _Response)
+ _Response.GoingToChangeCookieColl ();
+
+ // empy performance cache
+ _AllCookies = null;
+ _AllKeys = null;
+
+ BaseAdd (cookie.Name, cookie);
+
+ if (null != _Response)
+ _Response.OnCookieAdd (cookie);
+ }
+
+ public void Clear ()
+ {
+ _AllCookies = null;
+ _AllKeys = null;
+ BaseClear ();
+ }
+
+ public void CopyTo (Array dest, int index)
+ {
+ if (null == _AllCookies) {
+ _AllCookies = new HttpCookie [Count];
+
+ for (int i = 0; i != Count; i++)
+ _AllCookies [i] = Get (i);
+ }
+
+ _AllCookies.CopyTo (dest, index);
+ }
+
+ public HttpCookie Get (int index)
+ {
+ return BaseGet (index) as HttpCookie;
+ }
+
+ public HttpCookie Get (string name)
+ {
+ HttpCookie oRet = BaseGet (name) as HttpCookie;
+ if (null == oRet && _Response != null) {
+ _AllCookies = null;
+ _AllKeys = null;
+
+ _Response.GoingToChangeCookieColl ();
+
+ oRet = new HttpCookie (name);
+ BaseAdd (name, oRet);
+
+ _Response.OnCookieAdd (oRet);
+ }
+
+ return oRet;
+ }
+
+ public string GetKey (int index)
+ {
+ return BaseGetKey (index);
+ }
+
+ public void Remove (string name)
+ {
+ if (null != _Response)
+ _Response.GoingToChangeCookieColl ();
+
+ _AllCookies = null;
+ _AllKeys = null;
+ BaseRemove (name);
+
+ if (null != _Response)
+ _Response.ChangedCookieColl ();
+ }
+
+ public void Set (HttpCookie cookie)
+ {
+ if (null != _Response)
+ _Response.GoingToChangeCookieColl ();
+
+ _AllCookies = null;
+ _AllKeys = null;
+ BaseSet (cookie.Name, cookie);
+
+ if (null != _Response)
+ _Response.ChangedCookieColl();
+ }
+
+ internal void MakeCookieExpire (string name, string path)
+ {
+ DateTime expirationTime = new DateTime (1999, 10, 12); // This is the date MS sends!
+ HttpCookie willExpire = new HttpCookie (name, String.Empty, path, expirationTime);
+ Remove (name);
+ Add (willExpire);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/HttpException.cs b/mcs/class/System.Web/System.Web/HttpException.cs
new file mode 100644
index 00000000000..e94b325c0f5
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpException.cs
@@ -0,0 +1,86 @@
+//
+// System.Web.HttpException
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Text;
+//using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Web.Util;
+
+namespace System.Web
+{
+ public class HttpException : ExternalException
+ {
+ int _HttpCode;
+ int _HR;
+
+ public HttpException () : base ()
+ {
+ }
+
+ public HttpException (string sMessage) : base (sMessage)
+ {
+ }
+
+ public HttpException (string sMessage, Exception InnerException)
+ : base (sMessage, InnerException)
+ {
+ }
+
+ public HttpException (int iHttpCode, string sMessage) : base (sMessage)
+ {
+ _HttpCode = iHttpCode;
+ }
+
+ public HttpException (int iHttpCode, string sMessage, int iHR) : base (sMessage)
+ {
+ _HttpCode = iHttpCode;
+ _HR = iHR;
+ }
+
+ public HttpException (string sMessage, int iHR) : base (sMessage)
+ {
+ _HR = iHR;
+ }
+
+ public HttpException (int iHttpCode,
+ string sMessage,
+ Exception InnerException)
+ : base (sMessage, InnerException)
+ {
+ _HttpCode = iHttpCode;
+ }
+
+ [MonoTODO("Format messages")]
+ public string GetHtmlErrorMessage ()
+ {
+ StringBuilder sb = new StringBuilder ();
+ sb.Append ("<html>\n<title>");
+ sb.Append (HttpUtility.HtmlEncode (Message));
+ sb.Append ("</title><body><h1>Error</h1>\n<pre>");
+ sb.Append (HttpUtility.HtmlEncode (ToString ()));
+ sb.Append ("</pre></body>\n</html>\n");
+ return sb.ToString ();
+ }
+
+ [MonoTODO("Check error type and Set the correct error code")]
+ public int GetHttpCode ()
+ {
+ return _HttpCode;
+ }
+
+/* [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ extern static int GetLastError_internal ();*/
+
+ public static HttpException CreateFromLastError (string message)
+ {
+ WebTrace.WriteLine ("CreateFromLastError");
+ //return new HttpException (message, GetLastError_internal ());
+ return new HttpException (message, 0);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/HttpFileCollection.cs b/mcs/class/System.Web/System.Web/HttpFileCollection.cs
new file mode 100644
index 00000000000..423a5d4f605
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpFileCollection.cs
@@ -0,0 +1,73 @@
+//
+// System.Web.HttpFileCollection
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Collections.Specialized;
+
+namespace System.Web {
+ public sealed class HttpFileCollection : NameObjectCollectionBase {
+ private HttpPostedFile [] _AllFiles;
+ private string [] _AllKeys;
+
+ internal HttpFileCollection() : base() {
+ }
+
+ internal void AddFile(string name, HttpPostedFile file) {
+ _AllFiles = null;
+ _AllKeys = null;
+
+ BaseAdd(name, file);
+ }
+
+ public void CopyTo(Array Dest, int index) {
+ if (null == _AllFiles) {
+ _AllFiles = new HttpPostedFile[Count];
+ for (int i = 0; i != Count; i++) {
+ _AllFiles[i] = Get(i);
+ }
+ }
+
+ if (null != _AllFiles) {
+ _AllFiles.CopyTo(Dest, index);
+ }
+ }
+
+ public HttpPostedFile Get(string Name) {
+ return (HttpPostedFile) BaseGet(Name);
+ }
+
+ public HttpPostedFile Get(int index) {
+ return (HttpPostedFile) BaseGet(index);
+ }
+
+ public string GetKey(int index) {
+ return BaseGetKey(index);
+ }
+
+ public string [] AllKeys {
+ get {
+ if (null == _AllKeys) {
+ _AllKeys = BaseGetAllKeys();
+ }
+
+ return _AllKeys;
+ }
+ }
+
+ public HttpPostedFile this [string name] {
+ get {
+ return Get(name);
+ }
+ }
+
+ public HttpPostedFile this [int index] {
+ get {
+ return Get(index);
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpForbiddenHandler.cs b/mcs/class/System.Web/System.Web/HttpForbiddenHandler.cs
new file mode 100644
index 00000000000..1d45d683296
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpForbiddenHandler.cs
@@ -0,0 +1,27 @@
+//
+// System.Web.HttpForbiddenHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web
+{
+ class HttpForbiddenHandler : IHttpHandler
+ {
+ public void ProcessRequest (HttpContext context)
+ {
+ throw new HttpException (403, "Forbidden");
+ }
+
+ public bool IsReusable
+ {
+ get {
+ return true;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/HttpHelper.cs b/mcs/class/System.Web/System.Web/HttpHelper.cs
new file mode 100644
index 00000000000..9798f8b3b4b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpHelper.cs
@@ -0,0 +1,48 @@
+//
+// System.Web.HttpHelper
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Collections;
+using System.IO;
+
+namespace System.Web {
+ internal class HttpHelper {
+ internal static string [] ParseMultiValueHeader(string header) {
+ if (null == header) {
+ return null;
+ }
+
+ if (header.Length == 0) {
+ return null;
+ }
+
+ // Parse the , chars
+ Stack oValues = new Stack();
+
+ string sValue;
+
+ int iLastPos = -1;
+ int iPos = header.IndexOf(",");
+
+ while (iPos != -1) {
+ sValue = header.Substring(iLastPos + 1, iPos - iLastPos - 1).Trim();
+ iLastPos = iPos;
+
+ iPos = header.IndexOf(",", iPos + 1);
+ oValues.Push(sValue);
+ }
+
+ sValue = header.Substring(iLastPos + 1).Trim();
+ oValues.Push(sValue);
+
+ string [] arrValues = new string[oValues.Count];
+
+ Array.Copy(oValues.ToArray(), 0, arrValues, 0, oValues.Count);
+
+ return arrValues;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpMethodNotAllowedHandler.cs b/mcs/class/System.Web/System.Web/HttpMethodNotAllowedHandler.cs
new file mode 100644
index 00000000000..e89a6082509
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpMethodNotAllowedHandler.cs
@@ -0,0 +1,28 @@
+//
+// System.Web.HttpMethodNotAllowedHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web
+{
+ class HttpMethodNotAllowedHandler : IHttpHandler
+ {
+ public void ProcessRequest (HttpContext context)
+ {
+ throw new HttpException (405, "Forbidden");
+ }
+
+
+ public bool IsReusable
+ {
+ get {
+ return true;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/HttpModuleCollection.cs b/mcs/class/System.Web/System.Web/HttpModuleCollection.cs
new file mode 100644
index 00000000000..c7dc329abc8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpModuleCollection.cs
@@ -0,0 +1,73 @@
+//
+// System.Web.HttpModuleCollection
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Collections.Specialized;
+
+namespace System.Web {
+ public sealed class HttpModuleCollection : NameObjectCollectionBase {
+ private IHttpModule [] _Modules;
+ private string [] _Keys;
+
+ internal HttpModuleCollection() : base() {
+ }
+
+ internal void AddModule(string key, IHttpModule m) {
+ _Modules = null;
+ _Keys = null;
+
+ BaseAdd(key, m);
+ }
+
+ public void CopyTo(Array dest, int index) {
+ if (null == _Modules) {
+ _Modules = new IHttpModule[Count];
+
+ for (int i = 0; i != Count; i++) {
+ _Modules[i] = Get(i);
+ }
+ }
+
+ if (null != _Modules) {
+ _Modules.CopyTo(dest, index);
+ }
+ }
+
+ public IHttpModule Get(string key) {
+ return (IHttpModule) BaseGet(key);
+ }
+
+ public IHttpModule Get(int index) {
+ return (IHttpModule) BaseGet(index);
+ }
+
+ public string GetKey(int index) {
+ return GetKey(index);
+ }
+
+ public string [] AllKeys {
+ get {
+ if (null == _Keys) {
+ _Keys = BaseGetAllKeys();
+ }
+
+ return _Keys;
+ }
+ }
+
+ public IHttpModule this [string key] {
+ get {
+ return Get(key);
+ }
+ }
+
+ public IHttpModule this [int index] {
+ get {
+ return Get(index);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpParseException.cs b/mcs/class/System.Web/System.Web/HttpParseException.cs
new file mode 100644
index 00000000000..9683dc8a835
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpParseException.cs
@@ -0,0 +1,44 @@
+//
+// System.Web.HttpParseException.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+namespace System.Web {
+ public sealed class HttpParseException : HttpException {
+
+ #region Fields
+
+ string fileName;
+ int line;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO ("Figure out what to do with this.")]
+ internal HttpParseException (string message, Exception innerException, string sourceCode, string fileName, int line)
+ : base (message, innerException)
+ {
+ this.fileName = fileName;
+ this.line = line;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public string FileName {
+ get { return fileName; }
+ }
+
+ public int Line {
+ get { return line; }
+ }
+
+ #endregion // Properties
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpPostedFile.cs b/mcs/class/System.Web/System.Web/HttpPostedFile.cs
new file mode 100644
index 00000000000..02c02fc217a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpPostedFile.cs
@@ -0,0 +1,56 @@
+//
+// System.Web.HttpPostedFile
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.IO;
+
+namespace System.Web {
+ public sealed class HttpPostedFile {
+ private HttpRequestStream _Stream;
+ private string _ContentType;
+ private string _FileName;
+
+ internal HttpPostedFile(string file, string type, HttpRequestStream data) {
+ _Stream = data;
+ _FileName = file;
+ _ContentType = type;
+ }
+
+ public void SaveAs(string filename) {
+ FileStream File = new FileStream(filename, FileMode.Create);
+ if (_Stream.DataLength > 0) {
+ File.Write(_Stream.Data, _Stream.DataOffset, _Stream.DataLength);
+ }
+
+ File.Flush();
+ File.Close();
+ }
+
+ public int ContentLength {
+ get {
+ return _Stream.DataLength;
+ }
+ }
+
+ public string ContentType {
+ get {
+ return _ContentType;
+ }
+ }
+
+ public string FileName {
+ get {
+ return _FileName;
+ }
+ }
+
+ public Stream InputStream {
+ get {
+ return _Stream;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpRequest.cs b/mcs/class/System.Web/System.Web/HttpRequest.cs
new file mode 100644
index 00000000000..99105ce5b2f
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpRequest.cs
@@ -0,0 +1,1010 @@
+//
+// System.Web.HttpRequest
+//
+// Authors:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2001, 2002 Patrick Torstensson
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.IO;
+using System.Text;
+using System.Web.Configuration;
+using System.Web.Util;
+
+namespace System.Web {
+ [MonoTODO("Review security in all path access function")]
+ public sealed class HttpRequest {
+ private string [] _arrAcceptTypes;
+ private string [] _arrUserLanguages;
+
+ private byte [] _arrRawContent;
+ private int _iContentLength;
+
+ private string _sContentType;
+ private string _sHttpMethod;
+ private string _sRawUrl;
+ private string _sUserAgent;
+ private string _sUserHostAddress;
+ private string _sUserHostName;
+ private string _sPath;
+ private string _sPathInfo;
+ private string _sFilePath;
+ private string _sPathTranslated;
+ private string _sQueryStringRaw;
+ private string _sRequestType;
+ private string _sRequestRootVirtualDir;
+
+ private Encoding _oContentEncoding;
+
+ private Uri _oUriReferrer;
+ private Uri _oUrl;
+
+ private int _iTotalBytes;
+
+ private HttpContext _oContext;
+
+ private HttpWorkerRequest _WorkerRequest;
+ private HttpRequestStream _oInputStream;
+ private HttpClientCertificate _ClientCert;
+
+ private HttpValueCollection _oServerVariables;
+ private HttpValueCollection _oHeaders;
+ private HttpValueCollection _oQueryString;
+ private HttpValueCollection _oFormData;
+ private HttpValueCollection _oParams;
+
+ private HttpBrowserCapabilities _browser;
+
+ private HttpCookieCollection cookies;
+ private bool rewritten;
+
+ public HttpRequest(string Filename, string Url, string Querystring) {
+ _iContentLength = -1;
+ _iTotalBytes = -1;
+
+ _WorkerRequest = null;
+ _sPathTranslated = Filename;
+ _sRequestType = "GET";
+
+ _oUrl = new Uri(Url);
+ _sPath = _oUrl.AbsolutePath;
+
+ _sQueryStringRaw = Querystring;
+ _oQueryString = new HttpValueCollection(Querystring, true, WebEncoding.Encoding);
+ }
+
+ internal HttpRequest(HttpWorkerRequest WorkRequest, HttpContext Context) {
+ _WorkerRequest = WorkRequest;
+ _oContext = Context;
+
+ _iContentLength = -1;
+ _iTotalBytes = -1;
+ }
+
+ static private string MakeServerVariableFromHeader(string header) {
+ return "HTTP_" + header.ToUpper().Replace("-", "_");
+ }
+
+ [MonoTODO("Need to support non-raw mode also..")]
+ private string GetAllHeaders(bool Raw) {
+ StringBuilder oData;
+
+ if (null == _WorkerRequest) {
+ return null;
+ }
+
+ oData = new StringBuilder(512);
+
+ string sHeaderValue;
+ string sHeaderName;
+ int iCount = 0;
+
+ // Add all know headers
+ for (; iCount != 40; iCount++) {
+ sHeaderValue = _WorkerRequest.GetKnownRequestHeader(iCount);
+ if (null != sHeaderValue && sHeaderValue.Length > 0) {
+ sHeaderName = _WorkerRequest.GetKnownRequestHeader(iCount);
+ if (null != sHeaderName && sHeaderName.Length > 0) {
+ oData.Append(sHeaderName);
+ oData.Append(": ");
+ oData.Append(sHeaderValue);
+ oData.Append("\r\n");
+ }
+ }
+ }
+
+ // Get all other headers
+ string [][] arrUnknownHeaders = _WorkerRequest.GetUnknownRequestHeaders();
+ if (null != arrUnknownHeaders) {
+ for (iCount = 0; iCount != arrUnknownHeaders.Length; iCount++) {
+ oData.Append(arrUnknownHeaders[iCount][0]);
+ oData.Append(": ");
+ oData.Append(arrUnknownHeaders[iCount][1]);
+ oData.Append("\r\n");
+ }
+ }
+
+ return oData.ToString();
+ }
+
+ [MonoTODO("We need to handly 'dynamic' variables like AUTH_USER, that can be changed during runtime... special collection")]
+ private void ParseServerVariables() {
+ if (null == _WorkerRequest) {
+ return;
+ }
+
+ if (_oServerVariables == null) {
+ string sTmp;
+
+ _oServerVariables = new HttpValueCollection();
+
+ _oServerVariables.Add("ALL_HTTP", GetAllHeaders(false));
+ _oServerVariables.Add("ALL_RAW", GetAllHeaders(true));
+
+ _oServerVariables.Add("APPL_MD_PATH", _WorkerRequest.GetServerVariable("APPL_MD_PATH"));
+ _oServerVariables.Add("AUTH_PASSWORD", _WorkerRequest.GetServerVariable("AUTH_PASSWORD"));
+ _oServerVariables.Add("CERT_COOKIE", _WorkerRequest.GetServerVariable("CERT_COOKIE"));
+ _oServerVariables.Add("CERT_FLAGS", _WorkerRequest.GetServerVariable("CERT_FLAGS"));
+ _oServerVariables.Add("CERT_ISSUER", _WorkerRequest.GetServerVariable("CERT_ISSUER"));
+ _oServerVariables.Add("CERT_KEYSIZE", _WorkerRequest.GetServerVariable("CERT_KEYSIZE"));
+ _oServerVariables.Add("CERT_SECRETKEYSIZE", _WorkerRequest.GetServerVariable("CERT_SECRETKEYSIZE"));
+ _oServerVariables.Add("CERT_SERIALNUMBER", _WorkerRequest.GetServerVariable("CERT_SERIALNUMBER"));
+ _oServerVariables.Add("CERT_SERVER_ISSUER", _WorkerRequest.GetServerVariable("CERT_SERVER_ISSUER"));
+ _oServerVariables.Add("CERT_SERVER_SUBJECT", _WorkerRequest.GetServerVariable("CERT_SERVER_SUBJECT"));
+ _oServerVariables.Add("CERT_SUBJECT", _WorkerRequest.GetServerVariable("CERT_SUBJECT"));
+
+ _oServerVariables.Add("GATEWAY_INTERFACE", _WorkerRequest.GetServerVariable("GATEWAY_INTERFACE"));
+ _oServerVariables.Add("HTTPS", _WorkerRequest.GetServerVariable("HTTPS"));
+ _oServerVariables.Add("HTTPS_KEYSIZE", _WorkerRequest.GetServerVariable("HTTPS_KEYSIZE"));
+ _oServerVariables.Add("HTTPS_SECRETKEYSIZE", _WorkerRequest.GetServerVariable("HTTPS_SECRETKEYSIZE"));
+
+ _oServerVariables.Add("CONTENT_TYPE", ContentType);
+ _oServerVariables.Add("HTTPS_SERVER_ISSUER", _WorkerRequest.GetServerVariable("HTTPS_SERVER_ISSUER"));
+ _oServerVariables.Add("HTTPS_SERVER_SUBJECT", _WorkerRequest.GetServerVariable("HTTPS_SERVER_SUBJECT"));
+ _oServerVariables.Add("INSTANCE_ID", _WorkerRequest.GetServerVariable("INSTANCE_ID"));
+ _oServerVariables.Add("INSTANCE_META_PATH", _WorkerRequest.GetServerVariable("INSTANCE_META_PATH"));
+ _oServerVariables.Add("LOCAL_ADDR", _WorkerRequest.GetLocalAddress());
+ _oServerVariables.Add("REMOTE_ADDR", UserHostAddress);
+ _oServerVariables.Add("REMOTE_HOST", UserHostName);
+ _oServerVariables.Add("REQUEST_METHOD", HttpMethod);
+ _oServerVariables.Add("SERVER_NAME", _WorkerRequest.GetServerName());
+ _oServerVariables.Add("SERVER_PORT", _WorkerRequest.GetLocalPort().ToString());
+ _oServerVariables.Add("SERVER_PROTOCOL", _WorkerRequest.GetHttpVersion());
+ _oServerVariables.Add("SERVER_SOFTWARE", _WorkerRequest.GetServerVariable("SERVER_SOFTWARE"));
+
+ if (_WorkerRequest.IsSecure()) {
+ _oServerVariables.Add("SERVER_PORT_SECURE", "1");
+ } else {
+ _oServerVariables.Add("SERVER_PORT_SECURE", "0");
+ }
+
+ sTmp = _WorkerRequest.GetKnownRequestHeader(HttpWorkerRequest.HeaderContentLength);
+ if (null != sTmp) {
+ _oServerVariables.Add("CONTENT_LENGTH", sTmp);
+ }
+
+ // TODO: Should be dynamic
+ if (null != _oContext.User && _oContext.User.Identity.IsAuthenticated) {
+ _oServerVariables.Add("AUTH_TYPE", _oContext.User.Identity.AuthenticationType);
+ _oServerVariables.Add("AUTH_USER", _oContext.User.Identity.Name);
+ } else {
+ _oServerVariables.Add("AUTH_TYPE", "");
+ _oServerVariables.Add("AUTH_USER", "");
+ }
+
+ _oServerVariables.Add("PATH_INFO", PathInfo);
+ _oServerVariables.Add("PATH_TRANSLATED", PhysicalPath);
+ _oServerVariables.Add("QUERY_STRING", QueryStringRaw);
+ _oServerVariables.Add("SCRIPT_NAME", FilePath);
+ // end dynamic
+
+ _oServerVariables.MakeReadOnly();
+ }
+ }
+
+ [MonoTODO("Handle multipart/form-data")]
+ private void ParseFormData ()
+ {
+ if (_oFormData != null)
+ return;
+
+ string contentType = ContentType;
+ if (0 != String.Compare (contentType, "application/x-www-form-urlencoded", true)) {
+ if (contentType.Length > 0)
+ Console.WriteLine ("Content-Type -> {0} not supported", contentType);
+ _oFormData = new HttpValueCollection ();
+ return;
+ }
+
+ byte [] arrData = GetRawContent ();
+ Encoding enc = ContentEncoding;
+ string data = enc.GetString (arrData);
+ _oFormData = new HttpValueCollection (data, true, enc);
+ }
+
+ [MonoTODO("void Dispose")]
+ internal void Dispose() {
+ }
+
+ private byte [] GetRawContent ()
+ {
+ if (_arrRawContent != null)
+ return _arrRawContent;
+
+ if (null == _WorkerRequest) {
+ if (QueryStringRaw == null)
+ return null;
+ char [] q = QueryStringRaw.ToCharArray ();
+ _arrRawContent = new byte [q.Length];
+ for (int i = 0; i < q.Length; i++)
+ _arrRawContent [i] = (byte) q [i];
+ return _arrRawContent;
+ }
+
+ _arrRawContent = _WorkerRequest.GetPreloadedEntityBody ();
+ if (_arrRawContent == null)
+ _arrRawContent = new byte [0];
+
+ int length = ContentLength;
+ if (_WorkerRequest.IsEntireEntityBodyIsPreloaded () || length <= _arrRawContent.Length)
+ return _arrRawContent;
+
+ byte [] arrBuffer = new byte [Math.Min (16384, length)];
+ MemoryStream ms = new MemoryStream (arrBuffer.Length);
+ ms.Write (_arrRawContent, 0, _arrRawContent.Length);
+ int read = 0;
+ for (int loaded = _arrRawContent.Length; loaded < length; loaded += read) {
+ read = _WorkerRequest.ReadEntityBody (arrBuffer, arrBuffer.Length);
+ if (read == 0)
+ break;
+
+ ms.Write (arrBuffer, 0, read);
+ }
+
+ _arrRawContent = ms.GetBuffer ();
+ return _arrRawContent;
+ }
+
+ public string [] AcceptTypes {
+ get {
+ if (null == _arrAcceptTypes && null != _WorkerRequest) {
+ _arrAcceptTypes = HttpHelper.ParseMultiValueHeader(_WorkerRequest.GetKnownRequestHeader(HttpWorkerRequest.HeaderAccept));
+ }
+
+ return _arrAcceptTypes;
+
+ }
+ }
+
+ public string ApplicationPath {
+ get {
+ if (null != _WorkerRequest) {
+ return _WorkerRequest.GetAppPath();
+ }
+
+ return null;
+ }
+ }
+
+ public HttpBrowserCapabilities Browser {
+ get {
+ if (_browser == null)
+ _browser = new HttpBrowserCapabilities ();
+
+ return _browser;
+ }
+
+ set { _browser = value; }
+ }
+
+ public HttpClientCertificate ClientCertificate {
+ get {
+ if (null == _ClientCert) {
+ _ClientCert = new HttpClientCertificate(_oContext);
+ }
+
+ return _ClientCert;
+ }
+ }
+
+ private string GetValueFromHeader (string header, string attr)
+ {
+ int where = header.IndexOf (attr + '=');
+ if (where == -1)
+ return null;
+
+ where += attr.Length + 1;
+ int max = header.Length;
+ if (where >= max)
+ return String.Empty;
+
+ char ending = header [where];
+ if (ending != '"')
+ ending = ' ';
+
+ int end = header.Substring (where + 1).IndexOf (ending);
+ if (end == -1)
+ return (ending == '"') ? null : header.Substring (where);
+
+ return header.Substring (where, end);
+ }
+
+ public Encoding ContentEncoding
+ {
+ get {
+ if (_oContentEncoding == null) {
+ if (_WorkerRequest != null &&
+ (!_WorkerRequest.HasEntityBody () || ContentType != String.Empty)) {
+ _oContentEncoding = WebEncoding.Encoding;
+ } else {
+ string charset;
+ charset = GetValueFromHeader (_sContentType, "charset");
+ try {
+ _oContentEncoding = Encoding.GetEncoding (charset);
+ } catch {
+ _oContentEncoding = WebEncoding.Encoding;
+ }
+ }
+ }
+
+ return _oContentEncoding;
+ }
+
+ set {
+ _oContentEncoding = value;
+ }
+ }
+
+ public int ContentLength {
+ get {
+ if (_iContentLength == -1 && null != _WorkerRequest) {
+ string sLength = _WorkerRequest.GetKnownRequestHeader(HttpWorkerRequest.HeaderContentLength);
+ if (sLength != null) {
+ try {
+ _iContentLength = Int32.Parse(sLength);
+ }
+ catch(Exception) {
+ }
+ }
+ }
+
+ if (_iContentLength < 0) {
+ _iContentLength = 0;
+ }
+
+ return _iContentLength;
+ }
+ }
+
+ public string ContentType {
+ get {
+ if (null == _sContentType) {
+ if (null != _WorkerRequest) {
+ _sContentType = _WorkerRequest.GetKnownRequestHeader(HttpWorkerRequest.HeaderContentType);
+ }
+
+ if (null == _sContentType) {
+ _sContentType = string.Empty;
+ }
+ }
+
+ return _sContentType;
+ }
+ }
+
+ static private string GetCookieValue (string str, int length, ref int i)
+ {
+ if (i >= length)
+ return null;
+
+ int k = i;
+ while (k < length && Char.IsWhiteSpace (str [k]))
+ k++;
+
+ int begin = k;
+ while (k < length && str [k] != ';')
+ k++;
+
+ i = k;
+ return str.Substring (begin, i - begin).Trim ();
+ }
+
+ static private string GetCookieName (string str, int length, ref int i)
+ {
+ if (i >= length)
+ return null;
+
+ int k = i;
+ while (k < length && Char.IsWhiteSpace (str [k]))
+ k++;
+
+ int begin = k;
+ while (k < length && str [k] != ';' && str [k] != '=')
+ k++;
+
+ i = k + 1;
+ return str.Substring (begin, k - begin).Trim ();
+ }
+
+ private void GetCookies ()
+ {
+ string header = _WorkerRequest.GetKnownRequestHeader (HttpWorkerRequest.HeaderCookie);
+ if (header == null || header.Length == 0)
+ return;
+
+ /* RFC 2109
+ * cookie = "Cookie:" cookie-version
+ * 1*((";" | ",") cookie-value)
+ * cookie-value = NAME "=" VALUE [";" path] [";" domain]
+ * cookie-version = "$Version" "=" value
+ * NAME = attr
+ * VALUE = value
+ * path = "$Path" "=" value
+ * domain = "$Domain" "=" value
+ *
+ * MS ignores $Version!
+ * ',' as a separator produces errors.
+ */
+
+ string [] name_values = header.Trim ().Split (';');
+ int length = name_values.Length;
+ HttpCookie cookie = null;
+ int pos;
+ for (int i = 0; i < length; i++) {
+ pos = 0;
+ string name_value = name_values [i].Trim ();
+ string name = GetCookieName (name_value, name_value.Length, ref pos);
+ string value = GetCookieValue (name_value, name_value.Length, ref pos);
+ if (cookie != null) {
+ if (name == "$Path") {
+ cookie.Path = value;
+ continue;
+ } else if (name == "$Domain") {
+ cookie.Domain = value;
+ continue;
+ } else {
+ cookies.Add (cookie);
+ cookie = null;
+ }
+ }
+ cookie = new HttpCookie (name, value);
+ }
+
+ if (cookie != null)
+ cookies.Add (cookie);
+ }
+
+ public HttpCookieCollection Cookies
+ {
+ get {
+ if (cookies == null) {
+ cookies = new HttpCookieCollection (null, false);
+ if (_WorkerRequest != null)
+ GetCookies ();
+ }
+
+ return cookies;
+ }
+ }
+
+ public string CurrentExecutionFilePath {
+ get {
+ return FilePath;
+ }
+ }
+
+ public string FilePath {
+ get {
+ if (null == _sFilePath && null != _WorkerRequest) {
+ _sFilePath = _WorkerRequest.GetFilePath();
+ }
+
+ return _sFilePath;
+ }
+ }
+
+ [MonoTODO()]
+ public HttpFileCollection Files {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ [MonoTODO("Use stream filter in the request stream")]
+ public Stream Filter {
+ get {
+ throw new NotImplementedException();
+ }
+
+ set {
+ throw new NotImplementedException();
+ }
+ }
+
+
+ public NameValueCollection Form {
+ get {
+ ParseFormData();
+
+ return (NameValueCollection) _oFormData;
+ }
+ }
+
+ public NameValueCollection Headers {
+ get {
+ if (_oHeaders == null) {
+ _oHeaders = new HttpValueCollection();
+
+ if (null != _WorkerRequest) {
+ string sHeaderValue;
+ string sHeaderName;
+ int iCount = 0;
+
+ // Add all know headers
+ for (; iCount != 40; iCount++) {
+ sHeaderValue = _WorkerRequest.GetKnownRequestHeader(iCount);
+ if (null != sHeaderValue && sHeaderValue.Length > 0) {
+ sHeaderName = _WorkerRequest.GetKnownRequestHeader(iCount);
+ if (null != sHeaderName && sHeaderName.Length > 0) {
+ _oHeaders.Add(sHeaderName, sHeaderValue);
+ }
+ }
+ }
+
+ // Get all other headers
+ string [][] arrUnknownHeaders = _WorkerRequest.GetUnknownRequestHeaders();
+ if (null != arrUnknownHeaders) {
+ for (iCount = 0; iCount != arrUnknownHeaders.Length; iCount++) {
+ _oHeaders.Add(arrUnknownHeaders[iCount][0], arrUnknownHeaders[iCount][1]);
+ }
+ }
+ }
+
+ // Make headers read-only
+ _oHeaders.MakeReadOnly();
+ }
+
+ return (NameValueCollection) _oHeaders;
+ }
+ }
+
+ public string HttpMethod {
+ get {
+ if (null == _sHttpMethod) {
+ if (null != _WorkerRequest) {
+ _sHttpMethod = _WorkerRequest.GetHttpVerbName().ToUpper();
+ }
+
+ if (_sHttpMethod == null) {
+ if (RequestType != null)
+ _sHttpMethod = RequestType;
+ else
+ _sHttpMethod = "GET";
+ }
+ }
+
+ return _sHttpMethod;
+ }
+ }
+
+ public Stream InputStream {
+ get {
+ if (_oInputStream == null) {
+ byte [] arrInputData = GetRawContent ();
+
+ if (null != arrInputData) {
+ _oInputStream = new HttpRequestStream(arrInputData, 0, arrInputData.Length);
+ } else {
+ _oInputStream = new HttpRequestStream(null, 0, 0);
+ }
+ }
+
+ return _oInputStream;
+ }
+ }
+
+ public bool IsAuthenticated {
+ get {
+ if (_oContext != null && _oContext.User != null && _oContext.User.Identity != null) {
+ return _oContext.User.Identity.IsAuthenticated;
+ }
+
+ return false;
+ }
+ }
+
+ public bool IsSecureConnection {
+ get {
+ if (null != _WorkerRequest) {
+ return _WorkerRequest.IsSecure();
+ }
+
+ return false;
+ }
+ }
+
+ [MonoTODO("Call item in querystring, form, cookie and servervariables")]
+ public string this [string sKey] {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ [MonoTODO("Add cookie collection to our Params collection via merge")]
+ public NameValueCollection Params {
+ get {
+ if (_oParams == null) {
+ _oParams = new HttpValueCollection();
+
+ _oParams.Merge(QueryString);
+ _oParams.Merge(Form);
+ _oParams.Merge(ServerVariables);
+ // TODO: Cookie
+
+ _oParams.MakeReadOnly();
+ }
+
+ return (NameValueCollection) _oParams;
+ }
+ }
+
+ public string Path {
+ get {
+ if (_sPath == null) {
+ if (null != _WorkerRequest) {
+ _sPath = _WorkerRequest.GetUriPath();
+ }
+
+ if (_sPath == null) {
+ _sPath = string.Empty;
+ }
+ }
+
+ return _sPath;
+ }
+ }
+
+ public string PathInfo {
+ get {
+ if (_sPathInfo == null) {
+ if (null != _WorkerRequest) {
+ _sPathInfo = _WorkerRequest.GetPathInfo();
+ }
+
+ if (_sPathInfo == null) {
+ _sPathInfo = string.Empty;
+ }
+ }
+
+ return _sPathInfo;
+ }
+ }
+
+ public string PhysicalApplicationPath {
+ get {
+ if (null != _WorkerRequest) {
+ return _WorkerRequest.GetAppPathTranslated();
+ }
+
+ return null;
+ }
+ }
+
+ public string PhysicalPath {
+ get {
+ if (_sPathTranslated == null && _WorkerRequest != null) {
+ if (rewritten)
+ _sPathTranslated = _WorkerRequest.GetFilePathTranslated ();
+
+ if (null == _sPathTranslated)
+ _sPathTranslated = _WorkerRequest.MapPath (FilePath);
+ }
+
+ return _sPathTranslated;
+ }
+ }
+
+ public NameValueCollection QueryString {
+ get {
+ if (_oQueryString == null) {
+ _oQueryString = new HttpValueCollection(QueryStringRaw, true,
+ WebEncoding.Encoding);
+ }
+
+ return _oQueryString;
+ }
+ }
+
+ // Used to parse the querystring
+ internal string QueryStringRaw {
+ get {
+ if (_sQueryStringRaw == null && null != _WorkerRequest) {
+ byte [] arrQuerystringBytes = _WorkerRequest.GetQueryStringRawBytes();
+ if (null != arrQuerystringBytes && arrQuerystringBytes.Length > 0) {
+ _sQueryStringRaw = ContentEncoding.GetString(arrQuerystringBytes);
+ } else {
+ _sQueryStringRaw = _WorkerRequest.GetQueryString();
+ }
+ }
+
+ if (_sQueryStringRaw == null) {
+ _sQueryStringRaw = string.Empty;
+ }
+
+ return _sQueryStringRaw;
+ }
+ }
+
+ public string RawUrl {
+ get {
+ if (null == _sRawUrl) {
+ if (null != _WorkerRequest) {
+ _sRawUrl = _WorkerRequest.GetRawUrl();
+ } else {
+ _sRawUrl = Path;
+ if (QueryStringRaw != null && QueryStringRaw.Length > 0) {
+ _sRawUrl = _sRawUrl + "?" + QueryStringRaw;
+ }
+ }
+ }
+
+ return _sRawUrl;
+ }
+ }
+
+ public string RequestType {
+ get {
+ if (null == _sRequestType) {
+ return HttpMethod;
+ }
+
+ return _sRequestType;
+ }
+
+ set {
+ _sRequestType = value;
+ }
+ }
+
+
+ public NameValueCollection ServerVariables {
+ get {
+ ParseServerVariables();
+
+ return (NameValueCollection) _oServerVariables;
+ }
+ }
+
+ public int TotalBytes {
+ get {
+ if (_iTotalBytes == -1) {
+ if (null != InputStream) {
+ _iTotalBytes = (int) InputStream.Length;
+ } else {
+ _iTotalBytes = 0;
+ }
+ }
+
+ return _iTotalBytes;
+ }
+ }
+
+ public Uri Url {
+ get {
+ if (null == _oUrl) {
+ _oUrl = new Uri(RawUrl);
+ }
+
+ return _oUrl;
+ }
+ }
+
+ public Uri UrlReferrer {
+ get {
+ if (null == _oUriReferrer && null != _WorkerRequest) {
+ string sReferrer = _WorkerRequest.GetKnownRequestHeader(HttpWorkerRequest.HeaderReferer);
+ if (null != sReferrer && sReferrer.Length > 0) {
+ try {
+ if (sReferrer.IndexOf("://") >= 0) {
+ _oUriReferrer = new Uri(sReferrer);
+ } else {
+ _oUriReferrer = new Uri(this.Url, sReferrer);
+ }
+ }
+ catch (Exception) {
+ }
+ }
+ }
+
+ return _oUriReferrer;
+ }
+ }
+
+ public string UserAgent {
+ get {
+ if (_sUserAgent == null && _WorkerRequest != null) {
+ _sUserAgent = _WorkerRequest.GetKnownRequestHeader(HttpWorkerRequest.HeaderUserAgent);
+ }
+
+ if (_sUserAgent == null) {
+ _sUserAgent = string.Empty;
+ }
+
+ return _sUserAgent;
+ }
+ }
+
+ public string UserHostAddress {
+ get {
+ if (_sUserHostAddress == null && null != _WorkerRequest) {
+ _sUserHostAddress = _WorkerRequest.GetRemoteAddress();
+ }
+
+ if (_sUserHostAddress == null || _sUserHostAddress.Length == 0) {
+ _sUserHostAddress = "127.0.0.1";
+ }
+
+ return _sUserHostAddress;
+ }
+ }
+
+ public string UserHostName {
+ get {
+ if (_sUserHostName == null && null != _WorkerRequest) {
+ _sUserHostName = _WorkerRequest.GetRemoteName();
+ }
+
+ if (_sUserHostName == null || _sUserHostName.Length == 0) {
+ _sUserHostName = UserHostAddress;
+ }
+
+ return _sUserHostName;
+ }
+ }
+
+ public string [] UserLanguages {
+ get {
+ if (_arrUserLanguages == null && null != _WorkerRequest) {
+ _arrUserLanguages = HttpHelper.ParseMultiValueHeader(_WorkerRequest.GetKnownRequestHeader(HttpWorkerRequest.HeaderAcceptLanguage));
+ }
+
+ return _arrUserLanguages;
+ }
+ }
+
+ internal string RootVirtualDir {
+ get {
+ if (_sRequestRootVirtualDir == null) {
+ _sRequestRootVirtualDir = FilePath;
+ int pos = _sRequestRootVirtualDir.LastIndexOf ('/');
+ if (pos == -1 || pos == 0)
+ _sRequestRootVirtualDir = "/";
+ else
+ _sRequestRootVirtualDir = _sRequestRootVirtualDir.Substring (0, pos);
+ }
+
+ return _sRequestRootVirtualDir;
+ }
+ }
+
+ public byte [] BinaryRead(int count) {
+ int iSize = TotalBytes;
+ if (iSize == 0) {
+ throw new ArgumentException();
+ }
+
+ byte [] arrData = new byte[iSize];
+
+ int iRetSize = InputStream.Read(arrData, 0, iSize);
+ if (iRetSize != iSize) {
+ byte [] tmpData = new byte[iRetSize];
+ if (iRetSize > 0) {
+ Array.Copy(arrData, 0, tmpData, 0, iRetSize);
+ }
+
+ arrData = tmpData;
+ }
+
+ return arrData;
+ }
+
+ public int [] MapImageCoordinates(string ImageFieldName) {
+ NameValueCollection oItems;
+
+ if (HttpMethod == "GET" || HttpMethod == "HEAD") {
+ oItems = QueryString;
+ } else if (HttpMethod == "POST") {
+ oItems = Form;
+ } else {
+ return null;
+ }
+
+ int [] arrRet = null;
+ try {
+ string sX = oItems.Get(ImageFieldName + ".x");
+ string sY = oItems.Get(ImageFieldName + ".y");
+
+ if (null != sX && null != sY) {
+ int [] arrTmp = new Int32[2];
+ arrRet[0] = Int32.Parse(sX);
+ arrRet[1] = Int32.Parse(sY);
+
+ arrRet = arrTmp;
+ }
+ }
+ catch (Exception) {
+ }
+
+ return arrRet;
+ }
+
+ public string MapPath (string VirtualPath)
+ {
+ return MapPath (VirtualPath, RootVirtualDir, true);
+ }
+
+ [MonoTODO("allowCrossAppMapping?")]
+ public string MapPath (string virtualPath, string baseVirtualDir, bool allowCrossAppMapping)
+ {
+ if (_WorkerRequest == null)
+ throw new HttpException ("No HttpWorkerRequest!!!");
+
+ if (virtualPath == null || virtualPath.Length == 0)
+ virtualPath = ".";
+ else
+ virtualPath = virtualPath.Trim ();
+
+ if (System.IO.Path.DirectorySeparatorChar != '/')
+ virtualPath = virtualPath.Replace (System.IO.Path.DirectorySeparatorChar, '/');
+
+ if (UrlUtils.IsRooted (virtualPath)) {
+ virtualPath = UrlUtils.Reduce (virtualPath);
+ } else {
+ if (baseVirtualDir == null)
+ virtualPath = UrlUtils.Combine (RootVirtualDir, virtualPath);
+ else
+ virtualPath = UrlUtils.Combine (baseVirtualDir, virtualPath);
+ }
+
+ return _WorkerRequest.MapPath (virtualPath);
+ }
+
+ public void SaveAs(string filename, bool includeHeaders) {
+ FileStream oFile;
+ TextWriter oWriter;
+ HttpRequestStream oData;
+
+ oFile = new FileStream(filename, FileMode.CreateNew);
+ if (includeHeaders) {
+ oWriter = new StreamWriter(oFile);
+ oWriter.Write(HttpMethod + " " + Path);
+
+ if (QueryStringRaw != null && QueryStringRaw.Length > 0)
+ oWriter.Write("?" + QueryStringRaw);
+ if (_WorkerRequest != null) {
+ oWriter.Write(" " + _WorkerRequest.GetHttpVersion() + "\r\n");
+ oWriter.Write(GetAllHeaders(true));
+ } else {
+ oWriter.Write("\r\n");
+ }
+
+ oWriter.Write("\r\n");
+ oWriter.Flush();
+ }
+
+ oData = (HttpRequestStream) InputStream;
+
+ if (oData.DataLength > 0) {
+ oFile.Write(oData.Data, oData.DataOffset, oData.DataLength);
+ }
+
+ oFile.Flush();
+ oFile.Close();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpRequestStream.cs b/mcs/class/System.Web/System.Web/HttpRequestStream.cs
new file mode 100644
index 00000000000..c67281d3dd1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpRequestStream.cs
@@ -0,0 +1,142 @@
+//
+// System.Web.HttpRequestStream
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.IO;
+
+namespace System.Web {
+ public class HttpRequestStream : Stream {
+ private byte [] _arrData;
+ private int _iLength;
+ private int _iOffset;
+ private int _iPos;
+
+ internal HttpRequestStream(byte [] buffer, int offset, int length) {
+ _iPos = 0;
+ _iOffset = offset;
+ _iLength = length;
+
+ _arrData = buffer;
+ }
+
+ private void Reset() {
+ _iPos = 0;
+ _iOffset = 0;
+ _iLength = 0;
+
+ _arrData = null;
+ }
+
+ public override void Flush() {
+ }
+
+ public override void Close() {
+ Reset();
+ }
+
+ public override int Read(byte [] buffer, int offset, int length) {
+ int iBytes = length;
+
+ if (_iPos + length > _arrData.Length) {
+ iBytes = (int) _arrData.Length - _iPos;
+ }
+
+ if (iBytes <= 0) {
+ return 0;
+ }
+
+ Buffer.BlockCopy(_arrData, _iPos, buffer, offset, iBytes);
+ _iPos += iBytes;
+
+ return iBytes;
+ }
+
+ public override long Seek(long offset, SeekOrigin origin) {
+ switch (origin) {
+ case SeekOrigin.Begin : if (offset > _arrData.Length) {
+ throw new ArgumentException();
+ }
+ _iPos = (int) offset;
+ break;
+
+ case SeekOrigin.Current : if (((long) _iPos + offset > _arrData.Length) || (_iPos + (int) offset < 0)) {
+ throw new ArgumentException();
+ }
+ _iPos += Convert.ToInt32(offset);
+ break;
+
+ case SeekOrigin.End: if (_arrData.Length - offset < 0) {
+ throw new ArgumentException();
+ }
+
+ _iPos = Convert.ToInt32( _arrData.Length - offset);
+ break;
+ }
+
+ return (long) _iPos;
+ }
+
+ public override void SetLength(long length) {
+ throw new NotSupportedException();
+ }
+
+ public override void Write(byte [] buffer, int offset, int length) {
+ throw new NotSupportedException();
+ }
+
+ public override bool CanRead {
+ get {
+ return true;
+ }
+ }
+
+ public override bool CanSeek {
+ get {
+ return true;
+ }
+ }
+
+ public override bool CanWrite {
+ get {
+ return false;
+ }
+ }
+
+ public byte [] Data {
+ get {
+ return _arrData;
+ }
+ }
+
+ public int DataLength {
+ get {
+ return _iLength;
+ }
+ }
+
+ public int DataOffset {
+ get {
+ return _iOffset;
+ }
+ }
+
+ public override long Length {
+ get {
+ return (long) _arrData.Length;
+ }
+ }
+
+ public override long Position {
+ get {
+ return (long) _iPos;
+ }
+
+ set {
+ Seek(value, SeekOrigin.Begin);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpResponse.cs b/mcs/class/System.Web/System.Web/HttpResponse.cs
new file mode 100644
index 00000000000..07087d70a9d
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpResponse.cs
@@ -0,0 +1,901 @@
+//
+// System.Web.HttpResponse
+//
+// Authors:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using System.Threading;
+using System.Web.Util;
+
+namespace System.Web
+{
+ public sealed class HttpResponse
+ {
+ // Chunked encoding static helpers
+ static byte [] s_arrChunkSuffix = { 10, 13 };
+ static byte [] s_arrChunkEnd = { 10 , 13 };
+ static string s_sChunkedPrefix = "\r\n";
+
+ ArrayList _Headers;
+
+ bool _bClientDisconnected;
+ bool _bSuppressHeaders;
+ bool _bSuppressContent;
+ bool _bChunked;
+ bool _bEnded;
+ bool _bBuffering;
+ bool _bHeadersSent;
+ bool _bFlushing;
+ long _lContentLength;
+ int _iStatusCode;
+
+ bool _ClientDisconnected;
+
+ string _sContentType;
+ string _sCacheControl;
+ string _sTransferEncoding;
+ string _sCharset;
+ string _sStatusDescription;
+
+ HttpCookieCollection _Cookies;
+ HttpCachePolicy _CachePolicy;
+
+ Encoding _ContentEncoding;
+
+ HttpContext _Context;
+ HttpWriter _Writer;
+ TextWriter _TextWriter;
+
+ HttpWorkerRequest _WorkerRequest;
+
+ ArrayList fileDependencies;
+
+ public HttpResponse (TextWriter output)
+ {
+ _bBuffering = true;
+ _bFlushing = false;
+ _bHeadersSent = false;
+
+ _Headers = new ArrayList ();
+
+ _sContentType = "text/html";
+
+ _iStatusCode = 200;
+ _sCharset = null;
+ _sCacheControl = null;
+
+ _lContentLength = 0;
+ _bSuppressContent = false;
+ _bSuppressHeaders = false;
+ _bClientDisconnected = false;
+
+ _bChunked = false;
+
+ _TextWriter = output;
+ }
+
+ internal HttpResponse (HttpWorkerRequest WorkerRequest, HttpContext Context)
+ {
+ _Context = Context;
+ _WorkerRequest = WorkerRequest;
+
+ _bBuffering = true;
+ _bFlushing = false;
+ _bHeadersSent = false;
+
+ _Headers = new ArrayList ();
+
+ _sContentType = "text/html";
+
+ _iStatusCode = 200;
+ _sCharset = null;
+ _sCacheControl = null;
+
+ _lContentLength = 0;
+ _bSuppressContent = false;
+ _bSuppressHeaders = false;
+ _bClientDisconnected = false;
+
+ _bChunked = false;
+
+ _Writer = new HttpWriter (this);
+ _TextWriter = _Writer;
+ }
+
+ internal Encoder ContentEncoder
+ {
+ get {
+ return ContentEncoding.GetEncoder ();
+ }
+ }
+
+ internal void FinalFlush ()
+ {
+ Flush (true);
+ }
+
+ internal void DoFilter ()
+ {
+ if (null != _Writer)
+ _Writer.FilterData (true);
+ }
+
+ [MonoTODO("We need to add cache headers also")]
+ private ArrayList GenerateHeaders ()
+ {
+ ArrayList oHeaders = new ArrayList (_Headers.ToArray ());
+
+ oHeaders.Add (new HttpResponseHeader ("X-Powered-By", "Mono"));
+ // save culture info, we need us info here
+ CultureInfo oSavedInfo = Thread.CurrentThread.CurrentCulture;
+ Thread.CurrentThread.CurrentCulture = new CultureInfo (0x0409);
+
+ string date = DateTime.Now.ToUniversalTime ().ToString ("ddd, d MMM yyyy HH:mm:ss ");
+ oHeaders.Add (new HttpResponseHeader ("Date", date + "GMT"));
+
+ Thread.CurrentThread.CurrentCulture = oSavedInfo;
+
+ if (_lContentLength > 0) {
+ oHeaders.Add (new HttpResponseHeader (HttpWorkerRequest.HeaderContentLength,
+ _lContentLength.ToString ()));
+ }
+
+ if (_sContentType != null) {
+ if (_sContentType.IndexOf ("charset=") == -1) {
+ if (Charset.Length == 0) {
+ Charset = ContentEncoding.HeaderName;
+ }
+
+ // Time to build our string
+ if (Charset.Length > 0) {
+ _sContentType += "; charset=" + Charset;
+ }
+ }
+
+ oHeaders.Add (new HttpResponseHeader (HttpWorkerRequest.HeaderContentType,
+ _sContentType));
+ }
+
+ if (_sCacheControl != null) {
+ oHeaders.Add (new HttpResponseHeader (HttpWorkerRequest.HeaderPragma,
+ _sCacheControl));
+ }
+
+ if (_sTransferEncoding != null) {
+ oHeaders.Add (new HttpResponseHeader (HttpWorkerRequest.HeaderTransferEncoding,
+ _sTransferEncoding));
+ }
+
+ if (_Cookies != null) {
+ int length = _Cookies.Count;
+ for (int i = 0; i < length; i++) {
+ oHeaders.Add (_Cookies.Get (i).GetCookieHeader ());
+ }
+ }
+
+ return oHeaders;
+ }
+
+ private void SendHeaders ()
+ {
+ _WorkerRequest.SendStatus (StatusCode, StatusDescription);
+
+ ArrayList oHeaders = GenerateHeaders ();
+ foreach (HttpResponseHeader oHeader in oHeaders)
+ oHeader.SendContent (_WorkerRequest);
+
+ _bHeadersSent = true;
+ }
+
+ public string Status
+ {
+ get {
+ return String.Format ("{0} {1}", StatusCode, StatusDescription);
+ }
+
+ set {
+ string sMsg = "OK";
+ int iCode = 200;
+
+ try {
+ iCode = Int32.Parse (value.Substring (0, value.IndexOf (' ')));
+ sMsg = value.Substring (value.IndexOf (' ') + 1);
+ } catch (Exception) {
+ throw new HttpException ("Invalid status string");
+ }
+
+ StatusCode = iCode;
+ StatusDescription = sMsg;
+ }
+ }
+
+ [MonoTODO()]
+ public void AddCacheItemDependencies (ArrayList cacheKeys)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO()]
+ public void AddCacheItemDependency(string cacheKey)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void AddFileDependencies (ArrayList filenames)
+ {
+ if (filenames == null || filenames.Count == 0)
+ return;
+
+ if (fileDependencies == null) {
+ fileDependencies = (ArrayList) filenames.Clone ();
+ return;
+ }
+
+ foreach (string fn in filenames)
+ AddFileDependency (fn);
+ }
+
+ public void AddFileDependency (string filename)
+ {
+ if (fileDependencies == null)
+ fileDependencies = new ArrayList ();
+
+ fileDependencies.Add (filename);
+ }
+
+ public void AddHeader (string name, string value)
+ {
+ AppendHeader(name, value);
+ }
+
+ public void AppendCookie (HttpCookie cookie)
+ {
+ if (_bHeadersSent)
+ throw new HttpException ("Cannot append cookies after HTTP headers have been sent");
+
+ Cookies.Add (cookie);
+ }
+
+ [MonoTODO()]
+ public void AppendToLog (string param)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public string ApplyAppPathModifier (string virtualPath)
+ {
+ if (virtualPath == null)
+ return null;
+
+ if (virtualPath == "")
+ return _Context.Request.RootVirtualDir;
+
+ if (UrlUtils.IsRelativeUrl (virtualPath)) {
+ virtualPath = UrlUtils.Combine (_Context.Request.RootVirtualDir, virtualPath);
+ } else if (UrlUtils.IsRooted (virtualPath)) {
+ virtualPath = UrlUtils.Reduce (virtualPath);
+ }
+
+ return virtualPath;
+ }
+
+ public bool Buffer
+ {
+ get {
+ return BufferOutput;
+ }
+
+ set {
+ BufferOutput = value;
+ }
+ }
+
+ public bool BufferOutput
+ {
+ get {
+ return _bBuffering;
+ }
+
+ set {
+ if (_Writer != null)
+ _Writer.Update ();
+
+ _bBuffering = value;
+ }
+ }
+
+ public HttpCachePolicy Cache
+ {
+ get {
+ if (null == _CachePolicy)
+ _CachePolicy = new HttpCachePolicy ();
+
+ return _CachePolicy;
+ }
+ }
+
+ [MonoTODO("Set status in the cache policy")]
+ public string CacheControl
+ {
+ get {
+ return _sCacheControl;
+ }
+
+ set {
+ if (_bHeadersSent)
+ throw new HttpException ("Headers has been sent to the client");
+
+ _sCacheControl = value;
+ }
+ }
+
+ public string Charset
+ {
+ get {
+ if (null == _sCharset)
+ _sCharset = ContentEncoding.WebName;
+
+ return _sCharset;
+ }
+
+ set {
+ if (_bHeadersSent)
+ throw new HttpException ("Headers has been sent to the client");
+
+ _sCharset = value;
+ }
+ }
+
+ public Encoding ContentEncoding
+ {
+ get {
+ if (_ContentEncoding == null)
+ _ContentEncoding = WebEncoding.Encoding;
+
+ return _ContentEncoding;
+ }
+
+ set {
+ if (value == null)
+ throw new ArgumentException ("Can't set a null as encoding");
+
+ _ContentEncoding = value;
+
+ if (_Writer != null)
+ _Writer.Update ();
+ }
+ }
+
+ public string ContentType
+ {
+ get {
+ return _sContentType;
+ }
+
+ set {
+ if (_bHeadersSent)
+ throw new HttpException ("Headers has been sent to the client");
+
+ _sContentType = value;
+ }
+ }
+
+ public HttpCookieCollection Cookies
+ {
+ get {
+ if (null == _Cookies)
+ _Cookies = new HttpCookieCollection (this, false);
+
+ return _Cookies;
+ }
+ }
+
+ [MonoTODO("Set expires in the cache policy")]
+ public int Expires
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO("Set expiresabsolute in the cache policy")]
+ public DateTime ExpiresAbsolute
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public Stream Filter
+ {
+ get {
+ if (_Writer != null)
+ return _Writer.GetActiveFilter ();
+
+ return null;
+ }
+
+ set {
+ if (_Writer == null)
+ throw new HttpException ("Filtering is not allowed");
+
+ _Writer.ActivateFilter (value);
+ }
+ }
+
+ public bool IsClientConnected
+ {
+ get {
+ if (_ClientDisconnected)
+ return false;
+
+ if (null != _WorkerRequest && (!_WorkerRequest.IsClientConnected ())) {
+ _ClientDisconnected = false;
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ public TextWriter Output
+ {
+ get {
+ return _TextWriter;
+ }
+ }
+
+ public Stream OutputStream
+ {
+ get {
+ if (_Writer == null)
+ throw new HttpException ("an Output stream not available when " +
+ "running with custom text writer");
+
+ return _Writer.OutputStream;
+ }
+ }
+
+ public string StatusDescription
+ {
+ get {
+ if (null == _sStatusDescription)
+ _sStatusDescription =
+ HttpWorkerRequest.GetStatusDescription (_iStatusCode);
+
+ return _sStatusDescription;
+ }
+
+ set {
+ if (_bHeadersSent)
+ throw new HttpException ("Headers has been sent to the client");
+
+ _sStatusDescription = value;
+ }
+ }
+
+ public int StatusCode
+ {
+ get {
+ return _iStatusCode;
+ }
+
+ set {
+ if (_bHeadersSent)
+ throw new HttpException ("Headers has been sent to the client");
+
+ _sStatusDescription = null;
+ _iStatusCode = value;
+ }
+ }
+
+ public bool SuppressContent
+ {
+ get {
+ return _bSuppressContent;
+ }
+
+ set {
+ if (_bHeadersSent)
+ throw new HttpException ("Headers has been sent to the client");
+
+ _bSuppressContent = true;
+ }
+ }
+
+ public HttpRequest Request
+ {
+ get {
+ if (_Context == null)
+ return null;
+
+ return _Context.Request;
+ }
+ }
+
+ internal void AppendHeader (int iIndex, string value)
+ {
+ if (_bHeadersSent)
+ throw new HttpException ("Headers has been sent to the client");
+
+ switch (iIndex) {
+ case HttpWorkerRequest.HeaderContentLength:
+ _lContentLength = Int64.Parse (value);
+ break;
+ case HttpWorkerRequest.HeaderContentEncoding:
+ _sContentType = value;
+ break;
+ case HttpWorkerRequest.HeaderTransferEncoding:
+ _sTransferEncoding = value;
+ if (value.Equals ("chunked")) {
+ _bChunked = true;
+ } else {
+ _bChunked = false;
+ }
+ break;
+ case HttpWorkerRequest.HeaderPragma:
+ _sCacheControl = value;
+ break;
+ default:
+ _Headers.Add (new HttpResponseHeader (iIndex, value));
+ break;
+ }
+ }
+
+ public void AppendHeader (string name, string value)
+ {
+ if (_bHeadersSent)
+ throw new HttpException ("Headers has been sent to the client");
+
+ switch (name.ToLower ()) {
+ case "content-length":
+ _lContentLength = Int64.Parse (value);
+ break;
+ case "content-type":
+ _sContentType = value;
+ break;
+ case "transfer-encoding":
+ _sTransferEncoding = value;
+ if (value.Equals ("chunked")) {
+ _bChunked = true;
+ } else {
+ _bChunked = false;
+ }
+ break;
+ case "pragma":
+ _sCacheControl = value;
+ break;
+ default:
+ _Headers.Add (new HttpResponseHeader (name, value));
+ break;
+ }
+ }
+
+ public void BinaryWrite (byte [] buffer)
+ {
+ OutputStream.Write (buffer, 0, buffer.Length);
+ }
+
+ public void Clear ()
+ {
+ if (_Writer != null)
+ _Writer.Clear ();
+ }
+
+ public void ClearContent ()
+ {
+ Clear();
+ }
+
+ public void ClearHeaders ()
+ {
+ if (_bHeadersSent)
+ throw new HttpException ("Headers has been sent to the client");
+
+ _sContentType = "text/html";
+
+ _iStatusCode = 200;
+ _sCharset = null;
+ _Headers = new ArrayList ();
+ _sCacheControl = null;
+ _sTransferEncoding = null;
+
+ _lContentLength = 0;
+ _bSuppressContent = false;
+ _bSuppressHeaders = false;
+ _bClientDisconnected = false;
+ }
+
+ public void Close ()
+ {
+ _bClientDisconnected = false;
+ _WorkerRequest.CloseConnection ();
+ _bClientDisconnected = true;
+ }
+
+ internal void Dispose ()
+ {
+ if (_Writer != null) {
+ _Writer.Dispose ();
+ _Writer = null;
+ }
+ }
+
+ [MonoTODO("Handle callbacks into before done with session, needs to have a non ended flush here")]
+ internal void FlushAtEndOfRequest ()
+ {
+ Flush (true);
+ }
+
+ public void End ()
+ {
+ if (_bEnded)
+ return;
+
+ Flush ();
+ _bEnded = true;
+ _Context.ApplicationInstance.CompleteRequest ();
+ }
+
+ public void Flush ()
+ {
+ Flush (false);
+ }
+
+ private void Flush (bool bFinish)
+ {
+ if (_bFlushing)
+ return;
+
+ _bFlushing = true;
+
+ if (_Writer == null) {
+ _TextWriter.Flush ();
+ _bFlushing = false;
+ return;
+ }
+
+ try {
+ long length;
+ if (!_bHeadersSent && !_bSuppressHeaders && !_bClientDisconnected) {
+ if (bFinish) {
+ length = _Writer.BufferSize;
+ if (length == 0 && _lContentLength == 0)
+ _sContentType = null;
+
+ SendHeaders ();
+ length = _Writer.BufferSize;
+ if (length != 0)
+ _WorkerRequest.SendCalculatedContentLength ((int) length);
+ } else {
+ if (_lContentLength == 0 && _iStatusCode == 200 &&
+ _sTransferEncoding == null) {
+ // Check we are going todo chunked encoding
+ string sProto = Request.ServerVariables ["SERVER_PROTOCOL"];
+ sProto = "HTTP/1.0"; // Remove this line when we support properly
+ // chunked content
+
+ if (sProto != null && sProto == "HTTP/1.1") {
+ AppendHeader (
+ HttpWorkerRequest.HeaderTransferEncoding,
+ "chunked");
+ } else {
+ // Just in case, the old browsers send a HTTP/1.0
+ // request with Connection: Keep-Alive
+ AppendHeader (
+ HttpWorkerRequest.HeaderConnection,
+ "Close");
+ }
+ }
+
+ SendHeaders ();
+ }
+ }
+
+ if (!_bSuppressContent && Request.HttpMethod == "HEAD")
+ _bSuppressContent = true;
+
+ if (!_bSuppressContent) {
+ _bClientDisconnected = false;
+ if (_bChunked) {
+ Encoding oASCII = Encoding.ASCII;
+
+ string chunk = Convert.ToString(_Writer.BufferSize, 16);
+ byte [] arrPrefix = oASCII.GetBytes (chunk + s_sChunkedPrefix);
+
+ _WorkerRequest.SendResponseFromMemory (arrPrefix,
+ arrPrefix.Length);
+
+ _Writer.SendContent (_WorkerRequest);
+
+ _WorkerRequest.SendResponseFromMemory (s_arrChunkSuffix,
+ s_arrChunkSuffix.Length);
+ if (bFinish)
+ _WorkerRequest.SendResponseFromMemory (
+ s_arrChunkEnd, s_arrChunkEnd.Length);
+ } else {
+ _Writer.SendContent (_WorkerRequest);
+ }
+ } else {
+ _Writer.Clear ();
+ }
+
+ _WorkerRequest.FlushResponse (bFinish);
+
+ if (!bFinish)
+ _Writer.Clear ();
+ } finally {
+ _bFlushing = false;
+ }
+ }
+
+ public void Pics (string value)
+ {
+ AppendHeader ("PICS-Label", value);
+ }
+
+
+ public void Redirect (string url)
+ {
+ Redirect (url, true);
+ }
+
+ public void Redirect (string url, bool endResponse)
+ {
+ if (_bHeadersSent)
+ throw new HttpException ("Headers has been sent to the client");
+
+ Clear ();
+
+ url = ApplyAppPathModifier (url);
+ StatusCode = 302;
+ AppendHeader (HttpWorkerRequest.HeaderLocation, url);
+
+ // Text for browsers that can't handle location header
+ Write ("<html><head><title>Object moved</title></head><body>\r\n");
+ Write ("<h2>Object moved to <a href='" + url + "'>here</a></h2>\r\n");
+ Write ("</body><html>\r\n");
+
+ if (endResponse)
+ End ();
+ }
+
+ public void Write (char ch)
+ {
+ _TextWriter.Write(ch);
+ }
+
+ public void Write (object obj)
+ {
+ _TextWriter.Write(obj);
+ }
+
+ public void Write (string str)
+ {
+ _TextWriter.Write (str);
+ }
+
+ public void Write (char [] buffer, int index, int count)
+ {
+ _TextWriter.Write (buffer, index, count);
+ }
+
+ [MonoTODO()]
+ public static void RemoveOutputCacheItem (string path)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void SetCookie (HttpCookie cookie)
+ {
+ if (_bHeadersSent)
+ throw new HttpException ("Cannot append cookies after HTTP headers have been sent");
+
+ Cookies.Add (cookie);
+ }
+
+ private void WriteFromStream (Stream stream, long offset, long length, long bufsize)
+ {
+ if (offset < 0 || length <= 0)
+ return;
+
+ long stLength = stream.Length;
+ if (offset + length > stLength)
+ length = stLength - offset;
+
+ if (offset > 0)
+ stream.Seek (offset, SeekOrigin.Begin);
+
+ byte [] fileContent = new byte [bufsize];
+ int count = (int) Math.Min (Int32.MaxValue, bufsize);
+ while (length > 0 && (count = stream.Read (fileContent, 0, count)) != 0) {
+ _Writer.WriteBytes (fileContent, 0, count);
+ length -= count;
+ count = (int) Math.Min (length, fileContent.Length);
+ }
+ }
+
+ public void WriteFile (string filename)
+ {
+ WriteFile (filename, false);
+ }
+
+ public void WriteFile (string filename, bool readIntoMemory)
+ {
+ FileStream fs = null;
+ try {
+ fs = File.OpenRead (filename);
+ long size = fs.Length;
+ if (readIntoMemory) {
+ WriteFromStream (fs, 0, size, size);
+ } else {
+ WriteFromStream (fs, 0, size, 8192);
+ }
+ } finally {
+ if (fs != null)
+ fs.Close ();
+ }
+ }
+
+ public void WriteFile (string filename, long offset, long size)
+ {
+ FileStream fs = null;
+ try {
+ fs = File.OpenRead (filename);
+ WriteFromStream (fs, offset, size, 8192);
+ } finally {
+ if (fs != null)
+ fs.Close ();
+ }
+ }
+
+ public void WriteFile (IntPtr fileHandle, long offset, long size)
+ {
+ FileStream fs = null;
+ try {
+ fs = new FileStream (fileHandle, FileAccess.Read);
+ WriteFromStream (fs, offset, size, 8192);
+ } finally {
+ if (fs != null)
+ fs.Close ();
+ }
+ }
+
+ [MonoTODO()]
+ internal void OnCookieAdd (HttpCookie cookie)
+ {
+ }
+
+ [MonoTODO("Do we need this?")]
+ internal void OnCookieChange (HttpCookie cookie)
+ {
+ }
+
+ [MonoTODO()]
+ internal void GoingToChangeCookieColl ()
+ {
+ }
+
+ [MonoTODO()]
+ internal void ChangedCookieColl ()
+ {
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/HttpResponseHeader.cs b/mcs/class/System.Web/System.Web/HttpResponseHeader.cs
new file mode 100644
index 00000000000..c8cc64a5767
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpResponseHeader.cs
@@ -0,0 +1,49 @@
+//
+// System.Web.HttpResponseHeader
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+
+namespace System.Web {
+ internal class HttpResponseHeader {
+ private string _sHeader;
+ private string _sValue;
+ private int _iKnowHeaderId;
+
+ internal HttpResponseHeader(int KnowHeaderId, string value) {
+ _iKnowHeaderId = KnowHeaderId;
+ _sValue = value;
+ }
+
+ internal HttpResponseHeader(string header, string value) {
+ _sHeader = header;
+ _sValue = value;
+ }
+
+ internal string Name {
+ get {
+ if (null == _sHeader) {
+ return HttpWorkerRequest.GetKnownResponseHeaderName(_iKnowHeaderId);
+ }
+
+ return _sHeader;
+ }
+ }
+
+ internal string Value {
+ get {
+ return _sValue;
+ }
+ }
+
+ internal void SendContent(HttpWorkerRequest WorkerRequest) {
+ if (null != _sHeader) {
+ WorkerRequest.SendUnknownResponseHeader(_sHeader, _sValue);
+ } else {
+ WorkerRequest.SendKnownResponseHeader(_iKnowHeaderId, _sValue);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpResponseStream.cs b/mcs/class/System.Web/System.Web/HttpResponseStream.cs
new file mode 100644
index 00000000000..831118b67ae
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpResponseStream.cs
@@ -0,0 +1,87 @@
+//
+// System.Web.HttpResponseStream
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.IO;
+
+namespace System.Web {
+ /// <summary>
+ /// Simple wrapper around HttpWriter to support the Stream interface
+ /// </summary>
+ class HttpResponseStream : Stream {
+ private HttpWriter _Writer;
+
+ internal HttpResponseStream(HttpWriter Writer) {
+ _Writer = Writer;
+ }
+
+ public override void Flush() {
+ _Writer.Flush();
+ }
+
+ public override void Close() {
+ _Writer.Close();
+ }
+
+ public override int Read(byte [] buffer, int offset, int length) {
+ throw new NotSupportedException();
+ }
+
+ public override long Seek(long offset, SeekOrigin origin) {
+ throw new NotSupportedException();
+ }
+
+ public override void SetLength(long length) {
+ throw new NotSupportedException();
+ }
+
+ public override void Write(byte [] buffer, int offset, int length) {
+ if (offset < 0) {
+ throw new ArgumentOutOfRangeException("offset");
+ }
+
+ if (length <= 0) {
+ throw new ArgumentOutOfRangeException("length");
+ }
+
+ _Writer.WriteBytes(buffer, offset, length);
+ }
+
+ public override bool CanRead {
+ get {
+ return false;
+ }
+ }
+
+ public override bool CanSeek {
+ get {
+ return false;
+ }
+ }
+
+ public override bool CanWrite {
+ get {
+ return true;
+ }
+ }
+
+ public override long Length {
+ get {
+ throw new NotSupportedException();
+ }
+ }
+
+ public override long Position {
+ get {
+ throw new NotSupportedException();
+ }
+
+ set {
+ throw new NotSupportedException();
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpResponseStreamProxy.cs b/mcs/class/System.Web/System.Web/HttpResponseStreamProxy.cs
new file mode 100644
index 00000000000..30bf5709d43
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpResponseStreamProxy.cs
@@ -0,0 +1,48 @@
+//
+// System.Web.HttpResponseStreamProxy
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.IO;
+
+namespace System.Web {
+ /// <summary>
+ /// Used to detect if there is a valid filter proxy.
+ /// </summary>
+ class HttpResponseStreamProxy : HttpResponseStream {
+ bool _FilteringActive;
+
+ internal HttpResponseStreamProxy(HttpWriter Writer) : base(Writer) {
+ _FilteringActive = false;
+ }
+
+ internal void CheckFilteringState() {
+ if (_FilteringActive) {
+ throw new HttpException("Invalid response filter state");
+ }
+ }
+
+ internal bool Active {
+ get {
+ return _FilteringActive;
+ }
+ set {
+ _FilteringActive = value;
+ }
+ }
+
+ public override void Flush() {
+ }
+
+ public override void Close() {
+ }
+
+ public override void Write(byte [] buffer, int offset, int length) {
+ CheckFilteringState();
+
+ Write(buffer, offset, length);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpRuntime.cs b/mcs/class/System.Web/System.Web/HttpRuntime.cs
new file mode 100644
index 00000000000..7806b76f7ff
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpRuntime.cs
@@ -0,0 +1,463 @@
+//
+// System.Web.HttpRuntime
+//
+// Author:
+// Patrik Torstensson (ptorsten@hotmail.com)
+// Gaurav Vaish (gvaish@iitk.ac.in)
+//
+using System;
+using System.Collections;
+using System.Text;
+using System.Security;
+using System.Security.Permissions;
+using System.Threading;
+using System.Web.UI;
+using System.Web.Util;
+using System.Web.Caching;
+
+namespace System.Web {
+
+ public sealed class HttpRuntime {
+
+ // Security permission helper objects
+ private static IStackWalk appPathDiscoveryStackWalk;
+ private static IStackWalk ctrlPrincipalStackWalk;
+ private static IStackWalk sensitiveInfoStackWalk;
+ private static IStackWalk unmgdCodeStackWalk;
+ private static IStackWalk unrestrictedStackWalk;
+ private static IStackWalk reflectionStackWalk;
+
+ private static HttpRuntime _runtime;
+ private static string appDomainAppId;
+ private static string appDomainId;
+ private static string appDomainAppPath;
+ private static string appDomainAppVirtualPath;
+ private Cache _cache;
+
+ private int _activeRequests;
+ private HttpWorkerRequest.EndOfSendNotification _endOfSendCallback;
+ private AsyncCallback _handlerCallback;
+ private WaitCallback _appDomainCallback;
+
+ private bool _firstRequestStarted;
+ private bool _firstRequestExecuted;
+ private DateTime _firstRequestStartTime;
+
+ private Exception _initError;
+
+ static HttpRuntime ()
+ {
+ appPathDiscoveryStackWalk = null;
+ ctrlPrincipalStackWalk = null;
+ sensitiveInfoStackWalk = null;
+ unmgdCodeStackWalk = null;
+ unrestrictedStackWalk = null;
+
+ _runtime = new HttpRuntime ();
+ _runtime.Init();
+ }
+
+ public HttpRuntime ()
+ {
+ }
+
+ static internal object CreateInternalObject(Type type) {
+ return Activator.CreateInstance(type, true);
+ }
+
+ [MonoTODO()]
+ private void Init ()
+ {
+ try {
+ _cache = new Cache ();
+
+ // TODO: timeout manager
+ // TODO: Load all app domain data
+ // TODO: Trace manager
+ _endOfSendCallback = new HttpWorkerRequest.EndOfSendNotification(OnEndOfSend);
+ _handlerCallback = new AsyncCallback(OnHandlerReady);
+ _appDomainCallback = new WaitCallback(OnAppDomainUnload);
+ }
+ catch (Exception error) {
+ _initError = error;
+ }
+ }
+
+ private void OnFirstRequestStart() {
+ if (null == _initError) {
+ // TODO: First request initialize (config, trace, request queue)
+ }
+
+ // If we got an error during init, throw to client now..
+ if (null != _initError)
+ throw _initError;
+ }
+
+ private void OnFirstRequestEnd() {
+ }
+
+ private void OnHandlerReady(IAsyncResult ar) {
+ HttpContext context = (HttpContext) ar.AsyncState;
+ try {
+ IHttpAsyncHandler handler = context.AsyncHandler;
+
+ try {
+ handler.EndProcessRequest(ar);
+ }
+ catch (Exception error) {
+ context.AddError(error);
+ }
+ }
+ finally {
+ context.AsyncHandler = null;
+ }
+
+ FinishRequest(context, context.Error);
+ }
+
+ private void OnEndOfSend(HttpWorkerRequest request, object data) {
+ HttpContext context = (HttpContext) data;
+
+ context.Request.Dispose();
+ context.Response.Dispose();
+ }
+
+ internal void FinishRequest(HttpContext context, Exception error) {
+ if (context.Error != null)
+ Console.WriteLine ("context.Error: {0}", context.Error);
+ if (error == null) {
+ try {
+ context.Response.FlushAtEndOfRequest();
+ } catch (Exception obj) {
+ error = obj;
+ }
+ }
+
+ HttpWorkerRequest request = context.WorkerRequest;
+ if (null != error) {
+ WebTrace.WriteLine (error.ToString ());
+
+ context.Response.Clear ();
+ if (!(error is HttpException)) {
+ error = new HttpException (String.Empty, error);
+ }
+ context.Response.Write (((HttpException) error).GetHtmlErrorMessage ());
+ context.Response.FinalFlush ();
+ }
+
+ if (!_firstRequestExecuted) {
+ lock (this) {
+ if (!_firstRequestExecuted) {
+ OnFirstRequestEnd();
+ _firstRequestExecuted = true;
+ }
+ }
+ }
+
+ Interlocked.Decrement(ref _activeRequests);
+
+ if (null != request)
+ request.EndOfRequest();
+
+ // TODO: Schedule more work in request queue
+ }
+
+ private void OnAppDomainUnload(object state) {
+ Dispose();
+ }
+
+ [MonoTODO]
+ internal void Dispose() {
+ // TODO: Drain Request queue
+ // TODO: Stop request queue
+ // TODO: Move timeout value to config
+ WaitForRequests(5000);
+
+ _cache.Dispose();
+ HttpApplicationFactory.EndApplication();
+ }
+
+ [MonoTODO]
+ internal void WaitForRequests(int ms) {
+ DateTime timeout = DateTime.Now.AddMilliseconds(ms);
+
+ do {
+ // TODO: We should check the request queue here also
+ if (_activeRequests == 0)
+ return;
+
+ Thread.Sleep(100);
+ } while (timeout > DateTime.Now);
+ }
+
+ internal void InternalExecuteRequest(HttpWorkerRequest request)
+ {
+ if (request == null)
+ throw new ArgumentNullException ("request");
+
+ IHttpHandler handler;
+ IHttpAsyncHandler async_handler;
+
+ HttpContext context = new HttpContext(request);
+
+ request.SetEndOfSendNotification(_endOfSendCallback, context);
+
+ Interlocked.Increment(ref _activeRequests);
+
+ try {
+ if (!_firstRequestStarted) {
+ lock (this) {
+ if (!_firstRequestStarted) {
+ _firstRequestStartTime = DateTime.Now;
+
+ OnFirstRequestStart();
+ _firstRequestStarted = true;
+ }
+ }
+ }
+
+ handler = HttpApplicationFactory.GetInstance(context);
+ if (null == handler)
+ throw new HttpException(FormatResourceString("unable_to_create_app"));
+
+ if (handler is IHttpAsyncHandler) {
+ async_handler = (IHttpAsyncHandler) handler;
+
+ context.AsyncHandler = async_handler;
+ async_handler.BeginProcessRequest(context, _handlerCallback, context);
+ } else {
+ handler.ProcessRequest(context);
+ FinishRequest(context, null);
+ }
+ }
+ catch (Exception error) {
+ FinishRequest(context, error);
+ }
+ }
+
+ public static void ProcessRequest (HttpWorkerRequest Request)
+ {
+ // TODO: Request queue
+ _runtime.InternalExecuteRequest(Request);
+ }
+
+ public static Cache Cache {
+ get {
+ return _runtime._cache;
+ }
+ }
+
+ public static string AppDomainAppId {
+ get {
+ if (appDomainAppId == null)
+ appDomainAppId = (string) AppDomain.CurrentDomain.GetData (".appId");
+
+ return appDomainAppId;
+ }
+ }
+
+ public static string AppDomainAppPath {
+ get {
+ if (appDomainAppPath == null)
+ appDomainAppPath = (string) AppDomain.CurrentDomain.GetData (".appPath");
+
+ return appDomainAppPath;
+ }
+ }
+
+ public static string AppDomainAppVirtualPath {
+ get {
+ if (appDomainAppVirtualPath == null)
+ appDomainAppVirtualPath = (string) AppDomain.CurrentDomain.GetData (".appVPath");
+
+ return appDomainAppVirtualPath;
+ }
+ }
+
+ public static string AppDomainId {
+ get {
+ if (appDomainId == null)
+ appDomainId = (string) AppDomain.CurrentDomain.GetData (".domainId");
+
+ return appDomainId;
+ }
+ }
+
+ [MonoTODO]
+ public static string AspInstallDirectory {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public static string BinDirectory {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public static string ClrInstallDirectory {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public static string CodegenDir {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public static bool IsOnUNCShare {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ public static string MachineConfigurationDirectory {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public static void Close ()
+ {
+ _runtime.Dispose();
+ }
+
+ internal static string FormatResourceString (string key)
+ {
+ return GetResourceString (key);
+ }
+
+ internal static string FormatResourceString (string key, string arg0)
+ {
+ /*string format = GetResourceString (key);
+
+ if (format == null)
+ return null;
+
+ return String.Format (format, arg0);
+ */
+ return String.Format ("{0}: {1}", key, arg0);
+ }
+
+ [MonoTODO ("FormatResourceString (string, string, string)")]
+ internal static string FormatResourceString (string key, string arg0, string type) {
+ return String.Format ("{0}: {1} {2}", key, arg0, type);
+ }
+
+ [MonoTODO ("FormatResourceString (string, string, string, string)")]
+ internal static string FormatResourceString (string key, string arg0,
+ string arg1, string arg2)
+ {
+ return String.Format ("{0}: {1} {2} {3}", key, arg0, arg1, arg2);
+ }
+
+ [MonoTODO ("FormatResourceString (string, string[]")]
+ internal static string FormatResourceString (string key, string[] args)
+ {
+ //StringBuilder sb = new StringBuilder ();
+ /*sb.AppendFormat ("{0}: ", key);
+ foreach (string s in args)
+ sb.AppendFormat ("{0} ", s);
+
+ if (sb.Length > 0)
+ sb.Length--;
+ return sb.ToString ();*/
+ string s = key + ": ";
+ if (args != null)
+ foreach (string k in args)
+ s += k + " ";
+ return s;
+ }
+
+ private static string GetResourceString (string key) {
+ return _runtime.GetResourceStringFromResourceManager (key);
+ }
+
+ [MonoTODO ("GetResourceStringFromResourceManager (string)")]
+ private string GetResourceStringFromResourceManager (string key) {
+ return "String returned by HttpRuntime.GetResourceStringFromResourceManager";
+ }
+
+ #region Security Internal Methods (not impl)
+ [MonoTODO ("Get Application path from the appdomain object")]
+ internal static IStackWalk AppPathDiscovery {
+ get {
+ if (appPathDiscoveryStackWalk == null) {
+ appPathDiscoveryStackWalk = new FileIOPermission (
+ FileIOPermissionAccess.PathDiscovery, "<apppath>");
+ }
+ return appPathDiscoveryStackWalk;
+ }
+ }
+
+ internal static IStackWalk ControlPrincipal {
+ get {
+ if (ctrlPrincipalStackWalk == null) {
+ ctrlPrincipalStackWalk = new SecurityPermission (
+ SecurityPermissionFlag.ControlPrincipal);
+ }
+ return ctrlPrincipalStackWalk;
+ }
+ }
+
+ internal static IStackWalk Reflection {
+ get {
+ if (reflectionStackWalk == null) {
+ reflectionStackWalk = new ReflectionPermission (
+ ReflectionPermissionFlag.TypeInformation |
+ ReflectionPermissionFlag.MemberAccess);
+ }
+ return reflectionStackWalk;
+ }
+ }
+
+ internal static IStackWalk SensitiveInformation {
+ get {
+ if (sensitiveInfoStackWalk == null) {
+ sensitiveInfoStackWalk = new EnvironmentPermission (
+ PermissionState.Unrestricted);
+ }
+ return sensitiveInfoStackWalk;
+ }
+ }
+
+ internal static IStackWalk UnmanagedCode {
+ get {
+ if (unmgdCodeStackWalk == null) {
+ unmgdCodeStackWalk = new SecurityPermission (
+ SecurityPermissionFlag.UnmanagedCode);
+ }
+ return unmgdCodeStackWalk;
+ }
+ }
+
+ internal static IStackWalk Unrestricted {
+ get {
+ if (unrestrictedStackWalk == null) {
+ unrestrictedStackWalk = new PermissionSet (
+ PermissionState.Unrestricted);
+ }
+ return unrestrictedStackWalk;
+ }
+ }
+
+ internal static IStackWalk FileReadAccess (string file)
+ {
+ return new FileIOPermission (FileIOPermissionAccess.Read, file);
+ }
+
+ internal static IStackWalk PathDiscoveryAccess (string path)
+ {
+ return new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path);
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpServerUtility.cs b/mcs/class/System.Web/System.Web/HttpServerUtility.cs
new file mode 100644
index 00000000000..c41d72d9d56
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpServerUtility.cs
@@ -0,0 +1,283 @@
+/**
+ * Namespace: System.Web
+ * Class: HttpServerUtility
+ *
+ * Author: Wictor Wilén
+ * Contact: <wictor@ibizkit.se>, <patrik.torstensson@labs2.com>
+ * Status: ?%
+ *
+ * (C) Wictor Wilén (2002)
+ * ---------------------------------------
+ * 2002-03-27 Wictor Started implementation
+ * 2002-04-09 Patrik Added HttpContext constructor
+ * 2002-04-10 Patrik Moved encoding to HttpUtility and
+ * fixed all functions that used
+ * HttpContext
+ *
+ */
+using System;
+using System.IO;
+
+namespace System.Web {
+ public sealed class HttpServerUtility {
+
+ private static string _name = "";
+
+ private HttpContext _Context;
+ private HttpApplication _Application;
+
+ [MonoTODO()]
+ internal HttpServerUtility(HttpContext Context) {
+ _Context = Context;
+ }
+
+ [MonoTODO()]
+ internal HttpServerUtility(HttpApplication app) {
+ _Application = app;
+ }
+
+ // Properties
+
+
+ /// <summary>
+ /// Gets the server's computer name.
+ /// </summary>
+ public string MachineName {
+ get {
+ if(_name.Length == 0) {
+ _name = Environment.MachineName;
+ }
+ return _name;
+ }
+ }
+ /// <summary>
+ /// Gets and sets the request time-out in seconds.
+ /// </summary>
+ [MonoTODO()]
+ public int ScriptTimeout {
+ get {
+ throw new System.NotImplementedException();
+ }
+ set {
+ throw new System.NotImplementedException();
+ }
+ }
+
+ // Methods
+
+ /// <summary>
+ /// Clears the previous exception.
+ /// </summary>
+ public void ClearError() {
+ if (null != _Context) {
+ _Context.ClearError();
+ return;
+ }
+
+ if (null != _Application) {
+ _Application.ClearError();
+ }
+ }
+
+
+ /// <summary>
+ /// Creates a server instance of a COM object identified by the object's Programmatic Identifier (ProgID).
+ /// </summary>
+ /// <param name="progID">The class or type of object to be instantiated. </param>
+ /// <returns>The new object.</returns>
+ public object CreateObject(string progID) {
+ return CreateObject(Type.GetTypeFromProgID(progID));
+ }
+
+
+ /// <summary>
+ /// Creates a server instance of a COM object identified by the object's type.
+ /// </summary>
+ /// <param name="type">A Type representing the object to create. </param>
+ /// <returns>The new object.</returns>
+ [MonoTODO()]
+ public object CreateObject(Type type) {
+ Object o;
+ o = Activator.CreateInstance(type);
+
+ // TODO: Call OnStartPage()
+
+ return o;
+ }
+
+
+ /// <summary>
+ /// Creates a server instance of a COM object identified by the object's class identifier (CLSID).
+ /// </summary>
+ /// <param name="clsid">The class identifier of the object to be instantiated. </param>
+ /// <returns>The new object.</returns>
+ public object CreateObjectFromClsid(string clsid) {
+ Guid guid = new Guid(clsid);
+ return CreateObject(Type.GetTypeFromCLSID(guid));
+ }
+
+
+ /// <summary>
+ /// Executes a request to another page using the specified URL path to the page.
+ /// </summary>
+ /// <param name="path">The URL path of the new request. </param>
+ [MonoTODO()]
+ public void Execute(string path) {
+ throw new System.NotImplementedException();
+ }
+
+
+ /// <summary>
+ /// Executes a request to another page using the specified URL path to the page. A TextWriter captures output from the page.
+ /// </summary>
+ /// <param name="path">The URL path of the new request. </param>
+ /// <param name="writer">The TextWriter to capture the output. </param>
+ [MonoTODO()]
+ public void Execute(string path, TextWriter writer ) {
+ throw new System.NotImplementedException();
+ }
+
+
+
+ /// <summary>
+ /// Returns the previous exception.
+ /// </summary>
+ /// <returns>The previous exception that was thrown.</returns>
+ [MonoTODO()]
+ public Exception GetLastError() {
+ throw new System.NotImplementedException();
+ }
+
+
+
+ /// <summary>
+ /// Decodes an HTML-encoded string and returns the decoded string.
+ /// </summary>
+ /// <param name="s">The HTML string to decode. </param>
+ /// <returns>The decoded text.</returns>
+ [MonoTODO()]
+ public string HtmlDecode(string s) {
+ return HttpUtility.HtmlDecode(s);
+ }
+
+
+ /// <summary>
+ /// Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream.
+ /// </summary>
+ /// <param name="s">The HTML string to decode</param>
+ /// <param name="output">The TextWriter output stream containing the decoded string. </param>
+ public void HtmlDecode(string s, TextWriter output) {
+ output.Write(HttpUtility.HtmlDecode(s));
+ }
+
+ /// <summary>
+ /// HTML-encodes a string and returns the encoded string.
+ /// </summary>
+ /// <param name="s">The text string to encode. </param>
+ /// <returns>The HTML-encoded text.</returns>
+ public string HtmlEncode(string s) {
+ return HttpUtility.HtmlEncode(s);
+ }
+
+ /// <summary>
+ /// HTML-encodes a string and sends the resulting output to a TextWriter output stream.
+ /// </summary>
+ /// <param name="s">The string to encode. </param>
+ /// <param name="output">The TextWriter output stream containing the encoded string. </param>
+ public void HtmlEncode( string s, TextWriter output) {
+ output.Write(HtmlEncode(s));
+ }
+
+
+ /// <summary>
+ /// Returns the physical file path that corresponds to the specified virtual path on the Web server.
+ /// </summary>
+ /// <param name="path">The virtual path on the Web server. </param>
+ /// <returns>The physical file path that corresponds to path.</returns>
+ public string MapPath(string path) {
+ if (null == _Context) {
+ throw new HttpException("MapPath is not available");
+ }
+
+ return _Context.Request.MapPath(path);
+ }
+
+ /// <summary>
+ /// Terminates execution of the current page and begins execution of a new page using the specified URL path to the page.
+ /// </summary>
+ /// <param name="path">The URL path of the new page on the server to execute. </param>
+ [MonoTODO()]
+ public void Transfer(string path) {
+ throw new System.NotImplementedException();
+ }
+
+ /// <summary>
+ /// Terminates execution of the current page and begins execution of a new page using the specified URL path to the page. Specifies whether to clear the QueryString and Form collections.
+ /// </summary>
+ /// <param name="path">The URL path of the new page on the server to execute. </param>
+ /// <param name="preserveForm">If true, the QueryString and Form collections are preserved. If false, they are cleared. The default is false. </param>
+ [MonoTODO()]
+ public void Transfer(string path, bool preserveForm ) {
+ throw new System.NotImplementedException();
+ }
+
+ /// <summary>
+ /// URL-decodes a string and returns the decoded string.
+ /// </summary>
+ /// <param name="s">The text string to decode. </param>
+ /// <returns>The decoded text.</returns>
+ /// <remarks>
+ /// Post/html encoding @ ftp://ftp.isi.edu/in-notes/rfc1866.txt
+ /// Uncomment the line marked with RFC1738 to get pure RFC1738
+ /// and it will also consider the RFC1866 (ftp://ftp.isi.edu/in-notes/rfc1866.txt)
+ /// `application/x-www-form-urlencoded' format
+ /// </remarks>
+ public string UrlDecode(string s) {
+ return HttpUtility.UrlDecode(s);
+ }
+
+ /// <summary>
+ /// Decodes an HTML string received in a URL and sends the resulting output to a TextWriter output stream.
+ /// </summary>
+ /// <param name="s"></param>
+ /// <param name="output"></param>
+ public void UrlDecode(string s, TextWriter output) {
+ output.Write(UrlDecode(s));
+ }
+
+ /// <summary>
+ /// URL-encodes a string and returns the encoded string.
+ /// </summary>
+ /// <param name="s">The text to URL-encode. </param>
+ /// <returns>The URL encoded text.</returns>
+ public string UrlEncode(string s) {
+ return HttpUtility.UrlEncode(s);
+ }
+
+ /// <summary>
+ /// URL encodes a string and sends the resulting output to a TextWriter output stream.
+ /// </summary>
+ /// <param name="s">The text string to encode. </param>
+ /// <param name="output">The TextWriter output stream containing the encoded string. </param>
+ public void UrlEncode(string s, TextWriter output) {
+ output.Write(UrlEncode(s));
+ }
+
+ /// <summary>
+ /// URL-encodes the path portion of a URL string and returns the encoded string.
+ /// </summary>
+ /// <param name="s">The text to URL-encode.</param>
+ /// <returns>The URL encoded text.</returns>
+ /// <remarks>Does not do any browser specific adjustments, just encode everything</remarks>
+ public string UrlPathEncode(string s) {
+ // find the path portion (?)
+ int idx = s.IndexOf("?");
+ string s2 = s.Substring(0, idx-1);
+ s2 = UrlEncode(s2);
+ s2 += s.Substring(idx);
+
+ return s2;
+ }
+
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpStaticObjectsCollection.cs b/mcs/class/System.Web/System.Web/HttpStaticObjectsCollection.cs
new file mode 100644
index 00000000000..d2027061ea2
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpStaticObjectsCollection.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections;
+
+namespace System.Web {
+ public sealed class HttpStaticObjectsCollection : ICollection, IEnumerable {
+ private Hashtable _Objects;
+
+ // Needs to hold object items that can be latebound and can be serialized
+ public HttpStaticObjectsCollection() {
+ _Objects = new Hashtable();
+ }
+
+ public object GetObject(string name) {
+ return this[name];
+ }
+
+ public IEnumerator GetEnumerator() {
+ return _Objects.GetEnumerator ();
+ }
+
+ public void CopyTo(Array array, int index) {
+ _Objects.CopyTo (array, index);
+ }
+
+ internal IDictionary GetObjects() {
+ return _Objects;
+ }
+
+ public object this[string name] {
+ get {
+ return _Objects [name];
+ }
+ }
+
+ public int Count {
+ get {
+ return _Objects.Count;
+ }
+ }
+
+ public bool IsReadOnly {
+ get {
+ return true;
+ }
+ }
+
+ public bool IsSynchronized {
+ get {
+ return false;
+ }
+ }
+
+ public object SyncRoot {
+ get {
+ return this;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpUnhandledException.cs b/mcs/class/System.Web/System.Web/HttpUnhandledException.cs
new file mode 100644
index 00000000000..bb411bdf6f1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpUnhandledException.cs
@@ -0,0 +1,28 @@
+//
+// System.Web.HttpUnhandledException.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+namespace System.Web {
+ public sealed class HttpUnhandledException : HttpException {
+
+ #region Constructors
+
+ internal HttpUnhandledException (string message, Exception innerException)
+ : base (message, innerException)
+ {
+ }
+
+ [MonoTODO ("What does this do?")]
+ internal HttpUnhandledException (string message, string x, Exception innerException)
+ : base (message, innerException)
+ {
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpUtility.cs b/mcs/class/System.Web/System.Web/HttpUtility.cs
new file mode 100644
index 00000000000..280dba10fc8
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpUtility.cs
@@ -0,0 +1,777 @@
+//
+// System.Web.HttpUtility
+//
+// Authors:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Wictor Wilén (decode/encode functions) (wictor@ibizkit.se)
+// Tim Coleman (tim@timcoleman.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using System.Web.Util;
+
+namespace System.Web {
+ public sealed class HttpUtility {
+
+ #region Fields
+
+ const string _hex = "0123456789ABCDEF";
+ const string _chars = "<>;:.?=&@*+%/\\";
+ static Hashtable entities;
+ static string buildingHtmlEntityReferences = "Building HTML entity reference table.";
+
+ #endregion // Fields
+
+ #region Constructors
+
+ static HttpUtility ()
+ {
+ lock (buildingHtmlEntityReferences) {
+ // Build the hash table of HTML entity references. This list comes
+ // from the HTML 4.01 W3C recommendation.
+ entities = new Hashtable ();
+ entities.Add ("nbsp", '\u00A0');
+ entities.Add ("iexcl", '\u00A1');
+ entities.Add ("cent", '\u00A2');
+ entities.Add ("pound", '\u00A3');
+ entities.Add ("curren", '\u00A4');
+ entities.Add ("yen", '\u00A5');
+ entities.Add ("brvbar", '\u00A6');
+ entities.Add ("sect", '\u00A7');
+ entities.Add ("uml", '\u00A8');
+ entities.Add ("copy", '\u00A9');
+ entities.Add ("ordf", '\u00AA');
+ entities.Add ("laquo", '\u00AB');
+ entities.Add ("not", '\u00AC');
+ entities.Add ("shy", '\u00AD');
+ entities.Add ("reg", '\u00AE');
+ entities.Add ("macr", '\u00AF');
+ entities.Add ("deg", '\u00B0');
+ entities.Add ("plusmn", '\u00B1');
+ entities.Add ("sup2", '\u00B2');
+ entities.Add ("sup3", '\u00B3');
+ entities.Add ("acute", '\u00B4');
+ entities.Add ("micro", '\u00B5');
+ entities.Add ("para", '\u00B6');
+ entities.Add ("middot", '\u00B7');
+ entities.Add ("cedil", '\u00B8');
+ entities.Add ("sup1", '\u00B9');
+ entities.Add ("ordm", '\u00BA');
+ entities.Add ("raquo", '\u00BB');
+ entities.Add ("frac14", '\u00BC');
+ entities.Add ("frac12", '\u00BD');
+ entities.Add ("frac34", '\u00BE');
+ entities.Add ("iquest", '\u00BF');
+ entities.Add ("Agrave", '\u00C0');
+ entities.Add ("Aacute", '\u00C1');
+ entities.Add ("Acirc", '\u00C2');
+ entities.Add ("Atilde", '\u00C3');
+ entities.Add ("Auml", '\u00C4');
+ entities.Add ("Aring", '\u00C5');
+ entities.Add ("AElig", '\u00C6');
+ entities.Add ("Ccedil", '\u00C7');
+ entities.Add ("Egrave", '\u00C8');
+ entities.Add ("Eacute", '\u00C9');
+ entities.Add ("Ecirc", '\u00CA');
+ entities.Add ("Euml", '\u00CB');
+ entities.Add ("Igrave", '\u00CC');
+ entities.Add ("Iacute", '\u00CD');
+ entities.Add ("Icirc", '\u00CE');
+ entities.Add ("Iuml", '\u00CF');
+ entities.Add ("ETH", '\u00D0');
+ entities.Add ("Ntilde", '\u00D1');
+ entities.Add ("Ograve", '\u00D2');
+ entities.Add ("Oacute", '\u00D3');
+ entities.Add ("Ocirc", '\u00D4');
+ entities.Add ("Otilde", '\u00D5');
+ entities.Add ("Ouml", '\u00D6');
+ entities.Add ("times", '\u00D7');
+ entities.Add ("Oslash", '\u00D8');
+ entities.Add ("Ugrave", '\u00D9');
+ entities.Add ("Uacute", '\u00DA');
+ entities.Add ("Ucirc", '\u00DB');
+ entities.Add ("Uuml", '\u00DC');
+ entities.Add ("Yacute", '\u00DD');
+ entities.Add ("THORN", '\u00DE');
+ entities.Add ("szlig", '\u00DF');
+ entities.Add ("agrave", '\u00E0');
+ entities.Add ("aacute", '\u00E1');
+ entities.Add ("acirc", '\u00E2');
+ entities.Add ("atilde", '\u00E3');
+ entities.Add ("auml", '\u00E4');
+ entities.Add ("aring", '\u00E5');
+ entities.Add ("aelig", '\u00E6');
+ entities.Add ("ccedil", '\u00E7');
+ entities.Add ("egrave", '\u00E8');
+ entities.Add ("eacute", '\u00E9');
+ entities.Add ("ecirc", '\u00EA');
+ entities.Add ("euml", '\u00EB');
+ entities.Add ("igrave", '\u00EC');
+ entities.Add ("iacute", '\u00ED');
+ entities.Add ("icirc", '\u00EE');
+ entities.Add ("iuml", '\u00EF');
+ entities.Add ("eth", '\u00F0');
+ entities.Add ("ntilde", '\u00F1');
+ entities.Add ("ograve", '\u00F2');
+ entities.Add ("oacute", '\u00F3');
+ entities.Add ("ocirc", '\u00F4');
+ entities.Add ("otilde", '\u00F5');
+ entities.Add ("ouml", '\u00F6');
+ entities.Add ("divide", '\u00F7');
+ entities.Add ("oslash", '\u00F8');
+ entities.Add ("ugrave", '\u00F9');
+ entities.Add ("uacute", '\u00FA');
+ entities.Add ("ucirc", '\u00FB');
+ entities.Add ("uuml", '\u00FC');
+ entities.Add ("yacute", '\u00FD');
+ entities.Add ("thorn", '\u00FE');
+ entities.Add ("yuml", '\u00FF');
+ entities.Add ("fnof", '\u0192');
+ entities.Add ("Alpha", '\u0391');
+ entities.Add ("Beta", '\u0392');
+ entities.Add ("Gamma", '\u0393');
+ entities.Add ("Delta", '\u0394');
+ entities.Add ("Epsilon", '\u0395');
+ entities.Add ("Zeta", '\u0396');
+ entities.Add ("Eta", '\u0397');
+ entities.Add ("Theta", '\u0398');
+ entities.Add ("Iota", '\u0399');
+ entities.Add ("Kappa", '\u039A');
+ entities.Add ("Lambda", '\u039B');
+ entities.Add ("Mu", '\u039C');
+ entities.Add ("Nu", '\u039D');
+ entities.Add ("Xi", '\u039E');
+ entities.Add ("Omicron", '\u039F');
+ entities.Add ("Pi", '\u03A0');
+ entities.Add ("Rho", '\u03A1');
+ entities.Add ("Sigma", '\u03A3');
+ entities.Add ("Tau", '\u03A4');
+ entities.Add ("Upsilon", '\u03A5');
+ entities.Add ("Phi", '\u03A6');
+ entities.Add ("Chi", '\u03A7');
+ entities.Add ("Psi", '\u03A8');
+ entities.Add ("Omega", '\u03A9');
+ entities.Add ("alpha", '\u03B1');
+ entities.Add ("beta", '\u03B2');
+ entities.Add ("gamma", '\u03B3');
+ entities.Add ("delta", '\u03B4');
+ entities.Add ("epsilon", '\u03B5');
+ entities.Add ("zeta", '\u03B6');
+ entities.Add ("eta", '\u03B7');
+ entities.Add ("theta", '\u03B8');
+ entities.Add ("iota", '\u03B9');
+ entities.Add ("kappa", '\u03BA');
+ entities.Add ("lambda", '\u03BB');
+ entities.Add ("mu", '\u03BC');
+ entities.Add ("nu", '\u03BD');
+ entities.Add ("xi", '\u03BE');
+ entities.Add ("omicron", '\u03BF');
+ entities.Add ("pi", '\u03C0');
+ entities.Add ("rho", '\u03C1');
+ entities.Add ("sigmaf", '\u03C2');
+ entities.Add ("sigma", '\u03C3');
+ entities.Add ("tau", '\u03C4');
+ entities.Add ("upsilon", '\u03C5');
+ entities.Add ("phi", '\u03C6');
+ entities.Add ("chi", '\u03C7');
+ entities.Add ("psi", '\u03C8');
+ entities.Add ("omega", '\u03C9');
+ entities.Add ("thetasym", '\u03D1');
+ entities.Add ("upsih", '\u03D2');
+ entities.Add ("piv", '\u03D6');
+ entities.Add ("bull", '\u2022');
+ entities.Add ("hellip", '\u2026');
+ entities.Add ("prime", '\u2032');
+ entities.Add ("Prime", '\u2033');
+ entities.Add ("oline", '\u203E');
+ entities.Add ("frasl", '\u2044');
+ entities.Add ("weierp", '\u2118');
+ entities.Add ("image", '\u2111');
+ entities.Add ("real", '\u211C');
+ entities.Add ("trade", '\u2122');
+ entities.Add ("alefsym", '\u2135');
+ entities.Add ("larr", '\u2190');
+ entities.Add ("uarr", '\u2191');
+ entities.Add ("rarr", '\u2192');
+ entities.Add ("darr", '\u2193');
+ entities.Add ("harr", '\u2194');
+ entities.Add ("crarr", '\u21B5');
+ entities.Add ("lArr", '\u21D0');
+ entities.Add ("uArr", '\u21D1');
+ entities.Add ("rArr", '\u21D2');
+ entities.Add ("dArr", '\u21D3');
+ entities.Add ("hArr", '\u21D4');
+ entities.Add ("forall", '\u2200');
+ entities.Add ("part", '\u2202');
+ entities.Add ("exist", '\u2203');
+ entities.Add ("empty", '\u2205');
+ entities.Add ("nabla", '\u2207');
+ entities.Add ("isin", '\u2208');
+ entities.Add ("notin", '\u2209');
+ entities.Add ("ni", '\u220B');
+ entities.Add ("prod", '\u220F');
+ entities.Add ("sum", '\u2211');
+ entities.Add ("minus", '\u2212');
+ entities.Add ("lowast", '\u2217');
+ entities.Add ("radic", '\u221A');
+ entities.Add ("prop", '\u221D');
+ entities.Add ("infin", '\u221E');
+ entities.Add ("ang", '\u2220');
+ entities.Add ("and", '\u2227');
+ entities.Add ("or", '\u2228');
+ entities.Add ("cap", '\u2229');
+ entities.Add ("cup", '\u222A');
+ entities.Add ("int", '\u222B');
+ entities.Add ("there4", '\u2234');
+ entities.Add ("sim", '\u223C');
+ entities.Add ("cong", '\u2245');
+ entities.Add ("asymp", '\u2248');
+ entities.Add ("ne", '\u2260');
+ entities.Add ("equiv", '\u2261');
+ entities.Add ("le", '\u2264');
+ entities.Add ("ge", '\u2265');
+ entities.Add ("sub", '\u2282');
+ entities.Add ("sup", '\u2283');
+ entities.Add ("nsub", '\u2284');
+ entities.Add ("sube", '\u2286');
+ entities.Add ("supe", '\u2287');
+ entities.Add ("oplus", '\u2295');
+ entities.Add ("otimes", '\u2297');
+ entities.Add ("perp", '\u22A5');
+ entities.Add ("sdot", '\u22C5');
+ entities.Add ("lceil", '\u2308');
+ entities.Add ("rceil", '\u2309');
+ entities.Add ("lfloor", '\u230A');
+ entities.Add ("rfloor", '\u230B');
+ entities.Add ("lang", '\u2329');
+ entities.Add ("rang", '\u232A');
+ entities.Add ("loz", '\u25CA');
+ entities.Add ("spades", '\u2660');
+ entities.Add ("clubs", '\u2663');
+ entities.Add ("hearts", '\u2665');
+ entities.Add ("diams", '\u2666');
+ entities.Add ("quot", '\u0022');
+ entities.Add ("amp", '\u0026');
+ entities.Add ("lt", '\u003C');
+ entities.Add ("gt", '\u003E');
+ entities.Add ("OElig", '\u0152');
+ entities.Add ("oelig", '\u0153');
+ entities.Add ("Scaron", '\u0160');
+ entities.Add ("scaron", '\u0161');
+ entities.Add ("Yuml", '\u0178');
+ entities.Add ("circ", '\u02C6');
+ entities.Add ("tilde", '\u02DC');
+ entities.Add ("ensp", '\u2002');
+ entities.Add ("emsp", '\u2003');
+ entities.Add ("thinsp", '\u2009');
+ entities.Add ("zwnj", '\u200C');
+ entities.Add ("zwj", '\u200D');
+ entities.Add ("lrm", '\u200E');
+ entities.Add ("rlm", '\u200F');
+ entities.Add ("ndash", '\u2013');
+ entities.Add ("mdash", '\u2014');
+ entities.Add ("lsquo", '\u2018');
+ entities.Add ("rsquo", '\u2019');
+ entities.Add ("sbquo", '\u201A');
+ entities.Add ("ldquo", '\u201C');
+ entities.Add ("rdquo", '\u201D');
+ entities.Add ("bdquo", '\u201E');
+ entities.Add ("dagger", '\u2020');
+ entities.Add ("Dagger", '\u2021');
+ entities.Add ("permil", '\u2030');
+ entities.Add ("lsaquo", '\u2039');
+ entities.Add ("rsaquo", '\u203A');
+ entities.Add ("euro", '\u20AC');
+ }
+ }
+
+ public HttpUtility ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Methods
+
+ public static void HtmlAttributeEncode (string s, TextWriter output)
+ {
+ output.Write(HtmlAttributeEncode(s));
+ }
+
+ public static string HtmlAttributeEncode (string s)
+ {
+ if (null == s)
+ return null;
+
+ StringBuilder output = new StringBuilder ();
+
+ foreach (char c in s)
+ switch (c) {
+ case '&' :
+ output.Append ("&amp;");
+ break;
+ case '"' :
+ output.Append ("&quot;");
+ break;
+ default:
+ output.Append (c);
+ break;
+ }
+
+ return output.ToString();
+ }
+
+ public static string UrlDecode (string str)
+ {
+ return UrlDecode(str, WebEncoding.Encoding);
+ }
+
+ private static char [] GetChars (ArrayList b, Encoding e)
+ {
+ byte [] bytes = (byte []) b.ToArray (typeof (byte));
+ return e.GetChars (bytes);
+ }
+
+ public static string UrlDecode (string s, Encoding e)
+ {
+ if (null == s)
+ return null;
+
+ if (e == null)
+ e = WebEncoding.Encoding;
+
+ StringBuilder output = new StringBuilder ();
+ long len = s.Length;
+ NumberStyles hexa = NumberStyles.HexNumber;
+ ArrayList bytes = new ArrayList ();
+ char [] chars;
+
+ for (int i = 0; i < len; i++) {
+ if (s [i] == '%' && i + 2 < len) {
+ if (s [i + 1] == 'u' && i + 5 < len) {
+ if (bytes.Count > 0) {
+ chars = GetChars (bytes, e);
+ output.Append (chars);
+ bytes.Clear ();
+ }
+ output.Append ((char) Int32.Parse (s.Substring (i + 2, 4), hexa));
+ i += 5;
+ } else {
+ bytes.Add ((byte) Int32.Parse (s.Substring (i + 1, 2), hexa));
+ i += 2;
+ }
+ }
+ else {
+ if (bytes.Count > 0) {
+ chars = GetChars (bytes, e);
+ output.Append (chars);
+ bytes.Clear ();
+ }
+
+ if (s [i] == '+') {
+ output.Append (' ');
+ } else {
+ output.Append (s [i]);
+ }
+ }
+ }
+
+ if (bytes.Count > 0) {
+ chars = GetChars (bytes, e);
+ output.Append (chars);
+ }
+
+ return output.ToString ();
+ }
+
+ public static string UrlDecode (byte [] bytes, Encoding e)
+ {
+ if (bytes == null)
+ return null;
+
+ return UrlDecode (bytes, 0, bytes.Length, e);
+ }
+
+ private static int GetInt (byte b)
+ {
+ char c = Char.ToUpper ((char) b);
+ if (c >= '0' && c <= '9')
+ return c - '0';
+
+ if (c < 'A' || c > 'F')
+ return 0;
+
+ return (c - 'A' + 10);
+ }
+
+ private static char GetChar (byte [] bytes, int offset, int length)
+ {
+ int value = 0;
+ int end = length + offset;
+ for (int i = offset; i < end; i++)
+ value = (value << 4) + GetInt (bytes [offset]);
+
+ return (char) value;
+ }
+
+ public static string UrlDecode (byte [] bytes, int offset, int count, Encoding e)
+ {
+ if (bytes == null || count == 0)
+ return null;
+
+ if (bytes == null)
+ throw new ArgumentNullException ("bytes");
+
+ if (offset < 0 || offset > bytes.Length)
+ throw new ArgumentOutOfRangeException ("offset");
+
+ if (count < 0 || offset + count > bytes.Length)
+ throw new ArgumentOutOfRangeException ("count");
+
+ StringBuilder output = new StringBuilder ();
+ ArrayList byteArray = new ArrayList ();
+ char [] chars;
+
+ int end = count + offset;
+ for (int i = offset; i < end; i++) {
+ if (bytes [i] == '%' && i + 2 < count) {
+ if (bytes [i + 1] == (byte) 'u' && i + 5 < end) {
+ if (byteArray.Count > 0) {
+ chars = GetChars (byteArray, e);
+ output.Append (chars);
+ byteArray.Clear ();
+ }
+ output.Append (GetChar (bytes, offset + 2, 4));
+ i += 5;
+ } else {
+ byteArray.Add ((byte) GetChar (bytes, offset + 1, 2));
+ i += 2;
+ }
+ } else {
+ if (byteArray.Count > 0) {
+ chars = GetChars (byteArray, e);
+ output.Append (chars);
+ byteArray.Clear ();
+ }
+
+ if (bytes [i] == '+') {
+ output.Append (' ');
+ } else {
+ output.Append ((char) bytes [i]);
+ }
+ }
+ }
+
+ if (byteArray.Count > 0) {
+ chars = GetChars (byteArray, e);
+ output.Append (chars);
+ }
+
+ return output.ToString ();
+ }
+
+ public static byte [] UrlDecodeToBytes (byte [] bytes)
+ {
+ if (bytes == null)
+ return null;
+
+ return UrlDecodeToBytes (bytes, 0, bytes.Length);
+ }
+
+ public static byte [] UrlDecodeToBytes (string str)
+ {
+ return UrlDecodeToBytes (str, WebEncoding.Encoding);
+ }
+
+ public static byte [] UrlDecodeToBytes (string str, Encoding e)
+ {
+ if (str == null)
+ return null;
+
+ if (e == null)
+ throw new ArgumentNullException ("e");
+
+ return UrlDecodeToBytes (e.GetBytes (str));
+ }
+
+ public static byte [] UrlDecodeToBytes (byte [] bytes, int offset, int count)
+ {
+ if (bytes == null)
+ return null;
+
+ int len = bytes.Length;
+ if (offset < 0 || offset >= len)
+ throw new ArgumentOutOfRangeException("offset");
+
+ if (count < 0 || offset <= len - count)
+ throw new ArgumentOutOfRangeException("count");
+
+ ArrayList result = new ArrayList ();
+ int end = offset + count;
+ for (int i = offset; i < end; i++){
+ char c = (char) bytes [i];
+ if (c == '+')
+ c = ' ';
+ else if (c == '%' && i < end - 2) {
+ c = GetChar (bytes, i, 2);
+ i += 2;
+ }
+ result.Add ((byte) c);
+ }
+
+ return (byte []) result.ToArray (typeof (byte));
+ }
+
+ public static string UrlEncode(string str)
+ {
+ return UrlEncode(str, WebEncoding.Encoding);
+ }
+
+ public static string UrlEncode (string s, Encoding Enc)
+ {
+ if (s == null)
+ return null;
+
+ byte [] bytes = Enc.GetBytes (s);
+ return Encoding.ASCII.GetString (UrlEncodeToBytes (bytes, 0, bytes.Length));
+ }
+
+ public static string UrlEncode (byte [] bytes)
+ {
+ if (bytes == null)
+ return null;
+
+ return Encoding.ASCII.GetString (UrlEncodeToBytes (bytes, 0, bytes.Length));
+ }
+
+ public static string UrlEncode (byte [] bytes, int offset, int count)
+ {
+ if (bytes == null)
+ return null;
+
+ return Encoding.ASCII.GetString (UrlEncodeToBytes (bytes, offset, count));
+ }
+
+ public static byte [] UrlEncodeToBytes (string str)
+ {
+ return UrlEncodeToBytes (str, WebEncoding.Encoding);
+ }
+
+ public static byte [] UrlEncodeToBytes (string str, Encoding e)
+ {
+ if (str == null)
+ return null;
+
+ byte [] bytes = e.GetBytes (str);
+ return UrlEncodeToBytes (bytes, 0, bytes.Length);
+ }
+
+ public static byte [] UrlEncodeToBytes (byte [] bytes)
+ {
+ if (bytes == null)
+ return null;
+
+ return UrlEncodeToBytes (bytes, 0, bytes.Length);
+ }
+
+ static char [] hexChars = "0123456789ABCDEF".ToCharArray ();
+
+ public static byte [] UrlEncodeToBytes (byte [] bytes, int offset, int count)
+ {
+ if (bytes == null)
+ return null;
+
+ int len = bytes.Length;
+ if (offset < 0 || offset >= len)
+ throw new ArgumentOutOfRangeException("offset");
+
+ if (count < 0 || offset < len - count)
+ throw new ArgumentOutOfRangeException("count");
+
+ ArrayList result = new ArrayList ();
+ int end = offset + count;
+ for (int i = offset; i < end; i++) {
+ char c = (char) bytes [i];
+ if (c == ' ')
+ result.Add ((byte) '+');
+ else if ((c < '0' && c != '-' && c != '.') ||
+ (c < 'A' && c > '9') ||
+ (c > 'Z' && c < 'a' && c != '_') ||
+ (c > 'z')) {
+ result.Add ((byte) '%');
+ int idx = ((int) c) >> 4;
+ result.Add ((byte) hexChars [idx]);
+ idx = ((int) c) & 0x0F;
+ result.Add ((byte) hexChars [idx]);
+ } else {
+ result.Add ((byte) c);
+ }
+ }
+
+ return (byte []) result.ToArray (typeof (byte));
+ }
+
+ public static string UrlEncodeUnicode (string str)
+ {
+ if (str == null)
+ return null;
+
+ StringBuilder result = new StringBuilder ();
+ int end = str.Length;
+ for (int i = 0; i < end; i++) {
+ int idx;
+ char c = str [i];
+ if (c == ' ') {
+ result.Append ('+');
+ continue;
+ }
+
+ if (c > 255) {
+ result.Append ("%u");
+ idx = ((int) c) >> 24;
+ result.Append (hexChars [idx]);
+ idx = (((int) c) >> 16) & 0x0F;
+ result.Append (hexChars [idx]);
+ idx = (((int) c) >> 8) & 0x0F;
+ result.Append (hexChars [idx]);
+ idx = ((int) c) & 0x0F;
+ result.Append (hexChars [idx]);
+ continue;
+ }
+
+ if ((c < '0' && c != '-' && c != '.') ||
+ (c < 'A' && c > '9') ||
+ (c > 'Z' && c < 'a' && c != '_') ||
+ (c > 'z')) {
+ result.Append ('%');
+ idx = ((int) c) >> 4;
+ result.Append (hexChars [idx]);
+ idx = ((int) c) & 0x0F;
+ result.Append (hexChars [idx]);
+ continue;
+ }
+
+ result.Append (c);
+ }
+
+ return result.ToString ();
+ }
+
+ public static byte [] UrlEncodeUnicodeToBytes (string str)
+ {
+ if (str == null)
+ return null;
+
+ return Encoding.ASCII.GetBytes (UrlEncodeUnicode (str));
+ }
+
+ /// <summary>
+ /// Decodes an HTML-encoded string and returns the decoded string.
+ /// </summary>
+ /// <param name="s">The HTML string to decode. </param>
+ /// <returns>The decoded text.</returns>
+ public static string HtmlDecode (string s)
+ {
+ bool insideEntity = false; // used to indicate that we are in a potential entity
+ string entity = String.Empty;
+ StringBuilder output = new StringBuilder ();
+
+ foreach (char c in s) {
+ switch (c) {
+ case '&' :
+ output.Append (entity);
+ entity = "&";
+ insideEntity = true;
+ break;
+ case ';' :
+ if (!insideEntity) {
+ output.Append (c);
+ break;
+ }
+
+ entity += c;
+ int length = entity.Length;
+ if (length >= 2 && entity[1] == '#' && entity[2] != ';')
+ entity = ((char) Int32.Parse (entity.Substring (2, entity.Length - 3))).ToString();
+ else if (length > 1 && entities.ContainsKey (entity.Substring (1, entity.Length - 2)))
+ entity = entities [entity.Substring (1, entity.Length - 2)].ToString ();
+
+ output.Append (entity);
+ entity = String.Empty;
+ insideEntity = false;
+ break;
+ default :
+ if (insideEntity)
+ entity += c;
+ else
+ output.Append (c);
+ break;
+ }
+ }
+ output.Append (entity);
+ return output.ToString ();
+ }
+
+ /// <summary>
+ /// Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream.
+ /// </summary>
+ /// <param name="s">The HTML string to decode</param>
+ /// <param name="output">The TextWriter output stream containing the decoded string. </param>
+ public static void HtmlDecode(string s, TextWriter output)
+ {
+ output.Write (HtmlDecode (s));
+ }
+
+ /// <summary>
+ /// HTML-encodes a string and returns the encoded string.
+ /// </summary>
+ /// <param name="s">The text string to encode. </param>
+ /// <returns>The HTML-encoded text.</returns>
+ public static string HtmlEncode (string s)
+ {
+ StringBuilder output = new StringBuilder ();
+
+ foreach (char c in s)
+ switch (c) {
+ case '&' :
+ output.Append ("&amp;");
+ break;
+ case '>' :
+ output.Append ("&gt;");
+ break;
+ case '<' :
+ output.Append ("&lt;");
+ break;
+ case '"' :
+ output.Append ("&quot;");
+ break;
+ default:
+ if ((int) c > 128) {
+ output.Append ("&#");
+ output.Append (((int) c).ToString ());
+ output.Append (";");
+ }
+ else
+ output.Append (c);
+ break;
+ }
+ return output.ToString ();
+ }
+
+ /// <summary>
+ /// HTML-encodes a string and sends the resulting output to a TextWriter output stream.
+ /// </summary>
+ /// <param name="s">The string to encode. </param>
+ /// <param name="output">The TextWriter output stream containing the encoded string. </param>
+ public static void HtmlEncode(string s, TextWriter output)
+ {
+ output.Write (HtmlEncode (s));
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpValidationStatus.cs b/mcs/class/System.Web/System.Web/HttpValidationStatus.cs
new file mode 100644
index 00000000000..0933b9a6737
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpValidationStatus.cs
@@ -0,0 +1,17 @@
+//
+// System.Web.HttpValidationStatus.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+namespace System.Web {
+ [Serializable]
+ public enum HttpValidationStatus {
+ Invalid = 0x1,
+ IgnoreThisRequest,
+ Valid
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/HttpValueCollection.cs b/mcs/class/System.Web/System.Web/HttpValueCollection.cs
new file mode 100644
index 00000000000..a120094cbea
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpValueCollection.cs
@@ -0,0 +1,192 @@
+//
+// System.Web.HttpValueCollection
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// Gonzalo Paniagua (gonzalo@ximian.com)
+//
+using System;
+using System.Collections.Specialized;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Web.Util;
+
+namespace System.Web
+{
+ [Serializable]
+ class HttpValueCollection : NameValueCollection
+ {
+ bool _bHeaders;
+
+ internal HttpValueCollection ()
+ {
+ _bHeaders = false;
+ }
+
+ internal HttpValueCollection (string sData)
+ {
+ FillFromQueryString (sData, WebEncoding.Encoding);
+ IsReadOnly = true;
+ }
+
+ internal HttpValueCollection(string sData, bool ReadOnly, Encoding encoding)
+ {
+ FillFromQueryString (sData, encoding);
+ IsReadOnly = ReadOnly;
+ }
+
+ protected HttpValueCollection (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ // string = header1: value1\r\nheader2: value2
+ internal void FillFromHeaders (string sHeaders, Encoding encoding)
+ {
+ _bHeaders = true;
+ char [] arrSplitValue = new char [] {':'};
+ string sKey, sValue;
+
+ sKey = "";
+ sValue = "";
+
+ string [] arrValues = sHeaders.Split (new char [] {'\r', '\n'});
+ foreach (string sLine in arrValues) {
+ string [] arrKeyValue = sLine.Split (arrSplitValue);
+ if (arrKeyValue.Length == 1 && arrKeyValue [0].Length == 0) {
+ // Empty \r or \n is ignored
+ continue;
+ }
+
+ if (arrKeyValue[0] != sKey && sKey.Length > 0) {
+ Add (HttpUtility.UrlDecode (sKey, encoding),
+ HttpUtility.UrlDecode (sValue, encoding));
+ }
+
+ if (arrKeyValue.Length == 1) {
+ sValue += "\r\n" + arrKeyValue [0].Trim();
+ continue;
+ } else if (arrKeyValue.Length == 2) {
+ if (arrKeyValue[0].Length == 0) {
+ sValue += arrKeyValue [1].Trim();
+ continue;
+ }
+
+ sKey = arrKeyValue [0].Trim();
+ sValue = arrKeyValue [1].Trim();
+ }
+ }
+
+ if (sKey.Length > 0) {
+ Add (HttpUtility.UrlDecode (sKey, encoding),
+ HttpUtility.UrlDecode (sValue, encoding));
+ }
+ }
+
+ internal void FillFromHeaders (string sData)
+ {
+ FillFromHeaders (sData, WebEncoding.Encoding);
+ }
+
+ // String = test=aaa&kalle=nisse
+ internal void FillFromQueryString (string sData, Encoding encoding)
+ {
+ _bHeaders = false;
+
+ string k, v;
+ int eq;
+ string [] arrValues = sData.Split (new char [] {'&'});
+ foreach (string sValue in arrValues) {
+ eq = sValue.IndexOf ('=');
+ if (eq == 0)
+ throw new InvalidOperationException ("Data is malformed");
+
+ if (eq == -1) {
+ k = HttpUtility.UrlDecode (sValue.Trim (), encoding);
+ Add (k, String.Empty);
+ continue;
+ }
+
+ k = sValue.Substring (0, eq).Trim ();
+ if (k.Length == 0)
+ throw new InvalidOperationException ("Data is malformed");
+
+ v = String.Empty;
+ if (eq + 1 < sValue.Length) {
+ v = sValue.Substring (eq + 1).Trim ();
+ if (v.Length == 0)
+ v = String.Empty;
+ }
+
+ k = HttpUtility.UrlDecode (k, encoding);
+ if (v.Length > 0)
+ v = HttpUtility.UrlDecode (v, encoding);
+
+ Add (k, v);
+ }
+ }
+
+ internal void FillFromQueryString (string sData)
+ {
+ FillFromQueryString (sData, WebEncoding.Encoding);
+ }
+
+ internal void FillFromCookieString (string sData)
+ {
+ FillFromQueryString (sData, WebEncoding.Encoding);
+ }
+
+ internal void MakeReadOnly ()
+ {
+ IsReadOnly = true;
+ }
+
+ internal void MakeReadWrite ()
+ {
+ IsReadOnly = false;
+ }
+
+ internal void Merge (NameValueCollection oData)
+ {
+ foreach (string sKey in oData)
+ Add (sKey, oData [sKey]);
+ }
+
+ internal void Reset ()
+ {
+ Clear ();
+ }
+
+ internal string ToString (bool UrlEncode)
+ {
+ StringBuilder result = new StringBuilder ();
+ string eq = (_bHeaders ? ":" : "=");
+ string separator = (_bHeaders ? "\r\n" : "&");
+
+ foreach (string strKey in AllKeys) {
+
+ if (result.Length > 0)
+ result.Append (separator);
+
+ if (UrlEncode) {
+ // use encoding
+ result.Append (HttpUtility.UrlEncode (strKey, WebEncoding.Encoding));
+ result.Append (eq);
+ result.Append (HttpUtility.UrlEncode (Get (strKey), WebEncoding.Encoding));
+ } else {
+ result.Append (strKey);
+ result.Append (eq);
+ result.Append (Get (strKey));
+ }
+ }
+
+ return result.ToString ();
+ }
+
+ virtual new public string ToString ()
+ {
+ return ToString (false);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/HttpWorkerRequest.cs b/mcs/class/System.Web/System.Web/HttpWorkerRequest.cs
new file mode 100644
index 00000000000..4eede54bbf2
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpWorkerRequest.cs
@@ -0,0 +1,529 @@
+//
+// System.Web.HttpWorkerRequest
+//
+// Authors:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+// (constants from Bob Smith (bob@thestuff.net))
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) Patrik Torstensson
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+using System;
+using System.Collections;
+using System.Runtime.InteropServices;
+
+namespace System.Web
+{
+ public abstract class HttpWorkerRequest : IHttpMapPath
+ {
+ public delegate void EndOfSendNotification (HttpWorkerRequest wr, object extraData);
+
+ public const int HeaderAccept = 20;
+ public const int HeaderAcceptCharset = 21;
+ public const int HeaderAcceptEncoding = 22;
+ public const int HeaderAcceptLanguage = 23;
+ public const int HeaderAcceptRanges = 20;
+ public const int HeaderAge = 21;
+ public const int HeaderAllow = 10;
+ public const int HeaderAuthorization = 24;
+ public const int HeaderCacheControl = 0;
+ public const int HeaderConnection = 1;
+ public const int HeaderContentEncoding = 13;
+ public const int HeaderContentLanguage = 14;
+ public const int HeaderContentLength = 11;
+ public const int HeaderContentLocation = 15;
+ public const int HeaderContentMd5 = 16;
+ public const int HeaderContentRange = 17;
+ public const int HeaderContentType = 12;
+ public const int HeaderCookie = 25;
+ public const int HeaderDate = 2;
+ public const int HeaderEtag = 22;
+ public const int HeaderExpect = 26;
+ public const int HeaderExpires = 18;
+ public const int HeaderFrom = 27;
+ public const int HeaderHost = 28;
+ public const int HeaderIfMatch = 29;
+ public const int HeaderIfModifiedSince = 30;
+ public const int HeaderIfNoneMatch = 31;
+ public const int HeaderIfRange = 32;
+ public const int HeaderIfUnmodifiedSince = 33;
+ public const int HeaderKeepAlive = 3;
+ public const int HeaderLastModified = 19;
+ public const int HeaderLocation = 23;
+ public const int HeaderMaxForwards = 34;
+ public const int HeaderPragma = 4;
+ public const int HeaderProxyAuthenticate = 24;
+ public const int HeaderProxyAuthorization = 35;
+ public const int HeaderRange = 37;
+ public const int HeaderReferer = 36;
+ public const int HeaderRetryAfter = 25;
+ public const int HeaderServer = 26;
+ public const int HeaderSetCookie = 27;
+ public const int HeaderTe = 38;
+ public const int HeaderTrailer = 5;
+ public const int HeaderTransferEncoding = 6;
+ public const int HeaderUpgrade = 7;
+ public const int HeaderUserAgent = 39;
+ public const int HeaderVary = 28;
+ public const int HeaderVia = 8;
+ public const int HeaderWarning = 9;
+ public const int HeaderWwwAuthenticate = 29;
+ public const int ReasonCachePolicy = 2;
+ public const int ReasonCacheSecurity = 3;
+ public const int ReasonClientDisconnect = 4;
+ public const int ReasonDefault = 0;
+ public const int ReasonFileHandleCacheMiss = 1;
+ public const int ReasonResponseCacheMiss = 0;
+ public const int RequestHeaderMaximum = 40;
+ public const int ResponseHeaderMaximum = 30;
+
+ static string [][] s_HttpStatusDescriptions;
+ static string [] s_HttpRequestHeaderNames;
+ static string [] s_HttpResponseHeaderNames;
+
+ static Hashtable s_HttpResponseHeadersTable;
+ static Hashtable s_HttpRequestHeaderTable;
+
+ static HttpWorkerRequest ()
+ {
+ string [] sSubCodes;
+
+ s_HttpStatusDescriptions = new string [6][];
+
+ sSubCodes = new String [3];
+ sSubCodes [0] = "Continue";
+ sSubCodes [1] = "Switching Protocols";
+ sSubCodes [2] = "Processing";
+ s_HttpStatusDescriptions [1] = sSubCodes;
+
+ sSubCodes = new String [8];
+ sSubCodes [0] = "OK";
+ sSubCodes [1] = "Created";
+ sSubCodes [2] = "Accepted";
+ sSubCodes [3] = "Non-Authoritative Information";
+ sSubCodes [4] = "No Content";
+ sSubCodes [5] = "Reset Content";
+ sSubCodes [6] = "Partial Content";
+ sSubCodes [7] = "Multi-Status";
+ s_HttpStatusDescriptions [2] = sSubCodes;
+
+ sSubCodes = new String [8];
+ sSubCodes [0] = "Multiple Choices";
+ sSubCodes [1] = "Moved Permanently";
+ sSubCodes [2] = "Found";
+ sSubCodes [3] = "See Other";
+ sSubCodes [4] = "Not Modified";
+ sSubCodes [5] = "Use Proxy";
+ sSubCodes [6] = String.Empty;
+ sSubCodes [7] = "Temporary Redirect";
+ s_HttpStatusDescriptions [3] = sSubCodes;
+
+ sSubCodes = new String [24];
+ sSubCodes [0] = "Bad Request";
+ sSubCodes [1] = "Unauthorized";
+ sSubCodes [2] = "Payment Required";
+ sSubCodes [3] = "Forbidden";
+ sSubCodes [4] = "Not Found";
+ sSubCodes [5] = "Method Not Allowed";
+ sSubCodes [6] = "Not Acceptable";
+ sSubCodes [7] = "Proxy Authentication Required";
+ sSubCodes [8] = "Request Timeout";
+ sSubCodes [9] = "Conflict";
+ sSubCodes [10] = "Gone";
+ sSubCodes [11] = "Length Required";
+ sSubCodes [12] = "Precondition Failed";
+ sSubCodes [13] = "Request Entity Too Large";
+ sSubCodes [14] = "Request-Uri Too Long";
+ sSubCodes [15] = "Unsupported Media Type";
+ sSubCodes [16] = "Requested Range Not Satisfiable";
+ sSubCodes [17] = "Expectation Failed";
+ sSubCodes [18] = String.Empty;
+ sSubCodes [19] = String.Empty;
+ sSubCodes [20] = String.Empty;
+ sSubCodes [21] = "Unprocessable Entity";
+ sSubCodes [22] = "Locked";
+ sSubCodes [23] = "Failed Dependency";
+ s_HttpStatusDescriptions [4] = sSubCodes;
+
+ sSubCodes = new String [8];
+ sSubCodes [0] = "Internal Server Error";
+ sSubCodes [1] = "Not Implemented";
+ sSubCodes [2] = "Bad Gateway";
+ sSubCodes [3] = "Service Unavailable";
+ sSubCodes [4] = "Gateway Timeout";
+ sSubCodes [5] = "Http Version Not Supported";
+ sSubCodes [6] = String.Empty;
+ sSubCodes [7] = "Insufficient Storage";
+ s_HttpStatusDescriptions [5] = sSubCodes;
+
+ InitLookupTables ();
+ }
+
+ protected HttpWorkerRequest ()
+ {
+ }
+
+ static private void InitLookupTables ()
+ {
+ // Performance arrays
+ s_HttpRequestHeaderNames = new string [40];
+ s_HttpResponseHeaderNames = new string [30];
+
+ // Lookup tables (name -> id)
+ s_HttpRequestHeaderTable = new Hashtable ();
+ s_HttpResponseHeadersTable = new Hashtable ();
+
+ AddHeader (true, true, 0, "Cache-Control");
+ AddHeader (true, true, 1, "Connection");
+ AddHeader (true, true, 2, "Date");
+ AddHeader (true, true, 3, "Keep-Alive");
+ AddHeader (true, true, 4, "Pragma");
+ AddHeader (true, true, 5, "Trailer");
+ AddHeader (true, true, 6, "Transfer-Encoding");
+ AddHeader (true, true, 7, "Upgrade");
+ AddHeader (true, true, 8, "Via");
+ AddHeader (true, true, 9, "Warning");
+ AddHeader (true, true, 10, "Allow");
+ AddHeader (true, true, 11, "Content-Length");
+ AddHeader (true, true, 12, "Content-Type");
+ AddHeader (true, true, 13, "Content-Encoding");
+ AddHeader (true, true, 14, "Content-Language");
+ AddHeader (true, true, 15, "Content-Location");
+ AddHeader (true, true, 16, "Content-MD5");
+ AddHeader (true, true, 17, "Content-Range");
+ AddHeader (true, true, 18, "Expires");
+ AddHeader (true, true, 19, "Last-Modified");
+ AddHeader (true, false, 20, "Accept");
+ AddHeader (true, false, 21, "Accept-Charset");
+ AddHeader (true, false, 22, "Accept-Encoding");
+ AddHeader (true, false, 23, "Accept-Language");
+ AddHeader (true, false, 24, "Authorization");
+ AddHeader (true, false, 25, "Cookie");
+ AddHeader (true, false, 26, "Expect");
+ AddHeader (true, false, 27, "From");
+ AddHeader (true, false, 28, "Host");
+ AddHeader (true, false, 29, "If-Match");
+ AddHeader (true, false, 30, "If-Modified-Since");
+ AddHeader (true, false, 31, "If-None-Match");
+ AddHeader (true, false, 32, "If-Range");
+ AddHeader (true, false, 33, "If-Unmodified-Since");
+ AddHeader (true, false, 34, "Max-Forwards");
+ AddHeader (true, false, 35, "Proxy-Authorization");
+ AddHeader (true, false, 36, "Referer");
+ AddHeader (true, false, 37, "Range");
+ AddHeader (true, false, 38, "TE");
+ AddHeader (true, false, 39, "User-Agent");
+ AddHeader (false, true, 20, "Accept-Ranges");
+ AddHeader (false, true, 21, "Age");
+ AddHeader (false, true, 22, "ETag");
+ AddHeader (false, true, 23, "Location");
+ AddHeader (false, true, 24, "Proxy-Authenticate");
+ AddHeader (false, true, 25, "Retry-After");
+ AddHeader (false, true, 26, "Server");
+ AddHeader (false, true, 27, "Set-Cookie");
+ AddHeader (false, true, 28, "Vary");
+ AddHeader (false, true, 29, "WWW-Authenticate");
+ }
+
+ static private void AddHeader(bool bRequest, bool bResponse, int iID, string sHeader)
+ {
+ if (bResponse) {
+ s_HttpResponseHeaderNames [iID] = sHeader;
+ s_HttpResponseHeadersTable.Add (sHeader, iID);
+ }
+
+ if (bRequest) {
+ s_HttpRequestHeaderNames [iID] = sHeader;
+ s_HttpRequestHeaderTable.Add (sHeader, iID);
+ }
+ }
+
+ public virtual void CloseConnection ()
+ {
+ }
+
+ public abstract void EndOfRequest ();
+ public abstract void FlushResponse (bool finalFlush);
+
+ public virtual string GetAppPath ()
+ {
+ return null;
+ }
+
+ public virtual string GetAppPathTranslated ()
+ {
+ return null;
+ }
+
+ public virtual string GetAppPoolID ()
+ {
+ return null;
+ }
+
+ public virtual long GetBytesRead ()
+ {
+ return 0;
+ }
+
+ public virtual byte[] GetClientCertificate ()
+ {
+ return new byte[0];
+ }
+
+ public virtual byte[] GetClientCertificateBinaryIssuer ()
+ {
+ return new byte[0];
+ }
+
+ public virtual int GetClientCertificateEncoding ()
+ {
+ return 0;
+ }
+
+ public virtual byte[] GetClientCertificatePublicKey ()
+ {
+ return new byte[0];
+ }
+
+ public virtual DateTime GetClientCertificateValidFrom ()
+ {
+ return DateTime.Now;
+ }
+
+ public virtual DateTime GetClientCertificateValidUntil ()
+ {
+ return DateTime.Now;
+ }
+
+ public virtual long GetConnectionID ()
+ {
+ return 0;
+ }
+
+ public virtual string GetFilePath ()
+ {
+ return GetUriPath();
+ }
+
+ public virtual string GetFilePathTranslated ()
+ {
+ return null;
+ }
+
+ public abstract string GetHttpVerbName ();
+ public abstract string GetHttpVersion ();
+
+ public virtual string GetKnownRequestHeader (int index)
+ {
+ return null;
+ }
+
+ public static int GetKnownRequestHeaderIndex (string header)
+ {
+ object index;
+ index = s_HttpRequestHeaderTable [header];
+ if (null != index)
+ return (Int32) index;
+
+ return -1;
+ }
+
+ public static string GetKnownRequestHeaderName (int index)
+ {
+ return s_HttpRequestHeaderNames [index];
+ }
+
+ public static int GetKnownResponseHeaderIndex (string header)
+ {
+ object index;
+
+ index = s_HttpResponseHeadersTable [header];
+ if (null != index)
+ return (Int32) index;
+
+ return -1;
+ }
+
+ public static string GetKnownResponseHeaderName(int index)
+ {
+ return s_HttpResponseHeaderNames [index];
+ }
+
+ public abstract string GetLocalAddress ();
+ public abstract int GetLocalPort ();
+
+ public virtual string GetPathInfo ()
+ {
+ return String.Empty;
+ }
+
+ public virtual byte [] GetPreloadedEntityBody ()
+ {
+ return null;
+ }
+
+ public virtual string GetProtocol ()
+ {
+ return (IsSecure ()) ? "https" : "http";
+ }
+
+ public abstract string GetQueryString ();
+
+ public virtual byte[] GetQueryStringRawBytes ()
+ {
+ return null;
+ }
+
+ public abstract string GetRawUrl ();
+ public abstract string GetRemoteAddress ();
+
+ public virtual string GetRemoteName ()
+ {
+ return GetRemoteAddress();
+ }
+
+ public abstract int GetRemotePort ();
+
+ public virtual int GetRequestReason ()
+ {
+ return 0;
+ }
+
+ public virtual string GetServerName ()
+ {
+ return GetLocalAddress();
+ }
+
+ public virtual string GetServerVariable (string name)
+ {
+ return null;
+ }
+
+ public static string GetStatusDescription (int code)
+ {
+ if (code>= 100 && code < 600) {
+ int iMajor = code / 100;
+ int iMinor = code % 100;
+ if (iMinor < (int) s_HttpStatusDescriptions [iMajor].Length)
+ return s_HttpStatusDescriptions [iMajor][iMinor];
+ }
+
+ return String.Empty;
+ }
+
+ public virtual string GetUnknownRequestHeader (string name)
+ {
+ return null;
+ }
+
+ [CLSCompliant(false)]
+ public virtual string [][] GetUnknownRequestHeaders ()
+ {
+ return null;
+ }
+
+ public abstract string GetUriPath ();
+
+ public virtual long GetUrlContextID ()
+ {
+ return 0;
+ }
+
+ public virtual IntPtr GetUserToken ()
+ {
+ throw new NotSupportedException ();
+ }
+
+ public virtual IntPtr GetVirtualPathToken ()
+ {
+ throw new NotSupportedException ();
+ }
+
+ public bool HasEntityBody ()
+ {
+ string sContentLength = GetKnownRequestHeader (HeaderContentLength);
+ if (null != sContentLength && sContentLength != "0")
+ return true;
+
+ if (null != GetKnownRequestHeader (HeaderTransferEncoding))
+ return true;
+
+ if (null != GetPreloadedEntityBody () || IsEntireEntityBodyIsPreloaded ())
+ return true;
+
+ return false;
+ }
+
+ public virtual bool HeadersSent ()
+ {
+ return true;
+ }
+
+ public virtual bool IsClientConnected ()
+ {
+ return true;
+ }
+
+ public virtual bool IsEntireEntityBodyIsPreloaded ()
+ {
+ return false;
+ }
+
+ public virtual bool IsSecure ()
+ {
+ return false;
+ }
+
+ public virtual string MapPath (string virtualPath)
+ {
+ return null;
+ }
+
+ public virtual int ReadEntityBody (byte[] buffer, int size)
+ {
+ return 0;
+ }
+
+ public virtual void SendCalculatedContentLength (int contentLength)
+ {
+ }
+
+ public abstract void SendKnownResponseHeader (int index, string value);
+ public abstract void SendResponseFromFile (IntPtr handle, long offset, long length);
+ public abstract void SendResponseFromFile (string filename, long offset, long length);
+ public abstract void SendResponseFromMemory (byte [] data, int length);
+
+ public virtual void SendResponseFromMemory (IntPtr data, int length)
+ {
+ if (length <= 0)
+ return;
+
+ byte [] dataBytes = new byte [length];
+ Marshal.Copy (data, dataBytes, 0, length);
+ SendResponseFromMemory (dataBytes, length);
+ }
+
+ public abstract void SendStatus (int statusCode, string statusDescription);
+ public abstract void SendUnknownResponseHeader (string name, string value);
+
+ public virtual void SetEndOfSendNotification (EndOfSendNotification callback, object extraData)
+ {
+ }
+
+ public virtual string MachineConfigPath
+ {
+ get {
+ return null;
+ }
+ }
+
+ public virtual string MachineInstallDirectory
+ {
+ get {
+ return null;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/HttpWriter.cs b/mcs/class/System.Web/System.Web/HttpWriter.cs
new file mode 100644
index 00000000000..55e62ac2842
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/HttpWriter.cs
@@ -0,0 +1,209 @@
+//
+// System.Web.HttpWriter
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.IO;
+using System.Text;
+using System.Web.Util;
+
+namespace System.Web
+{
+ public sealed class HttpWriter : TextWriter
+ {
+ HttpResponse _Response;
+
+ HttpResponseStream _ResponseStream;
+
+ MemoryStream _OutputStream;
+ StreamWriter _OutputHelper;
+ Encoder _Encoder;
+ Encoding _Encoding;
+
+ Stream _OutputFilter;
+ HttpResponseStreamProxy _OutputProxy;
+
+ internal HttpWriter (HttpResponse Response)
+ {
+ _Response = Response;
+
+ _OutputStream = new MemoryStream (32768);
+ _OutputHelper = new StreamWriter (_OutputStream, WebEncoding.Encoding);
+ _ResponseStream = new HttpResponseStream (this);
+
+ Update ();
+ }
+
+ internal void Dispose ()
+ {
+ _OutputHelper.Close ();
+ _OutputStream.Close ();
+ _OutputFilter.Close ();
+ }
+
+ internal Stream GetActiveFilter ()
+ {
+ if (null == _OutputFilter) {
+ // Create a filter proxy to allow us to know if we have a valid filter
+ if (null == _OutputProxy)
+ _OutputProxy = new HttpResponseStreamProxy (this);
+
+ return _OutputProxy;
+ }
+ return _OutputFilter;
+ }
+
+ internal void ActivateFilter (Stream OutputFilter)
+ {
+ if (null == _OutputProxy)
+ throw new HttpException ("Invalid filter usage");
+
+ _OutputFilter = OutputFilter;
+ }
+
+ internal void FilterData (bool CloseStream)
+ {
+ // Check if we have any filter at all
+ if (null == _OutputFilter)
+ return;
+
+ FlushBuffers ();
+
+ // Save our current data
+ byte [] arrData = _OutputStream.ToArray ();
+
+ // Remove our internal data
+ Clear ();
+
+ // If we have a filter then we have a proxy
+ _OutputProxy.Active = true;
+
+ try {
+ // Call the filter (it does a callback into our HttpWriter again)
+ _OutputFilter.Write (arrData, 0, arrData.Length);
+
+ if (CloseStream)
+ _OutputFilter.Close ();
+ } finally {
+ _OutputProxy.Active = false;
+ }
+ }
+
+ internal void Clear ()
+ {
+ _OutputHelper.Close ();
+ _OutputStream.Close ();
+
+ // Quick way of doing cleanup
+ _OutputStream = new MemoryStream (32768);
+ _OutputHelper = new StreamWriter (_OutputStream, WebEncoding.Encoding);
+ }
+
+ internal void SendContent (HttpWorkerRequest Handler)
+ {
+ FlushBuffers();
+
+ int l = (int)_OutputStream.Length;
+ if (l > 0) {
+ byte [] arrContent = _OutputStream.ToArray ();
+ Handler.SendResponseFromMemory (arrContent, l);
+ }
+ }
+
+ internal void Update ()
+ {
+ _Encoder = _Response.ContentEncoder;
+ _Encoding = _Response.ContentEncoding;
+ }
+
+ internal long BufferSize
+ {
+ get {
+ FlushBuffers ();
+ return _OutputStream.Length;
+ }
+ }
+
+ internal void FlushBuffers ()
+ {
+ _OutputHelper.Flush ();
+ _OutputStream.Flush ();
+ }
+
+ public override Encoding Encoding
+ {
+ get { return _Encoding; }
+ }
+
+ public Stream OutputStream
+ {
+ get { return _ResponseStream; }
+ }
+
+ public override void Close ()
+ {
+ FlushBuffers ();
+ _Response.Flush ();
+ _Response.Close ();
+ }
+
+ public override void Flush ()
+ {
+ FlushBuffers ();
+ _Response.Flush ();
+ }
+
+ private void CheckIfFlush ()
+ {
+ if (!_Response.BufferOutput) {
+ FlushBuffers ();
+ _Response.Flush ();
+ }
+ }
+
+ public override void Write (char ch)
+ {
+ _OutputHelper.Write (ch);
+ CheckIfFlush ();
+ }
+
+ public override void Write (object obj)
+ {
+ _OutputHelper.Write (obj.ToString ());
+ CheckIfFlush ();
+ }
+
+ public override void Write (string s)
+ {
+ _OutputHelper.Write (s);
+ CheckIfFlush ();
+ }
+
+ public override void Write (char [] buffer, int index, int count)
+ {
+ _OutputHelper.Write (buffer, index, count);
+ CheckIfFlush ();
+ }
+
+ public void WriteBytes (byte [] buffer, int index, int count)
+ {
+ _OutputStream.Write (buffer, index, count);
+ CheckIfFlush ();
+ }
+
+ public override void WriteLine ()
+ {
+ _OutputHelper.Write ("\r\n");
+ CheckIfFlush ();
+ }
+
+ public void WriteString (string s, int index, int count)
+ {
+ _OutputHelper.Write (s.Substring (index, count));
+ CheckIfFlush ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/IHttpAsyncHandler.cs b/mcs/class/System.Web/System.Web/IHttpAsyncHandler.cs
new file mode 100644
index 00000000000..06e62cba463
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/IHttpAsyncHandler.cs
@@ -0,0 +1,18 @@
+//
+// System.Web.IHttpAsyncHandler.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+namespace System.Web
+{
+ public interface IHttpAsyncHandler : IHttpHandler
+ {
+ IAsyncResult BeginProcessRequest(HttpContext context,
+ AsyncCallback cb,
+ object extraData);
+ void EndProcessRequest(IAsyncResult result);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/IHttpHandler.cs b/mcs/class/System.Web/System.Web/IHttpHandler.cs
new file mode 100644
index 00000000000..8bad2c1b1bd
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/IHttpHandler.cs
@@ -0,0 +1,16 @@
+//
+// System.IHttpHandler.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+namespace System.Web
+{
+ public interface IHttpHandler
+ {
+ bool IsReusable { get; }
+ void ProcessRequest(HttpContext context);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/IHttpHandlerFactory.cs b/mcs/class/System.Web/System.Web/IHttpHandlerFactory.cs
new file mode 100644
index 00000000000..b8cc4a3d2c5
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/IHttpHandlerFactory.cs
@@ -0,0 +1,19 @@
+//
+// System.Web.IHttpHandlerFactory.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+namespace System.Web
+{
+ public interface IHttpHandlerFactory
+ {
+ IHttpHandler GetHandler(HttpContext context,
+ string requestType,
+ string url,
+ string pathTranslated);
+ void ReleaseHandler(IHttpHandler handler);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/IHttpMapPath.cs b/mcs/class/System.Web/System.Web/IHttpMapPath.cs
new file mode 100644
index 00000000000..933ffb47336
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/IHttpMapPath.cs
@@ -0,0 +1,19 @@
+//
+// System.Web.IHttpMapPath
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Web
+{
+ interface IHttpMapPath
+ {
+ string MapPath (string path);
+ string MachineConfigPath { get; }
+ }
+
+}
+
diff --git a/mcs/class/System.Web/System.Web/IHttpModule.cs b/mcs/class/System.Web/System.Web/IHttpModule.cs
new file mode 100644
index 00000000000..a98d2f54d29
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/IHttpModule.cs
@@ -0,0 +1,14 @@
+//
+// System.Web.IHttpModule.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+namespace System.Web {
+ public interface IHttpModule {
+ void Dispose();
+ void Init(HttpApplication context);
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/MimeTypes.cs b/mcs/class/System.Web/System.Web/MimeTypes.cs
new file mode 100644
index 00000000000..ff267d853c1
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/MimeTypes.cs
@@ -0,0 +1,471 @@
+//
+// System.Web.MimeTypes
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+
+namespace System.Web
+{
+ class MimeTypes
+ {
+ static Hashtable mimeTypes;
+
+ static MimeTypes ()
+ {
+ mimeTypes = new Hashtable (CaseInsensitiveHashCodeProvider.Default,
+ CaseInsensitiveComparer.Default);
+
+ mimeTypes.Add ("3dm", "x-world/x-3dmf");
+ mimeTypes.Add ("3dmf", "x-world/x-3dmf");
+ mimeTypes.Add ("aab", "application/x-authorware-bin");
+ mimeTypes.Add ("aam", "application/x-authorware-map");
+ mimeTypes.Add ("aas", "application/x-authorware-seg");
+ mimeTypes.Add ("abc", "text/vnd.abc");
+ mimeTypes.Add ("acgi", "text/html");
+ mimeTypes.Add ("afl", "video/animaflex");
+ mimeTypes.Add ("ai", "application/postscript");
+ mimeTypes.Add ("aif", "audio/aiff");
+ mimeTypes.Add ("aifc", "audio/aiff");
+ mimeTypes.Add ("aiff", "audio/aiff");
+ mimeTypes.Add ("aim", "application/x-aim");
+ mimeTypes.Add ("aip", "text/x-audiosoft-intra");
+ mimeTypes.Add ("ani", "application/x-navi-animation");
+ mimeTypes.Add ("aos", "application/x-nokia-9000-communicator-add-on-software");
+ mimeTypes.Add ("aps", "application/mime");
+ mimeTypes.Add ("art", "image/x-jg");
+ mimeTypes.Add ("asf", "video/x-ms-asf");
+ mimeTypes.Add ("asm", "text/x-asm");
+ mimeTypes.Add ("asp", "text/asp");
+ mimeTypes.Add ("asx", "application/x-mplayer2");
+ mimeTypes.Add ("au", "audio/x-au");
+ mimeTypes.Add ("avi", "video/avi");
+ mimeTypes.Add ("avs", "video/avs-video");
+ mimeTypes.Add ("bcpio", "application/x-bcpio");
+ mimeTypes.Add ("bm", "image/bmp");
+ mimeTypes.Add ("bmp", "image/bmp");
+ mimeTypes.Add ("boo", "application/book");
+ mimeTypes.Add ("book", "application/book");
+ mimeTypes.Add ("boz", "application/x-bzip2");
+ mimeTypes.Add ("bsh", "application/x-bsh");
+ mimeTypes.Add ("bz", "application/x-bzip");
+ mimeTypes.Add ("bz2", "application/x-bzip2");
+ mimeTypes.Add ("c", "text/plain");
+ mimeTypes.Add ("c++", "text/plain");
+ mimeTypes.Add ("cat", "application/vnd.ms-pki.seccat");
+ mimeTypes.Add ("cc", "text/plain");
+ mimeTypes.Add ("ccad", "application/clariscad");
+ mimeTypes.Add ("cco", "application/x-cocoa");
+ mimeTypes.Add ("cdf", "application/cdf");
+ mimeTypes.Add ("cer", "application/pkix-cert");
+ mimeTypes.Add ("cha", "application/x-chat");
+ mimeTypes.Add ("chat", "application/x-chat");
+ mimeTypes.Add ("class", "application/java");
+ mimeTypes.Add ("conf", "text/plain");
+ mimeTypes.Add ("cpio", "application/x-cpio");
+ mimeTypes.Add ("cpp", "text/plain");
+ mimeTypes.Add ("cpt", "application/x-cpt");
+ mimeTypes.Add ("crl", "application/pkix-crl");
+ mimeTypes.Add ("crt", "application/pkix-cert");
+ mimeTypes.Add ("csh", "application/x-csh");
+ mimeTypes.Add ("css", "text/css");
+ mimeTypes.Add ("cxx", "text/plain");
+ mimeTypes.Add ("dcr", "application/x-director");
+ mimeTypes.Add ("deepv", "application/x-deepv");
+ mimeTypes.Add ("def", "text/plain");
+ mimeTypes.Add ("der", "application/x-x509-ca-cert");
+ mimeTypes.Add ("dif", "video/x-dv");
+ mimeTypes.Add ("dir", "application/x-director");
+ mimeTypes.Add ("dl", "video/dl");
+ mimeTypes.Add ("doc", "application/msword");
+ mimeTypes.Add ("dot", "application/msword");
+ mimeTypes.Add ("dp", "application/commonground");
+ mimeTypes.Add ("drw", "application/drafting");
+ mimeTypes.Add ("dv", "video/x-dv");
+ mimeTypes.Add ("dvi", "application/x-dvi");
+ mimeTypes.Add ("dwf", "drawing/x-dwf (old)");
+ mimeTypes.Add ("dwg", "application/acad");
+ mimeTypes.Add ("dxf", "application/dxf");
+ mimeTypes.Add ("dxr", "application/x-director");
+ mimeTypes.Add ("el", "text/x-script.elisp");
+ mimeTypes.Add ("elc", "application/x-elc");
+ mimeTypes.Add ("eps", "application/postscript");
+ mimeTypes.Add ("es", "application/x-esrehber");
+ mimeTypes.Add ("etx", "text/x-setext");
+ mimeTypes.Add ("evy", "application/envoy");
+ mimeTypes.Add ("f", "text/plain");
+ mimeTypes.Add ("f77", "text/plain");
+ mimeTypes.Add ("f90", "text/plain");
+ mimeTypes.Add ("fdf", "application/vnd.fdf");
+ mimeTypes.Add ("fif", "image/fif");
+ mimeTypes.Add ("fli", "video/fli");
+ mimeTypes.Add ("flo", "image/florian");
+ mimeTypes.Add ("flx", "text/vnd.fmi.flexstor");
+ mimeTypes.Add ("fmf", "video/x-atomic3d-feature");
+ mimeTypes.Add ("for", "text/plain");
+ mimeTypes.Add ("fpx", "image/vnd.fpx");
+ mimeTypes.Add ("frl", "application/freeloader");
+ mimeTypes.Add ("funk", "audio/make");
+ mimeTypes.Add ("g", "text/plain");
+ mimeTypes.Add ("g3", "image/g3fax");
+ mimeTypes.Add ("gif", "image/gif");
+ mimeTypes.Add ("gl", "video/gl");
+ mimeTypes.Add ("gsd", "audio/x-gsm");
+ mimeTypes.Add ("gsm", "audio/x-gsm");
+ mimeTypes.Add ("gsp", "application/x-gsp");
+ mimeTypes.Add ("gss", "application/x-gss");
+ mimeTypes.Add ("gtar", "application/x-gtar");
+ mimeTypes.Add ("gz", "application/x-gzip");
+ mimeTypes.Add ("gzip", "application/x-gzip");
+ mimeTypes.Add ("h", "text/plain");
+ mimeTypes.Add ("hdf", "application/x-hdf");
+ mimeTypes.Add ("help", "application/x-helpfile");
+ mimeTypes.Add ("hgl", "application/vnd.hp-HPGL");
+ mimeTypes.Add ("hh", "text/plain");
+ mimeTypes.Add ("hlb", "text/x-script");
+ mimeTypes.Add ("hlp", "application/x-helpfile");
+ mimeTypes.Add ("hpg", "application/vnd.hp-HPGL");
+ mimeTypes.Add ("hpgl", "application/vnd.hp-HPGL");
+ mimeTypes.Add ("hqx", "application/binhex");
+ mimeTypes.Add ("hta", "application/hta");
+ mimeTypes.Add ("htc", "text/x-component");
+ mimeTypes.Add ("htm", "text/html");
+ mimeTypes.Add ("html", "text/html");
+ mimeTypes.Add ("htmls", "text/html");
+ mimeTypes.Add ("htt", "text/webviewhtml");
+ mimeTypes.Add ("htx ", "text/html");
+ mimeTypes.Add ("ice ", "x-conference/x-cooltalk");
+ mimeTypes.Add ("ico", "image/x-icon");
+ mimeTypes.Add ("idc", "text/plain");
+ mimeTypes.Add ("ief", "image/ief");
+ mimeTypes.Add ("iefs", "image/ief");
+ mimeTypes.Add ("iges", "application/iges");
+ mimeTypes.Add ("igs", "application/iges");
+ mimeTypes.Add ("ima", "application/x-ima");
+ mimeTypes.Add ("imap", "application/x-httpd-imap");
+ mimeTypes.Add ("inf ", "application/inf");
+ mimeTypes.Add ("ins", "application/x-internett-signup");
+ mimeTypes.Add ("ip ", "application/x-ip2");
+ mimeTypes.Add ("isu", "video/x-isvideo");
+ mimeTypes.Add ("it", "audio/it");
+ mimeTypes.Add ("iv", "application/x-inventor");
+ mimeTypes.Add ("ivr", "i-world/i-vrml");
+ mimeTypes.Add ("ivy", "application/x-livescreen");
+ mimeTypes.Add ("jam ", "audio/x-jam");
+ mimeTypes.Add ("jav", "text/plain");
+ mimeTypes.Add ("java", "text/plain");
+ mimeTypes.Add ("jcm ", "application/x-java-commerce");
+ mimeTypes.Add ("jfif", "image/jpeg");
+ mimeTypes.Add ("jfif-tbnl", "image/jpeg");
+ mimeTypes.Add ("jpe", "image/jpeg");
+ mimeTypes.Add ("jpeg", "image/jpeg");
+ mimeTypes.Add ("jps", "image/x-jps");
+ mimeTypes.Add ("js ", "application/x-javascript");
+ mimeTypes.Add ("jut", "image/jutvision");
+ mimeTypes.Add ("kar", "audio/midi");
+ mimeTypes.Add ("ksh", "text/x-script.ksh");
+ mimeTypes.Add ("la ", "audio/nspaudio");
+ mimeTypes.Add ("lam", "audio/x-liveaudio");
+ mimeTypes.Add ("latex ", "application/x-latex");
+ mimeTypes.Add ("list", "text/plain");
+ mimeTypes.Add ("lma", "audio/nspaudio");
+ mimeTypes.Add ("log ", "text/plain");
+ mimeTypes.Add ("lsp ", "application/x-lisp");
+ mimeTypes.Add ("lst ", "text/plain");
+ mimeTypes.Add ("lsx", "text/x-la-asf");
+ mimeTypes.Add ("ltx", "application/x-latex");
+ mimeTypes.Add ("m", "text/plain");
+ mimeTypes.Add ("m1v", "video/mpeg");
+ mimeTypes.Add ("m2a", "audio/mpeg");
+ mimeTypes.Add ("m2v", "video/mpeg");
+ mimeTypes.Add ("m3u ", "audio/x-mpequrl");
+ mimeTypes.Add ("man", "application/x-troff-man");
+ mimeTypes.Add ("map", "application/x-navimap");
+ mimeTypes.Add ("mar", "text/plain");
+ mimeTypes.Add ("mbd", "application/mbedlet");
+ mimeTypes.Add ("mc$", "application/x-magic-cap-package-1.0");
+ mimeTypes.Add ("mcd", "application/mcad");
+ mimeTypes.Add ("mcf", "image/vasa");
+ mimeTypes.Add ("mcp", "application/netmc");
+ mimeTypes.Add ("me ", "application/x-troff-me");
+ mimeTypes.Add ("mht", "message/rfc822");
+ mimeTypes.Add ("mhtml", "message/rfc822");
+ mimeTypes.Add ("mid", "audio/midi");
+ mimeTypes.Add ("midi", "audio/midi");
+ mimeTypes.Add ("mif", "application/x-mif");
+ mimeTypes.Add ("mime ", "message/rfc822");
+ mimeTypes.Add ("mjf", "audio/x-vnd.AudioExplosion.MjuiceMediaFile");
+ mimeTypes.Add ("mjpg ", "video/x-motion-jpeg");
+ mimeTypes.Add ("mm", "application/base64");
+ mimeTypes.Add ("mme", "application/base64");
+ mimeTypes.Add ("mod", "audio/mod");
+ mimeTypes.Add ("moov", "video/quicktime");
+ mimeTypes.Add ("mov", "video/quicktime");
+ mimeTypes.Add ("movie", "video/x-sgi-movie");
+ mimeTypes.Add ("mp2", "video/mpeg");
+ mimeTypes.Add ("mp3", "audio/mpeg3");
+ mimeTypes.Add ("mpa", "audio/mpeg");
+ mimeTypes.Add ("mpc", "application/x-project");
+ mimeTypes.Add ("mpe", "video/mpeg");
+ mimeTypes.Add ("mpeg", "video/mpeg");
+ mimeTypes.Add ("mpg", "video/mpeg");
+ mimeTypes.Add ("mpga", "audio/mpeg");
+ mimeTypes.Add ("mpp", "application/vnd.ms-project");
+ mimeTypes.Add ("mpt", "application/x-project");
+ mimeTypes.Add ("mpv", "application/x-project");
+ mimeTypes.Add ("mpx", "application/x-project");
+ mimeTypes.Add ("mrc", "application/marc");
+ mimeTypes.Add ("ms", "application/x-troff-ms");
+ mimeTypes.Add ("mv", "video/x-sgi-movie");
+ mimeTypes.Add ("my", "audio/make");
+ mimeTypes.Add ("mzz", "application/x-vnd.AudioExplosion.mzz");
+ mimeTypes.Add ("nap", "image/naplps");
+ mimeTypes.Add ("naplps", "image/naplps");
+ mimeTypes.Add ("nc", "application/x-netcdf");
+ mimeTypes.Add ("ncm", "application/vnd.nokia.configuration-message");
+ mimeTypes.Add ("nif", "image/x-niff");
+ mimeTypes.Add ("niff", "image/x-niff");
+ mimeTypes.Add ("nix", "application/x-mix-transfer");
+ mimeTypes.Add ("nsc", "application/x-conference");
+ mimeTypes.Add ("nvd", "application/x-navidoc");
+ mimeTypes.Add ("oda", "application/oda");
+ mimeTypes.Add ("omc", "application/x-omc");
+ mimeTypes.Add ("omcd", "application/x-omcdatamaker");
+ mimeTypes.Add ("omcr", "application/x-omcregerator");
+ mimeTypes.Add ("p", "text/x-pascal");
+ mimeTypes.Add ("p10", "application/pkcs10");
+ mimeTypes.Add ("p12", "application/pkcs-12");
+ mimeTypes.Add ("p7a", "application/x-pkcs7-signature");
+ mimeTypes.Add ("p7c", "application/pkcs7-mime");
+ mimeTypes.Add ("p7m", "application/pkcs7-mime");
+ mimeTypes.Add ("p7r", "application/x-pkcs7-certreqresp");
+ mimeTypes.Add ("p7s", "application/pkcs7-signature");
+ mimeTypes.Add ("part ", "application/pro_eng");
+ mimeTypes.Add ("pas", "text/pascal");
+ mimeTypes.Add ("pbm ", "image/x-portable-bitmap");
+ mimeTypes.Add ("pcl", "application/x-pcl");
+ mimeTypes.Add ("pct", "image/x-pict");
+ mimeTypes.Add ("pcx", "image/x-pcx");
+ mimeTypes.Add ("pdb", "chemical/x-pdb");
+ mimeTypes.Add ("pdf", "application/pdf");
+ mimeTypes.Add ("pfunk", "audio/make");
+ mimeTypes.Add ("pgm", "image/x-portable-graymap");
+ mimeTypes.Add ("pic", "image/pict");
+ mimeTypes.Add ("pict", "image/pict");
+ mimeTypes.Add ("pkg", "application/x-newton-compatible-pkg");
+ mimeTypes.Add ("pko", "application/vnd.ms-pki.pko");
+ mimeTypes.Add ("pl", "text/plain");
+ mimeTypes.Add ("plx", "application/x-PiXCLscript");
+ mimeTypes.Add ("pm", "image/x-xpixmap");
+ mimeTypes.Add ("pm4 ", "application/x-pagemaker");
+ mimeTypes.Add ("pm5", "application/x-pagemaker");
+ mimeTypes.Add ("png", "image/png");
+ mimeTypes.Add ("pnm", "application/x-portable-anymap");
+ mimeTypes.Add ("pot", "application/mspowerpoint");
+ mimeTypes.Add ("pov", "model/x-pov");
+ mimeTypes.Add ("ppa", "application/vnd.ms-powerpoint");
+ mimeTypes.Add ("ppm", "image/x-portable-pixmap");
+ mimeTypes.Add ("pps", "application/mspowerpoint");
+ mimeTypes.Add ("ppt", "application/mspowerpoint");
+ mimeTypes.Add ("ppz", "application/mspowerpoint");
+ mimeTypes.Add ("pre", "application/x-freelance");
+ mimeTypes.Add ("prt", "application/pro_eng");
+ mimeTypes.Add ("ps", "application/postscript");
+ mimeTypes.Add ("pvu", "paleovu/x-pv");
+ mimeTypes.Add ("pwz ", "application/vnd.ms-powerpoint");
+ mimeTypes.Add ("py ", "text/x-script.phyton");
+ mimeTypes.Add ("pyc ", "applicaiton/x-bytecode.python");
+ mimeTypes.Add ("qcp ", "audio/vnd.qcelp");
+ mimeTypes.Add ("qd3 ", "x-world/x-3dmf");
+ mimeTypes.Add ("qd3d ", "x-world/x-3dmf");
+ mimeTypes.Add ("qif", "image/x-quicktime");
+ mimeTypes.Add ("qt", "video/quicktime");
+ mimeTypes.Add ("qtc", "video/x-qtc");
+ mimeTypes.Add ("qti", "image/x-quicktime");
+ mimeTypes.Add ("qtif", "image/x-quicktime");
+ mimeTypes.Add ("ra", "audio/x-pn-realaudio");
+ mimeTypes.Add ("ram", "audio/x-pn-realaudio");
+ mimeTypes.Add ("ras", "application/x-cmu-raster");
+ mimeTypes.Add ("rast", "image/cmu-raster");
+ mimeTypes.Add ("rexx ", "text/x-script.rexx");
+ mimeTypes.Add ("rf", "image/vnd.rn-realflash");
+ mimeTypes.Add ("rgb ", "image/x-rgb");
+ mimeTypes.Add ("rm", "application/vnd.rn-realmedia");
+ mimeTypes.Add ("rmi", "audio/mid");
+ mimeTypes.Add ("rmm ", "audio/x-pn-realaudio");
+ mimeTypes.Add ("rmp", "audio/x-pn-realaudio");
+ mimeTypes.Add ("rng", "application/ringing-tones");
+ mimeTypes.Add ("rnx ", "application/vnd.rn-realplayer");
+ mimeTypes.Add ("roff", "application/x-troff");
+ mimeTypes.Add ("rp ", "image/vnd.rn-realpix");
+ mimeTypes.Add ("rpm", "audio/x-pn-realaudio-plugin");
+ mimeTypes.Add ("rt", "text/richtext");
+ mimeTypes.Add ("rtf", "text/richtext");
+ mimeTypes.Add ("rtx", "text/richtext");
+ mimeTypes.Add ("rv", "video/vnd.rn-realvideo");
+ mimeTypes.Add ("s", "text/x-asm");
+ mimeTypes.Add ("s3m ", "audio/s3m");
+ mimeTypes.Add ("sbk ", "application/x-tbook");
+ mimeTypes.Add ("scm", "application/x-lotusscreencam");
+ mimeTypes.Add ("sdml", "text/plain");
+ mimeTypes.Add ("sdp ", "application/sdp");
+ mimeTypes.Add ("sdr", "application/sounder");
+ mimeTypes.Add ("sea", "application/sea");
+ mimeTypes.Add ("set", "application/set");
+ mimeTypes.Add ("sgm ", "text/sgml");
+ mimeTypes.Add ("sgml", "text/sgml");
+ mimeTypes.Add ("sh", "text/x-script.sh");
+ mimeTypes.Add ("shar", "application/x-bsh");
+ mimeTypes.Add ("shtml ", "text/html");
+ mimeTypes.Add ("sid", "audio/x-psid");
+ mimeTypes.Add ("sit", "application/x-sit");
+ mimeTypes.Add ("skd", "application/x-koan");
+ mimeTypes.Add ("skm ", "application/x-koan");
+ mimeTypes.Add ("skp ", "application/x-koan");
+ mimeTypes.Add ("skt ", "application/x-koan");
+ mimeTypes.Add ("sl ", "application/x-seelogo");
+ mimeTypes.Add ("smi ", "application/smil");
+ mimeTypes.Add ("smil ", "application/smil");
+ mimeTypes.Add ("snd", "audio/basic");
+ mimeTypes.Add ("sol", "application/solids");
+ mimeTypes.Add ("spc ", "application/x-pkcs7-certificates");
+ mimeTypes.Add ("spl", "application/futuresplash");
+ mimeTypes.Add ("spr", "application/x-sprite");
+ mimeTypes.Add ("sprite ", "application/x-sprite");
+ mimeTypes.Add ("src", "application/x-wais-source");
+ mimeTypes.Add ("ssi", "text/x-server-parsed-html");
+ mimeTypes.Add ("ssm ", "application/streamingmedia");
+ mimeTypes.Add ("sst", "application/vnd.ms-pki.certstore");
+ mimeTypes.Add ("step", "application/step");
+ mimeTypes.Add ("stl", "application/sla");
+ mimeTypes.Add ("stp", "application/step");
+ mimeTypes.Add ("sv4cpio", "application/x-sv4cpio");
+ mimeTypes.Add ("sv4crc", "application/x-sv4crc");
+ mimeTypes.Add ("svf", "image/x-dwg");
+ mimeTypes.Add ("svr", "application/x-world");
+ mimeTypes.Add ("swf", "application/x-shockwave-flash");
+ mimeTypes.Add ("t", "application/x-troff");
+ mimeTypes.Add ("talk", "text/x-speech");
+ mimeTypes.Add ("tar", "application/x-tar");
+ mimeTypes.Add ("tbk", "application/toolbook");
+ mimeTypes.Add ("tcl", "text/x-script.tcl");
+ mimeTypes.Add ("tcsh", "text/x-script.tcsh");
+ mimeTypes.Add ("tex", "application/x-tex");
+ mimeTypes.Add ("texi", "application/x-texinfo");
+ mimeTypes.Add ("texinfo", "application/x-texinfo");
+ mimeTypes.Add ("text", "text/plain");
+ mimeTypes.Add ("tgz", "application/x-compressed");
+ mimeTypes.Add ("tif", "image/tiff");
+ mimeTypes.Add ("tiff", "image/tiff");
+ mimeTypes.Add ("tr", "application/x-troff");
+ mimeTypes.Add ("tsi", "audio/tsp-audio");
+ mimeTypes.Add ("tsp", "audio/tsplayer");
+ mimeTypes.Add ("tsv", "text/tab-separated-values");
+ mimeTypes.Add ("turbot", "image/florian");
+ mimeTypes.Add ("txt", "text/plain");
+ mimeTypes.Add ("uil", "text/x-uil");
+ mimeTypes.Add ("uni", "text/uri-list");
+ mimeTypes.Add ("unis", "text/uri-list");
+ mimeTypes.Add ("unv", "application/i-deas");
+ mimeTypes.Add ("uri", "text/uri-list");
+ mimeTypes.Add ("uris", "text/uri-list");
+ mimeTypes.Add ("ustar", "multipart/x-ustar");
+ mimeTypes.Add ("uu", "text/x-uuencode");
+ mimeTypes.Add ("uue", "text/x-uuencode");
+ mimeTypes.Add ("vcd", "application/x-cdlink");
+ mimeTypes.Add ("vcs", "text/x-vCalendar");
+ mimeTypes.Add ("vda", "application/vda");
+ mimeTypes.Add ("vdo", "video/vdo");
+ mimeTypes.Add ("vew ", "application/groupwise");
+ mimeTypes.Add ("viv", "video/vivo");
+ mimeTypes.Add ("vivo", "video/vivo");
+ mimeTypes.Add ("vmd ", "application/vocaltec-media-desc");
+ mimeTypes.Add ("vmf", "application/vocaltec-media-file");
+ mimeTypes.Add ("voc", "audio/voc");
+ mimeTypes.Add ("vos", "video/vosaic");
+ mimeTypes.Add ("vox", "audio/voxware");
+ mimeTypes.Add ("vqe", "audio/x-twinvq-plugin");
+ mimeTypes.Add ("vqf", "audio/x-twinvq");
+ mimeTypes.Add ("vql", "audio/x-twinvq-plugin");
+ mimeTypes.Add ("vrml", "application/x-vrml");
+ mimeTypes.Add ("vrt", "x-world/x-vrt");
+ mimeTypes.Add ("vsd", "application/x-visio");
+ mimeTypes.Add ("vst", "application/x-visio");
+ mimeTypes.Add ("vsw ", "application/x-visio");
+ mimeTypes.Add ("w60", "application/wordperfect6.0");
+ mimeTypes.Add ("w61", "application/wordperfect6.1");
+ mimeTypes.Add ("w6w", "application/msword");
+ mimeTypes.Add ("wav", "audio/wav");
+ mimeTypes.Add ("wb1", "application/x-qpro");
+ mimeTypes.Add ("wbmp", "image/vnd.wap.wbmp");
+ mimeTypes.Add ("web", "application/vnd.xara");
+ mimeTypes.Add ("wiz", "application/msword");
+ mimeTypes.Add ("wk1", "application/x-123");
+ mimeTypes.Add ("wmf", "windows/metafile");
+ mimeTypes.Add ("wml", "text/vnd.wap.wml");
+ mimeTypes.Add ("wmlc ", "application/vnd.wap.wmlc");
+ mimeTypes.Add ("wmls", "text/vnd.wap.wmlscript");
+ mimeTypes.Add ("wmlsc ", "application/vnd.wap.wmlscriptc");
+ mimeTypes.Add ("word ", "application/msword");
+ mimeTypes.Add ("wp", "application/wordperfect");
+ mimeTypes.Add ("wp5", "application/wordperfect");
+ mimeTypes.Add ("wp6 ", "application/wordperfect");
+ mimeTypes.Add ("wpd", "application/wordperfect");
+ mimeTypes.Add ("wq1", "application/x-lotus");
+ mimeTypes.Add ("wri", "application/mswrite");
+ mimeTypes.Add ("wrl", "application/x-world");
+ mimeTypes.Add ("wrz", "model/vrml");
+ mimeTypes.Add ("wsc", "text/scriplet");
+ mimeTypes.Add ("wsrc", "application/x-wais-source");
+ mimeTypes.Add ("wtk ", "application/x-wintalk");
+ mimeTypes.Add ("xbm", "image/x-xbitmap");
+ mimeTypes.Add ("xdr", "video/x-amt-demorun");
+ mimeTypes.Add ("xgz", "xgl/drawing");
+ mimeTypes.Add ("xif", "image/vnd.xiff");
+ mimeTypes.Add ("xl", "application/excel");
+ mimeTypes.Add ("xla", "application/excel");
+ mimeTypes.Add ("xlb", "application/excel");
+ mimeTypes.Add ("xlc", "application/excel");
+ mimeTypes.Add ("xld ", "application/excel");
+ mimeTypes.Add ("xlk", "application/excel");
+ mimeTypes.Add ("xll", "application/excel");
+ mimeTypes.Add ("xlm", "application/excel");
+ mimeTypes.Add ("xls", "application/excel");
+ mimeTypes.Add ("xlt", "application/excel");
+ mimeTypes.Add ("xlv", "application/excel");
+ mimeTypes.Add ("xlw", "application/excel");
+ mimeTypes.Add ("xm", "audio/xm");
+ mimeTypes.Add ("xml", "text/xml");
+ mimeTypes.Add ("xmz", "xgl/movie");
+ mimeTypes.Add ("xpix", "application/x-vnd.ls-xpix");
+ mimeTypes.Add ("xpm", "image/xpm");
+ mimeTypes.Add ("x-png", "image/png");
+ mimeTypes.Add ("xsr", "video/x-amt-showrun");
+ mimeTypes.Add ("xwd", "image/x-xwd");
+ mimeTypes.Add ("xyz", "chemical/x-pdb");
+ mimeTypes.Add ("z", "application/x-compressed");
+ mimeTypes.Add ("zip", "application/zip");
+ mimeTypes.Add ("zsh", "text/x-script.zsh");
+ }
+
+ public static string GetMimeType (string fileName)
+ {
+ string result = null;
+ int dot = fileName.LastIndexOf ('.');
+
+ if (dot != -1 && fileName.Length > dot + 1)
+ result = mimeTypes [fileName.Substring (dot + 1)] as string;
+
+ if (result == null)
+ result = "application/octet-stream";
+
+ return result;
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/NOTES b/mcs/class/System.Web/System.Web/NOTES
new file mode 100644
index 00000000000..55926bd4ef9
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/NOTES
@@ -0,0 +1,21 @@
+Found another namespace not listed. System.Web.Hosting.
+HttpRuntime.ProcessRequest and HttpWorkerRequest seems to be the key.
+
+ASP maintains a pool of HttpApplication objects dirived from Global.asax.
+One is used per request, then reclamed after the request is totally
+complete.
+
+Read:
+http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguidnf/html/cpconaspnetapplications.asp
+
+
+Request notes:
+It apears each http request has its own thread. Need to figure out how to deal with this with apache.
+
+Session notes:
+When a request is finished, the contents of Request.Session are serialized and dumped to the State Server.
+When a request is started, a new Request.Session is created, data is deserialized from the State Server, and the objects are placed back into Request.Session.
+The State Server is accessed via the SessionStateModule which is used for both session ID and state data management.
+HttpApplicationState instance is created the first time a url within the applications virtual directory is accessed. Its accessable through HttpContext.Application.
+HttpApplicationState needs to use lock/unlock explicitly.
+Not shared across machines or multiple processes.
diff --git a/mcs/class/System.Web/System.Web/ProcessInfo.cs b/mcs/class/System.Web/System.Web/ProcessInfo.cs
new file mode 100644
index 00000000000..d9e8ec60421
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/ProcessInfo.cs
@@ -0,0 +1,90 @@
+//
+// System.Web.ProcessInfo
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+
+namespace System.Web {
+ public class ProcessInfo {
+
+ #region Fields
+
+ TimeSpan age;
+ int peakMemoryUsed;
+ int processID;
+ int requestCount;
+ ProcessShutdownReason shutdownReason;
+ DateTime startTime;
+ ProcessStatus status;
+
+ #endregion
+
+ #region Constructors
+
+ public ProcessInfo ()
+ {
+ }
+
+ public ProcessInfo (DateTime startTime, TimeSpan age, int processID, int requestCount, ProcessStatus status, ProcessShutdownReason shutdownReason, int peakMemoryUsed)
+ {
+ this.age = age;
+ this.peakMemoryUsed = peakMemoryUsed;
+ this.processID = processID;
+ this.requestCount = requestCount;
+ this.shutdownReason = shutdownReason;
+ this.startTime = startTime;
+ this.status = status;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public TimeSpan Age {
+ get { return age; }
+ }
+
+ public int PeakMemoryUsed {
+ get { return peakMemoryUsed; }
+ }
+
+ public int ProcessID {
+ get { return processID; }
+ }
+
+ public int RequestCount {
+ get { return requestCount; }
+ }
+
+ public ProcessShutdownReason ShutdownReason {
+ get { return shutdownReason; }
+ }
+
+ public DateTime StartTime {
+ get { return startTime; }
+ }
+
+ public ProcessStatus Status {
+ get { return status; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ public void SetAll (DateTime startTime, TimeSpan age, int processID, int requestCount, ProcessStatus status, ProcessShutdownReason shutdownReason, int peakMemoryUsed)
+ {
+ this.age = age;
+ this.peakMemoryUsed = peakMemoryUsed;
+ this.processID = processID;
+ this.requestCount = requestCount;
+ this.shutdownReason = shutdownReason;
+ this.startTime = startTime;
+ this.status = status;
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/ProcessModelInfo.cs b/mcs/class/System.Web/System.Web/ProcessModelInfo.cs
new file mode 100644
index 00000000000..7d6f1f6a10b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/ProcessModelInfo.cs
@@ -0,0 +1,52 @@
+//
+// System.Web.ProcessModelInfo
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+
+using System;
+
+namespace System.Web {
+ public class ProcessModelInfo {
+
+ #region Fields
+
+ #endregion
+
+ #region Constructors
+
+ public ProcessModelInfo ()
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ [MonoTODO ("Retrieve appropriate variables from worker")]
+ public static ProcessInfo GetCurrentProcessInfo ()
+ {
+ HttpContext httpContext;
+ DateTime startTime = DateTime.Now;
+ TimeSpan age = TimeSpan.Zero;
+ int processID = 0;
+ int requestCount = 0;
+ ProcessStatus status = ProcessStatus.Terminated;
+ ProcessShutdownReason shutdownReason = ProcessShutdownReason.None;
+ int peakMemoryUsed = 0;
+
+ httpContext = HttpContext.Current;
+ return new ProcessInfo (startTime, age, processID, requestCount, status, shutdownReason, peakMemoryUsed);
+ }
+
+ [MonoTODO ("Retrieve process information.")]
+ public static ProcessInfo[] GetHistory ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/ProcessShutdownReason.cs b/mcs/class/System.Web/System.Web/ProcessShutdownReason.cs
new file mode 100644
index 00000000000..8dcb0783a69
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/ProcessShutdownReason.cs
@@ -0,0 +1,23 @@
+//
+// System.Web.ProcessShutdownReason.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+namespace System.Web {
+ [Serializable]
+ public enum ProcessShutdownReason {
+ None,
+ Unexpected,
+ RequestsLimit,
+ RequestQueueLimit,
+ Timeout,
+ IdleTimeout,
+ MemoryLimitExceeded,
+ PingFailed,
+ DeadlockSuspected
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/ProcessStatus.cs b/mcs/class/System.Web/System.Web/ProcessStatus.cs
new file mode 100644
index 00000000000..a7897b54d3b
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/ProcessStatus.cs
@@ -0,0 +1,17 @@
+//
+// System.Web.ProcessStatus.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+namespace System.Web {
+ public enum ProcessStatus {
+ Alive = 0x1,
+ ShuttingDown,
+ ShutDown,
+ Terminated
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/StaticFileHandler.cs b/mcs/class/System.Web/System.Web/StaticFileHandler.cs
new file mode 100644
index 00000000000..463e9fd2e72
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/StaticFileHandler.cs
@@ -0,0 +1,48 @@
+//
+// System.Web.StaticFileHandler
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.IO;
+
+namespace System.Web
+{
+ class StaticFileHandler : IHttpHandler
+ {
+ public void ProcessRequest (HttpContext context)
+ {
+ HttpRequest request = context.Request;
+ HttpResponse response = context.Response;
+ string fileName = request.PhysicalPath;
+ FileInfo fi = new FileInfo (fileName);
+ if (!fi.Exists)
+ throw new HttpException (404, "File '" + fileName + "' does not exist");
+
+ if ((fi.Attributes & FileAttributes.Directory) != 0) {
+ response.Redirect (request.Path + '/');
+ return;
+ }
+
+ DateTime lastWT = fi.LastWriteTime;
+ try {
+ response.WriteFile (fileName);
+ response.ContentType = MimeTypes.GetMimeType (fileName);
+ } catch (Exception e) {
+ throw new HttpException (401, "Forbidden");
+ }
+ }
+
+ public bool IsReusable
+ {
+ get {
+ return true;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/System.Web/TODO b/mcs/class/System.Web/System.Web/TODO
new file mode 100644
index 00000000000..4de26ec8397
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/TODO
@@ -0,0 +1,19 @@
+HttpClientCertificate
+HttpApplicationState
+HttpFileCollection
+HttpModuleCollection
+HttpException
+HttpCompileException
+HttpParseException
+HttpUnhandledException
+HttpCapabilitiesBase
+HttpBrowserCapabilities
+HttpApplication
+HttpCachePolicy
+HttpCacheVaryByHeaders
+HttpCacheVaryByParams
+HttpPostedFile
+HttpStaticObjectsCollection
+ProcessInfo
+ProcessModelInfo
+TraceContext
diff --git a/mcs/class/System.Web/System.Web/TODOAttribute.cs b/mcs/class/System.Web/System.Web/TODOAttribute.cs
new file mode 100644
index 00000000000..e8d67ea5791
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/TODOAttribute.cs
@@ -0,0 +1,33 @@
+//
+// TODOAttribute.cs
+//
+// Author:
+// Ravi Pratap (ravi@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+using System;
+
+namespace System.Web {
+
+ /// <summary>
+ /// The TODO attribute is used to flag all incomplete bits in our class libraries
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Use this to decorate any element which you think is not complete
+ /// </remarks>
+ [AttributeUsage (AttributeTargets.All)]
+ internal class MonoTODOAttribute : Attribute {
+
+ string comment;
+
+ public MonoTODOAttribute ()
+ {}
+
+ public MonoTODOAttribute (string comment)
+ {
+ this.comment = comment;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/TraceContext.cs b/mcs/class/System.Web/System.Web/TraceContext.cs
new file mode 100644
index 00000000000..0708227547c
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/TraceContext.cs
@@ -0,0 +1,69 @@
+//
+// System.Web.TraceContext
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+
+namespace System.Web {
+ public sealed class TraceContext {
+ private HttpContext _Context;
+ private bool _Enabled;
+ private TraceMode _Mode;
+
+ public TraceContext(HttpContext Context) {
+ _Context = Context;
+ _Enabled = true;
+ }
+
+ public bool IsEnabled {
+ get {
+ return _Enabled;
+ }
+
+ set {
+ _Enabled = value;
+ }
+ }
+
+ public TraceMode TraceMode {
+ get {
+ return _Mode;
+ }
+
+ set {
+ _Mode = value;
+ }
+ }
+
+ public void Warn(string msg) {
+ Write(String.Empty, msg, null, true);
+ }
+
+ public void Warn(string category, string msg) {
+ Write(category, msg, null, true);
+ }
+
+ public void Warn(string category, string msg, Exception error) {
+ Write(category, msg, error, true);
+ }
+
+ public void Write(string msg) {
+ Write(String.Empty, msg, null, true);
+ }
+
+ public void Write(string category, string msg) {
+ Write(category, msg, null, true);
+ }
+
+ public void Write(string category, string msg, Exception error) {
+ Write(category, msg, error, true);
+ }
+
+ [MonoTODO("Save the data into a web dataset directly...")]
+ private void Write(string category, string msg, Exception error, bool Warning) {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/TraceMode.cs b/mcs/class/System.Web/System.Web/TraceMode.cs
new file mode 100644
index 00000000000..caab8229afd
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/TraceMode.cs
@@ -0,0 +1,16 @@
+//
+// System.Web.TraceMode.cs
+//
+// Author:
+// Bob Smith <bob@thestuff.net>
+//
+// (C) Bob Smith
+//
+
+namespace System.Web {
+ public enum TraceMode {
+ SortByTime,
+ SortByCategory,
+ Default
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/WebCategoryAttribute.cs b/mcs/class/System.Web/System.Web/WebCategoryAttribute.cs
new file mode 100644
index 00000000000..dd4b9ea5b46
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/WebCategoryAttribute.cs
@@ -0,0 +1,38 @@
+/**
+ * Namespace: System.Web
+ * Class: WebCategoryAttribute
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 95%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+
+namespace System.Web
+{
+ [AttributeUsage(AttributeTargets.All)]
+ internal sealed class WebCategoryAttribute : CategoryAttribute
+ {
+ public WebCategoryAttribute(string category) : base(category)
+ {
+ }
+
+ [MonoTODO]
+ protected override string GetLocalizedString(string value)
+ {
+ string retVal = base.GetLocalizedString(value);
+ if(retVal == null)
+ {
+ throw new NotImplementedException();
+ //retVal = "Category_" + something I don't know how to get!
+ }
+ return retVal;
+ }
+ }
+}
diff --git a/mcs/class/System.Web/System.Web/WebSysDescriptionAttribute.cs b/mcs/class/System.Web/System.Web/WebSysDescriptionAttribute.cs
new file mode 100644
index 00000000000..2425607069a
--- /dev/null
+++ b/mcs/class/System.Web/System.Web/WebSysDescriptionAttribute.cs
@@ -0,0 +1,44 @@
+/**
+ * Namespace: System.Web
+ * Class: WebSysDescriptionAttribute
+ *
+ * Author: Gaurav Vaish
+ * Maintainer: gvaish@iitk.ac.in
+ * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
+ * Implementation: yes
+ * Status: 95%
+ *
+ * (C) Gaurav Vaish (2002)
+ */
+
+using System;
+using System.ComponentModel;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web
+{
+ [AttributeUsage(AttributeTargets.All)]
+ internal class WebSysDescriptionAttribute : DescriptionAttribute
+ {
+ private bool isReplaced;
+
+ public WebSysDescriptionAttribute(string description) : base(description)
+ {
+ }
+
+ [MonoTODO]
+ public override string Description
+ {
+ get
+ {
+ if(!isReplaced)
+ {
+ throw new NotImplementedException();
+ //DescriptionValue = Description + do something I donno;
+ }
+ return Description;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/Test/DataBinderTests.cs b/mcs/class/System.Web/Test/DataBinderTests.cs
new file mode 100644
index 00000000000..96cde3ceb98
--- /dev/null
+++ b/mcs/class/System.Web/Test/DataBinderTests.cs
@@ -0,0 +1,181 @@
+//
+// System.Web.UI.DataBinderTests
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+//#define NUNIT // Comment out this one if you wanna play with the test without using NUnit
+
+#if NUNIT
+using NUnit.Framework;
+#else
+using System.Reflection;
+#endif
+
+using System.IO;
+using System;
+using System.Text;
+using System.Web;
+using System.Web.UI;
+using System.Runtime.CompilerServices;
+
+namespace MonoTests.System.Web.UI
+{
+#if NUNIT
+ public class DataBinderTests : TestCase
+ {
+#else
+ public class DataBinderTests
+ {
+#endif
+#if NUNIT
+ public static ITest Suite
+ {
+ get {
+ return new TestSuite (typeof (PathTest));
+ }
+ }
+
+ public DataBinderTests () : base ("MonoTests.System.Web.UI.DataBinderTests testcase") { }
+ public DataBinderTests (string name) : base (name) { }
+
+ protected override void SetUp ()
+ {
+#else
+ static DataBinderTests ()
+ {
+#endif
+ instance = new ClassInstance ("instance");
+ instance.another = new ClassInstance ("another");
+ }
+
+ static ClassInstance instance;
+
+ public void TestEval1 ()
+ {
+ try {
+ DataBinder.Eval (instance, "hello");
+ Fail ("Eval1 #1 didn't throw exception");
+ } catch (HttpException) {
+ }
+
+ object o = instance.Prop1;
+ AssertEquals ("Eval1 #2", DataBinder.Eval (instance, "Prop1"), o);
+ o = instance.Prop2;
+ AssertEquals ("Eval1 #3", DataBinder.Eval (instance, "Prop2"), o);
+ o = instance [0];
+ AssertEquals ("Eval1 #4", DataBinder.Eval (instance, "[0]"), o);
+ o = instance ["hi there!"];
+ AssertEquals ("Eval1 #4", DataBinder.Eval (instance, "[\"hi there!\"]"), o);
+ }
+
+ public void TestEval2 ()
+ {
+ try {
+ DataBinder.Eval (instance, "Another.hello");
+ Fail ("Eval2 #1 didn't throw exception");
+ } catch (HttpException) {
+ }
+
+ object o = instance.Another.Prop1;
+ AssertEquals ("Eval2 #2", DataBinder.Eval (instance, "Another.Prop1"), o);
+ o = instance.Another.Prop2;
+ AssertEquals ("Eval2 #3", DataBinder.Eval (instance, "Another.Prop2"), o);
+ o = instance.Another [0];
+ AssertEquals ("Eval2 #4", DataBinder.Eval (instance, "Another[0]"), o);
+ o = instance.Another ["hi there!"];
+ AssertEquals ("Eval2 #4", DataBinder.Eval (instance, "Another[\"hi there!\"]"), o);
+ AssertEquals ("Eval2 #5", DataBinder.Eval (instance,
+ "Another[\"hi there!\"] MS ignores this]"), o);
+
+ // MS gets fooled with this!!!
+ //AssertEquals ("Eval2 #4", DataBinder.Eval (instance, "Another[\"hi] there!\"]"), o);
+ }
+
+#if !NUNIT
+ void Assert (string msg, bool result)
+ {
+ if (!result)
+ Console.WriteLine (msg);
+ }
+
+ void AssertEquals (string msg, object expected, object real)
+ {
+ if (expected == null && real == null)
+ return;
+
+ if (expected != null && expected.Equals (real))
+ return;
+
+ Console.WriteLine ("{0}: expected: '{1}', got: '{2}'", msg, expected, real);
+ }
+
+ void Fail (string msg)
+ {
+ Console.WriteLine ("Failed: {0}", msg);
+ }
+
+ static void Main ()
+ {
+ DataBinderTests dbt = new DataBinderTests ();
+ Type t = typeof (DataBinderTests);
+ MethodInfo [] methods = t.GetMethods ();
+ foreach (MethodInfo m in methods) {
+ if (m.Name.Substring (0, 4) == "Test")
+ m.Invoke (dbt, null);
+ }
+ }
+#endif
+ }
+
+ class ClassInstance
+ {
+ public string hello = "Hello";
+ public ClassInstance another;
+ string prefix;
+
+ public ClassInstance (string prefix)
+ {
+ this.prefix = prefix;
+ }
+
+ public object Prop1
+ {
+ get {
+ return prefix + "This is Prop1";
+ }
+ }
+
+ public object Prop2
+ {
+ get {
+ return prefix + "This is Prop2";
+ }
+ }
+
+ public object this [int index]
+ {
+ get {
+ return prefix + "This is the indexer for int. Index: " + index;
+ }
+ }
+
+ public object this [string index]
+ {
+ get {
+ return prefix + "This is the indexer for string. Index: " + index;
+ }
+ }
+
+ public ClassInstance Another
+ {
+ get {
+ return another;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Web/Test/TestMonoWeb/AsyncHandler.cs b/mcs/class/System.Web/Test/TestMonoWeb/AsyncHandler.cs
new file mode 100644
index 00000000000..cab2351e1ed
--- /dev/null
+++ b/mcs/class/System.Web/Test/TestMonoWeb/AsyncHandler.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Threading;
+using System.Web;
+
+namespace TestMonoWeb {
+ /// <summary>
+ /// Summary description for AsyncHandler.
+ /// </summary>
+ public class AsyncHandler : IHttpAsyncHandler {
+ private HttpContext _context;
+ public bool IsReusable {
+ get {
+ //To enable pooling, return true here.
+ //This keeps the handler in memory.
+ return false;
+ }
+ }
+
+ public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) {
+ AsynchOperation asynch = new AsynchOperation(cb, context, null);
+ asynch.StartAsyncWork();
+
+ context.Response.Write("AsyncHandler.BeginProcessRequest<br>\n");
+ context.Response.Flush();
+
+ //Signal the application that asynchronous
+ //processing is being performed.
+ SomeResult asynchForBegin = new SomeResult();
+
+ //Processing is not synchronous.
+ asynchForBegin.SetSynch(false);
+
+ //Processing is not complete.
+ asynchForBegin.SetCompleted(false);
+
+ _context = context;
+
+ return new SomeResult();
+ }
+
+ public void EndProcessRequest(IAsyncResult result) {
+ _context.Response.Write("AsyncHandler.EndProcessRequest<br>\n");
+ }
+
+ //This method is required but is not called.
+ public void ProcessRequest(HttpContext context) {
+ }
+
+ }//end class
+
+ public class SomeResult : IAsyncResult {
+
+ /*
+ An instance of this class is returned to the application.
+ This class lets the application know how the BeginEventHandler method has been handled. The application checks the CompletedSynchronously method.
+ */
+
+ private bool _blnIsCompleted = false;
+ private Mutex myMutex = null;
+ private Object myAsynchStateObject = null;
+ private bool _blnCompletedSynchronously = false;
+
+ public void SetCompleted(bool blnTrueOrFalse) {
+ _blnIsCompleted = blnTrueOrFalse;
+ }
+
+ public void SetSynch(bool blnTrueOrFalse) {
+ _blnCompletedSynchronously = blnTrueOrFalse;
+ }
+
+ public bool IsCompleted {
+ /*
+ This is not called by the application. However, set it to true.
+ */
+ get {
+ return _blnIsCompleted;
+ }
+ }
+
+ public WaitHandle AsyncWaitHandle {
+ //The application does not call this method.
+ get {
+ return myMutex;
+ }
+ }
+
+ public Object AsyncState {
+ //The application does not call this method because
+ //null is passed in as the last parameter to BeginEventHandler.
+ get {
+ return myAsynchStateObject;
+ }
+ }
+
+ public bool CompletedSynchronously {
+ //The application wants to know if this is synchronous.
+ //Return true if the Begin method was called synchronously.
+ get {
+ return _blnCompletedSynchronously;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/Test/TestMonoWeb/AsyncModule.cs b/mcs/class/System.Web/Test/TestMonoWeb/AsyncModule.cs
new file mode 100644
index 00000000000..839297b1c9e
--- /dev/null
+++ b/mcs/class/System.Web/Test/TestMonoWeb/AsyncModule.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Web;
+
+namespace TestMonoWeb
+{
+ /// <summary>
+ /// Summary description for AsyncModule.
+ /// </summary>
+ public class AsyncModule : IHttpModule
+ {
+ HttpApplication _app;
+
+ public void Init(HttpApplication app) {
+ app.AddOnPreRequestHandlerExecuteAsync(
+ new BeginEventHandler(this.BeginPreHandlerExecute),
+ new EndEventHandler(this.EndPreHandlerExecute));
+
+ _app = app;
+ }
+
+ IAsyncResult BeginPreHandlerExecute(Object source, EventArgs e, AsyncCallback cb, Object extraData) {
+ ((HttpApplication) source).Context.Response.Write("AsyncModule.BeginPreHandlerExecute()<br>\n");
+
+ AsynchOperation asynch = new AsynchOperation(cb, _app.Context, extraData);
+ asynch.StartAsyncWork();
+ return asynch;
+ }
+
+ void EndPreHandlerExecute(IAsyncResult ar) {
+ ((AsynchOperation) ar).Context.Response.Write("AsyncModule.EndPreHandlerExecute()<br>\n");
+ }
+
+ public void Dispose() {
+ }
+ }
+}
diff --git a/mcs/class/System.Web/Test/TestMonoWeb/AsyncOperation.cs b/mcs/class/System.Web/Test/TestMonoWeb/AsyncOperation.cs
new file mode 100644
index 00000000000..46b0ff1f722
--- /dev/null
+++ b/mcs/class/System.Web/Test/TestMonoWeb/AsyncOperation.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Threading;
+using System.Web;
+
+namespace TestMonoWeb
+{
+ class AsynchOperation : IAsyncResult {
+ private bool _completed;
+ private Object _state;
+ private AsyncCallback _callback;
+ private HttpContext _context;
+
+ bool IAsyncResult.IsCompleted { get { return _completed; } }
+ WaitHandle IAsyncResult.AsyncWaitHandle { get { return null; } }
+ Object IAsyncResult.AsyncState { get { return _state; } }
+ bool IAsyncResult.CompletedSynchronously { get { return false; } }
+
+ public HttpContext Context {
+ get {
+ return _context;
+ }
+ }
+
+ public AsynchOperation(AsyncCallback callback, HttpContext context, Object state) {
+ _callback = callback;
+ _context = context;
+ _state = state;
+ _completed = false;
+ }
+
+ public void StartAsyncWork() {
+ ThreadPool.QueueUserWorkItem(new WaitCallback(DoSomething), null /*workItemState*/);
+ }
+
+ private void DoSomething(Object workItemState) {
+ // Just for testing..
+ Thread.Sleep(100);
+ _completed = true;
+ _callback(this);
+ }
+ }
+}
diff --git a/mcs/class/System.Web/Test/TestMonoWeb/README b/mcs/class/System.Web/Test/TestMonoWeb/README
new file mode 100644
index 00000000000..1d4950d8036
--- /dev/null
+++ b/mcs/class/System.Web/Test/TestMonoWeb/README
@@ -0,0 +1,5 @@
+This small test program tests HttpModule and HttpHandler. The test program can both handle async and sync tests.
+
+This program uses the temporary configuration for modules and handlers.
+
+- Patrik Torstensson \ No newline at end of file
diff --git a/mcs/class/System.Web/Test/TestMonoWeb/SyncHandler.cs b/mcs/class/System.Web/Test/TestMonoWeb/SyncHandler.cs
new file mode 100644
index 00000000000..7dd01bb65ab
--- /dev/null
+++ b/mcs/class/System.Web/Test/TestMonoWeb/SyncHandler.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Web;
+
+namespace TestMonoWeb
+{
+ public class SyncHandler : IHttpHandler {
+
+ public void ProcessRequest(HttpContext context) {
+ context.Response.Write("SyncHandler.ProcessRequest<br>\n");
+ }
+
+ public bool IsReusable {
+ get { return false; }
+ }
+ }
+}
diff --git a/mcs/class/System.Web/Test/TestMonoWeb/SyncModule.cs b/mcs/class/System.Web/Test/TestMonoWeb/SyncModule.cs
new file mode 100644
index 00000000000..7fddb06a8bf
--- /dev/null
+++ b/mcs/class/System.Web/Test/TestMonoWeb/SyncModule.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections;
+using System.Web;
+
+namespace TestMonoWeb
+{
+ public class SyncModule : IHttpModule {
+ public String ModuleName {
+ get { return "HelloWorldModule"; }
+ }
+ //In the Init function, register for HttpApplication
+ //events by adding your handlers.
+ public void Init(HttpApplication application) {
+ application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
+ application.EndRequest += (new EventHandler(this.Application_EndRequest));
+ }
+
+ //Your BeginRequest event handler.
+ private void Application_BeginRequest(Object source, EventArgs e) {
+ HttpApplication application = (HttpApplication)source;
+ HttpContext context = application.Context;
+
+ context.Response.Write("SyncModule.Application_BeginRequest()<br>\n");
+ }
+
+ //Your EndRequest event handler.
+ private void Application_EndRequest(Object source, EventArgs e) {
+ HttpApplication application = (HttpApplication)source;
+ HttpContext context = application.Context;
+
+ context.Response.Write("SyncModule.Application_EndRequest()<br>\n");
+ }
+
+ public void Dispose() {
+ }
+ }
+}
diff --git a/mcs/class/System.Web/Test/TestMonoWeb/Test1.cs b/mcs/class/System.Web/Test/TestMonoWeb/Test1.cs
new file mode 100644
index 00000000000..b453cd8b170
--- /dev/null
+++ b/mcs/class/System.Web/Test/TestMonoWeb/Test1.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Web;
+using System.Web.Hosting;
+using System.Web.Configuration;
+
+namespace TestMonoWeb
+{
+ public class MyHost : MarshalByRefObject {
+ public MyHost() {
+ }
+ }
+ /// <summary>
+ /// Summary description for Test1.
+ /// </summary>
+ public class Test1
+ {
+ static void Main(string[] args) {
+ // Create the application host
+ object host = ApplicationHost.CreateApplicationHost(typeof(MyHost), "/", "c:\\");
+
+ int request_count = 10;
+ SimpleWorkerRequest [] requests = new SimpleWorkerRequest[request_count];
+
+ int pos;
+ for (pos = 0; pos != request_count; pos++) {
+ requests[pos] = new SimpleWorkerRequest("test.aspx", "", Console.Out);
+ }
+
+ ModulesConfiguration.Add("syncmodule", typeof(SyncModule).AssemblyQualifiedName);
+ ModulesConfiguration.Add("asyncmodule", typeof(AsyncModule).AssemblyQualifiedName);
+
+ HandlerFactoryConfiguration.Add("get", "/", typeof(AsyncHandler).AssemblyQualifiedName);
+ //HandlerFactoryConfiguration.Add("get", "/", typeof(SyncHandler).AssemblyQualifiedName);
+
+ for (pos = 0; pos != request_count; pos++)
+ HttpRuntime.ProcessRequest(requests[pos]);
+
+ HttpRuntime.Close();
+/*
+ Console.Write("Press Enter to quit.");
+ Console.WriteLine();
+ Console.ReadLine();
+*/
+ }
+ }
+}
diff --git a/mcs/class/System.Web/Test/TestMonoWeb/TestMonoWeb.build b/mcs/class/System.Web/Test/TestMonoWeb/TestMonoWeb.build
new file mode 100644
index 00000000000..98ecbcc49c3
--- /dev/null
+++ b/mcs/class/System.Web/Test/TestMonoWeb/TestMonoWeb.build
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<project name="System" default="build">
+ <property name="debug" value="false"/>
+
+ <target name="build">
+ <csc target="exe" output="TestMonoWeb.exe" debug="${debug}">
+ <arg value="/nowarn:1595"/>
+ <arg value="/nowarn:0169"/>
+ <arg value="/nowarn:0649"/> <!-- always default value -->
+ <arg value="/nowarn:0067"/> <!-- event never used -->
+ <arg value="/nowarn:0679"/> <!-- internal virual -->
+ <arg value="/nowarn:0168"/> <!-- never used variable -->
+ <arg value="/nowarn:0162"/> <!-- unreachable code -->
+ <arg value="/unsafe"/>
+ <arg value="/noconfig"/>
+ <arg value="/debug"/>
+ <arg value="/r:System.dll"/>
+ <arg value="/r:System.Web.dll"/>
+ <arg value="/r:System.Drawing.dll"/>
+ <arg value="/r:System.Xml.dll"/>
+ <sources>
+ <includes name="**/*.cs"/>
+ </sources>
+ </csc>
+ </target>
+</project>
diff --git a/mcs/class/System.Web/Test/test.aspx b/mcs/class/System.Web/Test/test.aspx
new file mode 100644
index 00000000000..363fab9697f
--- /dev/null
+++ b/mcs/class/System.Web/Test/test.aspx
@@ -0,0 +1,29 @@
+<%@ page language="c#"%>
+<html>
+<head>
+<title>Test</title>
+<%Response.Write("Test");%>
+
+<script runat="server" language="c#">
+ void SubmitBtn_Click(Object sender, EventArgs e) {
+ Response.Write("Hi");
+ }
+</script>
+
+<form action="test.aspx" method="post" runat="server">
+<asp:button text="Click Me" OnClick="SubmitBtn_Click" runat="server"/>
+</form>
+
+<!-- output
+
+<html>
+<head>
+<title>Test</title>
+Test<form name="ctrl0" method="post" action="test.aspx" id="ctrl0">
+<input type="hidden" name="__VIEWSTATE" value="dDwtMTc0MDc5ODg1Mzs7Pg==" />
+
+<input type="submit" name="ctrl1" value="Click Me" />
+</form>
+
+
+--> \ No newline at end of file
diff --git a/mcs/class/System.Web/Test/test2.aspx b/mcs/class/System.Web/Test/test2.aspx
new file mode 100644
index 00000000000..168aa05cb58
--- /dev/null
+++ b/mcs/class/System.Web/Test/test2.aspx
@@ -0,0 +1,101 @@
+<%@ Page Language="C#" %>
+<html>
+<head>
+<script language="C#" runat="server">
+void Page_Load(Object Sender, EventArgs e) {
+ if (!IsPostBack) {
+ ArrayList values = new ArrayList();
+
+ values.Add(new PositionData("Microsoft", "Msft"));
+ values.Add(new PositionData("Intel", "Intc"));
+ values.Add(new PositionData("Dell", "Dell"));
+
+ Repeater1.DataSource = values;
+ Repeater1.DataBind();
+
+ Repeater2.DataSource = values;
+ Repeater2.DataBind();
+ Response.Write(Repeater1.Controls[0].ClientID);
+ Response.Write("<br>");
+ Response.Write(Repeater1.Controls[0].UniqueID);
+ Response.Write("<br>");
+ }
+ }
+
+ public class PositionData {
+
+ private string name;
+ private string ticker;
+
+ public PositionData(string name, string ticker) {
+ this.name = name;
+ this.ticker = ticker;
+ }
+
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+ public string Ticker {
+ get {
+ return ticker;
+ }
+ }
+ }
+
+ </script>
+
+</head>
+<body>
+
+<h3><font face="Verdana">Repeater Example</font></h3>
+
+<form runat=server>
+
+<b>Repeater1:</b>
+
+<p>
+
+<asp:Repeater id=Repeater1 runat="server">
+<HeaderTemplate>
+<table border=1>
+<tr>
+<td><b>Company</b></td>
+<td><b>Symbol</b></td>
+</tr>
+</HeaderTemplate>
+
+<ItemTemplate>
+<tr>
+<td> <%# DataBinder.Eval(Container.DataItem, "Name") %> <asp:label id="test"></td>
+<td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %> </td>
+</tr>
+</ItemTemplate>
+
+<FooterTemplate>
+</table>
+</FooterTemplate>
+
+</asp:Repeater>
+<p>
+
+<b>Repeater2:</b>
+<p>
+<asp:Repeater id=Repeater2 runat="server">
+
+<HeaderTemplate>
+Company data:
+ </HeaderTemplate>
+
+<ItemTemplate>
+<%# DataBinder.Eval(Container.DataItem, "Name") %> (<%# DataBinder.Eval(Container.DataItem, "Ticker") %>)
+ </ItemTemplate>
+
+<SeparatorTemplate>, </SeparatorTemplate>
+</asp:Repeater>
+</form>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/test3.aspx b/mcs/class/System.Web/Test/test3.aspx
new file mode 100644
index 00000000000..d8776e45f48
--- /dev/null
+++ b/mcs/class/System.Web/Test/test3.aspx
@@ -0,0 +1,23 @@
+<%@ Page Debug="true" %>
+<html>
+<script runat=server language="vb">
+
+Sub AnchorBtn_Click(Source As Object, E as EventArgs)
+ Message.InnerText = Message.InnerHtml
+ End Sub
+
+ </script>
+
+<body>
+<form method=post runat=server>
+
+<a OnServerClick="AnchorBtn_Click" runat=server> Click here at your peril.</a>
+
+<h1>
+<span id="Message" runat=server><span id="Message2" runat=server>narf</span></span>
+</h1>
+
+</form>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/test4.aspx b/mcs/class/System.Web/Test/test4.aspx
new file mode 100644
index 00000000000..f9c020c1d85
--- /dev/null
+++ b/mcs/class/System.Web/Test/test4.aspx
@@ -0,0 +1,119 @@
+<%@ Page Language="C#" Debug="true" %>
+<html>
+<head>
+<script language="C#" runat="server">
+// protected override void OnInit(EventArgs e){
+// throw new Exception();
+// }
+ protected override void LoadViewState(object savedState){
+ throw new Exception();
+ }
+ protected override object SaveViewState(){
+ throw new Exception();
+ }
+ void Page_Kill(Object Sender, EventArgs e) {
+ throw new Exception();
+ }
+ protected override void OnInit(EventArgs e){
+ EnableViewState = true;
+ TrackViewState();
+ ViewState["test"] = "DIE!";
+ }
+ void Page_Load(Object Sender, EventArgs e) {
+// ((Control)Sender).PreRender += new EventHandler(Page_Kill);
+ if (!IsPostBack) {
+ ArrayList values = new ArrayList();
+
+ values.Add(new PositionData("Microsoft", "Msft"));
+ values.Add(new PositionData("Intel", "Intc"));
+ values.Add(new PositionData("Dell", "Dell"));
+
+ Repeater1.DataSource = values;
+ Repeater1.DataBind();
+
+ Repeater2.DataSource = values;
+ Repeater2.DataBind();
+ Response.Write(Repeater1.Controls[0].ClientID);
+ Response.Write("<br>");
+ Response.Write(Repeater1.Controls[0].UniqueID);
+ Response.Write("<br>");
+ }
+ }
+
+ public class PositionData {
+
+ private string name;
+ private string ticker;
+
+ public PositionData(string name, string ticker) {
+ this.name = name;
+ this.ticker = ticker;
+ }
+
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+ public string Ticker {
+ get {
+ return ticker;
+ }
+ }
+ }
+
+ </script>
+
+</head>
+<body>
+
+<h3><font face="Verdana">Repeater Example</font></h3>
+
+<form runat=server>
+
+<b>Repeater1:</b>
+
+<p>
+
+<asp:Repeater id=Repeater1 runat="server">
+<HeaderTemplate>
+<table border=1>
+<tr>
+<td><b>Company</b></td>
+<td><b>Symbol</b></td>
+</tr>
+</HeaderTemplate>
+
+<ItemTemplate>
+<tr>
+<td> <%# DataBinder.Eval(Container.DataItem, "Name") %> <asp:label id="test"></td>
+<td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %> </td>
+</tr>
+</ItemTemplate>
+
+<FooterTemplate>
+</table>
+</FooterTemplate>
+
+</asp:Repeater>
+<p>
+
+<b>Repeater2:</b>
+<p>
+<asp:Repeater id=Repeater2 runat="server">
+
+<HeaderTemplate>
+Company data:
+ </HeaderTemplate>
+
+<ItemTemplate>
+<%# DataBinder.Eval(Container.DataItem, "Name") %> (<%# DataBinder.Eval(Container.DataItem, "Ticker") %>)
+ </ItemTemplate>
+
+<SeparatorTemplate>, </SeparatorTemplate>
+</asp:Repeater>
+</form>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/test5.aspx b/mcs/class/System.Web/Test/test5.aspx
new file mode 100644
index 00000000000..2aaf4bf06c2
--- /dev/null
+++ b/mcs/class/System.Web/Test/test5.aspx
@@ -0,0 +1,121 @@
+<%@ Page Language="C#" Debug="true" %>
+<html>
+<head>
+<%
+Response.Write(HttpWorkerRequest.HeaderAccept);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderAcceptCharset);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderAcceptEncoding);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderAcceptLanguage);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderAcceptRanges);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderAge);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderAllow);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderAuthorization);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderCacheControl);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderConnection);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderContentEncoding);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderContentLanguage);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderContentLength);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderContentLocation);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderContentMd5);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderContentRange);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderContentType);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderCookie);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderDate);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderEtag);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderExpect);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderExpires);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderFrom);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderHost);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderIfMatch);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderIfModifiedSince);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderIfNoneMatch);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderIfRange);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderIfUnmodifiedSince);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderKeepAlive);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderLastModified);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderLocation);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderMaxForwards);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderPragma);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderProxyAuthenticate);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderProxyAuthorization);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderRange);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderReferer);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderRetryAfter);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderServer);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderSetCookie);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderTe);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderTrailer);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderTransferEncoding);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderUpgrade);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderUserAgent);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderVary);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderVia);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderWarning);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.HeaderWwwAuthenticate);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.ReasonCachePolicy);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.ReasonCacheSecurity);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.ReasonClientDisconnect);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.ReasonDefault);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.ReasonFileHandleCacheMiss);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.ReasonResponseCacheMiss);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.RequestHeaderMaximum);
+Response.Write("<br>");
+Response.Write(HttpWorkerRequest.ResponseHeaderMaximum);
+Response.Write("<br>");
+%> \ No newline at end of file
diff --git a/mcs/class/System.Web/Test/test6.aspx b/mcs/class/System.Web/Test/test6.aspx
new file mode 100644
index 00000000000..594c4bc7bbb
--- /dev/null
+++ b/mcs/class/System.Web/Test/test6.aspx
@@ -0,0 +1,83 @@
+<html>
+<head>
+<!--
+ Author: Gaurav Vaish
+ Original Source: http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIWebControlsCalendarClassSelectedDateTopic.asp
+ Copyright: (C) Gaurav Vaish, 2001
+-->
+ <script language="C#" runat="server">
+
+ void Selection_Change(Object sender, EventArgs e)
+ {
+ Label1.Text = "The selected date is " + Calendar1.SelectedDate.ToShortDateString();
+ }
+
+ void Selection_Change_Month(Object sender, EventArgs e)
+ {
+ Label2.Text = "The selected date is " + Calendar2.SelectedDate.ToShortDateString();
+ }
+
+ void Selection_Change_DWM(Object sender, EventArgs e)
+ {
+ Label3.Text = "The selected date is " + Calendar3.SelectedDate.ToShortDateString();
+ }
+
+ </script>
+
+</head>
+<body>
+
+ <form runat="server">
+
+ <h3><font face="Verdana">Calendar Example</font></h3>
+
+ Select a date on the Calendar control.<br><br>
+
+ <asp:Calendar ID="Calendar1" runat="server"
+ SelectionMode="Day"
+ ShowGridLines="True"
+ OnSelectionChanged="Selection_Change">
+
+ <SelectedDayStyle BackColor="Yellow"
+ ForeColor="Red">
+ </SelectedDayStyle>
+
+ </asp:Calendar>
+
+ <asp:Label id="Label1" runat=server />
+
+ <hr><br>
+
+ <asp:Calendar ID="Calendar2" runat="server"
+ SelectionMode="DayWeek"
+ ShowGridLines="True"
+ OnSelectionChanged="Selection_Change_Month">
+
+ <SelectedDayStyle BackColor="Yellow"
+ ForeColor="Red">
+ </SelectedDayStyle>
+
+ </asp:Calendar>
+
+ <asp:Label id="Label2" runat=server />
+
+ <hr><br>
+
+ <asp:Calendar ID="Calendar3" runat="server"
+ SelectionMode="DayWeekMonth"
+ ShowGridLines="True"
+ OnSelectionChanged="Selection_Change_DWM">
+
+ <SelectedDayStyle BackColor="Yellow"
+ ForeColor="Red">
+ </SelectedDayStyle>
+
+ </asp:Calendar>
+
+ <asp:Label id="Label3" runat=server />
+
+ <hr><br>
+
+ </form>
+</body>
+</html> \ No newline at end of file
diff --git a/mcs/class/System.Web/list b/mcs/class/System.Web/list
new file mode 100755
index 00000000000..0fb7ac8e943
--- /dev/null
+++ b/mcs/class/System.Web/list
@@ -0,0 +1,369 @@
+System.Web/BeginEventHandler.cs
+System.Web/EndEventHandler.cs
+System.Web/HttpCacheRevalidation.cs
+System.Web/HttpCacheability.cs
+System.Web/HttpCookie.cs
+System.Web/HttpCookieCollection.cs
+System.Web/HttpRuntime.cs
+System.Web/HttpServerUtility.cs
+System.Web/HttpValidationStatus.cs
+System.Web/HttpWriter.cs
+System.Web/TraceContext.cs
+System.Web/HttpWorkerRequest.cs
+System.Web/IHttpAsyncHandler.cs
+System.Web/IHttpHandler.cs
+System.Web/IHttpHandlerFactory.cs
+System.Web/IHttpMapPath.cs
+System.Web/IHttpModule.cs
+System.Web/ProcessShutdownReason.cs
+System.Web/ProcessStatus.cs
+System.Web/TODOAttribute.cs
+System.Web/TraceMode.cs
+System.Web/WebCategoryAttribute.cs
+System.Web/WebSysDescriptionAttribute.cs
+System.Web/HttpApplication.cs
+System.Web/HttpApplicationState.cs
+System.Web/HttpApplicationFactory.cs
+System.Web/HttpAsyncResult.cs
+System.Web/HttpBrowserCapabilities.cs
+System.Web/HttpCachePolicy.cs
+System.Web/HttpClientCertificate.cs
+System.Web/HttpCompileException.cs
+System.Web/HttpContext.cs
+System.Web/HttpException.cs
+System.Web/HttpFileCollection.cs
+System.Web/HttpForbiddenHandler.cs
+System.Web/HttpHelper.cs
+System.Web/HttpParseException.cs
+System.Web/HttpRequest.cs
+System.Web/HttpRequestStream.cs
+System.Web/HttpResponse.cs
+System.Web/HttpResponseHeader.cs
+System.Web/HttpResponseStream.cs
+System.Web/HttpResponseStreamProxy.cs
+System.Web/HttpUtility.cs
+System.Web/HttpValueCollection.cs
+System.Web/HttpCacheValidateHandler.cs
+System.Web/HttpCacheVaryByHeaders.cs
+System.Web/HttpCacheVaryByParams.cs
+System.Web/HttpMethodNotAllowedHandler.cs
+System.Web/HttpModuleCollection.cs
+System.Web/HttpPostedFile.cs
+System.Web/HttpStaticObjectsCollection.cs
+System.Web/HttpUnhandledException.cs
+System.Web/MimeTypes.cs
+System.Web/ProcessInfo.cs
+System.Web/StaticFileHandler.cs
+System.Web.Caching/Cache.cs
+System.Web.Caching/CacheDefinitions.cs
+System.Web.Caching/CacheDependency.cs
+System.Web.Caching/CacheEntry.cs
+System.Web.Caching/CacheExpires.cs
+System.Web.Caching/ExpiresBuckets.cs
+System.Web.Configuration/AuthConfig.cs
+System.Web.Configuration/AuthenticationConfigHandler.cs
+System.Web.Configuration/AuthenticationMode.cs
+System.Web.Configuration/ClientTargetSectionHandler.cs
+System.Web.Configuration/FormsAuthPasswordFormat.cs
+System.Web.Configuration/FormsProtectionEnum.cs
+System.Web.Configuration/GlobalizationConfiguration.cs
+System.Web.Configuration/HttpCapabilitiesBase.cs
+System.Web.Configuration/HandlerFactoryConfiguration.cs
+System.Web.Configuration/HandlerFactoryProxy.cs
+System.Web.Configuration/HttpConfigurationContext.cs
+System.Web.Configuration/HttpHandlersSectionHandler.cs
+System.Web.Configuration/HttpModulesConfigurationHandler.cs
+System.Web.Configuration/HandlerItem.cs
+System.Web.Configuration/MachineKeyConfig.cs
+System.Web.Configuration/MachineKeyConfigHandler.cs
+System.Web.Configuration/ModulesConfiguration.cs
+System.Web.Configuration/ModuleItem.cs
+System.Web.Hosting/AppDomainFactory.cs
+System.Web.Hosting/ApplicationHost.cs
+System.Web.Hosting/IAppDomainFactory.cs
+System.Web.Hosting/IISAPIRuntime.cs
+System.Web.Hosting/ISAPIRuntime.cs
+System.Web.Hosting/SimpleWorkerRequest.cs
+System.Web.Mail/MailAttachment.cs
+System.Web.Mail/MailEncoding.cs
+System.Web.Mail/MailFormat.cs
+System.Web.Mail/MailMessage.cs
+System.Web.Mail/MailPriority.cs
+System.Web.Mail/SmtpMail.cs
+System.Web.UI/BuildMethod.cs
+System.Web.UI/BuildTemplateMethod.cs
+System.Web.UI/Control.cs
+System.Web.UI/DataBindingHandlerAttribute.cs
+System.Web.UI/DesignTimeParseData.cs
+System.Web.UI/HtmlTextWriter.cs
+System.Web.UI/HtmlTextWriterAttribute.cs
+System.Web.UI/HtmlTextWriterStyle.cs
+System.Web.UI/HtmlTextWriterTag.cs
+System.Web.UI/IAttributeAccessor.cs
+System.Web.UI/IDataBindingsAccessor.cs
+System.Web.UI/INamingContainer.cs
+System.Web.UI/IParserAccessor.cs
+System.Web.UI/IPostBackDataHandler.cs
+System.Web.UI/IPostBackEventHandler.cs
+System.Web.UI/IStateManager.cs
+System.Web.UI/ITagNameToTypeMapper.cs
+System.Web.UI/ITemplate.cs
+System.Web.UI/IValidator.cs
+System.Web.UI/ImageClickEventHandler.cs
+System.Web.UI/LiteralControl.cs
+System.Web.UI/LosFormatter.cs
+System.Web.UI/OutputCacheLocation.cs
+System.Web.UI/Pair.cs
+System.Web.UI/PersistenceMode.cs
+System.Web.UI/PropertyConverter.cs
+System.Web.UI/StateBag.cs
+System.Web.UI/StateItem.cs
+System.Web.UI/SimpleWebHandlerParser.cs
+System.Web.UI/ToolboxDataAttribute.cs
+System.Web.UI/Utils.cs
+System.Web.UI/ConstructorNeedsTagAttribute.cs
+System.Web.UI/ControlBuilderAttribute.cs
+System.Web.UI/ImageClickEventArgs.cs
+System.Web.UI/Page.cs
+System.Web.UI/PageHandlerFactory.cs
+System.Web.UI/PageParser.cs
+System.Web.UI/ParseChildrenAttribute.cs
+System.Web.UI/PartialCachingAttribute.cs
+System.Web.UI/PersistChildrenAttribute.cs
+System.Web.UI/PersistenceModeAttribute.cs
+System.Web.UI/SimpleHandlerFactory.cs
+System.Web.UI/TagPrefixAttribute.cs
+System.Web.UI/TemplateContainerAttribute.cs
+System.Web.UI/TemplateControlParser.cs
+System.Web.UI/UserControlParser.cs
+System.Web.UI/ValidatorCollection.cs
+System.Web.UI/ValidationPropertyAttribute.cs
+System.Web.UI/AttributeCollection.cs
+System.Web.UI/BaseParser.cs
+System.Web.UI/ControlBuilder.cs
+System.Web.UI/ControlCollection.cs
+System.Web.UI/CssStyleCollection.cs
+System.Web.UI/DataBinder.cs
+System.Web.UI/DataBinding.cs
+System.Web.UI/DataBindingCollection.cs
+System.Web.UI/DataBoundLiteralControl.cs
+System.Web.UI/EmptyControlCollection.cs
+System.Web.UI/RenderMethod.cs
+System.Web.UI/TemplateControl.cs
+System.Web.UI/TemplateParser.cs
+System.Web.UI/Triplet.cs
+System.Web.UI/UserControl.cs
+System.Web.UI/CompiledTemplateBuilder.cs
+System.Web.UI/WebServiceParser.cs
+System.Web.UI.HtmlControls/HtmlAnchor.cs
+System.Web.UI.HtmlControls/HtmlButton.cs
+System.Web.UI.HtmlControls/HtmlContainerControl.cs
+System.Web.UI.HtmlControls/HtmlControl.cs
+System.Web.UI.HtmlControls/HtmlForm.cs
+System.Web.UI.HtmlControls/HtmlGenericControl.cs
+System.Web.UI.HtmlControls/HtmlImage.cs
+System.Web.UI.HtmlControls/HtmlInputButton.cs
+System.Web.UI.HtmlControls/HtmlInputCheckBox.cs
+System.Web.UI.HtmlControls/HtmlInputControl.cs
+System.Web.UI.HtmlControls/HtmlInputFile.cs
+System.Web.UI.HtmlControls/HtmlInputHidden.cs
+System.Web.UI.HtmlControls/HtmlInputImage.cs
+System.Web.UI.HtmlControls/HtmlInputRadioButton.cs
+System.Web.UI.HtmlControls/HtmlInputText.cs
+System.Web.UI.HtmlControls/HtmlSelect.cs
+System.Web.UI.HtmlControls/HtmlTable.cs
+System.Web.UI.HtmlControls/HtmlTableCell.cs
+System.Web.UI.HtmlControls/HtmlTableCellCollection.cs
+System.Web.UI.HtmlControls/HtmlTableRow.cs
+System.Web.UI.HtmlControls/HtmlTableRowCollection.cs
+System.Web.UI.HtmlControls/HtmlTextArea.cs
+System.Web.UI.WebControls/AdCreatedEventArgs.cs
+System.Web.UI.WebControls/AdCreatedEventHandler.cs
+System.Web.UI.WebControls/AdRotator.cs
+System.Web.UI.WebControls/BaseCompareValidator.cs
+System.Web.UI.WebControls/BaseDataList.cs
+System.Web.UI.WebControls/BaseValidator.cs
+System.Web.UI.WebControls/BorderStyle.cs
+System.Web.UI.WebControls/BoundColumn.cs
+System.Web.UI.WebControls/Button.cs
+System.Web.UI.WebControls/ButtonColumn.cs
+System.Web.UI.WebControls/ButtonColumnType.cs
+System.Web.UI.WebControls/Calendar.cs
+System.Web.UI.WebControls/CalendarDay.cs
+System.Web.UI.WebControls/CalendarSelectionMode.cs
+System.Web.UI.WebControls/CheckBox.cs
+System.Web.UI.WebControls/CheckBoxList.cs
+System.Web.UI.WebControls/CommandEventArgs.cs
+System.Web.UI.WebControls/CommandEventHandler.cs
+System.Web.UI.WebControls/CompareValidator.cs
+System.Web.UI.WebControls/CustomValidator.cs
+System.Web.UI.WebControls/DataGrid.cs
+System.Web.UI.WebControls/DataGridColumn.cs
+System.Web.UI.WebControls/DataGridColumnCollection.cs
+System.Web.UI.WebControls/DataGridCommandEventArgs.cs
+System.Web.UI.WebControls/DataGridCommandEventHandler.cs
+System.Web.UI.WebControls/DataGridItem.cs
+System.Web.UI.WebControls/DataGridItemCollection.cs
+System.Web.UI.WebControls/DataGridItemEventArgs.cs
+System.Web.UI.WebControls/DataGridItemEventHandler.cs
+System.Web.UI.WebControls/DataGridLinkButton.cs
+System.Web.UI.WebControls/DataGridPageChangedEventArgs.cs
+System.Web.UI.WebControls/DataGridPageChangedEventHandler.cs
+System.Web.UI.WebControls/DataGridPagerStyle.cs
+System.Web.UI.WebControls/DataGridSortCommandEventArgs.cs
+System.Web.UI.WebControls/DataGridSortCommandEventHandler.cs
+System.Web.UI.WebControls/DataGridTableInternal.cs
+System.Web.UI.WebControls/DataKeyCollection.cs
+System.Web.UI.WebControls/DataList.cs
+System.Web.UI.WebControls/DataListCommandEventArgs.cs
+System.Web.UI.WebControls/DataListCommandEventHandler.cs
+System.Web.UI.WebControls/DataListItem.cs
+System.Web.UI.WebControls/DataListItemCollection.cs
+System.Web.UI.WebControls/DataListItemEventArgs.cs
+System.Web.UI.WebControls/DataListItemEventHandler.cs
+System.Web.UI.WebControls/DataSourceInternal.cs
+System.Web.UI.WebControls/DayNameFormat.cs
+System.Web.UI.WebControls/DayRenderEventArgs.cs
+System.Web.UI.WebControls/DayRenderEventHandler.cs
+System.Web.UI.WebControls/DropDownList.cs
+System.Web.UI.WebControls/EditCommandColumn.cs
+System.Web.UI.WebControls/FirstDayOfWeek.cs
+System.Web.UI.WebControls/FontInfo.cs
+System.Web.UI.WebControls/FontNamesConverter.cs
+System.Web.UI.WebControls/FontSize.cs
+System.Web.UI.WebControls/FontUnit.cs
+System.Web.UI.WebControls/FontUnitConverter.cs
+System.Web.UI.WebControls/GridLines.cs
+System.Web.UI.WebControls/HorizontalAlign.cs
+System.Web.UI.WebControls/HorizontalAlignConverter.cs
+System.Web.UI.WebControls/HyperLink.cs
+System.Web.UI.WebControls/HyperLinkColumn.cs
+System.Web.UI.WebControls/HyperLinkControlBuilder.cs
+System.Web.UI.WebControls/IRepeatInfoUser.cs
+System.Web.UI.WebControls/Image.cs
+System.Web.UI.WebControls/ImageAlign.cs
+System.Web.UI.WebControls/ImageButton.cs
+System.Web.UI.WebControls/Label.cs
+System.Web.UI.WebControls/LabelControlBuilder.cs
+System.Web.UI.WebControls/LinkButton.cs
+System.Web.UI.WebControls/LinkButtonControlBuilder.cs
+System.Web.UI.WebControls/LinkButtonInternal.cs
+System.Web.UI.WebControls/ListBox.cs
+System.Web.UI.WebControls/ListControl.cs
+System.Web.UI.WebControls/ListItem.cs
+System.Web.UI.WebControls/ListItemCollection.cs
+System.Web.UI.WebControls/ListItemControlBuilder.cs
+System.Web.UI.WebControls/ListItemType.cs
+System.Web.UI.WebControls/ListSelectionMode.cs
+System.Web.UI.WebControls/Literal.cs
+System.Web.UI.WebControls/LiteralControlBuilder.cs
+System.Web.UI.WebControls/MonthChangedEventArgs.cs
+System.Web.UI.WebControls/MonthChangedEventHandler.cs
+System.Web.UI.WebControls/NextPrevFormat.cs
+System.Web.UI.WebControls/PagedDataSource.cs
+System.Web.UI.WebControls/PagerMode.cs
+System.Web.UI.WebControls/PagerPosition.cs
+System.Web.UI.WebControls/Panel.cs
+System.Web.UI.WebControls/PlaceHolder.cs
+System.Web.UI.WebControls/PlaceHolderControlBuilder.cs
+System.Web.UI.WebControls/RadioButton.cs
+System.Web.UI.WebControls/RadioButtonList.cs
+System.Web.UI.WebControls/RangeValidator.cs
+System.Web.UI.WebControls/RegularExpressionValidator.cs
+System.Web.UI.WebControls/RepeatDirection.cs
+System.Web.UI.WebControls/RepeatInfo.cs
+System.Web.UI.WebControls/RepeatLayout.cs
+System.Web.UI.WebControls/Repeater.cs
+System.Web.UI.WebControls/RepeaterCommandEventArgs.cs
+System.Web.UI.WebControls/RepeaterCommandEventHandler.cs
+System.Web.UI.WebControls/RepeaterItem.cs
+System.Web.UI.WebControls/RepeaterItemCollection.cs
+System.Web.UI.WebControls/RepeaterItemEventArgs.cs
+System.Web.UI.WebControls/RepeaterItemEventHandler.cs
+System.Web.UI.WebControls/RequiredFieldValidator.cs
+System.Web.UI.WebControls/SelectedDatesCollection.cs
+System.Web.UI.WebControls/ServerValidateEventArgs.cs
+System.Web.UI.WebControls/ServerValidateEventHandler.cs
+System.Web.UI.WebControls/Style.cs
+System.Web.UI.WebControls/Table.cs
+System.Web.UI.WebControls/TableCell.cs
+System.Web.UI.WebControls/TableCellCollection.cs
+System.Web.UI.WebControls/TableCellControlBuilder.cs
+System.Web.UI.WebControls/TableHeaderCell.cs
+System.Web.UI.WebControls/TableItemStyle.cs
+System.Web.UI.WebControls/TableRow.cs
+System.Web.UI.WebControls/TableRowCollection.cs
+System.Web.UI.WebControls/TableStyle.cs
+System.Web.UI.WebControls/TargetConverter.cs
+System.Web.UI.WebControls/TemplateColumn.cs
+System.Web.UI.WebControls/TextAlign.cs
+System.Web.UI.WebControls/TextBox.cs
+System.Web.UI.WebControls/TextBoxControlBuilder.cs
+System.Web.UI.WebControls/TextBoxMode.cs
+System.Web.UI.WebControls/TitleFormat.cs
+System.Web.UI.WebControls/Unit.cs
+System.Web.UI.WebControls/UnitConverter.cs
+System.Web.UI.WebControls/UnitType.cs
+System.Web.UI.WebControls/ValidatedControlConverter.cs
+System.Web.UI.WebControls/ValidationCompareOperator.cs
+System.Web.UI.WebControls/ValidationDataType.cs
+System.Web.UI.WebControls/ValidationSummary.cs
+System.Web.UI.WebControls/ValidationSummaryDisplayMode.cs
+System.Web.UI.WebControls/ValidatorDisplay.cs
+System.Web.UI.WebControls/VerticalAlign.cs
+System.Web.UI.WebControls/VerticalAlignConverter.cs
+System.Web.UI.WebControls/WebColorConverter.cs
+System.Web.UI.WebControls/WebControl.cs
+System.Web.UI.WebControls/Xml.cs
+System.Web.Util/ApacheVersionInfo.cs
+System.Web.Util/DataSourceHelper.cs
+System.Web.Util/FileAction.cs
+System.Web.Util/FileChangeEventHandler.cs
+System.Web.Util/FileChangedEventArgs.cs
+System.Web.Util/FileChangesMonitor.cs
+System.Web.Util/FilePathParser.cs
+System.Web.Util/IISVersionInfo.cs
+System.Web.Util/NativeFileChangeEventHandler.cs
+System.Web.Util/UrlUtils.cs
+System.Web.Util/WebEncoding.cs
+System.Web.Util/WebEqualComparer.cs
+System.Web.Util/WebHashCodeProvider.cs
+System.Web.Util/WebTrace.cs
+System.Web.Security/DefaultAuthenticationEventArgs.cs
+System.Web.Security/DefaultAuthenticationEventHandler.cs
+System.Web.Security/DefaultAuthenticationModule.cs
+System.Web.Security/FileAuthorizationModule.cs
+System.Web.Security/FormsAuthentication.cs
+System.Web.Security/FormsAuthenticationEventArgs.cs
+System.Web.Security/FormsAuthenticationEventHandler.cs
+System.Web.Security/FormsAuthenticationModule.cs
+System.Web.Security/FormsAuthenticationTicket.cs
+System.Web.Security/FormsIdentity.cs
+System.Web.Security/PassportAuthenticationEventArgs.cs
+System.Web.Security/PassportAuthenticationEventHandler.cs
+System.Web.Security/PassportAuthenticationModule.cs
+System.Web.Security/PassportIdentity.cs
+System.Web.Security/UrlAuthorizationModule.cs
+System.Web.Security/WindowsAuthenticationEventArgs.cs
+System.Web.Security/WindowsAuthenticationEventHandler.cs
+System.Web.Security/WindowsAuthenticationModule.cs
+System.Web.SessionState/HttpSessionState.cs
+System.Web.SessionState/IReadOnlySessionState.cs
+System.Web.SessionState/IRequiresSessionState.cs
+System.Web.SessionState/SessionDictionary.cs
+System.Web.SessionState/SessionStateMode.cs
+System.Web.SessionState/SessionStateModule.cs
+System.Web.Compilation/AspComponentFoundry.cs
+System.Web.Compilation/AspElements.cs
+System.Web.Compilation/AspGenerator.cs
+System.Web.Compilation/AspParser.cs
+System.Web.Compilation/AspTokenizer.cs
+System.Web.Compilation/BaseCompiler.cs
+System.Web.Compilation/CachingCompiler.cs
+System.Web.Compilation/CompilationResult.cs
+System.Web.Compilation/CompilationException.cs
+System.Web.Compilation/GlobalAsaxCompiler.cs
+System.Web.Compilation/PageCompiler.cs
+System.Web.Compilation/UserControlCompiler.cs
+System.Web.Compilation/WebServiceCompiler.cs
+System.Web.Handlers/TraceHandler.cs
diff --git a/mcs/class/System.Web/makefile.gnu b/mcs/class/System.Web/makefile.gnu
new file mode 100644
index 00000000000..0333f0235a8
--- /dev/null
+++ b/mcs/class/System.Web/makefile.gnu
@@ -0,0 +1,13 @@
+topdir = ../..
+
+LIBRARY = $(topdir)/class/lib/System.Web.dll
+
+LIB_LIST = list
+LIB_FLAGS = -r corlib -r System -r System.Drawing -r System.Xml
+
+SOURCES_INCLUDE=*.cs
+SOURCES_EXCLUDE=./Test*
+
+export MONO_PATH = $(topdir)/class/lib:
+
+include $(topdir)/class/library.make
diff --git a/mcs/class/System.Web/makefile.trace b/mcs/class/System.Web/makefile.trace
new file mode 100644
index 00000000000..789f5a5f5a4
--- /dev/null
+++ b/mcs/class/System.Web/makefile.trace
@@ -0,0 +1,12 @@
+# Used to build System.Web with trace support
+NANT=$(RUNTIME) ../../nant/NAnt.exe
+MAKE_GNU=$(MAKE) -f makefile.gnu -C .
+PLATFORM=uname | grep CYGWIN 2> /dev/null
+all:
+ @echo "Building System.Web.dll with Trace enabled."
+ ($(PLATFORM) && $(NANT) trace) || \
+ $(MAKE_GNU) LIB_FLAGS="/d:TRACE /d:WEBTRACE -r corlib -r System -r System.Drawing -r System.Xml"
+
+clean:
+ ($(PLATFORM) && $(NANT) clean) || $(MAKE_GNU) clean
+