Propiedades Públicas en VB.NET
Siiiiiiiiiiiiii, se puede, quien decía que no ?
Para todos aquellos que modificaban el settings.designer.vb eliminando el ReadOnly de las propiedades y creando el set a pedal y haciéndolo cada vez que modificaban un setting va este sencillísimo código con un par de propiedades de ejemplo.
Mantener el Namespace “My” no es obligatorio.
En cualquier parte del proyecto (intellisense de por medio) se escribirá: My.Propiedades.Publicas…….
Copy y Paste lo de abajo y chauuuuuuu.
---------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
Partial Friend Class Propiedades
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As Propiedades = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New Propiedades), Propiedades)
Public Shared ReadOnly Property [Publicas]() As Propiedades
Get
Return defaultInstance
End Get
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("1")> _
Public Property EmpresaId() As Byte
Get
Return CType(Me("EmpresaId"), Byte)
End Get
Set(ByVal value As Byte)
Me("EmpresaId") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("1")> _
Public Property UsuarioId() As Short
Get
Return CType(Me("UsuarioId"), Short)
End Get
Set(ByVal value As Short)
Me("UsuarioId") = value
End Set
End Property
End Class
End Namespace