Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebParts / ProxyWebPart.cs / 1305376 / ProxyWebPart.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls.WebParts {
using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Util;
[
ToolboxItem(false)
]
public abstract class ProxyWebPart : WebPart {
private string _originalID;
private string _originalTypeName;
private string _originalPath;
private string _genericWebPartID;
protected ProxyWebPart(WebPart webPart) {
if (webPart == null) {
throw new ArgumentNullException("webPart");
}
GenericWebPart genericWebPart = webPart as GenericWebPart;
if (genericWebPart != null) {
Control childControl = genericWebPart.ChildControl;
if (childControl == null) {
throw new ArgumentException(SR.GetString(
SR.PropertyCannotBeNull, "ChildControl"), "webPart");
}
_originalID = childControl.ID;
if (String.IsNullOrEmpty(_originalID)) {
throw new ArgumentException(SR.GetString(
SR.PropertyCannotBeNullOrEmptyString, "ChildControl.ID"), "webPart");
}
Type originalType;
UserControl childUserControl = childControl as UserControl;
if (childUserControl != null) {
originalType = typeof(UserControl);
_originalPath = childUserControl.AppRelativeVirtualPath;
}
else {
originalType = childControl.GetType();
}
_originalTypeName = WebPartUtil.SerializeType(originalType);
_genericWebPartID = genericWebPart.ID;
if (String.IsNullOrEmpty(_genericWebPartID)) {
throw new ArgumentException(SR.GetString(
SR.PropertyCannotBeNullOrEmptyString, "ID"), "webPart");
}
ID = _genericWebPartID;
}
else {
_originalID = webPart.ID;
if (String.IsNullOrEmpty(_originalID)) {
throw new ArgumentException(SR.GetString(
SR.PropertyCannotBeNullOrEmptyString, "ID"), "webPart");
}
_originalTypeName = WebPartUtil.SerializeType(webPart.GetType());
ID = _originalID;
}
}
protected ProxyWebPart(string originalID, string originalTypeName, string originalPath, string genericWebPartID) {
if (String.IsNullOrEmpty(originalID)) {
throw ExceptionUtil.ParameterNullOrEmpty("originalID");
}
if (String.IsNullOrEmpty(originalTypeName)) {
throw ExceptionUtil.ParameterNullOrEmpty("originalTypeName");
}
// If you specify a path, this must be a GenericWebPart so genericWebPartID should not be null
if (!String.IsNullOrEmpty(originalPath) && String.IsNullOrEmpty(genericWebPartID)) {
throw ExceptionUtil.ParameterNullOrEmpty("genericWebPartID");
}
_originalID = originalID;
_originalTypeName = originalTypeName;
_originalPath = originalPath;
_genericWebPartID = genericWebPartID;
if (!String.IsNullOrEmpty(genericWebPartID)) {
ID = _genericWebPartID;
}
else {
ID = _originalID;
}
}
public string GenericWebPartID {
get {
return (_genericWebPartID != null) ? _genericWebPartID : String.Empty;
}
}
// Seal the ID property so we can set it in the constructor without an FxCop violation.
public sealed override string ID {
get {
return base.ID;
}
set {
base.ID = value;
}
}
public string OriginalID {
get {
return (_originalID != null) ? _originalID : String.Empty;
}
}
public string OriginalTypeName {
get {
return (_originalTypeName != null) ? _originalTypeName : String.Empty;
}
}
public string OriginalPath {
get {
return (_originalPath != null) ? _originalPath : String.Empty;
}
}
// Accept any ControlState, but do nothing with it, since it is actually the ControlState
// for the WebPart we are replacing.
protected internal override void LoadControlState(object savedState) {
}
// Accept any ViewState, but do nothing with it, since it is actually the ViewState
// for the WebPart we are replacing.
protected override void LoadViewState(object savedState) {
}
// Do not save any ControlState, since the ProxyWebPart itself does not need to save state
// between requests.
protected internal override object SaveControlState() {
// Call base in case it has some side-effects that the control relies on
base.SaveControlState();
return null;
}
// Do not save any ViewState, since the ProxyWebPart itself does not need to save state
// between requests.
protected override object SaveViewState() {
// Call base in case it has some side-effects that the control relies on
base.SaveViewState();
return null;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls.WebParts {
using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Util;
[
ToolboxItem(false)
]
public abstract class ProxyWebPart : WebPart {
private string _originalID;
private string _originalTypeName;
private string _originalPath;
private string _genericWebPartID;
protected ProxyWebPart(WebPart webPart) {
if (webPart == null) {
throw new ArgumentNullException("webPart");
}
GenericWebPart genericWebPart = webPart as GenericWebPart;
if (genericWebPart != null) {
Control childControl = genericWebPart.ChildControl;
if (childControl == null) {
throw new ArgumentException(SR.GetString(
SR.PropertyCannotBeNull, "ChildControl"), "webPart");
}
_originalID = childControl.ID;
if (String.IsNullOrEmpty(_originalID)) {
throw new ArgumentException(SR.GetString(
SR.PropertyCannotBeNullOrEmptyString, "ChildControl.ID"), "webPart");
}
Type originalType;
UserControl childUserControl = childControl as UserControl;
if (childUserControl != null) {
originalType = typeof(UserControl);
_originalPath = childUserControl.AppRelativeVirtualPath;
}
else {
originalType = childControl.GetType();
}
_originalTypeName = WebPartUtil.SerializeType(originalType);
_genericWebPartID = genericWebPart.ID;
if (String.IsNullOrEmpty(_genericWebPartID)) {
throw new ArgumentException(SR.GetString(
SR.PropertyCannotBeNullOrEmptyString, "ID"), "webPart");
}
ID = _genericWebPartID;
}
else {
_originalID = webPart.ID;
if (String.IsNullOrEmpty(_originalID)) {
throw new ArgumentException(SR.GetString(
SR.PropertyCannotBeNullOrEmptyString, "ID"), "webPart");
}
_originalTypeName = WebPartUtil.SerializeType(webPart.GetType());
ID = _originalID;
}
}
protected ProxyWebPart(string originalID, string originalTypeName, string originalPath, string genericWebPartID) {
if (String.IsNullOrEmpty(originalID)) {
throw ExceptionUtil.ParameterNullOrEmpty("originalID");
}
if (String.IsNullOrEmpty(originalTypeName)) {
throw ExceptionUtil.ParameterNullOrEmpty("originalTypeName");
}
// If you specify a path, this must be a GenericWebPart so genericWebPartID should not be null
if (!String.IsNullOrEmpty(originalPath) && String.IsNullOrEmpty(genericWebPartID)) {
throw ExceptionUtil.ParameterNullOrEmpty("genericWebPartID");
}
_originalID = originalID;
_originalTypeName = originalTypeName;
_originalPath = originalPath;
_genericWebPartID = genericWebPartID;
if (!String.IsNullOrEmpty(genericWebPartID)) {
ID = _genericWebPartID;
}
else {
ID = _originalID;
}
}
public string GenericWebPartID {
get {
return (_genericWebPartID != null) ? _genericWebPartID : String.Empty;
}
}
// Seal the ID property so we can set it in the constructor without an FxCop violation.
public sealed override string ID {
get {
return base.ID;
}
set {
base.ID = value;
}
}
public string OriginalID {
get {
return (_originalID != null) ? _originalID : String.Empty;
}
}
public string OriginalTypeName {
get {
return (_originalTypeName != null) ? _originalTypeName : String.Empty;
}
}
public string OriginalPath {
get {
return (_originalPath != null) ? _originalPath : String.Empty;
}
}
// Accept any ControlState, but do nothing with it, since it is actually the ControlState
// for the WebPart we are replacing.
protected internal override void LoadControlState(object savedState) {
}
// Accept any ViewState, but do nothing with it, since it is actually the ViewState
// for the WebPart we are replacing.
protected override void LoadViewState(object savedState) {
}
// Do not save any ControlState, since the ProxyWebPart itself does not need to save state
// between requests.
protected internal override object SaveControlState() {
// Call base in case it has some side-effects that the control relies on
base.SaveControlState();
return null;
}
// Do not save any ViewState, since the ProxyWebPart itself does not need to save state
// between requests.
protected override object SaveViewState() {
// Call base in case it has some side-effects that the control relies on
base.SaveViewState();
return null;
}
}
}
// 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
- GeometryGroup.cs
- SafeFileMapViewHandle.cs
- ListViewCommandEventArgs.cs
- SemanticBasicElement.cs
- CodeConditionStatement.cs
- VectorAnimationUsingKeyFrames.cs
- LineSegment.cs
- CodeAccessPermission.cs
- PackagePart.cs
- XmlNavigatorStack.cs
- ProfilePropertySettingsCollection.cs
- BamlLocalizabilityResolver.cs
- UnsafeNativeMethods.cs
- Decimal.cs
- HttpHandlerActionCollection.cs
- TextControlDesigner.cs
- QuaternionKeyFrameCollection.cs
- ExplicitDiscriminatorMap.cs
- WebPageTraceListener.cs
- IndentTextWriter.cs
- AsymmetricSignatureDeformatter.cs
- HandlerFactoryCache.cs
- QilInvoke.cs
- VersionPair.cs
- TypeResolvingOptions.cs
- UnmanagedMemoryAccessor.cs
- TemplateControl.cs
- SecUtil.cs
- ToolConsole.cs
- nulltextcontainer.cs
- shaper.cs
- Preprocessor.cs
- ThreadExceptionDialog.cs
- Properties.cs
- SimpleRecyclingCache.cs
- DesignerOptionService.cs
- ActivityDesignerLayoutSerializers.cs
- WorkflowTimerService.cs
- TransactionTraceIdentifier.cs
- BrushMappingModeValidation.cs
- StringUtil.cs
- XmlSerializationWriter.cs
- InfoCardSymmetricAlgorithm.cs
- SQLInt16.cs
- documentsequencetextcontainer.cs
- DesignerWidgets.cs
- Baml2006KnownTypes.cs
- Trigger.cs
- GroupBox.cs
- StrokeRenderer.cs
- EventPrivateKey.cs
- JsonUriDataContract.cs
- WasNotInstalledException.cs
- DictionaryEntry.cs
- RijndaelManaged.cs
- DrawListViewColumnHeaderEventArgs.cs
- _IPv6Address.cs
- RadioButtonBaseAdapter.cs
- EntityClassGenerator.cs
- BuilderPropertyEntry.cs
- StreamResourceInfo.cs
- RootBuilder.cs
- HtmlInputButton.cs
- ReverseInheritProperty.cs
- SqlAliasesReferenced.cs
- ShaderEffect.cs
- InternalDispatchObject.cs
- PropertyChangingEventArgs.cs
- PrePostDescendentsWalker.cs
- KeyValuePair.cs
- XamlClipboardData.cs
- SevenBitStream.cs
- BookmarkCallbackWrapper.cs
- DnsPermission.cs
- VisualTreeFlattener.cs
- Label.cs
- PrimitiveXmlSerializers.cs
- SQLMoney.cs
- MessageDecoder.cs
- ProtocolsConfigurationHandler.cs
- ProvidersHelper.cs
- SelectionUIHandler.cs
- PlanCompilerUtil.cs
- PriorityQueue.cs
- CodeAttributeDeclarationCollection.cs
- TypeInfo.cs
- DbProviderSpecificTypePropertyAttribute.cs
- SByteConverter.cs
- CodeChecksumPragma.cs
- ConfigurationSectionGroupCollection.cs
- SubtreeProcessor.cs
- NativeMethods.cs
- LineServicesCallbacks.cs
- PenThreadPool.cs
- FactoryGenerator.cs
- CryptoConfig.cs
- UnionExpr.cs
- LocalizationParserHooks.cs
- QilDataSource.cs
- XmlSchemaImporter.cs