Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / xsp / System / Web / Extensions / ui / ServiceReference.cs / 2 / ServiceReference.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Security.Permissions; using System.Web; using System.Web.Compilation; using System.Web.UI; using System.Web.Resources; using System.Web.Script.Services; [ AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("Path") ] public class ServiceReference { private string _path; private bool _inlineScript; public ServiceReference() { } public ServiceReference(string path) { Path = path; } [ ResourceDescription("ServiceReference_InlineScript"), DefaultValue(false), Category("Behavior") ] public bool InlineScript { get { return _inlineScript; } set { _inlineScript = value; } } [ ResourceDescription("ServiceReference_Path"), DefaultValue(""), Category("Behavior"), UrlProperty() ] public string Path { get { if (_path == null) { return String.Empty; } return _path; } set { _path = value; } } private string GetInlineScript(Control containingControl, HttpContext context, bool debug) { // Do not attempt to resolve inline service references on PageMethod requests. if (RestHandlerFactory.IsRestMethodCall(context.Request)) { return String.Empty; } string servicePath = GetServicePath(containingControl, false); try { servicePath = VirtualPathUtility.Combine(context.Request.FilePath, servicePath); } catch { throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.WebService_InvalidInlineVirtualPath, servicePath)); } return WebServiceClientProxyGenerator.GetInlineClientProxyScript(servicePath, context, debug); } private string GetServicePath(Control containingControl, bool encodeSpaces) { string path = Path; if (String.IsNullOrEmpty(path)) { throw new InvalidOperationException(AtlasWeb.ServiceReference_PathCannotBeEmpty); } if (encodeSpaces) { path = containingControl.ResolveClientUrl(path); } else { path = containingControl.ResolveUrl(path); } return path; } private string GetProxyPath(Control containingControl, bool debug) { if (debug) return GetServicePath(containingControl, true) + RestHandlerFactory.ClientDebugProxyRequestPathInfo; else return GetServicePath(containingControl, true) + RestHandlerFactory.ClientProxyRequestPathInfo; } internal void Register(Control containingControl, HttpContext context, ScriptManager scriptManager, bool debug) { if (InlineScript) { RenderClientScriptBlock(GetInlineScript(containingControl, context, debug), scriptManager); } else { RegisterClientScriptInclude(GetProxyPath(containingControl, debug), scriptManager); } } private static void RegisterClientScriptInclude(string path, ScriptManager scriptManager) { scriptManager.RegisterClientScriptIncludeInternal(scriptManager, typeof(ScriptManager), path, path); } private static void RenderClientScriptBlock(string script, ScriptManager scriptManager) { scriptManager.RegisterClientScriptBlockInternal(scriptManager, typeof(ScriptManager), script, script, true); } [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] public override string ToString() { if (!String.IsNullOrEmpty(Path)) { return Path; } else { return GetType().Name; } } } } // 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.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Security.Permissions; using System.Web; using System.Web.Compilation; using System.Web.UI; using System.Web.Resources; using System.Web.Script.Services; [ AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("Path") ] public class ServiceReference { private string _path; private bool _inlineScript; public ServiceReference() { } public ServiceReference(string path) { Path = path; } [ ResourceDescription("ServiceReference_InlineScript"), DefaultValue(false), Category("Behavior") ] public bool InlineScript { get { return _inlineScript; } set { _inlineScript = value; } } [ ResourceDescription("ServiceReference_Path"), DefaultValue(""), Category("Behavior"), UrlProperty() ] public string Path { get { if (_path == null) { return String.Empty; } return _path; } set { _path = value; } } private string GetInlineScript(Control containingControl, HttpContext context, bool debug) { // Do not attempt to resolve inline service references on PageMethod requests. if (RestHandlerFactory.IsRestMethodCall(context.Request)) { return String.Empty; } string servicePath = GetServicePath(containingControl, false); try { servicePath = VirtualPathUtility.Combine(context.Request.FilePath, servicePath); } catch { throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.WebService_InvalidInlineVirtualPath, servicePath)); } return WebServiceClientProxyGenerator.GetInlineClientProxyScript(servicePath, context, debug); } private string GetServicePath(Control containingControl, bool encodeSpaces) { string path = Path; if (String.IsNullOrEmpty(path)) { throw new InvalidOperationException(AtlasWeb.ServiceReference_PathCannotBeEmpty); } if (encodeSpaces) { path = containingControl.ResolveClientUrl(path); } else { path = containingControl.ResolveUrl(path); } return path; } private string GetProxyPath(Control containingControl, bool debug) { if (debug) return GetServicePath(containingControl, true) + RestHandlerFactory.ClientDebugProxyRequestPathInfo; else return GetServicePath(containingControl, true) + RestHandlerFactory.ClientProxyRequestPathInfo; } internal void Register(Control containingControl, HttpContext context, ScriptManager scriptManager, bool debug) { if (InlineScript) { RenderClientScriptBlock(GetInlineScript(containingControl, context, debug), scriptManager); } else { RegisterClientScriptInclude(GetProxyPath(containingControl, debug), scriptManager); } } private static void RegisterClientScriptInclude(string path, ScriptManager scriptManager) { scriptManager.RegisterClientScriptIncludeInternal(scriptManager, typeof(ScriptManager), path, path); } private static void RenderClientScriptBlock(string script, ScriptManager scriptManager) { scriptManager.RegisterClientScriptBlockInternal(scriptManager, typeof(ScriptManager), script, script, true); } [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] public override string ToString() { if (!String.IsNullOrEmpty(Path)) { return Path; } else { return GetType().Name; } } } } // 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
- MappingSource.cs
- ConditionalAttribute.cs
- ClientEndpointLoader.cs
- RelatedView.cs
- SafeReversePInvokeHandle.cs
- SemaphoreSecurity.cs
- URLMembershipCondition.cs
- ColorPalette.cs
- GestureRecognitionResult.cs
- VoiceInfo.cs
- RepeatButtonAutomationPeer.cs
- DataGridParentRows.cs
- ProcessExitedException.cs
- ApplicationDirectoryMembershipCondition.cs
- DatePicker.cs
- GeneralTransform3DGroup.cs
- ItemContainerPattern.cs
- SimpleWebHandlerParser.cs
- RawStylusInput.cs
- EntityContainer.cs
- EntityDesignerDataSourceView.cs
- Win32.cs
- DataTemplate.cs
- SqlNodeTypeOperators.cs
- EqualityComparer.cs
- ObsoleteAttribute.cs
- XamlReaderHelper.cs
- PasswordTextContainer.cs
- Native.cs
- EventManager.cs
- WebPartCatalogAddVerb.cs
- RuleSettingsCollection.cs
- XamlReaderHelper.cs
- Vector.cs
- LinearGradientBrush.cs
- Size3DValueSerializer.cs
- ToolStripSeparator.cs
- TimelineGroup.cs
- UnsafeNativeMethods.cs
- ObjectDataSourceMethodEditor.cs
- Msec.cs
- CodeDomDesignerLoader.cs
- XmlQueryStaticData.cs
- HttpConfigurationSystem.cs
- ArrangedElement.cs
- DataContractAttribute.cs
- TextElementEnumerator.cs
- FixedSOMSemanticBox.cs
- OdbcParameterCollection.cs
- Visual3D.cs
- activationcontext.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- EventEntry.cs
- XmlDownloadManager.cs
- XmlSerializationGeneratedCode.cs
- ResXResourceReader.cs
- ArrayWithOffset.cs
- ConfigsHelper.cs
- NetStream.cs
- EventEntry.cs
- NetworkAddressChange.cs
- MsmqIntegrationInputMessage.cs
- FileChangesMonitor.cs
- FlowDocumentPageViewerAutomationPeer.cs
- URLBuilder.cs
- InfoCardBaseException.cs
- PaperSize.cs
- ArithmeticException.cs
- CodeStatement.cs
- ScriptResourceAttribute.cs
- shaper.cs
- PermissionListSet.cs
- StylusEditingBehavior.cs
- ObjectManager.cs
- ActiveXSite.cs
- QilReference.cs
- SqlDataSourceWizardForm.cs
- FormParameter.cs
- TextMetrics.cs
- OdbcEnvironmentHandle.cs
- XmlDataSourceView.cs
- CatalogPartCollection.cs
- BitmapCodecInfoInternal.cs
- IdentityElement.cs
- DodSequenceMerge.cs
- Resources.Designer.cs
- GacUtil.cs
- CatalogZoneBase.cs
- WindowsListBox.cs
- SingleKeyFrameCollection.cs
- AccessorTable.cs
- DependentList.cs
- ReferentialConstraint.cs
- AuthenticationServiceManager.cs
- WindowInteropHelper.cs
- MembershipUser.cs
- ValidationPropertyAttribute.cs
- CursorConverter.cs
- ServiceContractAttribute.cs
- XmlnsDictionary.cs