del método WebPart.EnsureInterfaces
NOTA: esta API está ahora obsoleta.
Proporciona una notificación para un elemento Web conectable que debe asegurar todos sus interfaces se registran utilizando el método RegisterInterface .
Espacio de nombres: Microsoft.SharePoint.WebPartPages
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
<ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")> _
Public Overridable Sub EnsureInterfaces
'Uso
Dim instance As WebPart
instance.EnsureInterfaces()
[ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")]
public virtual void EnsureInterfaces()
Comentarios
Al desarrollar un elemento Web conectable debe invalidar el método EnsureInterfaces . Reemplazar este método no es necesario cuando está desarrollando un elemento Web que no admite conexiones.
Ejemplos
En el ejemplo de código siguiente se muestra un método invalidado EnsureInterfaces . Este ejemplo de código forma parte de un ejemplo más extenso de la interfaz ICellProvider .
Para obtener información general de los pasos de la creación de un elemento Web conectable, vea 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