Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Configuration / CodeSubDirectory.cs / 1305376 / CodeSubDirectory.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System; using System.Xml; using System.Configuration; using System.Collections.Specialized; using System.Collections; using System.Globalization; using System.IO; using System.Text; using System.Web.Compilation; using System.Reflection; using System.Web.Hosting; using System.Web.UI; using System.CodeDom.Compiler; using System.Web.Util; using System.ComponentModel; using System.Security.Permissions; public sealed class CodeSubDirectory : ConfigurationElement { private const string dirNameAttribName = "directoryName"; private static ConfigurationPropertyCollection _properties; private static readonly ConfigurationProperty _propDirectoryName = new ConfigurationProperty(dirNameAttribName, typeof(string), null, StdValidatorsAndConverters.WhiteSpaceTrimStringConverter, StdValidatorsAndConverters.NonEmptyStringValidator, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey); static CodeSubDirectory() { _properties = new ConfigurationPropertyCollection(); _properties.Add(_propDirectoryName); } internal CodeSubDirectory() { } public CodeSubDirectory(string directoryName) { DirectoryName = directoryName; } protected override ConfigurationPropertyCollection Properties { get { return _properties; } } [ConfigurationProperty(dirNameAttribName, IsRequired = true, IsKey = true, DefaultValue = "")] [TypeConverter(typeof(WhiteSpaceTrimStringConverter))] public string DirectoryName { get { return (string)base[_propDirectoryName]; } set { base[_propDirectoryName] = value; } } // The assembly is named after the directory internal string AssemblyName { get { return DirectoryName; } } // Validate the element for runtime use internal void DoRuntimeValidation() { string directoryName = DirectoryName; // If the app is precompiled, don't attempt further validation, sine the directory // will not actually exist (VSWhidbey 394333) if (BuildManager.IsPrecompiledApp) { return; } // Make sure it's just a valid simple directory name if (!Util.IsValidFileName(directoryName)) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_CodeSubDirectory, directoryName), ElementInformation.Properties[dirNameAttribName].Source, ElementInformation.Properties[dirNameAttribName].LineNumber); } VirtualPath codeVirtualSubDir = HttpRuntime.CodeDirectoryVirtualPath.SimpleCombineWithDir(directoryName); // Make sure the specified directory exists if (!VirtualPathProvider.DirectoryExistsNoThrow(codeVirtualSubDir)) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_CodeSubDirectory_Not_Exist, codeVirtualSubDir), ElementInformation.Properties[dirNameAttribName].Source, ElementInformation.Properties[dirNameAttribName].LineNumber); } // Look at the actual physical dir to get its name canonicalized (VSWhidbey 288568) string physicalDir = codeVirtualSubDir.MapPathInternal(); FindFileData ffd; FindFileData.FindFile(physicalDir, out ffd); // If the name was not canonical, reject it if (!StringUtil.EqualsIgnoreCase(directoryName, ffd.FileNameLong)) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_CodeSubDirectory, directoryName), ElementInformation.Properties[dirNameAttribName].Source, ElementInformation.Properties[dirNameAttribName].LineNumber); } if (BuildManager.IsReservedAssemblyName(directoryName)) { throw new ConfigurationErrorsException( SR.GetString(SR.Reserved_AssemblyName, directoryName), ElementInformation.Properties[dirNameAttribName].Source, ElementInformation.Properties[dirNameAttribName].LineNumber); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System; using System.Xml; using System.Configuration; using System.Collections.Specialized; using System.Collections; using System.Globalization; using System.IO; using System.Text; using System.Web.Compilation; using System.Reflection; using System.Web.Hosting; using System.Web.UI; using System.CodeDom.Compiler; using System.Web.Util; using System.ComponentModel; using System.Security.Permissions; public sealed class CodeSubDirectory : ConfigurationElement { private const string dirNameAttribName = "directoryName"; private static ConfigurationPropertyCollection _properties; private static readonly ConfigurationProperty _propDirectoryName = new ConfigurationProperty(dirNameAttribName, typeof(string), null, StdValidatorsAndConverters.WhiteSpaceTrimStringConverter, StdValidatorsAndConverters.NonEmptyStringValidator, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey); static CodeSubDirectory() { _properties = new ConfigurationPropertyCollection(); _properties.Add(_propDirectoryName); } internal CodeSubDirectory() { } public CodeSubDirectory(string directoryName) { DirectoryName = directoryName; } protected override ConfigurationPropertyCollection Properties { get { return _properties; } } [ConfigurationProperty(dirNameAttribName, IsRequired = true, IsKey = true, DefaultValue = "")] [TypeConverter(typeof(WhiteSpaceTrimStringConverter))] public string DirectoryName { get { return (string)base[_propDirectoryName]; } set { base[_propDirectoryName] = value; } } // The assembly is named after the directory internal string AssemblyName { get { return DirectoryName; } } // Validate the element for runtime use internal void DoRuntimeValidation() { string directoryName = DirectoryName; // If the app is precompiled, don't attempt further validation, sine the directory // will not actually exist (VSWhidbey 394333) if (BuildManager.IsPrecompiledApp) { return; } // Make sure it's just a valid simple directory name if (!Util.IsValidFileName(directoryName)) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_CodeSubDirectory, directoryName), ElementInformation.Properties[dirNameAttribName].Source, ElementInformation.Properties[dirNameAttribName].LineNumber); } VirtualPath codeVirtualSubDir = HttpRuntime.CodeDirectoryVirtualPath.SimpleCombineWithDir(directoryName); // Make sure the specified directory exists if (!VirtualPathProvider.DirectoryExistsNoThrow(codeVirtualSubDir)) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_CodeSubDirectory_Not_Exist, codeVirtualSubDir), ElementInformation.Properties[dirNameAttribName].Source, ElementInformation.Properties[dirNameAttribName].LineNumber); } // Look at the actual physical dir to get its name canonicalized (VSWhidbey 288568) string physicalDir = codeVirtualSubDir.MapPathInternal(); FindFileData ffd; FindFileData.FindFile(physicalDir, out ffd); // If the name was not canonical, reject it if (!StringUtil.EqualsIgnoreCase(directoryName, ffd.FileNameLong)) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_CodeSubDirectory, directoryName), ElementInformation.Properties[dirNameAttribName].Source, ElementInformation.Properties[dirNameAttribName].LineNumber); } if (BuildManager.IsReservedAssemblyName(directoryName)) { throw new ConfigurationErrorsException( SR.GetString(SR.Reserved_AssemblyName, directoryName), ElementInformation.Properties[dirNameAttribName].Source, ElementInformation.Properties[dirNameAttribName].LineNumber); } } } } // 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
- ConnectionStringSettingsCollection.cs
- WebColorConverter.cs
- ChannelBuilder.cs
- XmlSecureResolver.cs
- BamlLocalizableResourceKey.cs
- XPathDocumentBuilder.cs
- CellTreeNodeVisitors.cs
- HelpKeywordAttribute.cs
- Row.cs
- BindableAttribute.cs
- Menu.cs
- _SSPISessionCache.cs
- HyperLinkStyle.cs
- PointLight.cs
- ObjectListGeneralPage.cs
- DefaultBinder.cs
- Odbc32.cs
- ListContractAdapter.cs
- Zone.cs
- ShaperBuffers.cs
- TemplateComponentConnector.cs
- ScriptControl.cs
- Evaluator.cs
- InputElement.cs
- Repeater.cs
- DNS.cs
- PartialList.cs
- FontEmbeddingManager.cs
- SelectionRange.cs
- ImageAnimator.cs
- TimersDescriptionAttribute.cs
- OSFeature.cs
- RunInstallerAttribute.cs
- Oid.cs
- DependencyObjectType.cs
- Line.cs
- DrawingContext.cs
- AutomationPatternInfo.cs
- SrgsElement.cs
- RuntimeConfig.cs
- ResourceContainer.cs
- ValidationErrorCollection.cs
- FaultReasonText.cs
- UIPermission.cs
- BitmapInitialize.cs
- Int32CollectionValueSerializer.cs
- EventHandlerList.cs
- ArraySegment.cs
- StringExpressionSet.cs
- NameTable.cs
- SizeAnimationBase.cs
- MetadataHelper.cs
- TimeSpanValidatorAttribute.cs
- BaseConfigurationRecord.cs
- ExtensionQuery.cs
- NamespaceExpr.cs
- BitmapEffectGroup.cs
- HttpListenerContext.cs
- MessageQueueConverter.cs
- AssociationSet.cs
- LexicalChunk.cs
- Vector.cs
- Button.cs
- MethodBuilder.cs
- AutomationProperty.cs
- Dictionary.cs
- SqlNodeAnnotation.cs
- PageAsyncTask.cs
- SystemKeyConverter.cs
- TextContainerChangeEventArgs.cs
- NamespaceEmitter.cs
- XamlBuildTaskServices.cs
- XmlCustomFormatter.cs
- WinFormsSpinner.cs
- VectorValueSerializer.cs
- NamespaceCollection.cs
- ServiceDescriptionImporter.cs
- KeyInstance.cs
- BaseParaClient.cs
- QuaternionConverter.cs
- DelegatedStream.cs
- ButtonField.cs
- StyleCollection.cs
- GenericRootAutomationPeer.cs
- DigitShape.cs
- PeerResolverMode.cs
- ToolStripItemCollection.cs
- columnmapkeybuilder.cs
- ControlBuilderAttribute.cs
- GradientBrush.cs
- NamedElement.cs
- AnnotationAdorner.cs
- LambdaCompiler.Lambda.cs
- DetailsView.cs
- FixedBufferAttribute.cs
- ImageMapEventArgs.cs
- CodeMemberEvent.cs
- RelationshipEndMember.cs
- DefaultMemberAttribute.cs
- ReadContentAsBinaryHelper.cs