Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Metadata / ObjectLayer / MetadataAssemblyHelper.cs / 1305376 / MetadataAssemblyHelper.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Reflection; using System.Collections.Generic; using System.Diagnostics; using System.Data.Common.Utils; namespace System.Data.Metadata.Edm { internal static class MetadataAssemblyHelper { static byte [] EcmaPublicKeyToken = System.Data.EntityModel.SchemaObjectModel.ScalarType.ConvertToByteArray(AssemblyRef.EcmaPublicKey); static byte [] MsPublicKeyToken = System.Data.EntityModel.SchemaObjectModel.ScalarType.ConvertToByteArray(AssemblyRef.MicrosoftPublicKey); private static Memoizer_filterAssemblyCacheByAssembly = new Memoizer (MetadataAssemblyHelper.ComputeShouldFilterAssembly, EqualityComparer .Default); internal static Assembly SafeLoadReferencedAssembly(AssemblyName assemblyName) { Assembly assembly = null; try { assembly = Assembly.Load(assemblyName); } catch (System.IO.FileNotFoundException) { // See 552932: ObjectItemCollection: fails on referenced assemblies that are not available } return assembly; } private static bool ComputeShouldFilterAssembly(Assembly assembly) { AssemblyName assemblyName = new AssemblyName(assembly.FullName); return ShouldFilterAssembly(assemblyName); } internal static bool ShouldFilterAssembly(Assembly assembly) { return _filterAssemblyCacheByAssembly.Evaluate(assembly); } /// Is the assembly and its referened assemblies not expected to have any metadata private static bool ShouldFilterAssembly(AssemblyName assemblyName) { return (ArePublicKeyTokensEqual(assemblyName.GetPublicKeyToken(), EcmaPublicKeyToken) || ArePublicKeyTokensEqual(assemblyName.GetPublicKeyToken(), MsPublicKeyToken)); } private static bool ArePublicKeyTokensEqual(byte [] left, byte [] right) { // some assemblies don't have public keys if (left.Length != right.Length) { return false; } for (int i = 0; i < left.Length; i++) { if (left[i] != right[i]) { return false; } } return true; } internal static IEnumerableGetNonSystemReferencedAssemblies(Assembly assembly) { foreach (AssemblyName name in assembly.GetReferencedAssemblies()) { if (!ShouldFilterAssembly(name)) { Assembly referenceAssembly = SafeLoadReferencedAssembly(name); if(referenceAssembly != null ) { yield return referenceAssembly; } } } } } } // 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
- UdpDiscoveryEndpointElement.cs
- BitmapMetadataEnumerator.cs
- AnnouncementInnerClientCD1.cs
- DrawingCollection.cs
- TableLayout.cs
- DateTime.cs
- DbReferenceCollection.cs
- LocatorGroup.cs
- DataGridViewCellPaintingEventArgs.cs
- ValidationHelper.cs
- WebHttpBindingCollectionElement.cs
- PageContent.cs
- ZipIOCentralDirectoryFileHeader.cs
- EmptyEnumerable.cs
- ControlCollection.cs
- EnumDataContract.cs
- DesignerTextBoxAdapter.cs
- GatewayDefinition.cs
- DateTimeOffsetConverter.cs
- SerTrace.cs
- PathGradientBrush.cs
- SqlParameterCollection.cs
- QueryContinueDragEvent.cs
- ValidatorCompatibilityHelper.cs
- ComplexType.cs
- SqlInfoMessageEvent.cs
- PreservationFileReader.cs
- OptimizerPatterns.cs
- QilVisitor.cs
- AppDomainUnloadedException.cs
- followingquery.cs
- SerializationStore.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- SourceExpressionException.cs
- MobileTemplatedControlDesigner.cs
- MultiByteCodec.cs
- ConsoleTraceListener.cs
- HttpCapabilitiesBase.cs
- OuterGlowBitmapEffect.cs
- _TimerThread.cs
- RSAOAEPKeyExchangeDeformatter.cs
- FormView.cs
- WindowsListViewGroupHelper.cs
- RequestCache.cs
- GridViewRowPresenter.cs
- FlagsAttribute.cs
- ParseElement.cs
- MissingMemberException.cs
- DotExpr.cs
- NamespaceDecl.cs
- CodeSnippetStatement.cs
- ELinqQueryState.cs
- PropertyMetadata.cs
- AnnotationResource.cs
- CompilerTypeWithParams.cs
- ComponentChangedEvent.cs
- Validator.cs
- Lazy.cs
- DataFormat.cs
- RawTextInputReport.cs
- XsltSettings.cs
- Int16AnimationBase.cs
- ModuleBuilder.cs
- OdbcError.cs
- FileCodeGroup.cs
- InputLanguage.cs
- ServiceActivationException.cs
- XmlAnyAttributeAttribute.cs
- WebPartConnectionsConnectVerb.cs
- TextElementEnumerator.cs
- DbDeleteCommandTree.cs
- ThumbAutomationPeer.cs
- DbProviderConfigurationHandler.cs
- PassportIdentity.cs
- ColorMatrix.cs
- ListChangedEventArgs.cs
- ContainerFilterService.cs
- NetStream.cs
- ControlCodeDomSerializer.cs
- WebPartConnectionCollection.cs
- Translator.cs
- QilNode.cs
- PublishLicense.cs
- ConsumerConnectionPointCollection.cs
- SecureEnvironment.cs
- TempEnvironment.cs
- ExtentKey.cs
- RightsManagementEncryptionTransform.cs
- AllMembershipCondition.cs
- ErrorItem.cs
- DefaultValueConverter.cs
- NetworkAddressChange.cs
- OleDbConnectionInternal.cs
- VBCodeProvider.cs
- BinaryConverter.cs
- WebPartRestoreVerb.cs
- FusionWrap.cs
- RegexWriter.cs
- DynamicPropertyHolder.cs
- ToolboxItemFilterAttribute.cs