Question

Je voudrais savoir comment accéder à une méthode protégée.

J'ai un contrôle WebBrowser (Awesomium) qui a de nombreuses méthodes protégées.

Je créé un navigateur à onglets avec ce WebControl dans un WinForm.

Maintenant, je ne peux pas utiliser par exemple InjectKeyboard méthode parce que c'est protégé.

Ceci est la méthode:

//     Injects a keyboard event.
//
// Parameter:
//   keyEvent:
//     The keyboard event to inject. You'll need to initialize the members of the
//     passed Awesomium.Core.WebKeyboardEvent, yourself.
//
// Note:
//      Awesomium.Windows.Forms.WebControl handles this internally. Inheritors do
//     not need to call this method unless they implement custom logic.  This method
//     bypasses settings of the Awesomium.Windows.Forms.WebControl.InputController.
//      For performance reasons, no validity check is performed when calling protected
//     members.  Inheritors should perform any such checks (see Awesomium.Windows.Forms.WebControl.IsLive),
//     before calling these members.

protected void InjectKeyboardEvent(WebKeyboardEvent keyEvent);

Alors que dans l'API Link est

Pourquoi ont-ils protéger cette méthode et comment puis-je utiliser?

Était-ce utile?

La solution

Hériter de cette classe et d'exposer la méthode si vous devez (tel que proposé par le commentaire ci-dessus la méthode).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top