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
- AsymmetricKeyExchangeDeformatter.cs
- ItemCollection.cs
- XmlSchemaSubstitutionGroup.cs
- RewritingValidator.cs
- DataGridTable.cs
- GCHandleCookieTable.cs
- Separator.cs
- Selection.cs
- SchemeSettingElementCollection.cs
- ExclusiveTcpListener.cs
- FormViewInsertEventArgs.cs
- IPHostEntry.cs
- SettingsPropertyWrongTypeException.cs
- XmlSchemaAnnotated.cs
- SEHException.cs
- Misc.cs
- TypeDelegator.cs
- SqlUserDefinedAggregateAttribute.cs
- Int16AnimationUsingKeyFrames.cs
- BindingCollectionElement.cs
- DesignerVerbCollection.cs
- DataGridViewTextBoxEditingControl.cs
- X509RawDataKeyIdentifierClause.cs
- JulianCalendar.cs
- SoapServerProtocol.cs
- SafeBitVector32.cs
- Geometry3D.cs
- WindowsStreamSecurityElement.cs
- FreezableDefaultValueFactory.cs
- UnauthorizedAccessException.cs
- DragAssistanceManager.cs
- QilInvokeLateBound.cs
- DateTimeParse.cs
- WebControlsSection.cs
- ObjectDataSourceSelectingEventArgs.cs
- ReachPrintTicketSerializer.cs
- CompositeDataBoundControl.cs
- GlyphingCache.cs
- ImageMetadata.cs
- EditorPartDesigner.cs
- HashRepartitionEnumerator.cs
- TcpStreams.cs
- OverflowException.cs
- XPathAncestorIterator.cs
- RayMeshGeometry3DHitTestResult.cs
- InputScope.cs
- CellNormalizer.cs
- StringValidatorAttribute.cs
- PersistenceException.cs
- TextLineBreak.cs
- PropertyItemInternal.cs
- HtmlInputHidden.cs
- StringSorter.cs
- StylusPlugInCollection.cs
- Point.cs
- ItemsControlAutomationPeer.cs
- ArraySortHelper.cs
- ButtonChrome.cs
- NetworkStream.cs
- lengthconverter.cs
- IncrementalHitTester.cs
- ContentElement.cs
- XComponentModel.cs
- ShapeTypeface.cs
- PackUriHelper.cs
- HashSet.cs
- DataQuery.cs
- XmlSerializerSection.cs
- PreservationFileWriter.cs
- ContravarianceAdapter.cs
- FixedSOMPage.cs
- CaseInsensitiveOrdinalStringComparer.cs
- FreeFormDesigner.cs
- LinqDataSourceDeleteEventArgs.cs
- List.cs
- Span.cs
- ListParagraph.cs
- ExceptionCollection.cs
- TextWriter.cs
- ForwardPositionQuery.cs
- Wildcard.cs
- SQLCharsStorage.cs
- CheckBoxRenderer.cs
- PathFigureCollectionValueSerializer.cs
- Menu.cs
- DataGrid.cs
- DocumentationServerProtocol.cs
- SvcMapFile.cs
- BufferedGraphicsManager.cs
- HtmlControlDesigner.cs
- COAUTHIDENTITY.cs
- GenericRootAutomationPeer.cs
- TriggerBase.cs
- XmlSerializerAssemblyAttribute.cs
- FunctionDescription.cs
- WhitespaceRuleReader.cs
- FrameworkTextComposition.cs
- ReadOnlyObservableCollection.cs
- CurrentChangedEventManager.cs
- ParserStreamGeometryContext.cs