📄 listitem.cs
字号:
using System;
namespace System.Web.UI.WebControls
{
/// <summary>
/// Summary description for ListItem.
/// </summary>
public class ListItem : System.Web.UI.IStateManager, System.Web.UI.IAttributeAccessor, System.Web.UI.IParserAccessor
{
//TODO:literal
/*
private static literal int MARKED = 1;
private static literal int SELECTED = 0;
private static literal int TEXTISDIRTY = 2;
private static literal int VALUEISDIRTY = 3;
*/
private System.Web.UI.AttributeCollection m_attributes;
private System.Collections.BitArray misc;
private string m_text;
private string m_value;
public ListItem() : this(null, null)
{
}
public ListItem(string itemtext) : this(itemtext, null)
{
}
public ListItem(string itemtext, string itemvalue)
{
this.m_text = itemtext;
this.m_value = itemvalue;
this.misc = new System.Collections.BitArray(4);
}
public override bool Equals(object obj)
{
System.Web.UI.WebControls.ListItem V_0;
V_0 = obj as System.Web.UI.WebControls.ListItem;
if(V_0 != null)
{
if(this.Value.Equals(V_0.Value))
{
return this.Text.Equals(V_0.Text);
}
}
return(false);
}
public static ListItem FromString(string s)
{
return(new ListItem(s));
}
public override int GetHashCode()
{
return base.GetHashCode();
}
internal void LoadViewState(object state)
{
System.Web.UI.Pair V_0;
if(state != null)
{
if(state is System.Web.UI.Pair)
{
V_0 = state as System.Web.UI.Pair;
if(V_0.First != null)
{
this.Text = (string)V_0.First;
}
this.Value = (string)V_0.Second;
return;
}
this.Text = (string)state;
}
}
internal object SaveViewSate()
{
if(this.misc[2] && this.misc[3])
{
return new System.Web.UI.Pair(this.Text, this.Value);
}
else if(this.misc[2])
{
return(this.Text);
}
else if(this.misc[3])
{
return new System.Web.UI.Pair(null, this.Value);
}
else
{
return(null);
}
}
string System.Web.UI.IAttributeAccessor.GetAttribute(string name)
{
return(this.Attributes[name]);
}
void System.Web.UI.IAttributeAccessor.SetAttribute(string name, string value)
{
this.Attributes[name] = value;
}
void System.Web.UI.IParserAccessor.AddParsedSubObject(object obj)
{
if(obj is System.Web.UI.LiteralControl)
{
this.Text = ((System.Web.UI.LiteralControl)obj).Text;
return;
}
if(obj is System.Web.UI.LiteralControl)
{
throw new System.Web.HttpException(
System.Web.HttpRuntime.FormatResourceString(
"Control_Cannot_Databind",
"ListItem"
)
);
}
throw new System.Web.HttpException(
System.Web.HttpRuntime.FormatResourceString(
"Cannot_Have_Children_Of_Type",
"ListItem",
obj.GetType().Name
)
);
}
void System.Web.UI.IStateManager.LoadViewState(object state)
{
this.LoadViewState(state);
}
void System.Web.UI.IStateManager.TrackViewState()
{
this.TrackViewState();
}
bool System.Web.UI.IStateManager.IsTrackingViewState
{
get
{
return(this.misc[1]);
}
}
object System.Web.UI.IStateManager.SaveViewState()
{
return(this.SaveViewSate());
}
internal void TrackViewState()
{
this.misc[1] = true;
}
public override string ToString()
{
return(this.Text);
}
internal bool Dirty
{
get
{
if(!(this.misc[2]))
{
return(this.misc[3]);
}
return(true);
}
set
{
this.misc[2] = true;
this.misc[3] = true;
}
}
public bool Selected
{
get
{
return(this.misc[0]);
}
set
{
this.misc[0] = value;
}
}
public string Value
{
get
{
if(this.m_value != null)
{
return(this.m_value);
}
if(this.m_text != null)
{
return(this.m_text);
}
return(string.Empty);
}
set
{
this.m_value = value;
if(((System.Web.UI.IStateManager)this).IsTrackingViewState)
{
this.misc[3] = true;
}
}
}
public string Text
{
get
{
if(this.m_text != null)
{
return(this.m_text);
}
if(this.m_value != null)
{
return(this.m_value);
}
return(string.Empty);
}
set
{
this.m_text = value;
if(((System.Web.UI.IStateManager)this).IsTrackingViewState)
{
this.misc[2] = true;
}
}
}
public System.Web.UI.AttributeCollection Attributes
{
get
{
if(this.m_attributes == null)
{
this.m_attributes = new System.Web.UI.AttributeCollection(new System.Web.UI.StateBag(true));
}
return(this.m_attributes);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -