|
41-60 of 409
Previous
Next |
|
Initializing Class Members
by Rahul Gupta
|
|
Force the Extension of a Class Without Overriding Any Single Method
by Matthew Johnson
|
|
GetAllMembers - Retrieving a hashtable containing all the members in a type
by Francesco Balena
Return a case-insensitive hashtable containing all the members in a type
Note: requires Imports System.Reflection
Example:
Dim ht As Hashtable = GetAllMembers(GetType(String), False)
For Each key As Object In ht.Keys
Dim member As MemberInfo = DirectCast(ht(key), MemberInfo)
Debug.
|
|
How to Write, Use, and Test a Singleton Class
by Elayaraja David
|
|
LoadAssembly - Loading an assembly identified by the path or the partial name
by Francesco Balena
Load an assembly identified by the path or the partial name
Note: requires Imports System.Reflection
Examples:
1) Dim asm As [Assembly] = LoadAssembly("System.Web")
2) Dim asm As [Assembly] = LoadAssembly("C:\MyApp\MyAssembly.dll")
|
|
Adding Design-Time support to your classes
by Marco Bellinaso
If you use VS.NET you know that there are a number of classes that offer visual design-time support, i.e. they can be dragged and dropped on your form, and their properties can be set through the Properties Window. This saves you from writing the instance declaration and the code to set the ...
|
|
Write a Primary Key Class in CMP EJB
by Elayaraja David
|
|
HaveSameValue - Check whether all the input controls have the same property value
by Marco Bellinaso
Return True if all the controls in the input array have the same value for the specified property
Note: requires the GetField function
Example:
Debug.WriteLine(HaveSameValue("Text", TextBox1, Button1, Button2))
Debug.WriteLine(HaveSameValue("ForeColor", Button1, Button2))
Button1.ForeColor ...
|
|
SetPropertyEx - Set a property of multiple controls/objects
by Marco Bellinaso
Set a property of multiple controls/objects in a single step, and return True if successful
Note: requires the SetProperty function
Example: SetPropertyEx("Text", "OK!!!", TextBox1, Button1, Button2)
|
|
AddRemoveEventHandler - Add or remove an event handler through reflection
by Francesco Balena
Add or remove an event handler through reflection, and return True if successful
Examples:
add an event handler for Button1's Click event
AddRemoveEventHandler(Button1, "Click", New EventHandler(AddressOf OnButton1Click))
remove an event handler for Button1's Click event
AddR
|
|
GetField - Retrieving the value of a public field via reflection
by Francesco Balena
Return the value of the public field with the specified name, defined inside the obj object
Note: requires Imports System.Reflection
Example:
Public TestField As String = "hello"
...
MessageBox.Show(GetField(Me, "TestField", ""))
|
|
GetProperty - Reading a property via reflection
by Francesco Balena
Read a property via reflection or return a default value
Example: MessageBox.Show(GetProperty(Button1, "Text", ""))
|
|
InvokeMethod - Invoking a method via reflection
by Francesco Balena
Invoke a method via reflection and return its result - return null if method doesn't exist or throws
Note: requires Imports System.Reflection
Example:
Function GetCompleteName(ByVal firstName As String, ByVal lastName As String)
Return lastName & ", " & firstName
End Function
...
MessageBox.
|
|
IsMemberSupported - Check whether an object supports a member with the specified name
by Marco Bellinaso
Check whether an object supports a member with the specified name
Examples:
Debug.WriteLine(IsMemberSupported(Button1, "BackColor")) ' => True
Debug.WriteLine(IsMemberSupported(Button1, "Focus")) ' => True
Debug.WriteLine(IsMemberSupported(Button1, "TextColor")) ' => False
Debug.
|
|
SetProperty - Setting a property via reflection
by Francesco Balena
Set a property via reflection and return True if successful
Example: SetProperty(Button1, "Text", "Click me")
|
|
Extend Swing's JTable to Support Rendering of Different Cell Types in a Column
by Lara D'Abreo
|
|
LoadBinaryData - Deserializing an object from a file in binary format
by Marco Bellinaso
Deserialize an object from a file in binary format
It can handle types that the SOAP serialization can't
Requires:
Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary
|
|
SaveBinaryData - Serializing an object to file in binary format
by Marco Bellinaso
Serialize an object to file in binary format
It can handle types that the SOAP serialization can't
Requires:
Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary
|
|
Abstract classes as interfaces
by Danny Kalev
In software design, you should plan ahead the interface of a class hierarchy to make sure that all related concrete classes share a common interface. This can be achieved by using abstract ...
|
|
Dynamically setting an event handler for a class' event via reflection
by Francesco Balena
Here it is some code that shows how to use reflection to dynamically set an event handler for a class' event.
Sub TestSub()
' create a Person
Dim pe As New Person()
' get a reference to the EventInfo for this object
Dim peEv As EventInfo = pe.GetType.
|
|
41-60 of 409
Previous
Next |