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
- TextFormatter.cs
- AppDomainAttributes.cs
- StandardOleMarshalObject.cs
- PipelineComponent.cs
- EventTrigger.cs
- WorkflowCompensationBehavior.cs
- ExpressionVisitor.cs
- HttpsHostedTransportConfiguration.cs
- CodeParameterDeclarationExpressionCollection.cs
- WmlTextViewAdapter.cs
- SymmetricKeyWrap.cs
- DataGridAddNewRow.cs
- Icon.cs
- ResourcePermissionBaseEntry.cs
- DirectionalLight.cs
- NonParentingControl.cs
- TextContainerChangedEventArgs.cs
- UnmanagedMemoryStreamWrapper.cs
- ScalarOps.cs
- SocketElement.cs
- HtmlInputText.cs
- NumericExpr.cs
- ByteAnimationBase.cs
- DataBindingExpressionBuilder.cs
- StrongName.cs
- PropertyTab.cs
- InputMethodStateChangeEventArgs.cs
- CaseInsensitiveHashCodeProvider.cs
- Emitter.cs
- TriggerAction.cs
- RegexNode.cs
- StylesEditorDialog.cs
- HostingEnvironmentException.cs
- MDIControlStrip.cs
- WindowsListViewItemCheckBox.cs
- CheckBoxPopupAdapter.cs
- CryptoStream.cs
- TreeViewCancelEvent.cs
- CatalogZone.cs
- XmlJsonWriter.cs
- InstanceData.cs
- SurrogateEncoder.cs
- TextView.cs
- XPathNavigator.cs
- BulletChrome.cs
- WorkflowMarkupSerializerMapping.cs
- MetaDataInfo.cs
- SQLStringStorage.cs
- TypeConverters.cs
- NavigationFailedEventArgs.cs
- AccessedThroughPropertyAttribute.cs
- BamlRecords.cs
- DefaultHttpHandler.cs
- AttributeAction.cs
- IteratorFilter.cs
- NGCSerializer.cs
- SiteMap.cs
- ConfigXmlElement.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- BooleanProjectedSlot.cs
- RemoteWebConfigurationHostServer.cs
- CodePropertyReferenceExpression.cs
- __Filters.cs
- ILGenerator.cs
- EntityDataSourceValidationException.cs
- PreProcessInputEventArgs.cs
- safelinkcollection.cs
- Latin1Encoding.cs
- TcpTransportElement.cs
- RepeatButton.cs
- SafePEFileHandle.cs
- ConfigurationSettings.cs
- ServiceAuthorizationBehavior.cs
- RelationshipWrapper.cs
- loginstatus.cs
- XpsSerializerWriter.cs
- InvalidFilterCriteriaException.cs
- UITypeEditor.cs
- InternalResources.cs
- CloseSequenceResponse.cs
- Line.cs
- IndentedTextWriter.cs
- SamlAssertionKeyIdentifierClause.cs
- SizeKeyFrameCollection.cs
- XpsDigitalSignature.cs
- SystemException.cs
- HtmlFormWrapper.cs
- SchemaManager.cs
- ReachUIElementCollectionSerializer.cs
- ThumbAutomationPeer.cs
- WaitHandle.cs
- XmlCompatibilityReader.cs
- FileDialog_Vista_Interop.cs
- ImageAnimator.cs
- EventLogException.cs
- ExpressionEditorAttribute.cs
- HandleTable.cs
- ProtocolsConfiguration.cs
- Listbox.cs
- StylusDownEventArgs.cs