Code:
/ 4.0 / 4.0 / 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. 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
- IgnoreDeviceFilterElement.cs
- Int32.cs
- MatrixUtil.cs
- FixedSOMImage.cs
- Icon.cs
- CompilationUtil.cs
- MethodBody.cs
- DesignerPerfEventProvider.cs
- AvTraceDetails.cs
- RestClientProxyHandler.cs
- AddingNewEventArgs.cs
- HwndHostAutomationPeer.cs
- ConfigsHelper.cs
- ToolStripItemTextRenderEventArgs.cs
- Configuration.cs
- XmlArrayItemAttributes.cs
- AutoCompleteStringCollection.cs
- BitSet.cs
- TypedColumnHandler.cs
- TraceUtils.cs
- HtmlTable.cs
- TreeView.cs
- InstanceKeyCollisionException.cs
- DataServiceExpressionVisitor.cs
- TextShapeableCharacters.cs
- TripleDESCryptoServiceProvider.cs
- InvalidAsynchronousStateException.cs
- formatter.cs
- SqlUserDefinedTypeAttribute.cs
- ComplusEndpointConfigContainer.cs
- ChannelPoolSettingsElement.cs
- MimeBasePart.cs
- EntityDataSourceMemberPath.cs
- TextSelectionHelper.cs
- CopyAction.cs
- SerialStream.cs
- StopStoryboard.cs
- ColorTranslator.cs
- Stopwatch.cs
- Base64Encoder.cs
- ConnectionStringEditor.cs
- PeerTransportListenAddressValidator.cs
- CloseCollectionAsyncResult.cs
- TreeIterator.cs
- SignatureTargetIdManager.cs
- SQLRoleProvider.cs
- LingerOption.cs
- IntranetCredentialPolicy.cs
- Debugger.cs
- EventMappingSettingsCollection.cs
- SQLStringStorage.cs
- NCryptSafeHandles.cs
- Int32CollectionConverter.cs
- SqlDependencyUtils.cs
- AdornerDecorator.cs
- AspNetHostingPermission.cs
- TaskFileService.cs
- CodeNamespaceCollection.cs
- ScriptReferenceEventArgs.cs
- AppliesToBehaviorDecisionTable.cs
- GetReadStreamResult.cs
- ContentType.cs
- FunctionUpdateCommand.cs
- DiscardableAttribute.cs
- WebPartCancelEventArgs.cs
- CustomCategoryAttribute.cs
- XPathSelectionIterator.cs
- HostingEnvironmentSection.cs
- ConstructorNeedsTagAttribute.cs
- BitmapDownload.cs
- DetailsViewPageEventArgs.cs
- SID.cs
- TemplateBindingExpressionConverter.cs
- NativeMethods.cs
- FixedSOMLineCollection.cs
- XmlSchemaNotation.cs
- IImplicitResourceProvider.cs
- SemanticResultValue.cs
- CompilerErrorCollection.cs
- PeerNearMe.cs
- CloudCollection.cs
- ADConnectionHelper.cs
- EditBehavior.cs
- MDIWindowDialog.cs
- PropertyEmitterBase.cs
- AsyncResult.cs
- SiteIdentityPermission.cs
- RSAOAEPKeyExchangeDeformatter.cs
- HitTestWithGeometryDrawingContextWalker.cs
- SafeRegistryHandle.cs
- ProfileGroupSettingsCollection.cs
- StorageComplexPropertyMapping.cs
- OleStrCAMarshaler.cs
- ConnectionPoolManager.cs
- HttpCacheParams.cs
- AuthenticatingEventArgs.cs
- DataServiceHost.cs
- TextProviderWrapper.cs
- AffineTransform3D.cs
- Invariant.cs