Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CompositeControl.cs
- EdmType.cs
- GridSplitterAutomationPeer.cs
- TabRenderer.cs
- TextParagraphProperties.cs
- XmlNodeComparer.cs
- EventlogProvider.cs
- EntityException.cs
- ParameterDataSourceExpression.cs
- HandleExceptionArgs.cs
- Container.cs
- HierarchicalDataBoundControl.cs
- LogLogRecord.cs
- XamlWrappingReader.cs
- Vector.cs
- Random.cs
- SystemResources.cs
- UIPropertyMetadata.cs
- SmtpDigestAuthenticationModule.cs
- MULTI_QI.cs
- RawTextInputReport.cs
- Transform.cs
- X509ChainElement.cs
- AspNetHostingPermission.cs
- HostedHttpContext.cs
- FormView.cs
- ApplicationDirectoryMembershipCondition.cs
- AspCompat.cs
- UserPersonalizationStateInfo.cs
- SocketAddress.cs
- validationstate.cs
- HotCommands.cs
- TextDecorations.cs
- ManifestResourceInfo.cs
- SystemColors.cs
- ContractsBCL.cs
- TableRow.cs
- Margins.cs
- DelegatingTypeDescriptionProvider.cs
- BookmarkEventArgs.cs
- DbParameterHelper.cs
- _DigestClient.cs
- PrtCap_Builder.cs
- SvcFileManager.cs
- XmlKeywords.cs
- httpserverutility.cs
- View.cs
- SortAction.cs
- NetSectionGroup.cs
- ParserStack.cs
- StringUtil.cs
- RuntimeArgumentHandle.cs
- DispatcherFrame.cs
- TimeoutException.cs
- filewebrequest.cs
- WebPartTransformerAttribute.cs
- VariableValue.cs
- DotAtomReader.cs
- _ConnectOverlappedAsyncResult.cs
- Line.cs
- RemotingAttributes.cs
- CheckBoxList.cs
- SynchronizedInputProviderWrapper.cs
- ServiceDescriptionData.cs
- BitmapImage.cs
- InputMethodStateTypeInfo.cs
- UInt32Storage.cs
- AttachmentService.cs
- OperationContractGenerationContext.cs
- TableAdapterManagerNameHandler.cs
- InputLanguage.cs
- MouseBinding.cs
- AxDesigner.cs
- RequestCacheManager.cs
- TextEditorCopyPaste.cs
- GeneralTransform.cs
- TemplateXamlParser.cs
- X509Certificate.cs
- MessageQueueAccessControlEntry.cs
- RemoteWebConfigurationHostServer.cs
- FtpWebResponse.cs
- ServiceOperationInfoTypeConverter.cs
- SmiEventStream.cs
- SevenBitStream.cs
- ContainerVisual.cs
- BStrWrapper.cs
- DateTimeOffsetConverter.cs
- ProfileSection.cs
- EventArgs.cs
- InstancePersistenceContext.cs
- UserNamePasswordServiceCredential.cs
- StdRegProviderWrapper.cs
- ToolStripContentPanel.cs
- GuidelineSet.cs
- AttributeEmitter.cs
- PointHitTestResult.cs
- AmbientValueAttribute.cs
- SqlGatherConsumedAliases.cs
- GeometryCombineModeValidation.cs
- DataGridViewHitTestInfo.cs