Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / ServiceReference.cs / 1305376 / 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.Web;
using System.Web.Compilation;
using System.Web.UI;
using System.Web.Resources;
using System.Web.Script.Services;
[
DefaultProperty("Path")
]
public class ServiceReference {
private string _path;
private bool _inlineScript;
// needed at design time to remember what control owns this service reference (SM or SMP)
internal Control _containingControl;
public ServiceReference() {
}
public ServiceReference(string path) {
// do not use the virtual Path property setter here as it would violate Microsft.Usage:DoNotCallOverridableMethodsInConstructors
// A derived class is not likely to use this constructor anyway -- if they do, and they rely on an overridden Path property,
// they could call the property directly rather than use this constructor.
_path = path;
}
[
ResourceDescription("ServiceReference_InlineScript"),
DefaultValue(false),
Category("Behavior")
]
public virtual bool InlineScript {
get {
return _inlineScript;
}
set {
_inlineScript = value;
}
}
[
ResourceDescription("ServiceReference_Path"),
DefaultValue(""),
Category("Behavior"),
UrlProperty()
]
public virtual string Path {
get {
return _path ?? String.Empty;
}
set {
_path = value;
}
}
protected internal virtual string GetProxyScript(ScriptManager scriptManager, Control containingControl) {
string serviceUrl = GetServiceUrl(containingControl, false);
try {
serviceUrl = VirtualPathUtility.Combine(containingControl.Context.Request.FilePath, serviceUrl);
}
catch {
throw new ArgumentException(
String.Format(CultureInfo.InvariantCulture, AtlasWeb.WebService_InvalidInlineVirtualPath, serviceUrl));
}
return WebServiceClientProxyGenerator.GetInlineClientProxyScript(serviceUrl,
containingControl.Context,
scriptManager.IsDebuggingEnabled);
}
[SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings", Justification="Cannot change to URI for compatibility, and yet must also provide this extensibility point.")]
protected internal virtual string GetProxyUrl(ScriptManager scriptManager, Control containingControl) {
return GetServiceUrl(containingControl, true) +
((scriptManager.DesignMode || scriptManager.IsDebuggingEnabled) ?
RestHandlerFactory.ClientDebugProxyRequestPathInfo :
RestHandlerFactory.ClientProxyRequestPathInfo);
}
private string GetServiceUrl(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;
}
internal void Register(Control containingControl, ScriptManager scriptManager) {
if (InlineScript) {
if (!scriptManager.IsRestMethodCall) {
string script = GetProxyScript(scriptManager, containingControl);
if (!String.IsNullOrEmpty(script)) {
scriptManager.RegisterClientScriptBlockInternal(scriptManager, typeof(ScriptManager), script, script, true);
}
}
}
else {
string url = GetProxyUrl(scriptManager, containingControl);
if (!String.IsNullOrEmpty(url)) {
scriptManager.RegisterClientScriptIncludeInternal(scriptManager, typeof(ScriptManager), url, url);
}
}
}
[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.Web;
using System.Web.Compilation;
using System.Web.UI;
using System.Web.Resources;
using System.Web.Script.Services;
[
DefaultProperty("Path")
]
public class ServiceReference {
private string _path;
private bool _inlineScript;
// needed at design time to remember what control owns this service reference (SM or SMP)
internal Control _containingControl;
public ServiceReference() {
}
public ServiceReference(string path) {
// do not use the virtual Path property setter here as it would violate Microsft.Usage:DoNotCallOverridableMethodsInConstructors
// A derived class is not likely to use this constructor anyway -- if they do, and they rely on an overridden Path property,
// they could call the property directly rather than use this constructor.
_path = path;
}
[
ResourceDescription("ServiceReference_InlineScript"),
DefaultValue(false),
Category("Behavior")
]
public virtual bool InlineScript {
get {
return _inlineScript;
}
set {
_inlineScript = value;
}
}
[
ResourceDescription("ServiceReference_Path"),
DefaultValue(""),
Category("Behavior"),
UrlProperty()
]
public virtual string Path {
get {
return _path ?? String.Empty;
}
set {
_path = value;
}
}
protected internal virtual string GetProxyScript(ScriptManager scriptManager, Control containingControl) {
string serviceUrl = GetServiceUrl(containingControl, false);
try {
serviceUrl = VirtualPathUtility.Combine(containingControl.Context.Request.FilePath, serviceUrl);
}
catch {
throw new ArgumentException(
String.Format(CultureInfo.InvariantCulture, AtlasWeb.WebService_InvalidInlineVirtualPath, serviceUrl));
}
return WebServiceClientProxyGenerator.GetInlineClientProxyScript(serviceUrl,
containingControl.Context,
scriptManager.IsDebuggingEnabled);
}
[SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings", Justification="Cannot change to URI for compatibility, and yet must also provide this extensibility point.")]
protected internal virtual string GetProxyUrl(ScriptManager scriptManager, Control containingControl) {
return GetServiceUrl(containingControl, true) +
((scriptManager.DesignMode || scriptManager.IsDebuggingEnabled) ?
RestHandlerFactory.ClientDebugProxyRequestPathInfo :
RestHandlerFactory.ClientProxyRequestPathInfo);
}
private string GetServiceUrl(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;
}
internal void Register(Control containingControl, ScriptManager scriptManager) {
if (InlineScript) {
if (!scriptManager.IsRestMethodCall) {
string script = GetProxyScript(scriptManager, containingControl);
if (!String.IsNullOrEmpty(script)) {
scriptManager.RegisterClientScriptBlockInternal(scriptManager, typeof(ScriptManager), script, script, true);
}
}
}
else {
string url = GetProxyUrl(scriptManager, containingControl);
if (!String.IsNullOrEmpty(url)) {
scriptManager.RegisterClientScriptIncludeInternal(scriptManager, typeof(ScriptManager), url, url);
}
}
}
[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
- BasicExpandProvider.cs
- XmlSchemaAnyAttribute.cs
- ExpressionPrinter.cs
- SqlDataSourceView.cs
- MediaTimeline.cs
- PackUriHelper.cs
- DataGridViewLinkColumn.cs
- RowCache.cs
- BindingGroup.cs
- HostUtils.cs
- WebBaseEventKeyComparer.cs
- ToolStripPanelRow.cs
- TypeToStringValueConverter.cs
- StrokeDescriptor.cs
- InfoCardBinaryReader.cs
- QilFunction.cs
- ContainerCodeDomSerializer.cs
- Mutex.cs
- OlePropertyStructs.cs
- OleDbTransaction.cs
- ParentQuery.cs
- AdornerDecorator.cs
- CookielessHelper.cs
- GlobalizationSection.cs
- Int64Converter.cs
- ErasingStroke.cs
- NamedPipeTransportManager.cs
- SharedPersonalizationStateInfo.cs
- PersonalizationStateInfoCollection.cs
- NavigatorOutput.cs
- WorkflowInvoker.cs
- ProxyWebPartConnectionCollection.cs
- DoubleStorage.cs
- RemoteAsymmetricSignatureFormatter.cs
- DataServiceConfiguration.cs
- RulePatternOps.cs
- ChannelSettingsElement.cs
- PerformanceCounterPermissionAttribute.cs
- ObjectItemAssemblyLoader.cs
- CodeDirectiveCollection.cs
- DoubleAnimationBase.cs
- IIS7WorkerRequest.cs
- SQlBooleanStorage.cs
- TemplateControlBuildProvider.cs
- WebPartMenu.cs
- UIntPtr.cs
- _SslStream.cs
- OutputCacheModule.cs
- InvokeGenerator.cs
- ServiceBuildProvider.cs
- NumericUpDown.cs
- X509CertificateChain.cs
- TypeUtil.cs
- _RequestCacheProtocol.cs
- ReflectionTypeLoadException.cs
- EdmToObjectNamespaceMap.cs
- SpinWait.cs
- XNodeValidator.cs
- XhtmlTextWriter.cs
- XmlQueryOutput.cs
- EntityTypeBase.cs
- XmlNotation.cs
- DockPatternIdentifiers.cs
- ManagementQuery.cs
- TextDecorationCollection.cs
- ConfigurationElementCollection.cs
- ItemContainerPattern.cs
- ReceiveMessageContent.cs
- IisTraceWebEventProvider.cs
- DataGridViewColumnStateChangedEventArgs.cs
- WhitespaceSignificantCollectionAttribute.cs
- _PooledStream.cs
- DataGridViewColumnCollectionEditor.cs
- ByValueEqualityComparer.cs
- MaterialCollection.cs
- CodeValidator.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- SafeTokenHandle.cs
- Contracts.cs
- TargetException.cs
- XmlComplianceUtil.cs
- UrlAuthorizationModule.cs
- PersonalizationProviderHelper.cs
- BinaryEditor.cs
- BamlResourceSerializer.cs
- StylusPlugInCollection.cs
- PenContext.cs
- RemotingException.cs
- VirtualPath.cs
- Stack.cs
- ErrorFormatterPage.cs
- ApplicationSecurityManager.cs
- ClipboardProcessor.cs
- SelectingProviderEventArgs.cs
- HtmlInputCheckBox.cs
- DiscriminatorMap.cs
- DataServiceQueryException.cs
- XmlExpressionDumper.cs
- FieldAccessException.cs
- CodeExpressionRuleDeclaration.cs