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
- CodeTypeDelegate.cs
- ProtocolsConfigurationHandler.cs
- AsymmetricSecurityProtocolFactory.cs
- Logging.cs
- SerTrace.cs
- UnsafeNativeMethods.cs
- NamespaceEmitter.cs
- PeerNameRecordCollection.cs
- MultiAsyncResult.cs
- xmlfixedPageInfo.cs
- DataGridViewToolTip.cs
- safex509handles.cs
- Popup.cs
- AttachmentService.cs
- ItemCheckEvent.cs
- DateTimeConstantAttribute.cs
- InvalidEnumArgumentException.cs
- WorkflowRuntimeServiceElementCollection.cs
- TextEditor.cs
- ChangeToolStripParentVerb.cs
- DtrList.cs
- HtmlMeta.cs
- OrthographicCamera.cs
- LayoutSettings.cs
- GenericAuthenticationEventArgs.cs
- BamlTreeMap.cs
- ProfileSettingsCollection.cs
- CounterSet.cs
- XmlComplianceUtil.cs
- OleDbErrorCollection.cs
- NetSectionGroup.cs
- AvTraceDetails.cs
- ConfigXmlWhitespace.cs
- WindowsTab.cs
- ThaiBuddhistCalendar.cs
- TextFormatterImp.cs
- ParameterRetriever.cs
- TCPListener.cs
- TextFragmentEngine.cs
- MimeReturn.cs
- LiteralTextParser.cs
- ByteStack.cs
- RoamingStoreFileUtility.cs
- MultiTargetingUtil.cs
- BlockCollection.cs
- StaticExtensionConverter.cs
- GcHandle.cs
- ClientConvert.cs
- CursorInteropHelper.cs
- SecurityContextSecurityToken.cs
- DataServiceHostFactory.cs
- ContentElement.cs
- BamlBinaryReader.cs
- Clause.cs
- BindingFormattingDialog.cs
- Int32AnimationBase.cs
- QueueProcessor.cs
- ConsoleCancelEventArgs.cs
- XmlSchemaAttributeGroup.cs
- StrokeNodeEnumerator.cs
- RawKeyboardInputReport.cs
- TextRange.cs
- ISO2022Encoding.cs
- ScrollItemProviderWrapper.cs
- BamlReader.cs
- IsolatedStorageFile.cs
- fixedPageContentExtractor.cs
- ScopeElement.cs
- ConfigurationProperty.cs
- SqlUtils.cs
- SafeIUnknown.cs
- DbMetaDataColumnNames.cs
- Point4D.cs
- KeyConverter.cs
- BrowserInteropHelper.cs
- Collection.cs
- BuildProvider.cs
- DataControlField.cs
- PowerStatus.cs
- FormClosedEvent.cs
- ErrorStyle.cs
- JsonDeserializer.cs
- PixelFormatConverter.cs
- PropertyChangingEventArgs.cs
- Aggregates.cs
- Int32Converter.cs
- RegexMatchCollection.cs
- ListViewGroupConverter.cs
- ToolBarPanel.cs
- XmlValidatingReaderImpl.cs
- DBPropSet.cs
- MetadataStore.cs
- XmlSchemaAppInfo.cs
- ResourceAssociationTypeEnd.cs
- HttpModulesSection.cs
- TextTreeTextBlock.cs
- WasNotInstalledException.cs
- DataStreams.cs
- ControlPropertyNameConverter.cs
- XslTransform.cs