Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / ScriptResourceInfo.cs / 1305376 / ScriptResourceInfo.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Web.Handlers; using System.Web.Resources; using System.Web.Util; internal class ScriptResourceInfo { private string _contentType; private bool _performSubstitution; private string _scriptName; private string _scriptResourceName; private string _typeName; private bool _isDebug; private string _cdnPath; private string _cdnPathSecureConnection; private static readonly IDictionary _scriptCache = Hashtable.Synchronized(new Hashtable()); private static readonly IDictionary _duplicateScriptAttributesChecked = Hashtable.Synchronized(new Hashtable()); public static readonly ScriptResourceInfo Empty = new ScriptResourceInfo(); private ScriptResourceInfo() { } public ScriptResourceInfo(WebResourceAttribute wra, ScriptResourceAttribute sra, Assembly assembly) : this() { _scriptName = wra.WebResource; _cdnPath = wra.CdnPath; _contentType = wra.ContentType; _performSubstitution = wra.PerformSubstitution; _isDebug = !String.IsNullOrEmpty(_scriptName) && _scriptName.EndsWith(".debug.js", StringComparison.OrdinalIgnoreCase); if (sra != null) { _scriptResourceName = sra.StringResourceName; _typeName = sra.StringResourceClientTypeName; } if (!String.IsNullOrEmpty(_cdnPath)) { _cdnPath = AssemblyResourceLoader.FormatCdnUrl(assembly, _cdnPath); _cdnPathSecureConnection = AssemblyResourceLoader.FormatCdnUrl(assembly, wra.CdnPathSecureConnection); } } public string CdnPath { get { return _cdnPath; } } public string CdnPathSecureConnection { get { return _cdnPathSecureConnection; } } public string ContentType { get { return _contentType; } } public bool IsDebug { get { return _isDebug; } } public bool PerformSubstitution { get { return _performSubstitution; } } public string ScriptName { get { return _scriptName; } } public string ScriptResourceName { get { return _scriptResourceName; } } public string TypeName { get { return _typeName; } } public static ScriptResourceInfo GetInstance(Assembly assembly, string resourceName) { // The first time this API is called, check for attributes that point to the same script if (!_duplicateScriptAttributesChecked.Contains(assembly)) { Dictionaryscripts = new Dictionary (); foreach (ScriptResourceAttribute attr in assembly.GetCustomAttributes(typeof(ScriptResourceAttribute), false)) { string scriptName = attr.ScriptName; if (scripts.ContainsKey(scriptName)) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, AtlasWeb.ScriptResourceHandler_DuplicateScriptResources, scriptName, assembly.GetName())); } scripts.Add(scriptName, true); } _duplicateScriptAttributesChecked[assembly] = true; } Pair cacheKey = new Pair (assembly, resourceName); ScriptResourceInfo resourceInfo = (ScriptResourceInfo)_scriptCache[cacheKey]; if (resourceInfo == null) { WebResourceAttribute webResourceAttribute = null; ScriptResourceAttribute scriptResourceAttribute = null; // look for a WebResourceAttribute with that name object[] attrs = assembly.GetCustomAttributes(typeof(WebResourceAttribute), false); foreach (WebResourceAttribute wra in attrs) { if (String.Equals(wra.WebResource, resourceName, StringComparison.Ordinal)) { webResourceAttribute = wra; break; } } if (webResourceAttribute != null) { // look for a script resource attribute with that name attrs = assembly.GetCustomAttributes(typeof(ScriptResourceAttribute), false); foreach (ScriptResourceAttribute sra in attrs) { if (String.Equals(sra.ScriptName, resourceName, StringComparison.Ordinal)) { scriptResourceAttribute = sra; break; } } resourceInfo = new ScriptResourceInfo(webResourceAttribute, scriptResourceAttribute, assembly); } else { resourceInfo = ScriptResourceInfo.Empty; } // Cache the results so we don't have to do this again _scriptCache[cacheKey] = resourceInfo; } return resourceInfo; } } } // 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.Collections; using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Web.Handlers; using System.Web.Resources; using System.Web.Util; internal class ScriptResourceInfo { private string _contentType; private bool _performSubstitution; private string _scriptName; private string _scriptResourceName; private string _typeName; private bool _isDebug; private string _cdnPath; private string _cdnPathSecureConnection; private static readonly IDictionary _scriptCache = Hashtable.Synchronized(new Hashtable()); private static readonly IDictionary _duplicateScriptAttributesChecked = Hashtable.Synchronized(new Hashtable()); public static readonly ScriptResourceInfo Empty = new ScriptResourceInfo(); private ScriptResourceInfo() { } public ScriptResourceInfo(WebResourceAttribute wra, ScriptResourceAttribute sra, Assembly assembly) : this() { _scriptName = wra.WebResource; _cdnPath = wra.CdnPath; _contentType = wra.ContentType; _performSubstitution = wra.PerformSubstitution; _isDebug = !String.IsNullOrEmpty(_scriptName) && _scriptName.EndsWith(".debug.js", StringComparison.OrdinalIgnoreCase); if (sra != null) { _scriptResourceName = sra.StringResourceName; _typeName = sra.StringResourceClientTypeName; } if (!String.IsNullOrEmpty(_cdnPath)) { _cdnPath = AssemblyResourceLoader.FormatCdnUrl(assembly, _cdnPath); _cdnPathSecureConnection = AssemblyResourceLoader.FormatCdnUrl(assembly, wra.CdnPathSecureConnection); } } public string CdnPath { get { return _cdnPath; } } public string CdnPathSecureConnection { get { return _cdnPathSecureConnection; } } public string ContentType { get { return _contentType; } } public bool IsDebug { get { return _isDebug; } } public bool PerformSubstitution { get { return _performSubstitution; } } public string ScriptName { get { return _scriptName; } } public string ScriptResourceName { get { return _scriptResourceName; } } public string TypeName { get { return _typeName; } } public static ScriptResourceInfo GetInstance(Assembly assembly, string resourceName) { // The first time this API is called, check for attributes that point to the same script if (!_duplicateScriptAttributesChecked.Contains(assembly)) { Dictionaryscripts = new Dictionary (); foreach (ScriptResourceAttribute attr in assembly.GetCustomAttributes(typeof(ScriptResourceAttribute), false)) { string scriptName = attr.ScriptName; if (scripts.ContainsKey(scriptName)) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, AtlasWeb.ScriptResourceHandler_DuplicateScriptResources, scriptName, assembly.GetName())); } scripts.Add(scriptName, true); } _duplicateScriptAttributesChecked[assembly] = true; } Pair cacheKey = new Pair (assembly, resourceName); ScriptResourceInfo resourceInfo = (ScriptResourceInfo)_scriptCache[cacheKey]; if (resourceInfo == null) { WebResourceAttribute webResourceAttribute = null; ScriptResourceAttribute scriptResourceAttribute = null; // look for a WebResourceAttribute with that name object[] attrs = assembly.GetCustomAttributes(typeof(WebResourceAttribute), false); foreach (WebResourceAttribute wra in attrs) { if (String.Equals(wra.WebResource, resourceName, StringComparison.Ordinal)) { webResourceAttribute = wra; break; } } if (webResourceAttribute != null) { // look for a script resource attribute with that name attrs = assembly.GetCustomAttributes(typeof(ScriptResourceAttribute), false); foreach (ScriptResourceAttribute sra in attrs) { if (String.Equals(sra.ScriptName, resourceName, StringComparison.Ordinal)) { scriptResourceAttribute = sra; break; } } resourceInfo = new ScriptResourceInfo(webResourceAttribute, scriptResourceAttribute, assembly); } else { resourceInfo = ScriptResourceInfo.Empty; } // Cache the results so we don't have to do this again _scriptCache[cacheKey] = resourceInfo; } return resourceInfo; } } } // 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
- NamespaceEmitter.cs
- MembershipPasswordException.cs
- SegmentInfo.cs
- DesignerForm.cs
- TextServicesDisplayAttribute.cs
- PageHandlerFactory.cs
- ContainerUtilities.cs
- BindingOperations.cs
- SeparatorAutomationPeer.cs
- PathStreamGeometryContext.cs
- SqlDataSource.cs
- XPathNavigatorException.cs
- FillBehavior.cs
- IUnknownConstantAttribute.cs
- QueryInterceptorAttribute.cs
- MarginCollapsingState.cs
- UInt32.cs
- VisualTreeFlattener.cs
- TemplateBuilder.cs
- CounterCreationDataCollection.cs
- OrthographicCamera.cs
- NavigationFailedEventArgs.cs
- AppDomainInstanceProvider.cs
- WorkflowApplicationUnloadedException.cs
- DockPanel.cs
- HyperLinkField.cs
- PlanCompiler.cs
- Menu.cs
- ConversionContext.cs
- PageAsyncTaskManager.cs
- ProcessModelInfo.cs
- NavigationWindow.cs
- PenThread.cs
- TraceHwndHost.cs
- MultiBindingExpression.cs
- KeyMatchBuilder.cs
- WindowsAltTab.cs
- CircleHotSpot.cs
- MissingSatelliteAssemblyException.cs
- DictionarySectionHandler.cs
- DesignerDataColumn.cs
- MD5.cs
- PenThreadWorker.cs
- TextTreeInsertUndoUnit.cs
- wgx_exports.cs
- EventWaitHandle.cs
- WebErrorHandler.cs
- ImageMapEventArgs.cs
- TextEndOfLine.cs
- WebPartsPersonalization.cs
- connectionpool.cs
- DataContractSerializerSection.cs
- UIPermission.cs
- MultiTouchSystemGestureLogic.cs
- ResolveMatchesMessageCD1.cs
- DbMetaDataCollectionNames.cs
- BinHexEncoder.cs
- ContextMenuStrip.cs
- AbstractDataSvcMapFileLoader.cs
- HttpCacheVaryByContentEncodings.cs
- Style.cs
- _HeaderInfo.cs
- ComponentResourceKeyConverter.cs
- VariableElement.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- SchemaTableColumn.cs
- XmlNotation.cs
- ToolStripHighContrastRenderer.cs
- VirtualizedItemPattern.cs
- TimelineGroup.cs
- EpmSyndicationContentDeSerializer.cs
- ISAPIRuntime.cs
- FileDetails.cs
- BackStopAuthenticationModule.cs
- Label.cs
- DesignTimeXamlWriter.cs
- MsmqIntegrationChannelFactory.cs
- ScriptResourceAttribute.cs
- BufferedMessageData.cs
- OwnerDrawPropertyBag.cs
- PathData.cs
- ToolStripDropTargetManager.cs
- OpCopier.cs
- TransmissionStrategy.cs
- ToolboxDataAttribute.cs
- SafeLocalMemHandle.cs
- FileLevelControlBuilderAttribute.cs
- TagNameToTypeMapper.cs
- DoubleConverter.cs
- DataSetMappper.cs
- ServiceDescriptions.cs
- ListBindableAttribute.cs
- GC.cs
- MexHttpsBindingCollectionElement.cs
- XmlSerializableServices.cs
- DataGridCellInfo.cs
- SQLDecimalStorage.cs
- MethodBody.cs
- IsolatedStorageSecurityState.cs
- GatewayIPAddressInformationCollection.cs