Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- ExpressionBindings.cs
- TypeDescriptionProvider.cs
- _NetRes.cs
- FilteredDataSetHelper.cs
- SourceElementsCollection.cs
- MsmqIntegrationBindingElement.cs
- SQLDoubleStorage.cs
- HyperLinkField.cs
- XmlAttributeHolder.cs
- ArgumentDesigner.xaml.cs
- ListView.cs
- Tag.cs
- SHA256CryptoServiceProvider.cs
- WebHeaderCollection.cs
- SchemaElementLookUpTable.cs
- DecoderFallback.cs
- AttributeQuery.cs
- Transform.cs
- Matrix.cs
- EdmPropertyAttribute.cs
- invalidudtexception.cs
- RemoteWebConfigurationHostServer.cs
- EdmType.cs
- NavigationHelper.cs
- RectValueSerializer.cs
- DataControlFieldCell.cs
- Attachment.cs
- FastEncoder.cs
- EntityDescriptor.cs
- CompareValidator.cs
- ImageSourceValueSerializer.cs
- ConfigViewGenerator.cs
- FixedTextSelectionProcessor.cs
- CustomAttribute.cs
- DefaultBinder.cs
- TypeGeneratedEventArgs.cs
- StrokeNodeEnumerator.cs
- ConvertBinder.cs
- GridViewRowCollection.cs
- SqlDependency.cs
- PropertyGridCommands.cs
- MeasurementDCInfo.cs
- PropertyChangedEventManager.cs
- IntSecurity.cs
- TableLayoutSettingsTypeConverter.cs
- PhonemeEventArgs.cs
- CompensateDesigner.cs
- ChangeDirector.cs
- UrlUtility.cs
- CheckBoxFlatAdapter.cs
- PipelineModuleStepContainer.cs
- RichTextBox.cs
- WebExceptionStatus.cs
- Configuration.cs
- ApplyTemplatesAction.cs
- ZoneButton.cs
- CompressionTransform.cs
- WebUtil.cs
- AutomationPattern.cs
- ReflectionTypeLoadException.cs
- DataGridAddNewRow.cs
- ServiceDescription.cs
- CheckBoxPopupAdapter.cs
- TripleDES.cs
- TextServicesDisplayAttribute.cs
- DynamicDataManager.cs
- MetafileHeaderWmf.cs
- JulianCalendar.cs
- IResourceProvider.cs
- InternalsVisibleToAttribute.cs
- Rect3D.cs
- InputEventArgs.cs
- QilStrConcatenator.cs
- SecurityException.cs
- GradientBrush.cs
- MILUtilities.cs
- KeyboardEventArgs.cs
- BindingsCollection.cs
- WebConfigurationHost.cs
- ProxyHelper.cs
- ContainerSelectorActiveEvent.cs
- WmpBitmapEncoder.cs
- EdgeModeValidation.cs
- ToggleButtonAutomationPeer.cs
- Unit.cs
- HostingEnvironmentException.cs
- RedirectionProxy.cs
- XsdCachingReader.cs
- FormattedTextSymbols.cs
- UnmanagedBitmapWrapper.cs
- GridViewCommandEventArgs.cs
- IProvider.cs
- OrderedDictionary.cs
- ElementHostPropertyMap.cs
- MembershipUser.cs
- ColumnResizeAdorner.cs
- CodeTypeReferenceExpression.cs
- OptimizedTemplateContentHelper.cs
- WindowsListViewScroll.cs
- WindowsRegion.cs