Files
acceptance-tests
data
docs
external
ikvm-native
libgc
llvm
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.NuGet.Build.Tasks
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.Btls.Interface
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Profiler.Log
Mono.Runtime.Tests
Mono.Security
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
SMDiagnostics
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Deployment
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Net.Http.WinHttpHandler
System.Numerics
System.Numerics.Vectors
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Reflection.Context
System.Runtime.Caching
System.Runtime.CompilerServices.Unsafe
System.Runtime.DurableInstancing
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mobile
System.Web.Mvc3
System.Web.Razor
System.Web.RegularExpressions
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms
System.Windows.Forms.DataVisualization
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
dlr
doc
legacy
lib
monodoc
notes
reference-assemblies
referencesource
SMDiagnostics
System
System.Activities
System.Activities.Core.Presentation
System.Activities.DurableInstancing
System.Activities.Presentation
System.ComponentModel.DataAnnotations
System.Configuration
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Entity.Design
System.Data.Linq
System.Data.SqlXml
System.IdentityModel
System.IdentityModel.Selectors
System.Net
System.Numerics
System.Runtime.Caching
System.Runtime.DurableInstancing
System.Runtime.Serialization
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Activities
System.ServiceModel.Channels
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.WasHosting
System.ServiceModel.Web
System.Web
System.Web.ApplicationServices
System.Web.DataVisualization
System.Web.DynamicData
System.Web.Entity
System.Web.Entity.Design
System.Web.Extensions
ApplicationServices
ClientServices
Compilation
Configuration
DynamicData
Globalization
Handlers
Management
Profile
Properties
Resources
Script
Security
Util
ui
WebControls
AjaxFrameworkMode.cs
AppLevelCompilationSectionCache.cs
ApplicationServiceManager.cs
AssemblyCache.cs
AsyncPostBackErrorEventArgs.cs
AsyncPostBackTrigger.cs
AuthenticationServiceManager.cs
BundleReflectionHelper.cs
ClientScriptManagerWrapper.cs
ClientUrlResolverWrapper.cs
CompositeScriptReference.cs
CompositeScriptReferenceEventArgs.cs
ControlUtil.cs
CustomErrorsSectionWrapper.cs
DeploymentSectionCache.cs
EmbeddedResourceFinder.cs
EmptyStringExpandableObjectConverter.cs
ExtenderControl.cs
HistoryEventArgs.cs
HtmlFormWrapper.cs
IClientScriptManager.cs
IClientUrlResolver.cs
ICompilationSection.cs
IControl.cs
ICustomErrorsSection.cs
IDeploymentSection.cs
IExtenderControl.cs
IHtmlForm.cs
IPage.cs
IScriptControl.cs
IScriptManagerInternal.cs
PageRequestManager.cs
PageWrapper.cs
PostBackTrigger.cs
ProfileServiceManager.cs
RegisteredArrayDeclaration.cs
RegisteredDisposeScript.cs
RegisteredExpandoAttribute.cs
RegisteredHiddenField.cs
RegisteredScript.cs
RegisteredScriptType.cs
ResourceCategoryAttribute.cs
ResourceDefaultValueAttribute.cs
ResourceDescriptionAttribute.cs
ResourceDisplayNameAttribute.cs
RoleServiceManager.cs
ScriptBehaviorDescriptor.cs
ScriptComponentDescriptor.cs
ScriptControl.cs
ScriptControlDescriptor.cs
ScriptControlManager.cs
ScriptDescriptor.cs
ScriptManager.cs.REMOVED.git-id
ScriptManagerProxy.cs
ScriptMode.cs
ScriptReference.cs
ScriptReferenceBase.cs
ScriptReferenceCollection.cs
ScriptReferenceEventArgs.cs
ScriptRegistrationManager.cs
ScriptResourceAttribute.cs
ScriptResourceDefinition.cs
ScriptResourceInfo.cs
ScriptResourceMapping.cs
ServiceReference.cs
ServiceReferenceCollection.cs
TargetControlTypeAttribute.cs
TargetControlTypeCache.cs
Timer.cs
UpdatePanel.cs
UpdatePanelControlTrigger.cs
UpdatePanelRenderMode.cs
UpdatePanelTrigger.cs
UpdatePanelTriggerCollection.cs
UpdatePanelUpdateMode.cs
UpdateProgress.cs
WebResourceUtil.cs
HttpResponseInternalBase.cs
HttpResponseInternalWrapper.cs
System.Web.Mobile
System.Web.Routing
System.Web.Services
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.WorkflowServices
System.Xaml.Hosting
System.Xml
System.Xml.Linq
XamlBuildTask
mscorlib
LICENSE.txt
PATENTS.TXT
README.Mono.md
README.md
test-helpers
LICENSE
Makefile
Open.snk
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
nunit24
packages
tests
tools
AUTHORS
COPYING
INSTALL.txt
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/mcs/class/referencesource/System.Web.Extensions/ui/CompositeScriptReference.cs

193 lines
10 KiB
C#
Raw Normal View History

//------------------------------------------------------------------------------
// <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;
}
}
}