Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Security / Policy / ApplicationDirectoryMembershipCondition.cs / 1 / ApplicationDirectoryMembershipCondition.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // ApplicationDirectoryMembershipCondition.cs // // Implementation of membership condition for "application directories" // namespace System.Security.Policy { using System; using SecurityElement = System.Security.SecurityElement; using System.Security.Policy; using URLString = System.Security.Util.URLString; using System.Collections; [Serializable] [System.Runtime.InteropServices.ComVisible(true)] sealed public class ApplicationDirectoryMembershipCondition : IMembershipCondition, IConstantMembershipCondition { //------------------------------------------------------ // // PRIVATE STATE DATA // //----------------------------------------------------- //----------------------------------------------------- // // PUBLIC CONSTRUCTORS // //----------------------------------------------------- public ApplicationDirectoryMembershipCondition() { } //------------------------------------------------------ // // IMEMBERSHIPCONDITION IMPLEMENTATION // //----------------------------------------------------- public bool Check( Evidence evidence ) { if (evidence == null) return false; IEnumerator enumerator = evidence.GetHostEnumerator(); while (enumerator.MoveNext()) { Object obj = enumerator.Current; if (obj is ApplicationDirectory) { ApplicationDirectory dir = (ApplicationDirectory)obj; IEnumerator innerEnumerator = evidence.GetHostEnumerator(); while (innerEnumerator.MoveNext()) { Object innerObj = innerEnumerator.Current; if (innerObj is Url) { // We need to add a wildcard at the end because IsSubsetOf // keys off of it. String appDir = dir.Directory; if (appDir != null && appDir.Length > 1) { if (appDir[appDir.Length-1] == '/') appDir += "*"; else appDir += "/*"; // comment URLString appDirString = new URLString( appDir ); if (((Url)innerObj).GetURLString().IsSubsetOf( appDirString )) { return true; } } } } } } return false; } public IMembershipCondition Copy() { return new ApplicationDirectoryMembershipCondition(); } public SecurityElement ToXml() { return ToXml( null ); } public void FromXml( SecurityElement e ) { FromXml( e, null ); } public SecurityElement ToXml( PolicyLevel level ) { SecurityElement root = new SecurityElement( "IMembershipCondition" ); System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType(), "System.Security.Policy.ApplicationDirectoryMembershipCondition" ); // If you hit this assert then most likely you are trying to change the name of this class. // This is ok as long as you change the hard coded string above and change the assert below. BCLDebug.Assert( this.GetType().FullName.Equals( "System.Security.Policy.ApplicationDirectoryMembershipCondition" ), "Class name changed!" ); root.AddAttribute( "version", "1" ); return root; } public void FromXml( SecurityElement e, PolicyLevel level ) { if (e == null) throw new ArgumentNullException("e"); if (!e.Tag.Equals( "IMembershipCondition" )) { throw new ArgumentException( Environment.GetResourceString( "Argument_MembershipConditionElement" ) ); } } public override bool Equals( Object o ) { return (o is ApplicationDirectoryMembershipCondition); } public override int GetHashCode() { return typeof( ApplicationDirectoryMembershipCondition ).GetHashCode(); } public override String ToString() { return Environment.GetResourceString( "ApplicationDirectory_ToString" ); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebScriptServiceHost.cs
- ListBox.cs
- EventSinkHelperWriter.cs
- ResourceContainer.cs
- HtmlForm.cs
- EllipseGeometry.cs
- LocatorManager.cs
- Scene3D.cs
- LinearKeyFrames.cs
- DoubleLink.cs
- InfocardExtendedInformationEntry.cs
- TextParagraphCache.cs
- SourceFileBuildProvider.cs
- EventProviderWriter.cs
- WSFederationHttpSecurityMode.cs
- ClientBuildManagerCallback.cs
- ResourceKey.cs
- CurrentChangedEventManager.cs
- UserMapPath.cs
- TlsnegoTokenProvider.cs
- HMACSHA256.cs
- DataObjectPastingEventArgs.cs
- SecurityDescriptor.cs
- PanelStyle.cs
- StorageEntityTypeMapping.cs
- DelegatingTypeDescriptionProvider.cs
- DependencyPropertyConverter.cs
- Directory.cs
- DotExpr.cs
- UpdatePanel.cs
- WebPartsPersonalization.cs
- SqlComparer.cs
- PropertyPathConverter.cs
- MatrixTransform.cs
- SecurityState.cs
- FigureParagraph.cs
- MemberInfoSerializationHolder.cs
- Compress.cs
- PathFigure.cs
- PenThreadPool.cs
- DataFormat.cs
- sqlnorm.cs
- PrivilegedConfigurationManager.cs
- PrinterSettings.cs
- Separator.cs
- HttpPostClientProtocol.cs
- EmptyEnumerator.cs
- MenuRendererClassic.cs
- StreamResourceInfo.cs
- XmlCountingReader.cs
- TreeNodeEventArgs.cs
- Freezable.cs
- XamlLoadErrorInfo.cs
- SelectionGlyphBase.cs
- BindableAttribute.cs
- SpellerHighlightLayer.cs
- HttpNamespaceReservationInstallComponent.cs
- Int64.cs
- SqlNotificationEventArgs.cs
- EventProviderTraceListener.cs
- ComplexTypeEmitter.cs
- ImagingCache.cs
- CodeDomConfigurationHandler.cs
- DesignTimeType.cs
- GetIndexBinder.cs
- FixedSOMPageConstructor.cs
- XslAstAnalyzer.cs
- SafeProcessHandle.cs
- mediaeventargs.cs
- Transform3D.cs
- InstancePersistenceCommand.cs
- TransportListener.cs
- ToolStripContentPanelRenderEventArgs.cs
- EntityConnectionStringBuilderItem.cs
- HandlerFactoryWrapper.cs
- CombinedGeometry.cs
- TaskScheduler.cs
- NameSpaceExtractor.cs
- PixelShader.cs
- X509Certificate2.cs
- FrameSecurityDescriptor.cs
- RsaSecurityTokenAuthenticator.cs
- StyleTypedPropertyAttribute.cs
- BitmapCodecInfoInternal.cs
- ExpressionPrefixAttribute.cs
- IBuiltInEvidence.cs
- TextRunProperties.cs
- EnumerableWrapperWeakToStrong.cs
- UnsafeNativeMethods.cs
- GZipUtils.cs
- MinimizableAttributeTypeConverter.cs
- BulletedListEventArgs.cs
- ExpressionVisitor.cs
- BridgeDataReader.cs
- TypeUnloadedException.cs
- SetIndexBinder.cs
- XmlBufferReader.cs
- HitTestWithGeometryDrawingContextWalker.cs
- SoapEnumAttribute.cs
- ParseNumbers.cs