You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -0,0 +1,13 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MicrosoftAjaxMode.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
public enum AjaxFrameworkMode {
|
||||
Enabled = 0,
|
||||
Disabled = 1,
|
||||
Explicit = 2,
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="AppLevelCompilationSectionCache.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Web.Configuration;
|
||||
|
||||
// The compilation section can be defined below the application level, but ScriptManager only considers the
|
||||
// application-level debug setting.
|
||||
internal sealed class AppLevelCompilationSectionCache : ICompilationSection {
|
||||
private static readonly AppLevelCompilationSectionCache _instance = new AppLevelCompilationSectionCache();
|
||||
|
||||
// Value is cached statically, because AppLevelCompilationSectionCache is a Singleton.
|
||||
private bool? _debug;
|
||||
|
||||
private AppLevelCompilationSectionCache() {
|
||||
}
|
||||
|
||||
public static AppLevelCompilationSectionCache Instance {
|
||||
get {
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Debug {
|
||||
get {
|
||||
if (_debug == null) {
|
||||
_debug = GetDebugFromConfig();
|
||||
}
|
||||
return _debug.Value;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
ConfigurationPermission(SecurityAction.Assert, Unrestricted = true),
|
||||
SecuritySafeCritical(),
|
||||
]
|
||||
private static bool GetDebugFromConfig() {
|
||||
CompilationSection section =
|
||||
(CompilationSection)WebConfigurationManager.GetWebApplicationSection("system.web/compilation");
|
||||
return section.Debug;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ApplicationServiceManager.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Web.UI;
|
||||
using System.Web.Resources;
|
||||
using System.Globalization;
|
||||
|
||||
internal static class ApplicationServiceManager {
|
||||
public const int StringBuilderCapacity = 128;
|
||||
|
||||
public static string MergeServiceUrls(string serviceUrl, string existingUrl, Control urlBase) {
|
||||
serviceUrl = serviceUrl.Trim();
|
||||
|
||||
if(serviceUrl.Length > 0) {
|
||||
serviceUrl = urlBase.ResolveClientUrl(serviceUrl);
|
||||
|
||||
if(String.IsNullOrEmpty(existingUrl)) {
|
||||
// proxy has specified a url and we don't have one yet, so use it
|
||||
existingUrl = serviceUrl;
|
||||
}
|
||||
else {
|
||||
// proxy has specified a url but we arleady have a url either from ScriptManager itself or a previous proxy.
|
||||
// The urls must agree or an exception is thrown.
|
||||
if(!string.Equals(serviceUrl, existingUrl, StringComparison.OrdinalIgnoreCase)) {
|
||||
throw new ArgumentException(AtlasWeb.AppService_MultiplePaths);
|
||||
}
|
||||
}
|
||||
}
|
||||
return existingUrl;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="AssemblyCache.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Script;
|
||||
|
||||
// Caches Assembly APIs to improve performance
|
||||
internal static class AssemblyCache {
|
||||
// PERF: Cache reference to System.Web.Extensions assembly. Use ScriptManager since it's guaranteed to be in S.W.E
|
||||
public static readonly Assembly SystemWebExtensions = typeof(ScriptManager).Assembly;
|
||||
public static readonly Assembly SystemWeb = typeof(Page).Assembly;
|
||||
|
||||
private static CompilationSection _compilationSection;
|
||||
internal static bool _useCompilationSection = true;
|
||||
|
||||
// Maps string (assembly name) to Assembly
|
||||
private static readonly Hashtable _assemblyCache = Hashtable.Synchronized(new Hashtable());
|
||||
// Maps assembly to Version
|
||||
// internal so it can be manipulated by the unit test suite
|
||||
internal static readonly Hashtable _versionCache = Hashtable.Synchronized(new Hashtable());
|
||||
// Maps an assembly to its ajax framework assembly attribute. If it doesn't have one, it maps it to a null value
|
||||
private static readonly ConcurrentDictionary<Assembly, AjaxFrameworkAssemblyAttribute> _ajaxAssemblyAttributeCache =
|
||||
new ConcurrentDictionary<Assembly, AjaxFrameworkAssemblyAttribute>();
|
||||
|
||||
private static CompilationSection CompilationSection {
|
||||
get {
|
||||
if (_compilationSection == null) {
|
||||
_compilationSection = RuntimeConfig.GetAppConfig().Compilation;
|
||||
}
|
||||
return _compilationSection;
|
||||
}
|
||||
}
|
||||
|
||||
public static Version GetVersion(Assembly assembly) {
|
||||
Debug.Assert(assembly != null);
|
||||
Version version = (Version)_versionCache[assembly];
|
||||
if (version == null) {
|
||||
// use new AssemblyName() instead of assembly.GetName() so it works in medium trust
|
||||
version = new AssemblyName(assembly.FullName).Version;
|
||||
_versionCache[assembly] = version;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
public static Assembly Load(string assemblyName) {
|
||||
Debug.Assert(!String.IsNullOrEmpty(assemblyName));
|
||||
Assembly assembly = (Assembly)_assemblyCache[assemblyName];
|
||||
if (assembly == null) {
|
||||
// _useCompilationSection must be set to false in a unit test environment since there
|
||||
// is no http runtime, and therefore no trust level is set.
|
||||
if (_useCompilationSection) {
|
||||
assembly = CompilationSection.LoadAssembly(assemblyName, true);
|
||||
}
|
||||
else {
|
||||
assembly = Assembly.Load(assemblyName);
|
||||
}
|
||||
_assemblyCache[assemblyName] = assembly;
|
||||
}
|
||||
return assembly;
|
||||
}
|
||||
|
||||
public static bool IsAjaxFrameworkAssembly(Assembly assembly) {
|
||||
return (GetAjaxFrameworkAssemblyAttribute(assembly) != null);
|
||||
}
|
||||
|
||||
public static AjaxFrameworkAssemblyAttribute GetAjaxFrameworkAssemblyAttribute(Assembly assembly) {
|
||||
Debug.Assert(assembly != null);
|
||||
AjaxFrameworkAssemblyAttribute ajaxFrameworkAssemblyAttribute;
|
||||
if (!_ajaxAssemblyAttributeCache.TryGetValue(assembly, out ajaxFrameworkAssemblyAttribute)) {
|
||||
ajaxFrameworkAssemblyAttribute = SafeGetAjaxFrameworkAssemblyAttribute(assembly);
|
||||
_ajaxAssemblyAttributeCache.TryAdd(assembly, ajaxFrameworkAssemblyAttribute);
|
||||
}
|
||||
return ajaxFrameworkAssemblyAttribute;
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "We do not want to throw from this method.")]
|
||||
internal static AjaxFrameworkAssemblyAttribute SafeGetAjaxFrameworkAssemblyAttribute(ICustomAttributeProvider attributeProvider) {
|
||||
try {
|
||||
foreach (Attribute attribute in attributeProvider.GetCustomAttributes(inherit: false)) {
|
||||
AjaxFrameworkAssemblyAttribute ajaxFrameworkAttribute = attribute as AjaxFrameworkAssemblyAttribute;
|
||||
if (ajaxFrameworkAttribute != null) {
|
||||
return ajaxFrameworkAttribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// Bug 34311: If we are unable to load the attribute, don't throw.
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="AsyncPostBackErrorEventArgs.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Web;
|
||||
|
||||
public class AsyncPostBackErrorEventArgs : EventArgs {
|
||||
private readonly Exception _exception;
|
||||
|
||||
public AsyncPostBackErrorEventArgs(Exception exception) {
|
||||
if (exception == null) {
|
||||
throw new ArgumentNullException("exception");
|
||||
}
|
||||
_exception = exception;
|
||||
}
|
||||
|
||||
public Exception Exception {
|
||||
get {
|
||||
return _exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,157 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="AsyncPostBackTrigger.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.Resources;
|
||||
using System.Web.Util;
|
||||
|
||||
public class AsyncPostBackTrigger : UpdatePanelControlTrigger {
|
||||
|
||||
private IScriptManagerInternal _scriptManager;
|
||||
|
||||
private Control _associatedControl;
|
||||
private static MethodInfo _eventHandler;
|
||||
private bool _eventHandled;
|
||||
private string _eventName;
|
||||
|
||||
public AsyncPostBackTrigger() {
|
||||
}
|
||||
|
||||
internal AsyncPostBackTrigger(IScriptManagerInternal scriptManager) {
|
||||
_scriptManager = scriptManager;
|
||||
}
|
||||
|
||||
private static MethodInfo EventHandler {
|
||||
get {
|
||||
if (_eventHandler == null) {
|
||||
_eventHandler = typeof(AsyncPostBackTrigger).GetMethod("OnEvent");
|
||||
}
|
||||
return _eventHandler;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID"),
|
||||
TypeConverter("System.Web.UI.Design.AsyncPostBackTriggerControlIDConverter, " +
|
||||
AssemblyRef.SystemWebExtensionsDesign)
|
||||
]
|
||||
public new string ControlID {
|
||||
get {
|
||||
return base.ControlID;
|
||||
}
|
||||
set {
|
||||
base.ControlID = value;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
DefaultValue(""),
|
||||
Category("Behavior"),
|
||||
ResourceDescription("AsyncPostBackTrigger_EventName"),
|
||||
TypeConverter("System.Web.UI.Design.AsyncPostBackTriggerEventNameConverter, " +
|
||||
AssemblyRef.SystemWebExtensionsDesign),
|
||||
]
|
||||
public string EventName {
|
||||
get {
|
||||
if (_eventName == null) {
|
||||
return String.Empty;
|
||||
}
|
||||
return _eventName;
|
||||
}
|
||||
set {
|
||||
_eventName = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal IScriptManagerInternal ScriptManager {
|
||||
get {
|
||||
if (_scriptManager == null) {
|
||||
Page page = Owner.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, Owner.ID));
|
||||
}
|
||||
}
|
||||
return _scriptManager;
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override void Initialize() {
|
||||
base.Initialize();
|
||||
|
||||
_associatedControl = FindTargetControl(true);
|
||||
|
||||
ScriptManager.RegisterAsyncPostBackControl(_associatedControl);
|
||||
|
||||
string eventName = EventName;
|
||||
if (eventName.Length != 0) {
|
||||
// If EventName is specified, attach our event handler to it
|
||||
EventInfo eventInfo = _associatedControl.GetType().GetEvent(eventName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public);
|
||||
if (eventInfo == null) {
|
||||
throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.AsyncPostBackTrigger_CannotFindEvent, eventName, ControlID, Owner.ID));
|
||||
}
|
||||
|
||||
MethodInfo handlerMethod = eventInfo.EventHandlerType.GetMethod("Invoke");
|
||||
ParameterInfo[] parameters = handlerMethod.GetParameters();
|
||||
if (!handlerMethod.ReturnType.Equals(typeof(void)) ||
|
||||
(parameters.Length != 2) ||
|
||||
(typeof(EventArgs).IsAssignableFrom(parameters[1].ParameterType) == false)) {
|
||||
throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.AsyncPostBackTrigger_InvalidEvent, eventName, ControlID, Owner.ID));
|
||||
}
|
||||
|
||||
Delegate handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, this, EventHandler);
|
||||
eventInfo.AddEventHandler(_associatedControl, handler);
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override bool HasTriggered() {
|
||||
if (!String.IsNullOrEmpty(EventName)) {
|
||||
// If EventName is specified we are triggered if our event was raised
|
||||
return _eventHandled;
|
||||
}
|
||||
else {
|
||||
// If EventName is not specified, check if the control that caused the
|
||||
// postback either has the exact UniqueID we're looking for, or at least
|
||||
// begins with it.
|
||||
string sourceElement = ScriptManager.AsyncPostBackSourceElementID;
|
||||
return
|
||||
(sourceElement == _associatedControl.UniqueID) ||
|
||||
(sourceElement.StartsWith(_associatedControl.UniqueID + "$", StringComparison.Ordinal));
|
||||
}
|
||||
}
|
||||
|
||||
// DevDiv Bugs 127369: This method should be private and the reflection lookup should assert reflection permission
|
||||
// so the private reflection works in medium trust.
|
||||
// However, ASP.NET AJAX 1.0 was released with this method public. Since it would be a breaking change to make it private
|
||||
// now, it was decided to leave it as is.
|
||||
[SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers",
|
||||
Justification="TODO: This will be fixed in fc_serverfx")]
|
||||
public void OnEvent(object sender, EventArgs e) {
|
||||
_eventHandled = true;
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
|
||||
public override string ToString() {
|
||||
if (String.IsNullOrEmpty(ControlID)) {
|
||||
return "AsyncPostBack";
|
||||
}
|
||||
else {
|
||||
return "AsyncPostBack: " + ControlID +
|
||||
(String.IsNullOrEmpty(EventName) ? String.Empty : ("." + EventName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="AuthenticationServiceManager.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.ApplicationServices;
|
||||
using System.Web.Resources;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.Security;
|
||||
|
||||
[
|
||||
DefaultProperty("Path"),
|
||||
TypeConverter(typeof(EmptyStringExpandableObjectConverter))
|
||||
]
|
||||
public class AuthenticationServiceManager {
|
||||
|
||||
private string _path;
|
||||
|
||||
internal static void ConfigureAuthenticationService(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, List<ScriptManagerProxy> proxies) {
|
||||
string authServiceUrl = null;
|
||||
AuthenticationServiceManager authManager;
|
||||
|
||||
if(scriptManager.HasAuthenticationServiceManager) {
|
||||
authManager = scriptManager.AuthenticationService;
|
||||
|
||||
// get ScriptManager.ServiceUrl
|
||||
authServiceUrl = authManager.Path.Trim();
|
||||
if(authServiceUrl.Length > 0) {
|
||||
authServiceUrl = scriptManager.ResolveUrl(authServiceUrl);
|
||||
}
|
||||
}
|
||||
|
||||
// combine proxy ServiceUrls (find the first one that has specified one)
|
||||
if(proxies != null) {
|
||||
foreach(ScriptManagerProxy proxy in proxies) {
|
||||
if(proxy.HasAuthenticationServiceManager) {
|
||||
authManager = proxy.AuthenticationService;
|
||||
|
||||
// combine urls
|
||||
authServiceUrl = ApplicationServiceManager.MergeServiceUrls(authManager.Path, authServiceUrl, proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
AuthenticationServiceManager.GenerateInitializationScript(ref sb, context, scriptManager, authServiceUrl);
|
||||
}
|
||||
|
||||
private static void GenerateInitializationScript(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, string serviceUrl) {
|
||||
bool authEnabled = ApplicationServiceHelper.AuthenticationServiceEnabled;
|
||||
|
||||
if (authEnabled) {
|
||||
if (sb == null) {
|
||||
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
|
||||
}
|
||||
|
||||
// The default path points to the built-in service (if it is enabled)
|
||||
// Note that the client can't default to this path because it doesn't know what the app root is, we must tell it.
|
||||
// We must specify the default path to the proxy even if a custom path is provided, because on the client they could
|
||||
// reset the path back to the default if they want.
|
||||
string defaultServicePath = scriptManager.ResolveClientUrl("~/" + System.Web.Script.Services.WebServiceData._authenticationServiceFileName);
|
||||
sb.Append("Sys.Services._AuthenticationService.DefaultWebServicePath = '");
|
||||
sb.Append(HttpUtility.JavaScriptStringEncode(defaultServicePath));
|
||||
sb.Append("';\n");
|
||||
}
|
||||
|
||||
bool pathSpecified = !String.IsNullOrEmpty(serviceUrl);
|
||||
if(pathSpecified) {
|
||||
if (sb == null) {
|
||||
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
|
||||
}
|
||||
sb.Append("Sys.Services.AuthenticationService.set_path('");
|
||||
sb.Append(HttpUtility.JavaScriptStringEncode(serviceUrl));
|
||||
sb.Append("');\n");
|
||||
}
|
||||
|
||||
// only emit this script if (1) the auth webservice is enabled or (2) a custom webservice url is specified
|
||||
if ((authEnabled || pathSpecified) &&
|
||||
(context != null && context.Request.IsAuthenticated)) {
|
||||
Debug.Assert(sb != null);
|
||||
sb.Append("Sys.Services.AuthenticationService._setAuthenticated(true);\n");
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
DefaultValue(""),
|
||||
Category("Behavior"),
|
||||
NotifyParentProperty(true),
|
||||
ResourceDescription("ApplicationServiceManager_Path"),
|
||||
UrlProperty()
|
||||
]
|
||||
public string Path {
|
||||
get {
|
||||
return _path ?? String.Empty;
|
||||
}
|
||||
set {
|
||||
_path = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Security review: We're calling into potentially untrusted code, as we don't check the identity of the target. But since we're neither passing sensitive information nor treating the return values as trusted, this is fine.
|
||||
*/
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Web.Compilation;
|
||||
|
||||
|
||||
internal sealed class BundleReflectionHelper {
|
||||
// Helper class for ScriptManager to call into Bundling
|
||||
// Expectation is that this Bundling will expose an object at System.Web.Optimization.BundleResolver.Current
|
||||
// and this type will have the following public methods:
|
||||
// bool IsBundleVirtualPath(string virtualPath);
|
||||
private delegate bool IsBundleVirtualPathDelegate(string virtualPath);
|
||||
private IsBundleVirtualPathDelegate IsBundleVirtualPathMethod { get; set; }
|
||||
|
||||
// IEnumerable<string> GetBundleContents(string virtualPath);
|
||||
private delegate IEnumerable<string> GetBundleContentsDelegate(string virtualPath);
|
||||
private GetBundleContentsDelegate GetBundleContentsMethod { get; set; }
|
||||
|
||||
// string GetBundleUrl(string virtualPath);
|
||||
private delegate string GetBundleUrlDelegate(string virtualPath);
|
||||
private GetBundleUrlDelegate GetBundleUrlMethod { get; set; }
|
||||
|
||||
// static object System.Web.Optimization.BundleResolver.Current
|
||||
private delegate object BundleResolverCurrentDelegate();
|
||||
private static BundleResolverCurrentDelegate BundleResolverCurrentMethod { get; set; }
|
||||
|
||||
|
||||
// Normal runtime code path, try to get the resolver from System.Web.Optimization.BundleResolver.Current and bind to its methods
|
||||
public BundleReflectionHelper() {
|
||||
BundleResolver = CallBundleResolverCurrent();
|
||||
}
|
||||
|
||||
// Unit tests can pass in their own bundleResolver
|
||||
public BundleReflectionHelper(object bundleResolver) {
|
||||
BundleResolver = bundleResolver;
|
||||
}
|
||||
|
||||
// ScriptManager will assume bundling is not enabled if this property is null.
|
||||
// Expectation is that this object type will have the following methods.
|
||||
// bool IsBundleVirtualPath(string virtualPath);
|
||||
// IEnumerable<string> GetBundleContents(string virtualPath);
|
||||
// string GetBundleUrl(string virtualPath);
|
||||
// Unit tests will set this directly, otherwise
|
||||
private object _resolver;
|
||||
internal object BundleResolver {
|
||||
get {
|
||||
return _resolver;
|
||||
}
|
||||
set {
|
||||
if (value != null) {
|
||||
Type resolverType = value.GetType();
|
||||
Type[] args = new Type[] { typeof(string) };
|
||||
IsBundleVirtualPathMethod = MakeDelegate<IsBundleVirtualPathDelegate>(value, resolverType.GetMethod("IsBundleVirtualPath", args));
|
||||
GetBundleContentsMethod = MakeDelegate<GetBundleContentsDelegate>(value, resolverType.GetMethod("GetBundleContents", args));
|
||||
GetBundleUrlMethod = MakeDelegate<GetBundleUrlDelegate>(value, resolverType.GetMethod("GetBundleUrl", args));
|
||||
// Only allow the set if all 3 methods are found
|
||||
if (IsBundleVirtualPathMethod != null && GetBundleContentsMethod != null && GetBundleUrlMethod != null) {
|
||||
_resolver = value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_resolver = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsBundleVirtualPath(string virtualPath) {
|
||||
if (BundleResolver != null) {
|
||||
try {
|
||||
return IsBundleVirtualPathMethod(virtualPath);
|
||||
}
|
||||
catch {
|
||||
// We never ever want to ---- up in an exception from this
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetBundleContents(string virtualPath) {
|
||||
if (BundleResolver != null) {
|
||||
try {
|
||||
return GetBundleContentsMethod(virtualPath);
|
||||
}
|
||||
catch {
|
||||
// We never ever want to ---- up in an exception from this
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetBundleUrl(string virtualPath) {
|
||||
if (BundleResolver != null) {
|
||||
try {
|
||||
return GetBundleUrlMethod(virtualPath);
|
||||
}
|
||||
catch {
|
||||
// We never ever want to ---- up in an exception from this
|
||||
}
|
||||
}
|
||||
|
||||
return virtualPath;
|
||||
}
|
||||
|
||||
// Attempts to call a static property System.Web.Optimziation.BundleResolver.Current
|
||||
// Only looks for the property once, but will call into the property every time
|
||||
private static bool s_lookedForCurrentProperty;
|
||||
internal static object CallBundleResolverCurrent() {
|
||||
if (!Volatile.Read(ref s_lookedForCurrentProperty)) {
|
||||
try {
|
||||
Type bundleResolverType = BuildManager.GetType("System.Web.Optimization.BundleResolver", throwOnError: false);
|
||||
if (bundleResolverType != null) {
|
||||
PropertyInfo bundleResolverCurrentProperty = bundleResolverType.GetProperty("Current", BindingFlags.Static | BindingFlags.Public);
|
||||
if (bundleResolverCurrentProperty != null) {
|
||||
BundleResolverCurrentMethod = MakeDelegate<BundleResolverCurrentDelegate>(null, bundleResolverCurrentProperty.GetGetMethod());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// We never want to throw an exception if this fails, we just want to treat this as bundling is off
|
||||
}
|
||||
Volatile.Write(ref s_lookedForCurrentProperty, true);
|
||||
}
|
||||
|
||||
if (BundleResolverCurrentMethod == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return BundleResolverCurrentMethod();
|
||||
}
|
||||
|
||||
private static T MakeDelegate<T>(object target, MethodInfo method) where T : class {
|
||||
return Delegate.CreateDelegate(typeof(T), target, method, false) as T;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ClientScriptManagerWrapper.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Web.UI;
|
||||
|
||||
internal sealed class ClientScriptManagerWrapper : IClientScriptManager {
|
||||
private readonly ClientScriptManager _clientScriptManager;
|
||||
|
||||
internal ClientScriptManagerWrapper(ClientScriptManager clientScriptManager) {
|
||||
Debug.Assert(clientScriptManager != null);
|
||||
_clientScriptManager = clientScriptManager;
|
||||
}
|
||||
|
||||
#region IClientScriptManager Members
|
||||
Dictionary<Assembly, Dictionary<String, Object>> IClientScriptManager.RegisteredResourcesToSuppress {
|
||||
get {
|
||||
return _clientScriptManager.RegisteredResourcesToSuppress;
|
||||
}
|
||||
}
|
||||
|
||||
string IClientScriptManager.GetPostBackEventReference(PostBackOptions options) {
|
||||
return _clientScriptManager.GetPostBackEventReference(options);
|
||||
}
|
||||
|
||||
string IClientScriptManager.GetWebResourceUrl(Type type, string resourceName) {
|
||||
return _clientScriptManager.GetWebResourceUrl(type, resourceName);
|
||||
}
|
||||
|
||||
void IClientScriptManager.RegisterClientScriptBlock(Type type, string key, string script) {
|
||||
_clientScriptManager.RegisterClientScriptBlock(type, key, script);
|
||||
}
|
||||
|
||||
void IClientScriptManager.RegisterClientScriptInclude(Type type, string key, string url) {
|
||||
_clientScriptManager.RegisterClientScriptInclude(type, key, url);
|
||||
}
|
||||
|
||||
void IClientScriptManager.RegisterClientScriptBlock(Type type, string key, string script, bool addScriptTags) {
|
||||
_clientScriptManager.RegisterClientScriptBlock(type, key, script, addScriptTags);
|
||||
}
|
||||
|
||||
void IClientScriptManager.RegisterStartupScript(Type type, string key, string script, bool addScriptTags) {
|
||||
_clientScriptManager.RegisterStartupScript(type, key, script, addScriptTags);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ClientUrlResolverWrapper.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Web.UI;
|
||||
|
||||
internal sealed class ClientUrlResolverWrapper : IClientUrlResolver {
|
||||
private readonly Control _control;
|
||||
|
||||
public ClientUrlResolverWrapper(Control control) {
|
||||
_control = control;
|
||||
}
|
||||
|
||||
#region IClientUrlResolver Members
|
||||
// DevDiv Bugs 197242: AppRelativeTemplateSourceDirectory needed for
|
||||
// CompositeReference url resolution
|
||||
string IClientUrlResolver.AppRelativeTemplateSourceDirectory {
|
||||
get {
|
||||
return _control.AppRelativeTemplateSourceDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
string IClientUrlResolver.ResolveClientUrl(string relativeUrl) {
|
||||
IClientUrlResolver resolver = _control as IClientUrlResolver;
|
||||
if (resolver != null) {
|
||||
return resolver.ResolveClientUrl(relativeUrl);
|
||||
}
|
||||
else {
|
||||
return _control.ResolveClientUrl(relativeUrl);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,192 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="CompositeScriptReference.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Drawing.Design;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Web.Handlers;
|
||||
using System.Web.Resources;
|
||||
using System.Web.Util;
|
||||
|
||||
[
|
||||
DefaultProperty("Path"),
|
||||
TypeConverter(typeof(EmptyStringExpandableObjectConverter))
|
||||
]
|
||||
public class CompositeScriptReference : ScriptReferenceBase {
|
||||
private ScriptReferenceCollection _scripts;
|
||||
|
||||
[
|
||||
ResourceDescription("CompositeScriptReference_Scripts"),
|
||||
Category("Behavior"),
|
||||
Editor("System.Web.UI.Design.CollectionEditorBase, " +
|
||||
AssemblyRef.SystemWebExtensionsDesign, typeof(UITypeEditor)),
|
||||
DefaultValue(null),
|
||||
PersistenceMode(PersistenceMode.InnerProperty),
|
||||
NotifyParentProperty(true),
|
||||
MergableProperty(false),
|
||||
]
|
||||
public ScriptReferenceCollection Scripts {
|
||||
get {
|
||||
if (_scripts == null) {
|
||||
_scripts = new ScriptReferenceCollection();
|
||||
}
|
||||
return _scripts;
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1055", Justification = "Consistent with other URL properties in ASP.NET.")]
|
||||
protected internal override string GetUrl(ScriptManager scriptManager, bool zip) {
|
||||
bool isDebuggingEnabled = !scriptManager.DeploymentSectionRetail &&
|
||||
((ScriptMode == ScriptMode.Debug) ||
|
||||
(((ScriptMode == ScriptMode.Inherit) || (ScriptMode == ScriptMode.Auto)) &&
|
||||
(scriptManager.IsDebuggingEnabled)));
|
||||
if (!String.IsNullOrEmpty(Path)) {
|
||||
string path = Path;
|
||||
if (isDebuggingEnabled) {
|
||||
path = GetDebugPath(path);
|
||||
}
|
||||
if (scriptManager.EnableScriptLocalization &&
|
||||
(ResourceUICultures != null) && (ResourceUICultures.Length != 0)) {
|
||||
|
||||
CultureInfo currentCulture = CultureInfo.CurrentUICulture;
|
||||
string cultureName = null;
|
||||
bool found = false;
|
||||
while (!currentCulture.Equals(CultureInfo.InvariantCulture)) {
|
||||
cultureName = currentCulture.ToString();
|
||||
foreach (string uiCulture in ResourceUICultures) {
|
||||
if (String.Equals(cultureName, uiCulture.Trim(), StringComparison.OrdinalIgnoreCase)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
currentCulture = currentCulture.Parent;
|
||||
}
|
||||
if (found) {
|
||||
path = (path.Substring(0, path.Length - 2) + cultureName + ".js");
|
||||
}
|
||||
}
|
||||
|
||||
// ResolveClientUrl is appropriate here because the path is consumed by the page it was declared within
|
||||
return ClientUrlResolver.ResolveClientUrl(path);
|
||||
}
|
||||
List<Tuple<Assembly, List<Tuple<string, CultureInfo>>>> resources =
|
||||
new List<Tuple<Assembly, List<Tuple<string, CultureInfo>>>>();
|
||||
Tuple<Assembly, List<Tuple<string, CultureInfo>>> resourceList = null;
|
||||
foreach (ScriptReference reference in Scripts) {
|
||||
if ((scriptManager.AjaxFrameworkMode == AjaxFrameworkMode.Explicit) &&
|
||||
reference.IsAjaxFrameworkScript(scriptManager) &&
|
||||
reference.EffectiveResourceName.StartsWith("MicrosoftAjax.", StringComparison.Ordinal)) {
|
||||
continue;
|
||||
}
|
||||
bool hasPath = !String.IsNullOrEmpty(reference.EffectivePath);
|
||||
#pragma warning disable 618
|
||||
// ScriptPath is obsolete but still functional
|
||||
bool hasScriptPath = (!String.IsNullOrEmpty(scriptManager.ScriptPath) && !reference.IgnoreScriptPath);
|
||||
#pragma warning restore 618
|
||||
// cacheAssembly will be null if ScriptPath is set, but we still need the resource assembly in that case
|
||||
Assembly resourceAssembly = null;
|
||||
string resourceName = null;
|
||||
Assembly cacheAssembly = null;
|
||||
ScriptMode effectiveScriptModeForReference = reference.EffectiveScriptMode;
|
||||
bool isDebuggingEnabledForReference =
|
||||
(effectiveScriptModeForReference == ScriptMode.Inherit) ?
|
||||
isDebuggingEnabled :
|
||||
(effectiveScriptModeForReference == ScriptMode.Debug);
|
||||
if (!hasPath) {
|
||||
resourceAssembly = reference.GetAssembly(scriptManager);
|
||||
resourceName = reference.EffectiveResourceName;
|
||||
reference.DetermineResourceNameAndAssembly(scriptManager, isDebuggingEnabledForReference,
|
||||
ref resourceName, ref resourceAssembly);
|
||||
if ((resourceAssembly != scriptManager.AjaxFrameworkAssembly) &&
|
||||
(resourceAssembly != AssemblyCache.SystemWebExtensions) &&
|
||||
AssemblyCache.IsAjaxFrameworkAssembly(resourceAssembly)) {
|
||||
// if it is coming from an assembly that is not the current ajax script assembly, make sure the assembly
|
||||
// is not meant to be an ajax script assembly.
|
||||
// it isnt an AjaxFrameworkScript but it might be from an assembly that is meant to
|
||||
// be an ajax script assembly, in which case we should throw an error.
|
||||
throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture,
|
||||
AtlasWeb.ScriptReference_ResourceRequiresAjaxAssembly, resourceName, resourceAssembly));
|
||||
}
|
||||
if (!hasScriptPath) {
|
||||
// The resource requested in the composite url will only contain the assembly name if it
|
||||
// will ultimately come from the assembly -- if ScriptPath is set, it doesn't.
|
||||
// We do still need to know the resource assembly in that case though, hence the separate
|
||||
// assembly variables.
|
||||
cacheAssembly = resourceAssembly;
|
||||
}
|
||||
}
|
||||
|
||||
CultureInfo culture = reference.DetermineCulture(scriptManager);
|
||||
if ((resourceList == null) || (resourceList.Item1 != cacheAssembly)) {
|
||||
resourceList = new Tuple<Assembly, List<Tuple<string, CultureInfo>>>(
|
||||
cacheAssembly, new List<Tuple<string, CultureInfo>>());
|
||||
resources.Add(resourceList);
|
||||
}
|
||||
if (hasPath || hasScriptPath) {
|
||||
if (hasPath) {
|
||||
if (String.IsNullOrEmpty(reference.Path)) {
|
||||
// the Path is coming from a script mapping, so its debug path applies
|
||||
resourceName = reference.GetPath(scriptManager, reference.EffectivePath, reference.ScriptInfo.DebugPath,
|
||||
isDebuggingEnabledForReference);
|
||||
}
|
||||
else {
|
||||
// path explicitly set, even if a mapping has a DebugPath it does not apply
|
||||
resourceName = reference.GetPath(scriptManager, reference.Path, null,
|
||||
isDebuggingEnabledForReference);
|
||||
}
|
||||
}
|
||||
else {
|
||||
#pragma warning disable 618
|
||||
// ScriptPath is obsolete but still functional
|
||||
resourceName = ScriptReference.GetScriptPath(resourceName, resourceAssembly,
|
||||
culture, scriptManager.ScriptPath);
|
||||
#pragma warning restore 618
|
||||
}
|
||||
|
||||
// ResolveClientUrl not appropriate here because the handler that will serve the response is not
|
||||
// in the same directory as the page that is generating the url. Instead, an absolute url is needed
|
||||
// as with ResolveUrl(). However, ResolveUrl() would prepend the entire application root name. For
|
||||
// example, ~/foo.js would be /TheApplicationRoot/foo.js. If there are many path based scripts the
|
||||
// app root would be repeated many times, which for deep apps or long named apps could cause the url
|
||||
// to reach the maximum 2048 characters very quickly. So, the path is combined with the control's
|
||||
// AppRelativeTemplateSourceDirectory manually, so that ~/foo.js remains ~/foo.js, and foo/bar.js
|
||||
// becomes ~/templatesource/foo/bar.js. Absolute paths can remain as is. The ScriptResourceHandler will
|
||||
// resolve the ~/ with the app root using VirtualPathUtility.ToAbsolute().
|
||||
if (UrlPath.IsRelativeUrl(resourceName) && !UrlPath.IsAppRelativePath(resourceName)) {
|
||||
resourceName = UrlPath.Combine(ClientUrlResolver.AppRelativeTemplateSourceDirectory, resourceName);
|
||||
}
|
||||
}
|
||||
resourceList.Item2.Add(new Tuple<string, CultureInfo>(resourceName, culture));
|
||||
}
|
||||
return ScriptResourceHandler.GetScriptResourceUrl(resources, zip);
|
||||
}
|
||||
|
||||
[Obsolete("Use IsAjaxFrameworkScript(ScriptManager)")]
|
||||
protected internal override bool IsFromSystemWebExtensions() {
|
||||
foreach (ScriptReference script in Scripts) {
|
||||
if (script.EffectiveAssembly == AssemblyCache.SystemWebExtensions) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected internal override bool IsAjaxFrameworkScript(ScriptManager scriptManager) {
|
||||
foreach (ScriptReference script in Scripts) {
|
||||
if (script.IsAjaxFrameworkScript(scriptManager)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ScriptReferenceEventArgs.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Web;
|
||||
|
||||
public class CompositeScriptReferenceEventArgs : EventArgs {
|
||||
private readonly CompositeScriptReference _compositeScript;
|
||||
|
||||
public CompositeScriptReferenceEventArgs(CompositeScriptReference compositeScript) {
|
||||
if (compositeScript == null) {
|
||||
throw new ArgumentNullException("compositeScript");
|
||||
}
|
||||
_compositeScript = compositeScript;
|
||||
}
|
||||
|
||||
public CompositeScriptReference CompositeScript {
|
||||
get {
|
||||
return _compositeScript;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ControlUtil.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web.Resources;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace System.Web.UI {
|
||||
internal class ControlUtil {
|
||||
internal static Control FindTargetControl(string controlID, Control control, bool searchNamingContainers) {
|
||||
Control foundControl;
|
||||
if (searchNamingContainers) {
|
||||
Control currentContainer;
|
||||
foundControl = null;
|
||||
|
||||
// DevDiv 73305: Do not assume starting control is not a naming container.
|
||||
if (control is INamingContainer) {
|
||||
currentContainer = control;
|
||||
}
|
||||
else {
|
||||
currentContainer = control.NamingContainer;
|
||||
}
|
||||
|
||||
do {
|
||||
foundControl = currentContainer.FindControl(controlID);
|
||||
currentContainer = currentContainer.NamingContainer;
|
||||
}
|
||||
while (foundControl == null && currentContainer != null);
|
||||
}
|
||||
else {
|
||||
foundControl = control.FindControl(controlID);
|
||||
}
|
||||
|
||||
return foundControl;
|
||||
}
|
||||
|
||||
internal static bool IsBuiltInHiddenField(string hiddenFieldName) {
|
||||
// Returns true is the field name represents a hidden field generated
|
||||
// by ASP.NET's core runtime. This includes fields such as ViewState and
|
||||
// EventValidation, but not ones generated by specific controls such as
|
||||
// TreeView and WebParts.
|
||||
|
||||
// If the field is less than two chars long it's not built-in. (Perf)
|
||||
if (hiddenFieldName.Length <= 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If it doesn't start with two underscores, it's not built-in. (Perf)
|
||||
if (hiddenFieldName[0] != '_' ||
|
||||
hiddenFieldName[1] != '_') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Examine list of built-in ASP.NET fields. The list was created by examining
|
||||
// the ASP.NET source code for hidden field registration and rendering.
|
||||
// We exclude __VIEWSTATEENCRYPTED and __VIEWSTATEFIELDCOUNT from the list
|
||||
// since they're covered by the general __VIEWSTATE part.
|
||||
return
|
||||
hiddenFieldName.StartsWith("__VIEWSTATE", StringComparison.Ordinal) ||
|
||||
String.Equals(hiddenFieldName, "__EVENTVALIDATION", StringComparison.Ordinal) ||
|
||||
String.Equals(hiddenFieldName, "__LASTFOCUS", StringComparison.Ordinal) ||
|
||||
String.Equals(hiddenFieldName, "__SCROLLPOSITIONX", StringComparison.Ordinal) ||
|
||||
String.Equals(hiddenFieldName, "__SCROLLPOSITIONY", StringComparison.Ordinal) ||
|
||||
String.Equals(hiddenFieldName, "__EVENTTARGET", StringComparison.Ordinal) ||
|
||||
String.Equals(hiddenFieldName, "__EVENTARGUMENT", StringComparison.Ordinal) ||
|
||||
String.Equals(hiddenFieldName, "__PREVIOUSPAGE", StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="CustomErrorsSectionWrapper.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Web.Configuration;
|
||||
|
||||
internal sealed class CustomErrorsSectionWrapper : ICustomErrorsSection {
|
||||
private readonly CustomErrorsSection _customErrorsSection;
|
||||
|
||||
public CustomErrorsSectionWrapper(CustomErrorsSection customErrorsSection) {
|
||||
Debug.Assert(customErrorsSection != null);
|
||||
_customErrorsSection = customErrorsSection;
|
||||
}
|
||||
|
||||
#region ICustomErrorsSection Members
|
||||
string ICustomErrorsSection.DefaultRedirect {
|
||||
get {
|
||||
return _customErrorsSection.DefaultRedirect;
|
||||
}
|
||||
}
|
||||
|
||||
CustomErrorCollection ICustomErrorsSection.Errors {
|
||||
get {
|
||||
return _customErrorsSection.Errors;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="DeploymentSectionCache.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Web.Configuration;
|
||||
|
||||
// DeploymentSection can only be defined in machine.config, so it is safe to cache statically in the application
|
||||
internal sealed class DeploymentSectionCache : IDeploymentSection {
|
||||
private static readonly DeploymentSectionCache _instance = new DeploymentSectionCache();
|
||||
// Value is cached statically, because DeploymentSectionCache is a Singleton.
|
||||
private bool? _retail;
|
||||
|
||||
private DeploymentSectionCache() {
|
||||
}
|
||||
|
||||
public static DeploymentSectionCache Instance {
|
||||
get {
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Retail {
|
||||
get {
|
||||
if (_retail == null) {
|
||||
_retail = GetRetailFromConfig();
|
||||
}
|
||||
return _retail.Value;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
ConfigurationPermission(SecurityAction.Assert, Unrestricted = true),
|
||||
SecuritySafeCritical()
|
||||
]
|
||||
private static bool GetRetailFromConfig() {
|
||||
DeploymentSection section = (DeploymentSection)WebConfigurationManager.GetSection("system.web/deployment");
|
||||
return section.Retail;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EmbeddedResourceFinder.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// This internal only class exists to work around a bug in
|
||||
// ToolboxBitmap.GetImageFromResource method which doesn't
|
||||
// work properly is the assembly name is different from
|
||||
// the namespace. The work around is to use a type which is
|
||||
// outside the root namespace.
|
||||
internal class EmbeddedResourceFinder { }
|
@@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="EmptyStringExpandableObjectConverter.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
// Used by objects that are subproperties of Controls. Improves the UI in the property grid by displaying
|
||||
// nothing as the property value, instead of the fully qualified type name.
|
||||
internal sealed class EmptyStringExpandableObjectConverter : ExpandableObjectConverter {
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value,
|
||||
Type destinationType) {
|
||||
if (destinationType == typeof(string)) {
|
||||
return String.Empty;
|
||||
}
|
||||
else {
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,172 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ExtenderControl.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.Resources;
|
||||
using System.Web.Util;
|
||||
|
||||
[
|
||||
DefaultProperty("TargetControlID"),
|
||||
Designer("System.Web.UI.Design.ExtenderControlDesigner, " + AssemblyRef.SystemWebExtensionsDesign),
|
||||
NonVisualControl(),
|
||||
ParseChildren(true),
|
||||
PersistChildren(false),
|
||||
ToolboxItem("System.Web.UI.Design.ExtenderControlToolboxItem, " + AssemblyRef.SystemWebExtensionsDesign),
|
||||
]
|
||||
public abstract class ExtenderControl : Control, IExtenderControl {
|
||||
private string _targetControlID;
|
||||
private IScriptManagerInternal _scriptManager;
|
||||
private new IPage _page;
|
||||
|
||||
protected ExtenderControl() {
|
||||
}
|
||||
|
||||
internal ExtenderControl(IScriptManagerInternal scriptManager, IPage page) {
|
||||
_scriptManager = scriptManager;
|
||||
_page = page;
|
||||
}
|
||||
|
||||
private IPage IPage {
|
||||
get {
|
||||
if (_page != null) {
|
||||
return _page;
|
||||
}
|
||||
else {
|
||||
Page page = Page;
|
||||
if (page == null) {
|
||||
throw new InvalidOperationException(AtlasWeb.Common_PageCannotBeNull);
|
||||
}
|
||||
return new PageWrapper(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IScriptManagerInternal ScriptManager {
|
||||
get {
|
||||
if (_scriptManager == null) {
|
||||
Page page = Page;
|
||||
if (page == null) {
|
||||
throw new InvalidOperationException(AtlasWeb.Common_PageCannotBeNull);
|
||||
}
|
||||
_scriptManager = System.Web.UI.ScriptManager.GetCurrent(page);
|
||||
if (_scriptManager == null) {
|
||||
throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture,
|
||||
AtlasWeb.Common_ScriptManagerRequired, ID));
|
||||
}
|
||||
}
|
||||
return _scriptManager;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
Category("Behavior"),
|
||||
DefaultValue(""),
|
||||
IDReferenceProperty,
|
||||
ResourceDescription("ExtenderControl_TargetControlID"),
|
||||
SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID"),
|
||||
]
|
||||
public string TargetControlID {
|
||||
get {
|
||||
return (_targetControlID == null) ? String.Empty : _targetControlID;
|
||||
}
|
||||
set {
|
||||
_targetControlID = value;
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
Browsable(false),
|
||||
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
|
||||
EditorBrowsable(EditorBrowsableState.Never)
|
||||
]
|
||||
public override bool Visible {
|
||||
get {
|
||||
return base.Visible;
|
||||
}
|
||||
set {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the closest UpdatePanel in the parent controls of the specified control.
|
||||
/// </summary>
|
||||
/// <param name="control">The control for which we want the closest UpdatePanel.</param>
|
||||
/// <returns>An UpdatePanel or null if none was found.</returns>
|
||||
private static UpdatePanel FindUpdatePanel(Control control) {
|
||||
Control parent = control.Parent;
|
||||
while (parent != null) {
|
||||
UpdatePanel parentPanel = parent as UpdatePanel;
|
||||
if (parentPanel != null) {
|
||||
return parentPanel;
|
||||
}
|
||||
parent = parent.Parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")]
|
||||
protected internal override void OnPreRender(EventArgs e) {
|
||||
base.OnPreRender(e);
|
||||
RegisterWithScriptManager();
|
||||
}
|
||||
|
||||
private void RegisterWithScriptManager() {
|
||||
if (String.IsNullOrEmpty(TargetControlID)) {
|
||||
throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture,
|
||||
AtlasWeb.ExtenderControl_TargetControlIDEmpty, ID));
|
||||
}
|
||||
|
||||
Control targetControl = FindControl(TargetControlID);
|
||||
if (targetControl == null) {
|
||||
throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture,
|
||||
AtlasWeb.ExtenderControl_TargetControlIDInvalid, ID, TargetControlID));
|
||||
}
|
||||
|
||||
// Check if the target control and its extender are in the same UpdatePanel if any:
|
||||
if (FindUpdatePanel(this) != FindUpdatePanel(targetControl)) {
|
||||
throw new InvalidOperationException(AtlasWeb.ExtenderControl_TargetControlDifferentUpdatePanel);
|
||||
}
|
||||
|
||||
ScriptManager.RegisterExtenderControl(this, targetControl);
|
||||
}
|
||||
|
||||
protected internal override void Render(HtmlTextWriter writer) {
|
||||
base.Render(writer);
|
||||
|
||||
// DevDiv 97460: ScriptDescriptors only render if in server form, verify to avoid silently failing.
|
||||
IPage.VerifyRenderingInServerForm(this);
|
||||
|
||||
// ScriptManager cannot be found in DesignMode, so do not attempt to register scripts.
|
||||
if (!DesignMode) {
|
||||
ScriptManager.RegisterScriptDescriptors(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract IEnumerable<ScriptDescriptor> GetScriptDescriptors(Control targetControl);
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
|
||||
Justification = "Implementation will likely return a new collection, which is too slow for a property")]
|
||||
protected abstract IEnumerable<ScriptReference> GetScriptReferences();
|
||||
|
||||
#region IExtenderControl Members
|
||||
IEnumerable<ScriptDescriptor> IExtenderControl.GetScriptDescriptors(Control targetControl) {
|
||||
return GetScriptDescriptors(targetControl);
|
||||
}
|
||||
|
||||
IEnumerable<ScriptReference> IExtenderControl.GetScriptReferences() {
|
||||
return GetScriptReferences();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
namespace System.Web.UI {
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
public class HistoryEventArgs : EventArgs {
|
||||
private NameValueCollection _state;
|
||||
|
||||
public HistoryEventArgs(NameValueCollection state) {
|
||||
_state = state;
|
||||
}
|
||||
|
||||
public NameValueCollection State {
|
||||
get { return _state; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="HtmlFormWrapper.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.HtmlControls;
|
||||
|
||||
namespace System.Web.UI {
|
||||
internal sealed class HtmlFormWrapper : IHtmlForm {
|
||||
private HtmlForm _form;
|
||||
|
||||
public HtmlFormWrapper(HtmlForm form) {
|
||||
Debug.Assert(form != null);
|
||||
_form = form;
|
||||
}
|
||||
|
||||
#region IHtmlForm Members
|
||||
string IHtmlForm.ClientID {
|
||||
get {
|
||||
return _form.ClientID;
|
||||
}
|
||||
}
|
||||
|
||||
string IHtmlForm.Method {
|
||||
get {
|
||||
return _form.Method;
|
||||
}
|
||||
}
|
||||
|
||||
void IHtmlForm.RenderControl(HtmlTextWriter writer) {
|
||||
_form.RenderControl(writer);
|
||||
}
|
||||
|
||||
void IHtmlForm.SetRenderMethodDelegate(RenderMethod renderMethod) {
|
||||
_form.SetRenderMethodDelegate(renderMethod);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user