Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / xsp / System / Web / Extensions / ui / ScriptResourceInfo.cs / 3 / 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.Text; 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 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(ScriptResourceAttribute attr) : this() { _scriptName = attr.ScriptName; _scriptResourceName = attr.ScriptResourceName; _typeName = attr.TypeName; } public string ContentType { get { return _contentType; } set { _contentType = value; } } public bool IsDebug { get { return _isDebug; } set { _isDebug = value; } } public bool PerformSubstitution { get { return _performSubstitution; } set { _performSubstitution = value; } } public string ScriptName { get { return _scriptName; } set { _scriptName = value; } } 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) { resourceInfo = ScriptResourceInfo.Empty; object[] attrs = assembly.GetCustomAttributes(typeof(ScriptResourceAttribute), false); // First look for a script resource attribute with that name for (int i = 0; i < attrs.Length; i++) { ScriptResourceAttribute sra = (ScriptResourceAttribute)attrs[i]; if (String.Equals(sra.ScriptName, resourceName, StringComparison.Ordinal)) { resourceInfo = new ScriptResourceInfo(sra); break; } } // Look for a web resource with that name, to get additional info if any attrs = assembly.GetCustomAttributes(typeof(WebResourceAttribute), false); for (int i = 0; i < attrs.Length; i++) { WebResourceAttribute wra = (WebResourceAttribute)attrs[i]; if (String.Equals(wra.WebResource, resourceName, StringComparison.Ordinal)) { if (resourceInfo == ScriptResourceInfo.Empty) { resourceInfo = new ScriptResourceInfo(); resourceInfo.ScriptName = resourceName; } resourceInfo.ContentType = wra.ContentType; resourceInfo.PerformSubstitution = wra.PerformSubstitution; break; } } resourceInfo.IsDebug = resourceName.EndsWith(".debug.js", StringComparison.OrdinalIgnoreCase); // 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.Text; 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 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(ScriptResourceAttribute attr) : this() { _scriptName = attr.ScriptName; _scriptResourceName = attr.ScriptResourceName; _typeName = attr.TypeName; } public string ContentType { get { return _contentType; } set { _contentType = value; } } public bool IsDebug { get { return _isDebug; } set { _isDebug = value; } } public bool PerformSubstitution { get { return _performSubstitution; } set { _performSubstitution = value; } } public string ScriptName { get { return _scriptName; } set { _scriptName = value; } } 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) { resourceInfo = ScriptResourceInfo.Empty; object[] attrs = assembly.GetCustomAttributes(typeof(ScriptResourceAttribute), false); // First look for a script resource attribute with that name for (int i = 0; i < attrs.Length; i++) { ScriptResourceAttribute sra = (ScriptResourceAttribute)attrs[i]; if (String.Equals(sra.ScriptName, resourceName, StringComparison.Ordinal)) { resourceInfo = new ScriptResourceInfo(sra); break; } } // Look for a web resource with that name, to get additional info if any attrs = assembly.GetCustomAttributes(typeof(WebResourceAttribute), false); for (int i = 0; i < attrs.Length; i++) { WebResourceAttribute wra = (WebResourceAttribute)attrs[i]; if (String.Equals(wra.WebResource, resourceName, StringComparison.Ordinal)) { if (resourceInfo == ScriptResourceInfo.Empty) { resourceInfo = new ScriptResourceInfo(); resourceInfo.ScriptName = resourceName; } resourceInfo.ContentType = wra.ContentType; resourceInfo.PerformSubstitution = wra.PerformSubstitution; break; } } resourceInfo.IsDebug = resourceName.EndsWith(".debug.js", StringComparison.OrdinalIgnoreCase); // 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
- CodeAttributeDeclaration.cs
- ChannelBase.cs
- HierarchicalDataBoundControl.cs
- DataGridDetailsPresenter.cs
- ExceptionHandler.cs
- XmlSerializationWriter.cs
- PersonalizableAttribute.cs
- PerspectiveCamera.cs
- MappingMetadataHelper.cs
- CapabilitiesRule.cs
- SymbolUsageManager.cs
- ProcessModelSection.cs
- SmiEventStream.cs
- ArcSegment.cs
- _ProxyChain.cs
- DataKeyPropertyAttribute.cs
- ListItemCollection.cs
- TemplateField.cs
- UserMapPath.cs
- IsolatedStorageException.cs
- CodeExporter.cs
- EmbeddedMailObjectsCollection.cs
- DBSqlParserColumnCollection.cs
- DbMetaDataFactory.cs
- xsdvalidator.cs
- DocumentPageViewAutomationPeer.cs
- CodeIndexerExpression.cs
- HtmlWindow.cs
- FtpWebResponse.cs
- ToolBarTray.cs
- GC.cs
- ResourceDictionaryCollection.cs
- BamlMapTable.cs
- IdnElement.cs
- StatusBarItemAutomationPeer.cs
- NavigationFailedEventArgs.cs
- TypeDefinition.cs
- StringHandle.cs
- TimeSpan.cs
- FrugalMap.cs
- EmptyImpersonationContext.cs
- ScalarOps.cs
- BamlMapTable.cs
- Atom10FormatterFactory.cs
- SynchronizedDispatch.cs
- ReflectionTypeLoadException.cs
- HijriCalendar.cs
- COM2PictureConverter.cs
- Keywords.cs
- ViewStateModeByIdAttribute.cs
- SQLDecimalStorage.cs
- SQLDecimalStorage.cs
- RequiredFieldValidator.cs
- PageParserFilter.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- WindowsEditBoxRange.cs
- _DigestClient.cs
- IntSecurity.cs
- MSAANativeProvider.cs
- XmlValidatingReader.cs
- HttpProfileBase.cs
- HttpRequestTraceRecord.cs
- StandardCommands.cs
- AssociatedControlConverter.cs
- TemplateXamlParser.cs
- ManifestSignatureInformation.cs
- CompressionTransform.cs
- CalendarTable.cs
- Image.cs
- DirectoryRedirect.cs
- AsymmetricSignatureDeformatter.cs
- DataGridViewImageColumn.cs
- WinFormsUtils.cs
- AttributeData.cs
- MatcherBuilder.cs
- HScrollBar.cs
- UserControl.cs
- CodeTypeMember.cs
- XmlAttributeProperties.cs
- ElapsedEventArgs.cs
- BaseHashHelper.cs
- StringComparer.cs
- RuleProcessor.cs
- SemanticResultKey.cs
- TextStore.cs
- xmlglyphRunInfo.cs
- CompilerParameters.cs
- FieldAccessException.cs
- QueryPageSettingsEventArgs.cs
- ResourceDescriptionAttribute.cs
- ListChangedEventArgs.cs
- OdbcEnvironment.cs
- _NegoStream.cs
- DataGridColumnCollection.cs
- SchemaCollectionCompiler.cs
- MatrixTransform3D.cs
- Activator.cs
- CmsInterop.cs
- OracleConnectionString.cs
- StaticExtensionConverter.cs