Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / xsp / System / Web / Extensions / ui / ServiceReference.cs / 1 / 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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TreeViewAutomationPeer.cs
- followingsibling.cs
- UnescapedXmlDiagnosticData.cs
- ActivityWithResultConverter.cs
- DBConnectionString.cs
- XmlBindingWorker.cs
- ExplicitDiscriminatorMap.cs
- ObjectHandle.cs
- FontSourceCollection.cs
- DecoderReplacementFallback.cs
- FullTrustAssemblyCollection.cs
- SystemBrushes.cs
- JulianCalendar.cs
- ListViewDeleteEventArgs.cs
- KeyEventArgs.cs
- ReadOnlyDictionary.cs
- PropertyFilterAttribute.cs
- CapabilitiesRule.cs
- FormatterConverter.cs
- QilSortKey.cs
- AccessDataSourceWizardForm.cs
- CssStyleCollection.cs
- DefaultParameterValueAttribute.cs
- XsltSettings.cs
- DataColumnMappingCollection.cs
- HtmlInputCheckBox.cs
- wgx_exports.cs
- ExternalCalls.cs
- RecordConverter.cs
- ValidateNames.cs
- TransformProviderWrapper.cs
- CustomAttributeFormatException.cs
- TableLayoutSettingsTypeConverter.cs
- FormsAuthenticationUser.cs
- ProfileInfo.cs
- FormatVersion.cs
- XmlTypeMapping.cs
- ScriptHandlerFactory.cs
- SqlBuilder.cs
- AlternateView.cs
- ChtmlMobileTextWriter.cs
- RowVisual.cs
- LayoutUtils.cs
- RoleManagerModule.cs
- DynamicArgumentDesigner.xaml.cs
- TextRange.cs
- COM2ExtendedUITypeEditor.cs
- ClientProxyGenerator.cs
- TextPointer.cs
- Axis.cs
- LinqDataSource.cs
- Globals.cs
- FontUnit.cs
- PermissionSetTriple.cs
- SHA512.cs
- objectresult_tresulttype.cs
- XmlUtilWriter.cs
- InputBinding.cs
- TypeConverterAttribute.cs
- WebException.cs
- SrgsSemanticInterpretationTag.cs
- CalculatedColumn.cs
- DefaultAsyncDataDispatcher.cs
- ListViewInsertionMark.cs
- Clipboard.cs
- VariableModifiersHelper.cs
- SiteOfOriginContainer.cs
- COM2ICategorizePropertiesHandler.cs
- DBCSCodePageEncoding.cs
- BackgroundWorker.cs
- SendSecurityHeaderElement.cs
- CodeMemberMethod.cs
- DeflateInput.cs
- TextSerializer.cs
- SimpleColumnProvider.cs
- _NTAuthentication.cs
- CommonProperties.cs
- FilterQuery.cs
- MethodImplAttribute.cs
- METAHEADER.cs
- PriorityRange.cs
- Visual3D.cs
- PreProcessInputEventArgs.cs
- WebReferencesBuildProvider.cs
- SmtpReplyReaderFactory.cs
- ActiveXContainer.cs
- XmlDownloadManager.cs
- TextRunTypographyProperties.cs
- UrlParameterReader.cs
- InputReportEventArgs.cs
- AlternationConverter.cs
- WmpBitmapDecoder.cs
- CmsUtils.cs
- DragCompletedEventArgs.cs
- UserControlParser.cs
- ErrorHandler.cs
- ComponentEditorForm.cs
- BypassElement.cs
- ToolStripContentPanel.cs
- IndexedDataBuffer.cs