Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / ScriptResourceMapping.cs / 1305376 / ScriptResourceMapping.cs
namespace System.Web.UI { using System; using System.Collections.Concurrent; using System.Globalization; using System.Reflection; using System.Web.Resources; using System.Web.Util; public class ScriptResourceMapping : IScriptResourceMapping { private ConcurrentDictionary, ScriptResourceDefinition> _definitions = new ConcurrentDictionary , ScriptResourceDefinition>(); public void AddDefinition(string name, ScriptResourceDefinition definition) { AddDefinition(name, null, definition); } public void AddDefinition(string name, Assembly assembly, ScriptResourceDefinition definition) { // dictionary indexer will update the value if it already exists if (String.IsNullOrEmpty(name)) { throw new ArgumentException(AtlasWeb.Common_NullOrEmpty, "name"); } if (definition == null) { throw new ArgumentNullException("definition"); } if (String.IsNullOrEmpty(definition.ResourceName) && String.IsNullOrEmpty(definition.Path)) { throw new ArgumentException(AtlasWeb.ScriptResourceDefinition_NameAndPathCannotBeEmpty, "definition"); } EnsureAbsoluteOrAppRelative(definition.Path); EnsureAbsoluteOrAppRelative(definition.DebugPath); EnsureAbsoluteOrAppRelative(definition.CdnPath); EnsureAbsoluteOrAppRelative(definition.CdnDebugPath); _definitions[new Tuple (name, assembly)] = definition; } public void Clear() { _definitions.Clear(); } private void EnsureAbsoluteOrAppRelative(string path) { if (!String.IsNullOrEmpty(path) && !UrlPath.IsAppRelativePath(path) && // ~/foo.. !UrlPath.IsRooted(path) && // /foo !Uri.IsWellFormedUriString(path, UriKind.Absolute)) { // http://... throw new InvalidOperationException( String.Format(CultureInfo.InvariantCulture, AtlasWeb.ScriptResourceDefinition_InvalidPath, path)); } } public ScriptResourceDefinition GetDefinition(string name, Assembly assembly) { if (String.IsNullOrEmpty(name)) { throw new ArgumentException(AtlasWeb.Common_NullOrEmpty, "name"); } ScriptResourceDefinition definition; _definitions.TryGetValue(new Tuple (name, assembly), out definition); return definition; } public ScriptResourceDefinition GetDefinition(ScriptReference scriptReference) { if (scriptReference == null) { throw new ArgumentNullException("scriptReference"); } string name = scriptReference.Name; Assembly assembly = null; ScriptResourceDefinition definition = null; if (!String.IsNullOrEmpty(name)) { assembly = scriptReference.GetAssembly(); if ((assembly != null) && AssemblyCache.IsAjaxFrameworkAssembly(assembly)) { assembly = null; } definition = ScriptManager.ScriptResourceMapping.GetDefinition(name, assembly); } return definition; } public ScriptResourceDefinition RemoveDefinition(string name, Assembly assembly) { if (String.IsNullOrEmpty(name)) { throw new ArgumentException(AtlasWeb.Common_NullOrEmpty, "name"); } ScriptResourceDefinition definition; _definitions.TryRemove(new Tuple (name, assembly), out definition); return definition; } #region IScriptResourceMapping Members IScriptResourceDefinition IScriptResourceMapping.GetDefinition(string name, Assembly assembly) { return GetDefinition(name, assembly); } #endregion } } // 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.Concurrent; using System.Globalization; using System.Reflection; using System.Web.Resources; using System.Web.Util; public class ScriptResourceMapping : IScriptResourceMapping { private ConcurrentDictionary , ScriptResourceDefinition> _definitions = new ConcurrentDictionary , ScriptResourceDefinition>(); public void AddDefinition(string name, ScriptResourceDefinition definition) { AddDefinition(name, null, definition); } public void AddDefinition(string name, Assembly assembly, ScriptResourceDefinition definition) { // dictionary indexer will update the value if it already exists if (String.IsNullOrEmpty(name)) { throw new ArgumentException(AtlasWeb.Common_NullOrEmpty, "name"); } if (definition == null) { throw new ArgumentNullException("definition"); } if (String.IsNullOrEmpty(definition.ResourceName) && String.IsNullOrEmpty(definition.Path)) { throw new ArgumentException(AtlasWeb.ScriptResourceDefinition_NameAndPathCannotBeEmpty, "definition"); } EnsureAbsoluteOrAppRelative(definition.Path); EnsureAbsoluteOrAppRelative(definition.DebugPath); EnsureAbsoluteOrAppRelative(definition.CdnPath); EnsureAbsoluteOrAppRelative(definition.CdnDebugPath); _definitions[new Tuple (name, assembly)] = definition; } public void Clear() { _definitions.Clear(); } private void EnsureAbsoluteOrAppRelative(string path) { if (!String.IsNullOrEmpty(path) && !UrlPath.IsAppRelativePath(path) && // ~/foo.. !UrlPath.IsRooted(path) && // /foo !Uri.IsWellFormedUriString(path, UriKind.Absolute)) { // http://... throw new InvalidOperationException( String.Format(CultureInfo.InvariantCulture, AtlasWeb.ScriptResourceDefinition_InvalidPath, path)); } } public ScriptResourceDefinition GetDefinition(string name, Assembly assembly) { if (String.IsNullOrEmpty(name)) { throw new ArgumentException(AtlasWeb.Common_NullOrEmpty, "name"); } ScriptResourceDefinition definition; _definitions.TryGetValue(new Tuple (name, assembly), out definition); return definition; } public ScriptResourceDefinition GetDefinition(ScriptReference scriptReference) { if (scriptReference == null) { throw new ArgumentNullException("scriptReference"); } string name = scriptReference.Name; Assembly assembly = null; ScriptResourceDefinition definition = null; if (!String.IsNullOrEmpty(name)) { assembly = scriptReference.GetAssembly(); if ((assembly != null) && AssemblyCache.IsAjaxFrameworkAssembly(assembly)) { assembly = null; } definition = ScriptManager.ScriptResourceMapping.GetDefinition(name, assembly); } return definition; } public ScriptResourceDefinition RemoveDefinition(string name, Assembly assembly) { if (String.IsNullOrEmpty(name)) { throw new ArgumentException(AtlasWeb.Common_NullOrEmpty, "name"); } ScriptResourceDefinition definition; _definitions.TryRemove(new Tuple (name, assembly), out definition); return definition; } #region IScriptResourceMapping Members IScriptResourceDefinition IScriptResourceMapping.GetDefinition(string name, Assembly assembly) { return GetDefinition(name, assembly); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- KeySpline.cs
- WindowsServiceElement.cs
- DecoderBestFitFallback.cs
- CheckedPointers.cs
- ValueType.cs
- StatusStrip.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- EntityClientCacheKey.cs
- PostBackOptions.cs
- CustomValidator.cs
- MasterPageBuildProvider.cs
- StorageConditionPropertyMapping.cs
- FeedUtils.cs
- HtmlControl.cs
- FormClosingEvent.cs
- serverconfig.cs
- WebBrowserHelper.cs
- MediaElementAutomationPeer.cs
- TabControlEvent.cs
- TextDecoration.cs
- DesignerEventService.cs
- GroupItemAutomationPeer.cs
- PriorityItem.cs
- ConfigurationLocation.cs
- TextServicesCompartmentContext.cs
- LogicalChannel.cs
- SamlAssertion.cs
- PEFileEvidenceFactory.cs
- DataGridViewSelectedRowCollection.cs
- CacheMode.cs
- SlipBehavior.cs
- InputQueueChannel.cs
- ThreadStateException.cs
- _ContextAwareResult.cs
- SystemIPAddressInformation.cs
- ProcessStartInfo.cs
- InkCanvasInnerCanvas.cs
- ConnectionPointCookie.cs
- QuadraticBezierSegment.cs
- PropertyPathWorker.cs
- LinkedList.cs
- newinstructionaction.cs
- DataGridViewTextBoxEditingControl.cs
- RegexStringValidatorAttribute.cs
- DynamicMetaObjectBinder.cs
- WebPartCollection.cs
- DiscreteKeyFrames.cs
- StyleModeStack.cs
- MethodSet.cs
- PolicyStatement.cs
- RootProfilePropertySettingsCollection.cs
- ContractInstanceProvider.cs
- Script.cs
- ProxyWebPart.cs
- oledbmetadatacollectionnames.cs
- StreamAsIStream.cs
- TextElementEditingBehaviorAttribute.cs
- DataBindEngine.cs
- FormViewDeletedEventArgs.cs
- TextFindEngine.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- DynamicRenderer.cs
- FontFamilyValueSerializer.cs
- StorageFunctionMapping.cs
- HtmlInputImage.cs
- WebBaseEventKeyComparer.cs
- ConfigXmlComment.cs
- CommandID.cs
- ListControl.cs
- RichTextBox.cs
- XPathNodeHelper.cs
- EndEvent.cs
- CustomErrorsSectionWrapper.cs
- DiscoveryReference.cs
- ObjectListShowCommandsEventArgs.cs
- CollaborationHelperFunctions.cs
- OrderedDictionary.cs
- Number.cs
- SrgsGrammarCompiler.cs
- SizeAnimationClockResource.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- MeshGeometry3D.cs
- _UriSyntax.cs
- EdmProperty.cs
- TimerExtension.cs
- KnownBoxes.cs
- TabItemAutomationPeer.cs
- SoapElementAttribute.cs
- DictionaryKeyPropertyAttribute.cs
- AppDomainGrammarProxy.cs
- GridViewUpdateEventArgs.cs
- PageStatePersister.cs
- BaseCAMarshaler.cs
- BrowserCapabilitiesFactoryBase.cs
- HandlerBase.cs
- WebBrowserNavigatedEventHandler.cs
- XmlValueConverter.cs
- RightsManagementResourceHelper.cs
- recordstate.cs
- BCryptHashAlgorithm.cs