jueves, 30 de julio de 2020

FUNCIONES DECLARADAS con Shared

Las funciones declaradas con Shared quieren decir que son definidas a nivel de clase no de instancia, por lo tanto la invocas directo con el nombre de la clase que la contenga, sin usar el "new"

por ejmeplo si tienes la clase

Public Class Prueba

  Public  Shared Function GetValor() As Int

      Return 10

  End Function

End Class

desde tu formulario lo usarias

TextBox1.Text = CStr(Prueba.GetValor())

o sea directamente nombre de la clase y nombre del metodo


Ejemplo de declaraciones de shared en la clase PermisosControles  del aplicativo seguridad plus.




Public Class ControlesPermisos

    Inherits DevExpress.XtraEditors.XtraForm


#Region "Declaraciones"


    Private Shared mDtListadoControles As New DataTable

    Private Shared WithEvents RibbonControl As DevExpress.XtraBars.Ribbon.RibbonControl

    Private Shared Solapas As DevExpress.XtraBars.Ribbon.RibbonPage

    Private Shared Grupo As DevExpress.XtraBars.Ribbon.RibbonPageGroup

    Private Shared Category As DevExpress.XtraBars.Ribbon.RibbonPageCategory

    Private Shared Boton As DevExpress.XtraBars.BarItemLink

    Private Shared ObjReqRN As New ReqRN


    Private Shared CotrolTab = New DevExpress.XtraTab.XtraTabControl

    Private Shared PageTab = New DevExpress.XtraTab.XtraTabPage

    'Private ColeccionTab = New DevExpress.XtraTab.XtraTabPageCollection

 

#End Region



#Region "Funciones"

    Public Shared Sub RegistrarCtrlMenues(ByRef unForm As Form)


        Dim Pagina As DevExpress.XtraBars.Ribbon.RibbonPage

        Dim Grupo As DevExpress.XtraBars.Ribbon.RibbonPageGroup

        Dim CntGrupo As Integer = 0

        Dim Boton As DevExpress.XtraBars.BarItemLink

        Dim CntBoton As Integer = 0

        Dim DT_Pagina, DT_Boton As New DataTable

        Dim idAplicacion As Integer = My.Application.IDAPLICACION



        Dim _descripcion As String

        Dim _descripcionUNO As String

        For Each Pagina In Principal.RBMenu.Pages

            ObjReqRN = New ReqRN

            'DT_Pagina =

            ObjReqRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_CONTROL_POR_APLICACION(idAplicacion, Pagina.Name.ToString, Pagina.Name.ToString)

            For Each Grupo In Pagina.Groups

                _descripcionUNO = Pagina.Name + "/" + Grupo.Name

                ObjReqRN = New ReqRN

                ObjReqRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_CONTROL_POR_APLICACION(idAplicacion, Grupo.Name.ToString, _descripcionUNO)

                For Each Boton In Grupo.ItemLinks

                    _descripcion = Pagina.Name + "/" + Grupo.Name + "/" + Boton.Item.Name ' REGISTRA LOS GRUPOS TAMBIEN

                    ' _descripcion = Pagina.Name + "/" + Boton.Item.Name ' AQUI NO REGISTRA LOS GRUPOPS SOLO LOS BOTONES

                    ObjReqRN = New ReqRN

                    ObjReqRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_CONTROL_POR_APLICACION(idAplicacion, Boton.Item.Name.ToString, _descripcion)

                Next 'Links

            Next 'Grupo

        Next 'Pagina


    End Sub




No hay comentarios:

Publicar un comentario

Los mail de oulook no se pueden reenviar.

 cuando en el asunto poseen un caracter especial por ejemplo @#$ los correos no salen y no te muestra ningun correo de rebote, especialmente...