Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Security / Policy / FirstMatchCodeGroup.cs / 1 / FirstMatchCodeGroup.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // FirstMatchCodeGroup.cs // // Representation for code groups used for the policy mechanism // namespace System.Security.Policy { using System; using System.Security.Util; using System.Security; using System.Collections; [Serializable] [System.Runtime.InteropServices.ComVisible(true)] sealed public class FirstMatchCodeGroup : CodeGroup { internal FirstMatchCodeGroup() : base() { } public FirstMatchCodeGroup( IMembershipCondition membershipCondition, PolicyStatement policy ) : base( membershipCondition, policy ) { } public override PolicyStatement Resolve( Evidence evidence ) { if (evidence == null) throw new ArgumentNullException("evidence"); if (this.MembershipCondition.Check( evidence )) { PolicyStatement childPolicy = null; IEnumerator enumerator = this.Children.GetEnumerator(); while (enumerator.MoveNext()) { childPolicy = ((CodeGroup)enumerator.Current).Resolve( evidence ); // If the child has a policy, we are done. if (childPolicy != null) break; } PolicyStatement thisPolicy = this.PolicyStatement; if (thisPolicy == null) { return childPolicy; } else if (childPolicy != null) { // Combine the child and this policy and return it. PolicyStatement combined = new PolicyStatement(); combined.SetPermissionSetNoCopy( thisPolicy.GetPermissionSetNoCopy().Union( childPolicy.GetPermissionSetNoCopy() ) ); // if both this group and matching child group are exclusive we need to throw an exception if (((thisPolicy.Attributes & childPolicy.Attributes) & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive) throw new PolicyException( Environment.GetResourceString( "Policy_MultipleExclusive" ) ); combined.Attributes = thisPolicy.Attributes | childPolicy.Attributes; return combined; } else { // Otherwise we just copy the this policy. return this.PolicyStatement; } } else { return null; } } public override CodeGroup ResolveMatchingCodeGroups( Evidence evidence ) { if (evidence == null) throw new ArgumentNullException("evidence"); if (this.MembershipCondition.Check( evidence )) { CodeGroup retGroup = this.Copy(); retGroup.Children = new ArrayList(); IEnumerator enumerator = this.Children.GetEnumerator(); while (enumerator.MoveNext()) { CodeGroup matchingGroups = ((CodeGroup)enumerator.Current).ResolveMatchingCodeGroups( evidence ); // If the child has a policy, we are done. if (matchingGroups != null) { retGroup.AddChild( matchingGroups ); break; } } return retGroup; } else { return null; } } public override CodeGroup Copy() { FirstMatchCodeGroup group = new FirstMatchCodeGroup(); group.MembershipCondition = this.MembershipCondition; group.PolicyStatement = this.PolicyStatement; group.Name = this.Name; group.Description = this.Description; IEnumerator enumerator = this.Children.GetEnumerator(); while (enumerator.MoveNext()) { group.AddChild( (CodeGroup)enumerator.Current ); } return group; } public override String MergeLogic { get { return Environment.GetResourceString( "MergeLogic_FirstMatch" ); } } internal override String GetTypeName() { return "System.Security.Policy.FirstMatchCodeGroup"; } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebConfigManager.cs
- ParagraphVisual.cs
- Panel.cs
- InvokeBase.cs
- TableRow.cs
- StatusBarPanel.cs
- ModifierKeysValueSerializer.cs
- DesignerListAdapter.cs
- EntityModelSchemaGenerator.cs
- StylusShape.cs
- XdrBuilder.cs
- TypeSource.cs
- PhysicalAddress.cs
- ComponentEvent.cs
- RegexStringValidatorAttribute.cs
- DrawItemEvent.cs
- METAHEADER.cs
- WorkflowPersistenceService.cs
- SHA256.cs
- XmlQueryTypeFactory.cs
- AutomationElementCollection.cs
- AssignDesigner.xaml.cs
- TableParaClient.cs
- CountdownEvent.cs
- EntityCommandExecutionException.cs
- Evidence.cs
- DataGridViewLayoutData.cs
- DesignerDataSourceView.cs
- ConnectionsZone.cs
- DnsPermission.cs
- PlanCompiler.cs
- ExpressionLink.cs
- CompletedAsyncResult.cs
- TraceLevelStore.cs
- TrustManagerPromptUI.cs
- ReaderWriterLockWrapper.cs
- JournalEntryListConverter.cs
- RepeatButton.cs
- SafeNativeMethods.cs
- Selection.cs
- Model3D.cs
- SecurityState.cs
- XmlSchemaComplexContentRestriction.cs
- DbgUtil.cs
- GeneralTransform3DTo2DTo3D.cs
- BamlRecords.cs
- RepeatBehaviorConverter.cs
- ConfigurationManagerHelper.cs
- OleDbFactory.cs
- InfoCardSchemas.cs
- CatalogZone.cs
- PerformanceCounterCategory.cs
- BaseDataBoundControl.cs
- DeflateStream.cs
- TreeNodeMouseHoverEvent.cs
- TraceUtils.cs
- TypeSystemProvider.cs
- Function.cs
- DataRelationCollection.cs
- ResXResourceReader.cs
- SecurityKeyIdentifier.cs
- SubtreeProcessor.cs
- HitTestDrawingContextWalker.cs
- ResXDataNode.cs
- TextBoxAutomationPeer.cs
- TcpProcessProtocolHandler.cs
- ProxyElement.cs
- ZipArchive.cs
- EventLogEntryCollection.cs
- ComEventsMethod.cs
- ExpressionEditorAttribute.cs
- ExpandableObjectConverter.cs
- ListSourceHelper.cs
- OperandQuery.cs
- XslException.cs
- TransformerInfoCollection.cs
- InputDevice.cs
- validationstate.cs
- Source.cs
- Rotation3D.cs
- IHttpResponseInternal.cs
- FilteredSchemaElementLookUpTable.cs
- IIS7UserPrincipal.cs
- HiddenFieldPageStatePersister.cs
- CacheForPrimitiveTypes.cs
- ThumbButtonInfo.cs
- DockPatternIdentifiers.cs
- CodeNamespace.cs
- ControlOperationBehavior.cs
- CommandBinding.cs
- TogglePatternIdentifiers.cs
- X509SubjectKeyIdentifierClause.cs
- _NetworkingPerfCounters.cs
- TabItemAutomationPeer.cs
- BooleanStorage.cs
- DocumentViewerHelper.cs
- RadioButtonList.cs
- SettingsPropertyIsReadOnlyException.cs
- CachedPathData.cs
- SystemTcpStatistics.cs