Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XPathNodeHelper.cs
- QilBinary.cs
- FontConverter.cs
- CompilerGeneratedAttribute.cs
- CodeTypeMember.cs
- PageHandlerFactory.cs
- Fonts.cs
- BindableTemplateBuilder.cs
- SafeFileMappingHandle.cs
- DesignerSerializationOptionsAttribute.cs
- SimpleFieldTemplateFactory.cs
- DataGridViewTextBoxEditingControl.cs
- RelationshipSet.cs
- ImageSourceConverter.cs
- ManifestResourceInfo.cs
- ShapeTypeface.cs
- IntegerValidatorAttribute.cs
- MemberInitExpression.cs
- FrameAutomationPeer.cs
- CompilerHelpers.cs
- CursorConverter.cs
- ListDataBindEventArgs.cs
- MemberAccessException.cs
- StorageMappingFragment.cs
- StandardToolWindows.cs
- DesignTimeTemplateParser.cs
- EventDescriptor.cs
- PageAsyncTaskManager.cs
- Point3DAnimation.cs
- UITypeEditor.cs
- ChtmlPhoneCallAdapter.cs
- sqlcontext.cs
- ImageSourceConverter.cs
- PageThemeBuildProvider.cs
- BaseParagraph.cs
- ListViewItem.cs
- RepeatInfo.cs
- Overlapped.cs
- TextRunProperties.cs
- control.ime.cs
- brushes.cs
- DataExchangeServiceBinder.cs
- BuildDependencySet.cs
- SetStateDesigner.cs
- ListDictionary.cs
- NativeObjectSecurity.cs
- MsmqIntegrationElement.cs
- QilPatternVisitor.cs
- GPPOINT.cs
- EventPrivateKey.cs
- MDIControlStrip.cs
- ScaleTransform3D.cs
- SingleSelectRootGridEntry.cs
- BindingExpression.cs
- HtmlInputReset.cs
- CompiledIdentityConstraint.cs
- TailPinnedEventArgs.cs
- TextEditorSelection.cs
- BuildResult.cs
- Registry.cs
- ButtonBase.cs
- TextBoxBaseDesigner.cs
- PartialCachingAttribute.cs
- SiteMapDataSourceView.cs
- Comparer.cs
- FlowLayout.cs
- UriExt.cs
- DataChangedEventManager.cs
- Label.cs
- CircleHotSpot.cs
- XmlSchemaParticle.cs
- EventManager.cs
- ResourcePart.cs
- ConfigurationLocation.cs
- ServicesUtilities.cs
- CryptoProvider.cs
- GatewayDefinition.cs
- SqlInternalConnectionTds.cs
- WorkflowServiceBuildProvider.cs
- RSAOAEPKeyExchangeFormatter.cs
- DataGridViewCellFormattingEventArgs.cs
- Dump.cs
- DateTimePicker.cs
- KeyManager.cs
- AssociatedControlConverter.cs
- WmlValidatorAdapter.cs
- FunctionImportElement.cs
- PromptBuilder.cs
- CommandField.cs
- XomlCompilerParameters.cs
- ConfigPathUtility.cs
- SignatureHelper.cs
- CompiledRegexRunner.cs
- SafeEventLogWriteHandle.cs
- DbProviderSpecificTypePropertyAttribute.cs
- MessageQueueEnumerator.cs
- PublishLicense.cs
- ParameterModifier.cs
- IImplicitResourceProvider.cs
- HandleExceptionArgs.cs