Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / Configuration / CodeSubDirectory.cs / 1 / 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; [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] 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; [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] 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
- ComponentManagerBroker.cs
- CollaborationHelperFunctions.cs
- CLRBindingWorker.cs
- SBCSCodePageEncoding.cs
- TypeBuilderInstantiation.cs
- OverflowException.cs
- TrackingServices.cs
- securitycriticaldata.cs
- OdbcReferenceCollection.cs
- WebPartConnectionsConfigureVerb.cs
- Queue.cs
- BitmapVisualManager.cs
- HttpCapabilitiesBase.cs
- Filter.cs
- CodeAttributeDeclaration.cs
- DataSourceControl.cs
- _ProxyRegBlob.cs
- XsdCachingReader.cs
- ObjectView.cs
- ToolStripContentPanel.cs
- SqlConnection.cs
- TextContainerChangedEventArgs.cs
- Number.cs
- OleDbConnectionInternal.cs
- WizardStepBase.cs
- OleDbDataAdapter.cs
- IPCCacheManager.cs
- WebPartRestoreVerb.cs
- TrackingServices.cs
- CustomError.cs
- OperatingSystem.cs
- InertiaTranslationBehavior.cs
- Tokenizer.cs
- DiscardableAttribute.cs
- DataGridViewTopLeftHeaderCell.cs
- VirtualPathUtility.cs
- AppLevelCompilationSectionCache.cs
- PageSetupDialog.cs
- FlowDocumentPaginator.cs
- ProbeMatchesApril2005.cs
- Journaling.cs
- RepeatInfo.cs
- ConsoleKeyInfo.cs
- SafeNativeMethods.cs
- _SSPIWrapper.cs
- SecurityTraceRecordHelper.cs
- UnknownBitmapDecoder.cs
- ErrorWebPart.cs
- XmlSchemaSimpleTypeList.cs
- NetDataContractSerializer.cs
- CheckBox.cs
- CapabilitiesUse.cs
- ComponentEditorForm.cs
- DefaultMemberAttribute.cs
- ComMethodElement.cs
- UpdateCompiler.cs
- FirstMatchCodeGroup.cs
- DataRelationPropertyDescriptor.cs
- IdentityNotMappedException.cs
- IdnElement.cs
- DataColumn.cs
- DataRow.cs
- ChtmlCommandAdapter.cs
- IntSumAggregationOperator.cs
- XmlIterators.cs
- ETagAttribute.cs
- TextEndOfSegment.cs
- ActivityInterfaces.cs
- DbConnectionFactory.cs
- AlphabetConverter.cs
- ImageList.cs
- OpenTypeMethods.cs
- ServiceProviders.cs
- SqlProviderManifest.cs
- VectorValueSerializer.cs
- UnsafePeerToPeerMethods.cs
- Serializer.cs
- SocketElement.cs
- DecoratedNameAttribute.cs
- ArrangedElementCollection.cs
- mediaeventshelper.cs
- DataObjectPastingEventArgs.cs
- Transform3D.cs
- ClientRoleProvider.cs
- ObjectStateFormatter.cs
- TdsParserSafeHandles.cs
- PlainXmlWriter.cs
- SolidBrush.cs
- PageRanges.cs
- ModelItemImpl.cs
- AssemblyNameProxy.cs
- SponsorHelper.cs
- OptimalTextSource.cs
- WebPartZoneBase.cs
- XmlSchemaInclude.cs
- XmlAnyElementAttributes.cs
- TCPClient.cs
- GeometryModel3D.cs
- CatalogPartChrome.cs
- SessionState.cs