Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / ScriptManagerProxy.cs / 1305376 / ScriptManagerProxy.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Drawing.Design; using System.Globalization; using System.Web; using System.Web.Resources; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Util; [ DefaultProperty("Scripts"), Designer("System.Web.UI.Design.ScriptManagerProxyDesigner, " + AssemblyRef.SystemWebExtensionsDesign), NonVisualControl(), ParseChildren(true), PersistChildren(false), ToolboxBitmap(typeof(EmbeddedResourceFinder), "System.Web.Resources.ScriptManagerProxy.bmp") ] public class ScriptManagerProxy : Control, IControl { private IScriptManagerInternal _scriptManager; private CompositeScriptReference _compositeScript; private ScriptReferenceCollection _scripts; private ServiceReferenceCollection _services; private ProfileServiceManager _profileServiceManager; private AuthenticationServiceManager _authenticationServiceManager; private RoleServiceManager _roleServiceManager; private static readonly object _navigateEvent = new object(); public ScriptManagerProxy() { } internal ScriptManagerProxy(IScriptManagerInternal scriptManager) { _scriptManager = scriptManager; } [ ResourceDescription("ScriptManager_AuthenticationService"), Category("Behavior"), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public AuthenticationServiceManager AuthenticationService { get { if(_authenticationServiceManager == null) { _authenticationServiceManager = new AuthenticationServiceManager(); } return _authenticationServiceManager; } } [ ResourceDescription("ScriptManager_CompositeScript"), Category("Behavior"), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public CompositeScriptReference CompositeScript { get { if (_compositeScript == null) { _compositeScript = new CompositeScriptReference(); } return _compositeScript; } } internal bool HasProfileServiceManager { get { return this._profileServiceManager != null; } } internal bool HasAuthenticationServiceManager { get { return this._authenticationServiceManager != null; } } internal bool HasRoleServiceManager { get { return this._roleServiceManager != null; } } internal EventHandlerNavigateEvent { get { return (EventHandler )Events[_navigateEvent]; } } [ ResourceDescription("ScriptManager_ProfileService"), Category("Behavior"), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public ProfileServiceManager ProfileService { get { if(_profileServiceManager == null) { _profileServiceManager = new ProfileServiceManager(); } return _profileServiceManager; } } [ ResourceDescription("ScriptManager_RoleService"), Category("Behavior"), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public RoleServiceManager RoleService { get { if(_roleServiceManager == null) { _roleServiceManager = new RoleServiceManager(); } return _roleServiceManager; } } private IScriptManagerInternal ScriptManager { get { if (_scriptManager == null) { Page page = Page; if (page == null) { throw new InvalidOperationException(AtlasWeb.Common_PageCannotBeNull); } _scriptManager = UI.ScriptManager.GetCurrent(Page); if (_scriptManager == null) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.Common_ScriptManagerRequired, ID)); } } return _scriptManager; } } [ ResourceDescription("ScriptManager_Scripts"), Category("Behavior"), DefaultValue(null), Editor("System.Web.UI.Design.CollectionEditorBase, " + AssemblyRef.SystemWebExtensionsDesign, typeof(UITypeEditor)), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public ScriptReferenceCollection Scripts { get { if (_scripts == null) { _scripts = new ScriptReferenceCollection(); } return _scripts; } } [ ResourceDescription("ScriptManager_Services"), Category("Behavior"), DefaultValue(null), Editor("System.Web.UI.Design.ServiceReferenceCollectionEditor, " + AssemblyRef.SystemWebExtensionsDesign, typeof(UITypeEditor)), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public ServiceReferenceCollection Services { get { if (_services == null) { _services = new ServiceReferenceCollection(); } return _services; } } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never) ] public override bool Visible { get { return base.Visible; } set { throw new NotImplementedException(); } } [ Category("Action"), ResourceDescription("ScriptManager_Navigate"), ] public event EventHandler Navigate { add { Events.AddHandler(_navigateEvent, value); } remove { Events.RemoveHandler(_navigateEvent, value); } } internal void CollectScripts(List scripts) { if ((_compositeScript != null) && (_compositeScript.Scripts.Count != 0)) { _compositeScript.ClientUrlResolver = this; _compositeScript.ContainingControl = this; _compositeScript.IsStaticReference = true; scripts.Add(_compositeScript); } // PERF: Use field directly to avoid creating List if not already created if (_scripts != null) { foreach (ScriptReference scriptReference in _scripts) { scriptReference.ClientUrlResolver = this; scriptReference.ContainingControl = this; scriptReference.IsStaticReference = true; scripts.Add(scriptReference); } } } [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")] protected internal override void OnInit(EventArgs e) { base.OnInit(e); if (!DesignMode) { ScriptManager.RegisterProxy(this); } } internal void RegisterServices(ScriptManager scriptManager) { // PERF: Use field directly to avoid creating List if not already created if (_services != null) { foreach (ServiceReference serviceReference in _services) { serviceReference.Register(this, scriptManager); } } } #region IControl Members HttpContextBase IControl.Context { get { return new System.Web.HttpContextWrapper(Context); } } bool IControl.DesignMode { get { return DesignMode; } } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Drawing.Design; using System.Globalization; using System.Web; using System.Web.Resources; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Util; [ DefaultProperty("Scripts"), Designer("System.Web.UI.Design.ScriptManagerProxyDesigner, " + AssemblyRef.SystemWebExtensionsDesign), NonVisualControl(), ParseChildren(true), PersistChildren(false), ToolboxBitmap(typeof(EmbeddedResourceFinder), "System.Web.Resources.ScriptManagerProxy.bmp") ] public class ScriptManagerProxy : Control, IControl { private IScriptManagerInternal _scriptManager; private CompositeScriptReference _compositeScript; private ScriptReferenceCollection _scripts; private ServiceReferenceCollection _services; private ProfileServiceManager _profileServiceManager; private AuthenticationServiceManager _authenticationServiceManager; private RoleServiceManager _roleServiceManager; private static readonly object _navigateEvent = new object(); public ScriptManagerProxy() { } internal ScriptManagerProxy(IScriptManagerInternal scriptManager) { _scriptManager = scriptManager; } [ ResourceDescription("ScriptManager_AuthenticationService"), Category("Behavior"), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public AuthenticationServiceManager AuthenticationService { get { if(_authenticationServiceManager == null) { _authenticationServiceManager = new AuthenticationServiceManager(); } return _authenticationServiceManager; } } [ ResourceDescription("ScriptManager_CompositeScript"), Category("Behavior"), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public CompositeScriptReference CompositeScript { get { if (_compositeScript == null) { _compositeScript = new CompositeScriptReference(); } return _compositeScript; } } internal bool HasProfileServiceManager { get { return this._profileServiceManager != null; } } internal bool HasAuthenticationServiceManager { get { return this._authenticationServiceManager != null; } } internal bool HasRoleServiceManager { get { return this._roleServiceManager != null; } } internal EventHandlerNavigateEvent { get { return (EventHandler )Events[_navigateEvent]; } } [ ResourceDescription("ScriptManager_ProfileService"), Category("Behavior"), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public ProfileServiceManager ProfileService { get { if(_profileServiceManager == null) { _profileServiceManager = new ProfileServiceManager(); } return _profileServiceManager; } } [ ResourceDescription("ScriptManager_RoleService"), Category("Behavior"), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public RoleServiceManager RoleService { get { if(_roleServiceManager == null) { _roleServiceManager = new RoleServiceManager(); } return _roleServiceManager; } } private IScriptManagerInternal ScriptManager { get { if (_scriptManager == null) { Page page = Page; if (page == null) { throw new InvalidOperationException(AtlasWeb.Common_PageCannotBeNull); } _scriptManager = UI.ScriptManager.GetCurrent(Page); if (_scriptManager == null) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.Common_ScriptManagerRequired, ID)); } } return _scriptManager; } } [ ResourceDescription("ScriptManager_Scripts"), Category("Behavior"), DefaultValue(null), Editor("System.Web.UI.Design.CollectionEditorBase, " + AssemblyRef.SystemWebExtensionsDesign, typeof(UITypeEditor)), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public ScriptReferenceCollection Scripts { get { if (_scripts == null) { _scripts = new ScriptReferenceCollection(); } return _scripts; } } [ ResourceDescription("ScriptManager_Services"), Category("Behavior"), DefaultValue(null), Editor("System.Web.UI.Design.ServiceReferenceCollectionEditor, " + AssemblyRef.SystemWebExtensionsDesign, typeof(UITypeEditor)), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false), ] public ServiceReferenceCollection Services { get { if (_services == null) { _services = new ServiceReferenceCollection(); } return _services; } } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never) ] public override bool Visible { get { return base.Visible; } set { throw new NotImplementedException(); } } [ Category("Action"), ResourceDescription("ScriptManager_Navigate"), ] public event EventHandler Navigate { add { Events.AddHandler(_navigateEvent, value); } remove { Events.RemoveHandler(_navigateEvent, value); } } internal void CollectScripts(List scripts) { if ((_compositeScript != null) && (_compositeScript.Scripts.Count != 0)) { _compositeScript.ClientUrlResolver = this; _compositeScript.ContainingControl = this; _compositeScript.IsStaticReference = true; scripts.Add(_compositeScript); } // PERF: Use field directly to avoid creating List if not already created if (_scripts != null) { foreach (ScriptReference scriptReference in _scripts) { scriptReference.ClientUrlResolver = this; scriptReference.ContainingControl = this; scriptReference.IsStaticReference = true; scripts.Add(scriptReference); } } } [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")] protected internal override void OnInit(EventArgs e) { base.OnInit(e); if (!DesignMode) { ScriptManager.RegisterProxy(this); } } internal void RegisterServices(ScriptManager scriptManager) { // PERF: Use field directly to avoid creating List if not already created if (_services != null) { foreach (ServiceReference serviceReference in _services) { serviceReference.Register(this, scriptManager); } } } #region IControl Members HttpContextBase IControl.Context { get { return new System.Web.HttpContextWrapper(Context); } } bool IControl.DesignMode { get { return DesignMode; } } #endregion } } // 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
- DtcInterfaces.cs
- Visitor.cs
- ViewCellSlot.cs
- CommandField.cs
- ColumnResizeAdorner.cs
- UserNameSecurityTokenProvider.cs
- ConditionValidator.cs
- ReadOnlyMetadataCollection.cs
- CfgRule.cs
- DesignerHelpers.cs
- XmlWriterSettings.cs
- ObjectQuery.cs
- _NTAuthentication.cs
- FocusTracker.cs
- EndpointAddressProcessor.cs
- Convert.cs
- PathData.cs
- ConfigXmlAttribute.cs
- IIS7UserPrincipal.cs
- TraceShell.cs
- Cursors.cs
- ExtractorMetadata.cs
- HotSpotCollection.cs
- ScriptResourceHandler.cs
- StringInfo.cs
- DiagnosticTraceSource.cs
- WorkflowCompensationBehavior.cs
- GacUtil.cs
- InternalConfigSettingsFactory.cs
- RadioButtonAutomationPeer.cs
- DataBoundControl.cs
- SoapMessage.cs
- Internal.cs
- SqlException.cs
- FieldNameLookup.cs
- ImageField.cs
- WorkflowMessageEventArgs.cs
- SpecularMaterial.cs
- GridViewUpdatedEventArgs.cs
- RealProxy.cs
- MethodImplAttribute.cs
- IndexedEnumerable.cs
- ScrollItemProviderWrapper.cs
- AddInControllerImpl.cs
- CompleteWizardStep.cs
- ContentFileHelper.cs
- ToolboxItem.cs
- PropertySet.cs
- MessageHeader.cs
- BinaryEditor.cs
- X509Extension.cs
- SQLStringStorage.cs
- ChannelManager.cs
- CapabilitiesPattern.cs
- TextCollapsingProperties.cs
- FastEncoder.cs
- TypeElementCollection.cs
- BufferedWebEventProvider.cs
- AllMembershipCondition.cs
- ServiceObjectContainer.cs
- ConnectAlgorithms.cs
- ParsedAttributeCollection.cs
- Native.cs
- BinaryUtilClasses.cs
- KeyPressEvent.cs
- TypeBuilderInstantiation.cs
- CompiledXpathExpr.cs
- EncryptedPackage.cs
- DBPropSet.cs
- OrderedDictionary.cs
- ProfileModule.cs
- SQLInt32.cs
- ToolStripSeparator.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- ColumnWidthChangedEvent.cs
- Interop.cs
- XPathException.cs
- PauseStoryboard.cs
- TemplateKey.cs
- InvariantComparer.cs
- ZipIOExtraFieldElement.cs
- Compress.cs
- PictureBox.cs
- ParentUndoUnit.cs
- RuntimeEnvironment.cs
- CalendarAutomationPeer.cs
- TypeBrowser.xaml.cs
- DataMemberAttribute.cs
- SoapUnknownHeader.cs
- ExpressionStringBuilder.cs
- FormsAuthenticationUser.cs
- ManifestResourceInfo.cs
- RangeBaseAutomationPeer.cs
- SoapServerMessage.cs
- ThicknessAnimationBase.cs
- ForEachAction.cs
- QuotedStringFormatReader.cs
- assemblycache.cs
- InputElement.cs
- DesignerSerializationVisibilityAttribute.cs