mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
* ApplicationFileParser.cs: it works now. Prior to these changes, we were using the compiler directly. * BaseParser.cs: added some useful properties and methods. * CodeBuilder.cs: use ILocation. * CodeRenderBuilder.cs: use ILocation. * CollectionBuilder.cs: use the RootBuilder to map tag names into Types. * ControlBuilder.cs: made it useful. * DataBindingBuilder.cs: the control type for data bound text is DataBoundLiteralControl now. * ObjectTagBuilder.cs: store some object tag attributes. * PageParser.cs: handle page-only directives. * RootBuilder.cs: bah. * SimpleWebHandlerParser.cs: made it dummy. * TemplateControl.cs: Modified file. * TemplateControlParser.cs: handle directives that are common to pages and user controls. * TemplateParser.cs: utility methods and handling of directives that are common to app, page and user controls. * UserControl.cs: added ControlBuilderAttribute. * UserControlControlBuilder.cs: builder for user controls. * UserControlParser.cs: use the new interfaces. svn path=/trunk/mcs/; revision=14142
191 lines
3.2 KiB
C#
191 lines
3.2 KiB
C#
//
|
|
// System.Web.UI.UserControl
|
|
//
|
|
// Authors:
|
|
// Gonzalo Paniagua Javier ([email protected])
|
|
//
|
|
// (C) 2002 Ximian, Inc (http://www.ximian.com)
|
|
//
|
|
using System;
|
|
using System.Web.Caching;
|
|
using System.Web.SessionState;
|
|
|
|
namespace System.Web.UI
|
|
{
|
|
[ControlBuilder (typeof (UserControlControlBuilder))]
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|