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
- HierarchicalDataSourceIDConverter.cs
- AtlasWeb.Designer.cs
- DropDownButton.cs
- DesigntimeLicenseContext.cs
- CustomErrorsSectionWrapper.cs
- ToolCreatedEventArgs.cs
- DataFormats.cs
- SubpageParagraph.cs
- _NegotiateClient.cs
- CachedPathData.cs
- ContainerUtilities.cs
- XPathNode.cs
- SessionStateUtil.cs
- ModelItemCollection.cs
- EmptyEnumerator.cs
- DateTimeParse.cs
- StubHelpers.cs
- RoleManagerSection.cs
- DrawingBrush.cs
- BamlTreeUpdater.cs
- XPathAncestorIterator.cs
- SocketAddress.cs
- MappedMetaModel.cs
- SequentialUshortCollection.cs
- IdentityReference.cs
- ArraySortHelper.cs
- Stylus.cs
- InkSerializer.cs
- ISAPIApplicationHost.cs
- ApplicationInfo.cs
- HtmlInputPassword.cs
- ContentFileHelper.cs
- UntrustedRecipientException.cs
- DataBoundLiteralControl.cs
- ByteKeyFrameCollection.cs
- SmuggledIUnknown.cs
- Tuple.cs
- designeractionlistschangedeventargs.cs
- Decoder.cs
- HttpConfigurationSystem.cs
- ColorComboBox.cs
- FileLevelControlBuilderAttribute.cs
- Line.cs
- DataControlFieldCollection.cs
- webproxy.cs
- ToolStripContainer.cs
- TextProperties.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- ServiceContractListItemList.cs
- InstalledFontCollection.cs
- SqlUtil.cs
- SemanticValue.cs
- RightNameExpirationInfoPair.cs
- ScriptDescriptor.cs
- CryptoApi.cs
- hresults.cs
- XmlSchemaSubstitutionGroup.cs
- CacheChildrenQuery.cs
- XmlTextReaderImplHelpers.cs
- RijndaelManaged.cs
- XmlSerializerVersionAttribute.cs
- DBBindings.cs
- ConcurrentDictionary.cs
- InputMethod.cs
- DbConnectionStringBuilder.cs
- ComplexLine.cs
- HtmlElementCollection.cs
- Vector3dCollection.cs
- BitConverter.cs
- BrushValueSerializer.cs
- PagesChangedEventArgs.cs
- ContentPosition.cs
- DownloadProgressEventArgs.cs
- ClientSession.cs
- CodeEntryPointMethod.cs
- CurrencyWrapper.cs
- SmiEventStream.cs
- SourceItem.cs
- GradientPanel.cs
- SessionPageStateSection.cs
- AbandonedMutexException.cs
- MessageDescription.cs
- RangeExpression.cs
- ExpandCollapseProviderWrapper.cs
- Itemizer.cs
- ProcessModelInfo.cs
- ViewCellSlot.cs
- HostingEnvironmentException.cs
- MDIClient.cs
- ConfigurationValidatorBase.cs
- SyntaxCheck.cs
- DbConnectionPool.cs
- EnglishPluralizationService.cs
- PatternMatchRules.cs
- ToolStripPanelRow.cs
- ClientEventManager.cs
- UnmanagedMarshal.cs
- BaseDataList.cs
- InstanceOwnerQueryResult.cs
- wgx_render.cs