Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / AddIn / AddIn / System / Addin / Hosting / Store / HostAdapter.cs / 1305376 / HostAdapter.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: HostAdapter ** ** Purpose: Represents an host adapter class on disk. ** ===========================================================*/ using System; using System.IO; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.Reflection; using System.Text; using System.AddIn.Contract; using System.AddIn.MiniReflection; using System.Diagnostics.Contracts; namespace System.AddIn { [Serializable] internal sealed class HostAdapter : PipelineComponent { private static readonly TypeInfo typeofIContract = new TypeInfo(typeof(System.AddIn.Contract.IContract)); private TypeInfo[] _potentialHAVs; private List_constructors; public HostAdapter(TypeInfo typeInfo, String assemblyLocation) : base(typeInfo, assemblyLocation) { _constructors = new List (); } public List Constructors { get { return _constructors; } } public TypeInfo[] HostAddinViews { get { return _potentialHAVs; } } public override string ToString() { return String.Format(CultureInfo.CurrentCulture, Res.HostAdapterToString, Name, BestAvailableLocation); } internal override bool Validate(TypeInfo type, Collection warnings) { _potentialHAVs = FindBaseTypesAndInterfaces(type); if (_potentialHAVs.Length == 0) { return false; } foreach (MiniConstructorInfo ci in type.GetConstructors(true)) { MiniParameterInfo[] pars = ci.GetParameters(); if (pars.Length != 1) { warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.HostAdapterUnusableCtorMultipleParams, type.AssemblyQualifiedName)); continue; } TypeInfo paramType = pars[0].ParameterType; bool success = false; try { if (paramType.IsInterface && (paramType.Implements(typeofIContract))) { _constructors.Add(paramType); success = true; } } catch (FileNotFoundException) { } catch (FileLoadException) { // Can happen for a constructor taking a type that isn't in mscorlib nor System.AddIn.Contract, and // also isn't in any of the directories that we would probe. } if (!success) { warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.HostAdapterUnusableCtorBadParam, type.AssemblyQualifiedName, paramType.FullName)); continue; } } if (_constructors.Count == 0) { warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.HostAdapterNoValidCtors, type.AssemblyQualifiedName)); return false; } return base.Validate(type, warnings); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: HostAdapter ** ** Purpose: Represents an host adapter class on disk. ** ===========================================================*/ using System; using System.IO; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.Reflection; using System.Text; using System.AddIn.Contract; using System.AddIn.MiniReflection; using System.Diagnostics.Contracts; namespace System.AddIn { [Serializable] internal sealed class HostAdapter : PipelineComponent { private static readonly TypeInfo typeofIContract = new TypeInfo(typeof(System.AddIn.Contract.IContract)); private TypeInfo[] _potentialHAVs; private List _constructors; public HostAdapter(TypeInfo typeInfo, String assemblyLocation) : base(typeInfo, assemblyLocation) { _constructors = new List (); } public List Constructors { get { return _constructors; } } public TypeInfo[] HostAddinViews { get { return _potentialHAVs; } } public override string ToString() { return String.Format(CultureInfo.CurrentCulture, Res.HostAdapterToString, Name, BestAvailableLocation); } internal override bool Validate(TypeInfo type, Collection warnings) { _potentialHAVs = FindBaseTypesAndInterfaces(type); if (_potentialHAVs.Length == 0) { return false; } foreach (MiniConstructorInfo ci in type.GetConstructors(true)) { MiniParameterInfo[] pars = ci.GetParameters(); if (pars.Length != 1) { warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.HostAdapterUnusableCtorMultipleParams, type.AssemblyQualifiedName)); continue; } TypeInfo paramType = pars[0].ParameterType; bool success = false; try { if (paramType.IsInterface && (paramType.Implements(typeofIContract))) { _constructors.Add(paramType); success = true; } } catch (FileNotFoundException) { } catch (FileLoadException) { // Can happen for a constructor taking a type that isn't in mscorlib nor System.AddIn.Contract, and // also isn't in any of the directories that we would probe. } if (!success) { warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.HostAdapterUnusableCtorBadParam, type.AssemblyQualifiedName, paramType.FullName)); continue; } } if (_constructors.Count == 0) { warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.HostAdapterNoValidCtors, type.AssemblyQualifiedName)); return false; } return base.Validate(type, warnings); } } } // 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
- UnsafeNativeMethods.cs
- ObjectDataSourceFilteringEventArgs.cs
- WebWorkflowRole.cs
- TextElementEnumerator.cs
- ForeignKeyFactory.cs
- CodeGenerator.cs
- ResourceProviderFactory.cs
- EntityContainerEntitySet.cs
- Quad.cs
- WebBrowserSiteBase.cs
- ToolStripStatusLabel.cs
- StylesEditorDialog.cs
- RuntimeHelpers.cs
- CannotUnloadAppDomainException.cs
- NullableBoolConverter.cs
- DirectoryRootQuery.cs
- RefreshPropertiesAttribute.cs
- EllipseGeometry.cs
- ConfigXmlAttribute.cs
- DataKeyCollection.cs
- XmlMembersMapping.cs
- SafeNativeMemoryHandle.cs
- ProviderConnectionPointCollection.cs
- ContentFileHelper.cs
- shaperfactory.cs
- BaseComponentEditor.cs
- DateTimeValueSerializer.cs
- TrustSection.cs
- ButtonChrome.cs
- AttributeCallbackBuilder.cs
- DiagnosticTrace.cs
- Stackframe.cs
- Vector3DAnimationUsingKeyFrames.cs
- CodeGenerator.cs
- XmlSchemaObject.cs
- CacheRequest.cs
- PreviewKeyDownEventArgs.cs
- ApplicationBuildProvider.cs
- XmlQueryRuntime.cs
- DesignerDataSourceView.cs
- DateTimeUtil.cs
- StrongNamePublicKeyBlob.cs
- RoleGroupCollection.cs
- AdapterDictionary.cs
- ContainerParagraph.cs
- SoapAttributes.cs
- LineSegment.cs
- MenuItem.cs
- ServiceMemoryGates.cs
- SafeCertificateStore.cs
- NavigationProperty.cs
- SafeFileMapViewHandle.cs
- ModelFunction.cs
- CommonObjectSecurity.cs
- IIS7WorkerRequest.cs
- WorkflowDurableInstance.cs
- WSFederationHttpBinding.cs
- MemoryRecordBuffer.cs
- WebCodeGenerator.cs
- MemberRelationshipService.cs
- DefaultWorkflowTransactionService.cs
- DeclarativeCatalogPart.cs
- DataGridViewDataConnection.cs
- ControlIdConverter.cs
- MetadataWorkspace.cs
- ValueChangedEventManager.cs
- XmlFormatExtensionAttribute.cs
- WeakReferenceList.cs
- ThreadStaticAttribute.cs
- ExtensibleClassFactory.cs
- storepermissionattribute.cs
- Double.cs
- Compiler.cs
- DynamicRendererThreadManager.cs
- MouseGestureConverter.cs
- RuntimeCompatibilityAttribute.cs
- Helper.cs
- ExclusiveNamedPipeTransportManager.cs
- Table.cs
- TextLineResult.cs
- SizeConverter.cs
- PageThemeParser.cs
- LoginDesignerUtil.cs
- DataGridPagerStyle.cs
- DefaultShape.cs
- DependencyObjectProvider.cs
- DesignerAutoFormatStyle.cs
- AttributeQuery.cs
- PathTooLongException.cs
- Partitioner.cs
- ContentPosition.cs
- EncryptedKeyIdentifierClause.cs
- ArrayList.cs
- SqlPersonalizationProvider.cs
- XmlSchemaAttributeGroup.cs
- CustomErrorsSection.cs
- Formatter.cs
- FileDataSource.cs
- XslNumber.cs
- CqlParser.cs