Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Security / Policy / ApplicationDirectoryMembershipCondition.cs / 1305376 / 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, IReportMatchMembershipCondition { //------------------------------------------------------ // // PRIVATE STATE DATA // //----------------------------------------------------- //----------------------------------------------------- // // PUBLIC CONSTRUCTORS // //----------------------------------------------------- public ApplicationDirectoryMembershipCondition() { } //------------------------------------------------------ // // IMEMBERSHIPCONDITION IMPLEMENTATION // //----------------------------------------------------- public bool Check( Evidence evidence ) { object usedEvidence = null; return (this as IReportMatchMembershipCondition).Check(evidence, out usedEvidence); } bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence) { usedEvidence = null; if (evidence == null) return false; ApplicationDirectory dir = evidence.GetHostEvidence(); Url url = evidence.GetHostEvidence (); if (dir != null && url != null) { // 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 += "/*"; URLString appDirString = new URLString(appDir); if (url.GetURLString().IsSubsetOf(appDirString)) { usedEvidence = dir; 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" ); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // 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, IReportMatchMembershipCondition { //------------------------------------------------------ // // PRIVATE STATE DATA // //----------------------------------------------------- //----------------------------------------------------- // // PUBLIC CONSTRUCTORS // //----------------------------------------------------- public ApplicationDirectoryMembershipCondition() { } //------------------------------------------------------ // // IMEMBERSHIPCONDITION IMPLEMENTATION // //----------------------------------------------------- public bool Check( Evidence evidence ) { object usedEvidence = null; return (this as IReportMatchMembershipCondition).Check(evidence, out usedEvidence); } bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence) { usedEvidence = null; if (evidence == null) return false; ApplicationDirectory dir = evidence.GetHostEvidence(); Url url = evidence.GetHostEvidence (); if (dir != null && url != null) { // 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 += "/*"; URLString appDirString = new URLString(appDir); if (url.GetURLString().IsSubsetOf(appDirString)) { usedEvidence = dir; 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" ); } } } // 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
- Misc.cs
- StyleSelector.cs
- ReadOnlyDataSourceView.cs
- ExtendedProperty.cs
- StickyNote.cs
- AVElementHelper.cs
- SharedConnectionInfo.cs
- Container.cs
- _SafeNetHandles.cs
- CultureInfo.cs
- MarshalByRefObject.cs
- ISAPIRuntime.cs
- _DomainName.cs
- TraceContextEventArgs.cs
- TouchEventArgs.cs
- TogglePattern.cs
- PropertyDescriptorGridEntry.cs
- TdsParserSafeHandles.cs
- TableLayoutStyle.cs
- AttachmentCollection.cs
- StateWorkerRequest.cs
- BitmapImage.cs
- OdbcDataReader.cs
- WindowsContainer.cs
- DiscoveryClientDocuments.cs
- CommentAction.cs
- HttpDigestClientElement.cs
- TrackingProvider.cs
- LoginUtil.cs
- ColumnCollection.cs
- NamespaceDecl.cs
- SiteMapProvider.cs
- SpeakInfo.cs
- FirstMatchCodeGroup.cs
- Effect.cs
- DataMemberFieldEditor.cs
- CodeVariableReferenceExpression.cs
- BitmapData.cs
- StylusPlugInCollection.cs
- EffectiveValueEntry.cs
- ISAPIApplicationHost.cs
- PointCollectionConverter.cs
- LinearQuaternionKeyFrame.cs
- SerializableAttribute.cs
- RedirectionProxy.cs
- ContactManager.cs
- PenContext.cs
- BamlTreeUpdater.cs
- Debug.cs
- _DisconnectOverlappedAsyncResult.cs
- LinqDataSourceInsertEventArgs.cs
- HtmlInputSubmit.cs
- ErrorEventArgs.cs
- NamedObject.cs
- ProgressBarHighlightConverter.cs
- MarkupCompilePass1.cs
- DataGridViewCell.cs
- MediaSystem.cs
- RootContext.cs
- Metadata.cs
- ManipulationInertiaStartingEventArgs.cs
- DictionaryBase.cs
- SectionXmlInfo.cs
- ClientBuildManager.cs
- ConfigurationCollectionAttribute.cs
- TypeToken.cs
- ArrayTypeMismatchException.cs
- Activity.cs
- IriParsingElement.cs
- WebPartUtil.cs
- XslAstAnalyzer.cs
- DesignerHelpers.cs
- HTMLTagNameToTypeMapper.cs
- SizeChangedInfo.cs
- Rules.cs
- ElapsedEventArgs.cs
- CultureTable.cs
- ColorAnimation.cs
- BufferModesCollection.cs
- Symbol.cs
- SynchronizedDispatch.cs
- GlyphCache.cs
- CacheChildrenQuery.cs
- NodeInfo.cs
- NullableDoubleSumAggregationOperator.cs
- PageStatePersister.cs
- GenericTypeParameterConverter.cs
- UniqueConstraint.cs
- CloseSequenceResponse.cs
- HttpServerVarsCollection.cs
- CatalogPart.cs
- PrimitiveCodeDomSerializer.cs
- LinkedResource.cs
- StateManagedCollection.cs
- Int64AnimationBase.cs
- DataGridViewUtilities.cs
- MemberCollection.cs
- KeyConstraint.cs
- PingReply.cs
- HttpRequestCacheValidator.cs