Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / Configuration / CodeSubDirectory.cs / 2 / 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); } } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlEventCache.cs
- PropVariant.cs
- TransformerInfo.cs
- ScrollPattern.cs
- RawMouseInputReport.cs
- HandlerFactoryCache.cs
- DbBuffer.cs
- PeerChannelListener.cs
- RootBrowserWindowAutomationPeer.cs
- _ConnectionGroup.cs
- LoginName.cs
- WindowsFont.cs
- HiddenField.cs
- MDIClient.cs
- SmiRecordBuffer.cs
- DockPattern.cs
- ResourceReferenceExpressionConverter.cs
- ComponentChangingEvent.cs
- PopupControlService.cs
- PackWebRequestFactory.cs
- WhiteSpaceTrimStringConverter.cs
- BrushValueSerializer.cs
- FilteredSchemaElementLookUpTable.cs
- ReadWriteControlDesigner.cs
- BaseInfoTable.cs
- PropertyInformationCollection.cs
- Types.cs
- FormViewPagerRow.cs
- AuthenticationManager.cs
- CanonicalXml.cs
- DigitalSignatureProvider.cs
- HttpCacheVaryByContentEncodings.cs
- DrawingServices.cs
- RequestContextBase.cs
- ChannelTokenTypeConverter.cs
- SendMailErrorEventArgs.cs
- TextElementEnumerator.cs
- RowVisual.cs
- CompilationRelaxations.cs
- ImpersonationContext.cs
- DeclaredTypeValidatorAttribute.cs
- BitmapEncoder.cs
- GenericIdentity.cs
- TextAdaptor.cs
- DoubleStorage.cs
- WindowsListViewGroupSubsetLink.cs
- ScopeElementCollection.cs
- AnnotationElement.cs
- DataProviderNameConverter.cs
- ConstraintManager.cs
- ProfileBuildProvider.cs
- GeneralTransform3DTo2D.cs
- RecognizerStateChangedEventArgs.cs
- ProcessHostServerConfig.cs
- ToolStripPanelSelectionBehavior.cs
- KeyGestureConverter.cs
- OdbcInfoMessageEvent.cs
- Size.cs
- CalendarKeyboardHelper.cs
- Material.cs
- CryptoHandle.cs
- GradientStop.cs
- ApplicationSettingsBase.cs
- FrameworkName.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- NestedContainer.cs
- SystemDropShadowChrome.cs
- XPathNodeList.cs
- NamedElement.cs
- ControlCollection.cs
- BufferedWebEventProvider.cs
- ConversionValidationRule.cs
- ChannelAcceptor.cs
- ParallelTimeline.cs
- IsolatedStoragePermission.cs
- HScrollProperties.cs
- NullableDoubleSumAggregationOperator.cs
- DataGridAutoFormat.cs
- EntityDataSourceDataSelection.cs
- BoolExpr.cs
- ComAdminWrapper.cs
- WorkflowMessageEventHandler.cs
- ConstNode.cs
- SQLRoleProvider.cs
- ApplicationHost.cs
- UriParserTemplates.cs
- _FtpControlStream.cs
- XmlBaseWriter.cs
- StateInitializationDesigner.cs
- RubberbandSelector.cs
- CodeParameterDeclarationExpressionCollection.cs
- SchemaNamespaceManager.cs
- MembershipUser.cs
- SQLMoney.cs
- ExpressionEditorAttribute.cs
- DescendantOverDescendantQuery.cs
- OrthographicCamera.cs
- EntitySetBase.cs
- MessageSecurityException.cs
- UpdatePanelTriggerCollection.cs