Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Security / Policy / AppDomainEvidenceFactory.cs / 1305376 / AppDomainEvidenceFactory.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== using System; using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Reflection; namespace System.Security.Policy { ////// Factory class which creates evidence on demand for an AppDomain /// internal sealed class AppDomainEvidenceFactory : IRuntimeEvidenceFactory { private AppDomain m_targetDomain; private Evidence m_entryPointEvidence; internal AppDomainEvidenceFactory(AppDomain target) { Contract.Assert(target != null); Contract.Assert(target == AppDomain.CurrentDomain, "AppDomainEvidenceFactory should not be used across domains."); m_targetDomain = target; } ////// AppDomain this factory generates evidence for /// public IEvidenceFactory Target { get { return m_targetDomain; } } ////// Return any evidence supplied by the AppDomain itself /// public IEnumerableGetFactorySuppliedEvidence() { // AppDomains do not contain serialized evidence return new EvidenceBase[] { }; } /// /// Generate evidence on demand for an AppDomain /// [SecuritySafeCritical] public EvidenceBase GenerateEvidence(Type evidenceType) { // For v1.x compatibility, the default AppDomain has the same evidence as the entry point // assembly. Since other AppDomains inherit their evidence from the default AppDomain by // default, they also use the entry point assembly. BCLDebug.Assert(m_targetDomain == AppDomain.CurrentDomain, "AppDomainEvidenceFactory should not be used across domains."); if (m_targetDomain.IsDefaultAppDomain()) { // If we don't already know the evidence for the entry point assembly, get that now. If we // have a RuntimeAssembly go directly to its EvidenceNoDemand property to avoid the full // demand that it will do on access to its Evidence property. if (m_entryPointEvidence == null) { Assembly entryAssembly = Assembly.GetEntryAssembly(); RuntimeAssembly entryRuntimeAssembly = entryAssembly as RuntimeAssembly; if (entryRuntimeAssembly != null) { m_entryPointEvidence = entryRuntimeAssembly.EvidenceNoDemand.Clone(); } else if (entryAssembly != null) { m_entryPointEvidence = entryAssembly.Evidence; } } // If the entry point assembly provided evidence, then we use that for the AppDomain if (m_entryPointEvidence != null) { return m_entryPointEvidence.GetHostEvidence(evidenceType); } } else { // If we're not the default domain, then we should inherit our evidence from the default // domain -- so ask it what evidence it has of this type. AppDomain defaultDomain = AppDomain.GetDefaultDomain(); return defaultDomain.GetHostEvidence(evidenceType); } // AppDomains do not generate any evidence on demand return null; } } } // 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
- DefaultHttpHandler.cs
- Table.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- OutOfMemoryException.cs
- SnapshotChangeTrackingStrategy.cs
- TextRangeProviderWrapper.cs
- SamlAdvice.cs
- SafeMemoryMappedFileHandle.cs
- DatagridviewDisplayedBandsData.cs
- CodeIndexerExpression.cs
- RefExpr.cs
- SchemaLookupTable.cs
- PointLightBase.cs
- TreeViewTemplateSelector.cs
- RadioButtonStandardAdapter.cs
- DrawingState.cs
- FixedSOMPageConstructor.cs
- TrackingProfile.cs
- BufferedReadStream.cs
- PaginationProgressEventArgs.cs
- Catch.cs
- XmlSchemaDatatype.cs
- RequestDescription.cs
- ThemeDirectoryCompiler.cs
- LoopExpression.cs
- ClientCultureInfo.cs
- FileClassifier.cs
- CommandLibraryHelper.cs
- EmptyImpersonationContext.cs
- Soap.cs
- PluralizationService.cs
- ReferencedCollectionType.cs
- webproxy.cs
- TextDecorations.cs
- RegionInfo.cs
- TableLayoutPanelBehavior.cs
- AuthenticodeSignatureInformation.cs
- ChangesetResponse.cs
- LogEntrySerializationException.cs
- Version.cs
- TextServicesCompartmentContext.cs
- TreeNodeSelectionProcessor.cs
- WindowsGraphics2.cs
- FormatterConverter.cs
- PipeStream.cs
- EventDrivenDesigner.cs
- SecurityHelper.cs
- AttachedPropertiesService.cs
- CacheRequest.cs
- TextFormatterImp.cs
- ResizingMessageFilter.cs
- CustomAttributeSerializer.cs
- ProfileGroupSettings.cs
- DatePickerTextBox.cs
- TextRunProperties.cs
- DayRenderEvent.cs
- Light.cs
- ColumnResult.cs
- COM2IDispatchConverter.cs
- XPathScanner.cs
- ConstructorExpr.cs
- BinHexDecoder.cs
- CellParaClient.cs
- XmlSchemaObjectTable.cs
- TrackingServices.cs
- HealthMonitoringSection.cs
- ScrollChrome.cs
- NativeMethods.cs
- TextStore.cs
- JumpPath.cs
- SafeNativeMethods.cs
- AbsoluteQuery.cs
- MsmqIntegrationBindingCollectionElement.cs
- MobileUserControl.cs
- WebPartDescriptionCollection.cs
- CustomAttribute.cs
- DataAdapter.cs
- FrameworkElement.cs
- SoapAttributeAttribute.cs
- DiscoveryOperationContext.cs
- MessageQuerySet.cs
- ErrorFormatter.cs
- SystemWebSectionGroup.cs
- XsltConvert.cs
- ZipFileInfoCollection.cs
- CannotUnloadAppDomainException.cs
- HandoffBehavior.cs
- CodeVariableReferenceExpression.cs
- ImmutableCollection.cs
- URLString.cs
- DictationGrammar.cs
- DurationConverter.cs
- ValidatedControlConverter.cs
- GridItemProviderWrapper.cs
- XmlSchemaAppInfo.cs
- ObjectViewFactory.cs
- TextBreakpoint.cs
- XmlQueryTypeFactory.cs
- ButtonBaseAutomationPeer.cs
- ViewCellRelation.cs