WebPart.EnsureInterfaces - Méthode
Remarque : cette API est désormais obsolète.
Fournit une notification pour un composant WebPart connectable qu'elle doit garantir tous ses interfaces sont inscrits en utilisant la méthode RegisterInterface .
Espace de noms : Microsoft.SharePoint.WebPartPages
Assembly : Microsoft.SharePoint (dans Microsoft.SharePoint.dll)
Syntaxe
'Déclaration
<ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")> _
Public Overridable Sub EnsureInterfaces
'Utilisation
Dim instance As WebPart
instance.EnsureInterfaces()
[ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")]
public virtual void EnsureInterfaces()
Remarques
Lors du développement d'un composant WebPart connectable, vous devez substituer la méthode EnsureInterfaces . Substitution de cette méthode n'est pas nécessaire lorsque vous développez un composant WebPart qui ne prend pas en charge les connexions.
Exemples
L'exemple de code suivant illustre une méthode substituée EnsureInterfaces . Cet exemple de code fait partie d'un exemple plus complet fourni pour l'interface ICellProvider .
Pour une vue d'ensemble des étapes de la création d'un composant WebPart connectable, voir Creating a Connectable Web Part.
// Step #4: Override the EnsureInterfaces() method and call the RegisterInterface method.
public override void EnsureInterfaces()
{
// If your Web Part is installed in the bin directory and the Code Access Security (CAS) setting doesn't
// allow Web Part Connections, an exception will be thrown. To allow your Web Part to behave
// well and continue working, a try/catch block should be used when attempting to register interfaces.
// Web Part Connections will only work if the level attribute of the <trust> tag in the
// web.config file is set to WSS_Minimal, WSS_Medium, or Full. By default a new SharePoint site
// is installed with the trust level set to WSS_Minimal.
try
{
// Register the ICellProvider Interface
// <param name="interfaceName">Friendly name of the interface that is being implemented.
// It must be unique on the client so the _WPQ_ token is used.</param>
// <param name="interfaceType">Specifies which interface is being implemented.</param>
// <param name="maxConnections">Defines how many times this interface can be connected.</param>
// <param name="runAtOptions">Determines where the interface can run.</param>
// <param name="interfaceObject">Reference to the object that is implementing this interface.</param>
// <param name="interfaceClientReference">Name used to reference the interface on the client.
// It must be unique on the client so the _WPQ_ token is used.</param>
// <param name="menuLabel">Label for the interface which appears in the UI</param>
// <param name="description">Description of the interface which appears in the UI</param>
// <param name="allowCrossPageConnection">Specifies if the interface can connect to a Web Part
// on a different page. This is an optional parameter with a default of false. Note that only some
// server side interfaces are allowed to connect across pages by the Web Part infrastructure.
// The ICellProvider interface is not allowed to connect across pages.</param>
RegisterInterface("MyCellProviderInterface_WPQ_", //InterfaceName
InterfaceTypes.ICellProvider, //InterfaceType
WebPart.UnlimitedConnections, //MaxConnections
ConnectionRunAt.Server, //RunAtOptions
this, //InterfaceObject
"CellProviderInterface_WPQ_", //InterfaceClientReference
"Provide Cell To", //MenuLabel
"Provides a single value to a cell consumer Web Part."); //Description
}
catch(SecurityException se)
{
_registrationErrorOccurred = true;
}
}
' Step #4: Override the EnsureInterfaces() method and call the RegisterInterface method.
Public Overrides Sub EnsureInterfaces()
' If your Web Part is installed in the bin directory and the Code Access Security (CAS) setting doesn't
' allow Web Part Connections, an exception will be thrown. To allow your Web Part to behave
' well and continue working, a try/catch block should be used when attempting to register interfaces.
' Web Part Connections will only work if the level attribute of the <trust> tag in the
' web.config file is set to WSS_Minimal, WSS_Medium, or Full. By default a new SharePoint site
' is installed with the trust level set to WSS_Minimal.
Try
' Register the ICellProvider Interface
' <param name="interfaceName">Friendly name of the interface that is being implemented.
' It must be unique on the client so the _WPQ_ token is used.</param>
' <param name="interfaceType">Specifies which interface is being implemented.</param>
' <param name="maxConnections">Defines how many times this interface can be connected.</param>
' <param name="runAtOptions">Determines where the interface can run.</param>
' <param name="interfaceObject">Reference to the object that is implementing this interface.</param>
' <param name="interfaceClientReference">Name used to reference the interface on the client.
' It must be unique on the client so the _WPQ_ token is used.</param>
' <param name="menuLabel">Label for the interface which appears in the UI</param>
' <param name="description">Description of the interface which appears in the UI</param>
' <param name="allowCrossPageConnection">Specifies if the interface can connect to a Web Part
' on a different page. This is an optional parameter with a default of false. Note that only some
' server side interfaces are allowed to connect across pages by the Web Part infrastructure.
' The ICellProvider interface is not allowed to connect across pages.</param>
RegisterInterface("MyCellProviderInterface_WPQ_", InterfaceTypes.ICellProvider, WebPart.UnlimitedConnections, ConnectionRunAt.Server, Me, "CellProviderInterface_WPQ_", "Provide Cell To", "Provides a single value to a cell consumer Web Part.") 'Description - MenuLabel - InterfaceClientReference - InterfaceObject - RunAtOptions - MaxConnections - InterfaceType - InterfaceName
Catch se As SecurityException
_registrationErrorOccurred = True
End Try
End Sub