Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / LiteralControl.cs / 1305376 / LiteralControl.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
* Control that holds a literal string
*
* Copyright (c) 1999 Microsoft Corporation
*/
namespace System.Web.UI {
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO;
///
/// Defines the properties and methods of the LiteralControl class. A
/// literal control is usually rendered as HTML text on a page.
///
/// LiteralControls behave as text holders, i.e., the parent of a LiteralControl may decide
/// to extract its text, and remove the control from its Control collection (typically for
/// performance reasons).
/// Therefore a control derived from LiteralControl must do any preprocessing of its Text
/// when it hands it out, that it would otherwise have done in its Render implementation.
///
///
[
ToolboxItem(false)
]
public class LiteralControl : Control, ITextControl {
internal string _text;
///
/// Creates a control that holds a literal string.
///
public LiteralControl() {
PreventAutoID();
SetEnableViewStateInternal(false);
}
///
/// Initializes a new instance of the LiteralControl class with
/// the specified text.
///
public LiteralControl(string text) : this() {
_text = (text != null) ? text : String.Empty;
}
///
/// Gets or sets the text content of the literal control.
///
public virtual string Text {
get {
return _text;
}
set {
_text = (value != null) ? value : String.Empty;
}
}
protected override ControlCollection CreateControlCollection() {
return new EmptyControlCollection(this);
}
///
/// Saves any state that was modified after mark.
///
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
protected internal override void Render(HtmlTextWriter output) {
output.Write(_text);
}
internal override void InitRecursive(Control namingContainer) {
ResolveAdapter();
if (AdapterInternal != null) {
AdapterInternal.OnInit(EventArgs.Empty);
}
else {
OnInit(EventArgs.Empty);
}
}
internal override void LoadRecursive() {
if (AdapterInternal != null) {
AdapterInternal.OnLoad(EventArgs.Empty);
}
else {
OnLoad(EventArgs.Empty);
}
}
internal override void PreRenderRecursiveInternal() {
if (AdapterInternal != null) {
AdapterInternal.OnPreRender(EventArgs.Empty);
}
else {
OnPreRender(EventArgs.Empty);
}
}
internal override void UnloadRecursive(bool dispose) {
if (AdapterInternal != null) {
AdapterInternal.OnUnload(EventArgs.Empty);
}
else {
OnUnload(EventArgs.Empty);
}
//
if (dispose)
Dispose();
}
}
/*
* Class used to access literal strings stored in a resource (perf optimization).
* This class is only public because it needs to be used by the generated classes.
* Users should not use directly.
*/
internal sealed class ResourceBasedLiteralControl : LiteralControl {
private TemplateControl _tplControl;
private int _offset; // Offset of the start of this string in the resource
private int _size; // Size of this string in bytes
private bool _fAsciiOnly; // Does the string contain only 7-bit ascii characters
internal ResourceBasedLiteralControl(TemplateControl tplControl, int offset, int size, bool fAsciiOnly) {
// Make sure we don't access invalid data
if (offset < 0 || offset+size > tplControl.MaxResourceOffset)
throw new ArgumentException();
_tplControl = tplControl;
_offset = offset;
_size = size;
_fAsciiOnly = fAsciiOnly;
PreventAutoID();
EnableViewState = false;
}
public override string Text {
get {
// If it's just a normal string, call the base
if (_size == 0)
return base.Text;
return StringResourceManager.ResourceToString(
_tplControl.StringResourcePointer, _offset, _size);
}
set {
// From now on, this will behave like a normal LiteralControl
_size = 0;
base.Text = value;
}
}
protected internal override void Render(HtmlTextWriter output) {
// If it's just a normal string, call the base
if (_size == 0) {
base.Render(output);
return;
}
output.WriteUTF8ResourceString(_tplControl.StringResourcePointer, _offset, _size, _fAsciiOnly);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
* Control that holds a literal string
*
* Copyright (c) 1999 Microsoft Corporation
*/
namespace System.Web.UI {
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO;
///
/// Defines the properties and methods of the LiteralControl class. A
/// literal control is usually rendered as HTML text on a page.
///
/// LiteralControls behave as text holders, i.e., the parent of a LiteralControl may decide
/// to extract its text, and remove the control from its Control collection (typically for
/// performance reasons).
/// Therefore a control derived from LiteralControl must do any preprocessing of its Text
/// when it hands it out, that it would otherwise have done in its Render implementation.
///
///
[
ToolboxItem(false)
]
public class LiteralControl : Control, ITextControl {
internal string _text;
///
/// Creates a control that holds a literal string.
///
public LiteralControl() {
PreventAutoID();
SetEnableViewStateInternal(false);
}
///
/// Initializes a new instance of the LiteralControl class with
/// the specified text.
///
public LiteralControl(string text) : this() {
_text = (text != null) ? text : String.Empty;
}
///
/// Gets or sets the text content of the literal control.
///
public virtual string Text {
get {
return _text;
}
set {
_text = (value != null) ? value : String.Empty;
}
}
protected override ControlCollection CreateControlCollection() {
return new EmptyControlCollection(this);
}
///
/// Saves any state that was modified after mark.
///
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
protected internal override void Render(HtmlTextWriter output) {
output.Write(_text);
}
internal override void InitRecursive(Control namingContainer) {
ResolveAdapter();
if (AdapterInternal != null) {
AdapterInternal.OnInit(EventArgs.Empty);
}
else {
OnInit(EventArgs.Empty);
}
}
internal override void LoadRecursive() {
if (AdapterInternal != null) {
AdapterInternal.OnLoad(EventArgs.Empty);
}
else {
OnLoad(EventArgs.Empty);
}
}
internal override void PreRenderRecursiveInternal() {
if (AdapterInternal != null) {
AdapterInternal.OnPreRender(EventArgs.Empty);
}
else {
OnPreRender(EventArgs.Empty);
}
}
internal override void UnloadRecursive(bool dispose) {
if (AdapterInternal != null) {
AdapterInternal.OnUnload(EventArgs.Empty);
}
else {
OnUnload(EventArgs.Empty);
}
//
if (dispose)
Dispose();
}
}
/*
* Class used to access literal strings stored in a resource (perf optimization).
* This class is only public because it needs to be used by the generated classes.
* Users should not use directly.
*/
internal sealed class ResourceBasedLiteralControl : LiteralControl {
private TemplateControl _tplControl;
private int _offset; // Offset of the start of this string in the resource
private int _size; // Size of this string in bytes
private bool _fAsciiOnly; // Does the string contain only 7-bit ascii characters
internal ResourceBasedLiteralControl(TemplateControl tplControl, int offset, int size, bool fAsciiOnly) {
// Make sure we don't access invalid data
if (offset < 0 || offset+size > tplControl.MaxResourceOffset)
throw new ArgumentException();
_tplControl = tplControl;
_offset = offset;
_size = size;
_fAsciiOnly = fAsciiOnly;
PreventAutoID();
EnableViewState = false;
}
public override string Text {
get {
// If it's just a normal string, call the base
if (_size == 0)
return base.Text;
return StringResourceManager.ResourceToString(
_tplControl.StringResourcePointer, _offset, _size);
}
set {
// From now on, this will behave like a normal LiteralControl
_size = 0;
base.Text = value;
}
}
protected internal override void Render(HtmlTextWriter output) {
// If it's just a normal string, call the base
if (_size == 0) {
base.Render(output);
return;
}
output.WriteUTF8ResourceString(_tplControl.StringResourcePointer, _offset, _size, _fAsciiOnly);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CacheVirtualItemsEvent.cs
- ServerReliableChannelBinder.cs
- GridLengthConverter.cs
- securitycriticaldataClass.cs
- XmlException.cs
- OrderByQueryOptionExpression.cs
- SchemaImporter.cs
- Block.cs
- Cursor.cs
- WhitespaceRule.cs
- Dictionary.cs
- SurrogateSelector.cs
- ClientProxyGenerator.cs
- FacetDescription.cs
- XmlUTF8TextReader.cs
- DbBuffer.cs
- WindowsEditBoxRange.cs
- EventKeyword.cs
- PropertyInfoSet.cs
- AbstractExpressions.cs
- ResolveResponse.cs
- ColumnPropertiesGroup.cs
- SeekStoryboard.cs
- IndexedString.cs
- InvalidOperationException.cs
- WebPartDescription.cs
- Typography.cs
- UxThemeWrapper.cs
- CodeSubDirectoriesCollection.cs
- Block.cs
- PathGradientBrush.cs
- ZoneMembershipCondition.cs
- DynamicMethod.cs
- DocumentGridPage.cs
- HiddenFieldPageStatePersister.cs
- DBSchemaTable.cs
- IWorkflowDebuggerService.cs
- Win32Native.cs
- PageBuildProvider.cs
- ContextDataSourceView.cs
- log.cs
- ElementHost.cs
- MenuAdapter.cs
- WindowsTokenRoleProvider.cs
- IdentitySection.cs
- PropertyToken.cs
- HostingEnvironment.cs
- mansign.cs
- SplitterCancelEvent.cs
- ImageClickEventArgs.cs
- ValidationEventArgs.cs
- ProvideValueServiceProvider.cs
- VisualStyleElement.cs
- DivideByZeroException.cs
- EntityDataSourceConfigureObjectContext.cs
- DesignerTransactionCloseEvent.cs
- DataControlPagerLinkButton.cs
- RewritingProcessor.cs
- DetailsViewInsertEventArgs.cs
- InProcStateClientManager.cs
- ConnectionManagementSection.cs
- BufferedReadStream.cs
- OpenTypeCommon.cs
- Listbox.cs
- QualificationDataAttribute.cs
- MarshalByRefObject.cs
- DefaultObjectMappingItemCollection.cs
- SqlMetaData.cs
- SQLInt32.cs
- HotSpotCollection.cs
- PathSegment.cs
- CloudCollection.cs
- CodeDomConfigurationHandler.cs
- EncryptedKey.cs
- ForeignKeyConstraint.cs
- _SpnDictionary.cs
- NotSupportedException.cs
- SequenceDesignerAccessibleObject.cs
- DecryptRequest.cs
- InternalMappingException.cs
- XmlUTF8TextWriter.cs
- DataListCommandEventArgs.cs
- IEnumerable.cs
- ZeroOpNode.cs
- CodeParameterDeclarationExpression.cs
- SqlMultiplexer.cs
- ScriptingRoleServiceSection.cs
- ProxyElement.cs
- baseshape.cs
- BrowserDefinition.cs
- ControlTemplate.cs
- ImageListImageEditor.cs
- NamespaceCollection.cs
- RIPEMD160Managed.cs
- GZipStream.cs
- LabelEditEvent.cs
- ApplicationHost.cs
- PersonalizationAdministration.cs
- TileModeValidation.cs
- XomlDesignerLoader.cs