Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Compiler / ReferencedAssemblyResolver.cs / 1305376 / ReferencedAssemblyResolver.cs
namespace System.Workflow.ComponentModel.Compiler { using System; using System.Reflection; using System.Collections.Specialized; using System.ComponentModel.Design; using System.Workflow.ComponentModel.Compiler; using System.Workflow.ComponentModel.Design; #region Class Assembly resolver // In the cases where the WorkflowCompiler is invoked directly, we need to deserialize the // xoml before we can create the real TypeProvider, hence it is necessary to look at the // referenced assemblies for any types that fail to load. In the VS scenarios, the TypeProvider // has already been created and the WorkflowMarkupSerializer will use it first. internal sealed class ReferencedAssemblyResolver { private StringCollection referencedAssemblies = new StringCollection(); private Assembly localAssembly; private bool resolving = false; public ReferencedAssemblyResolver(StringCollection referencedAssemblies, Assembly localAssembly) { this.referencedAssemblies = referencedAssemblies; this.localAssembly = localAssembly; } public Assembly ResolveEventHandler(object sender, ResolveEventArgs args) { return ResolveAssembly(args.Name); } internal void SetLocalAssembly(Assembly localAsm) { this.localAssembly = localAsm; } private Assembly ResolveAssembly(string name) { if (this.resolving) return null; // First look for the local assembly. if (this.localAssembly != null && name == this.localAssembly.FullName) return this.localAssembly; try { this.resolving = true; AssemblyName assemblyName = new AssemblyName(name); // Then try the referenced assemblies. foreach (string assemblyPath in this.referencedAssemblies) { try { AssemblyName referenceAssemblyName = AssemblyName.GetAssemblyName(assemblyPath); if (referenceAssemblyName != null && ParseHelpers.AssemblyNameEquals(referenceAssemblyName, assemblyName)) { Assembly reference = null; try { reference = Assembly.Load(referenceAssemblyName); } catch { reference = Assembly.LoadFrom(assemblyPath); } return reference; } } catch { // Eat up any exceptions! } } } finally { this.resolving = false; } return null; } } #endregion } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HashRepartitionEnumerator.cs
- PointCollectionValueSerializer.cs
- DetailsViewInsertedEventArgs.cs
- XsltSettings.cs
- InvokeBinder.cs
- Endpoint.cs
- ComplexType.cs
- MenuItem.cs
- DoubleCollectionConverter.cs
- SerializationFieldInfo.cs
- DbParameterCollectionHelper.cs
- TypeElement.cs
- FormatVersion.cs
- WebServiceEndpoint.cs
- MenuItem.cs
- ResXResourceWriter.cs
- ExceptionUtil.cs
- DesignerVerbCollection.cs
- RawStylusInput.cs
- TextureBrush.cs
- RegexMatch.cs
- Point3DIndependentAnimationStorage.cs
- DropAnimation.xaml.cs
- FontStretchConverter.cs
- Permission.cs
- WebPartVerb.cs
- DataRecord.cs
- EtwTrackingParticipant.cs
- XmlSchemaCollection.cs
- OdbcConnectionStringbuilder.cs
- FixedPageAutomationPeer.cs
- SharedPerformanceCounter.cs
- SafeRightsManagementHandle.cs
- DataServiceRequestOfT.cs
- BinaryObjectReader.cs
- OleStrCAMarshaler.cs
- BrushConverter.cs
- CancelRequestedQuery.cs
- GlyphCollection.cs
- TreeBuilderXamlTranslator.cs
- SessionEndingCancelEventArgs.cs
- _RegBlobWebProxyDataBuilder.cs
- EntityDataSourceDesigner.cs
- AnnotationHelper.cs
- PropertyPathWorker.cs
- ServerIdentity.cs
- DesignerForm.cs
- WindowsNonControl.cs
- AmbientProperties.cs
- AmbientProperties.cs
- dsa.cs
- XmlException.cs
- CreateUserErrorEventArgs.cs
- OleStrCAMarshaler.cs
- Compiler.cs
- FormatConvertedBitmap.cs
- MailMessageEventArgs.cs
- FastPropertyAccessor.cs
- OptimizedTemplateContent.cs
- BehaviorDragDropEventArgs.cs
- OdbcConnectionString.cs
- SystemMulticastIPAddressInformation.cs
- TrackingAnnotationCollection.cs
- InvalidCastException.cs
- GPRECT.cs
- XsltContext.cs
- Debug.cs
- Emitter.cs
- UpdateProgress.cs
- XamlParser.cs
- VirtualDirectoryMappingCollection.cs
- SessionStateItemCollection.cs
- PassportPrincipal.cs
- ListItem.cs
- TextElementCollection.cs
- WebEncodingValidator.cs
- TextElementEnumerator.cs
- ClientProtocol.cs
- CustomErrorCollection.cs
- LinqDataSourceInsertEventArgs.cs
- Label.cs
- CanonicalXml.cs
- SqlUdtInfo.cs
- PeerInvitationResponse.cs
- CapabilitiesState.cs
- WindowsButton.cs
- PageSetupDialog.cs
- QuaternionIndependentAnimationStorage.cs
- ProfileGroupSettings.cs
- Utils.cs
- CodeTypeParameterCollection.cs
- PrePrepareMethodAttribute.cs
- DoubleAnimation.cs
- TextBoxAutomationPeer.cs
- LockedAssemblyCache.cs
- DataStorage.cs
- MemberCollection.cs
- ItemChangedEventArgs.cs
- DispatcherEventArgs.cs
- CollectionBase.cs