14.1. What Is the My Namespace?

The My namespace is actually a set of wrapper classes and structures that encapsulate complete sets of .NET classes and automated object instantiations and initializations. The structure of My, shown in Figure 14-1, shows that it is similar to a real namespace hierarchy. These classes mean that rather than creating an instance of a system class, initializing it with the values you need, and then using it for the specific purpose you need it for, you can simply refer to the corresponding My class and let .NET work out what needs to happen behind the scenes to achieve the same result. Consider more complex tasks that require you to create up to dozens of classes to do something simple, such as establish user credentials or navigate through the file system efficiently. Then consider the same one-class access that My provides for such functions, and you begin to see what can be achieved.

Figure 14.1. Figure 14-1

Ten major classes compose the top level of My. Each class has a number of methods and properties that you can use in your application, and two of them, My.Application and My.Computer, have additional subordinate classes in the namespace-like structure, which in turn have their own methods and properties. In a moment you'll see what each of them can do in detail, but here's a quick reference:

Table 14.1. Classes in the Top Level of My
My ObjectPurpose
My.ApplicationUsed to access information about the application, My.Application also exposes certain events that are application-wide. In addition, this class has two subordinate My classes: My.Application.Log and My.Application.Info.
My.ComputerDeals with the computer system in which the application is running, and is the most extensive My object. In fact, the My.Computer class has a total of 11 subordinate My classes, ranging from My.Computer.Audio to My.Computer.Screen, with classes in between that deal with things such as the file system and the network.
My.FormsProvides quick access to the forms in the current application project
My.LogGives you direct access to the application log so you can interact with it more easily than before
My.RequestRelated to web page calls, the My.Request class, along with My.Response and My.WebServices, can be used to simplify your calls and interactions in web-based applications, and is the class used to hold the calls to the web service.
My.ResourcesEnables you to easily access the various resources in your application
My.ResponseHolds the web page response. See My.Request for more information.
My.SettingsUsed to access both application-wide and user-specific settings
My.UserUsed to determine the user's current login profile, including security information
My.WebServicesGives you easy access to all the web services referenced in the current application project

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.232.189