programming4us
programming4us
ENTERPRISE

Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 3) - Metadata in Windows Runtime - Namespaces

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Namespaces

As you experienced in the previous exercise, Windows Runtime types have hierarchical names. For example, the enumeration with the resolution scale values has the full name of Windows.Graphics.Display.ResolutionScale. The last tag of this name is the type’s simple name, and prefix tags form the namespace hierarchy. The top-level namespace is Windows. It has an embedded namespace, Graphics, and Graphics embeds Display.


NOTE .NET, Java, and C++ programmers are familiar with the concept of namespaces. Windows Runtime uses the namespace with exactly the same semantics as applied in .NET.

Namespaces are important concepts when managing the vast amount of types you utilize while creating your applications. If you had only type names poured into a big pool, it would be very difficult to find them and guess what type is the appropriate one for a certain task.

Another issue would be naming types. You cannot guarantee that no one else uses the same type name that you use. For example, when you name your type Circle, there is a great likelihood that someone else will use the same name. If you buy a package of custom UI components, there already may be a Circle type. How will your application know which Circle type to use at a certain location of the source code, and whether you intend to use your own Circle or the purchased one?

Namespaces are great constructs that help you to group objects into categories. Using well-designed namespace hierarchies makes you more productive, because you can find appropriate types for a certain task easily. For example, when you are about to display images on the screen, first you will look them in the Windows.Graphics.Imaging namespace, because its name suggest that such types exist there.

Namespaces also help you avoid conflicting type names. If you put your own types into their own namespaces (for example, you put Circle into the MyCompany.Shapes namespace), they won’t clash with types from other programmers or companies.

Types can have pretty long full names. Fortunately, all programming languages that manage the concept of namespaces offer some kind of constructs to avoid full names, and allow writing only the simple names. Let’s take a look at a few examples.

C# offers the using clause to help resolve type names:

using Windows.UI.Xaml;

namespace MyAppNamespace
{
class MyClass: UserControl
{
public MyClass()
{
// ...
selectedItem = this.FindName(itemName) as ListBoxItem;
// ...
}
}
}

Visual Basic offers the same construct with the Imports keyword:

Imports Windows.UI.Xaml

Namespace MyAppNamespace

Class MyClass
Inherits UserControl

Public Sub New()
' ...
selectedItem = TryCast(Me.FindName(itemName), ListBoxItem)
' ...
End Sub
End Class
End Namespace

It is not surprising that C++ offers the same concept with the using namespace clause, too:

using namespace Windows::UI::Xaml;

namespace MyAppNamespace
{
class MyClass: UserControl
{
public MyClass()
{
// ...
selectedItem = dynamic_cast<ListBoxItem^>(this->FindName(itemName);
// ...
}
}
}

The using, Imports, and using namespace constructs in C#, Visual Basic, and C++, respectively, instruct the compiler that type names should be looked up in the specified namespaces. This mechanism allows writing only ListBoxItem type names in your programs, because the compiler will check the Windows.UI.Xaml namespace as well. Otherwise, you would have to write the full Windows.UI.Xaml.ListBoxItem name.


NOTE Of course, objects in Windows Runtime namespaces can be accessed from JavaScript programs, too.
Other  
  •  Windows 8 Architecture from a Developer’s Point of View : Windows 8 Development Architecture
  •  Windows 7 : Programming KMDF Hardware Driver - Mapping Resources - Code to Map Resources
  •  Windows 7 : Programming KMDF Hardware Driver - Handling Interrupts (part 2) - Deferred Processing for Interrupts
  •  Windows 7 : Programming KMDF Hardware Driver - Handling Interrupts (part 1) - Code for EvtInterruptIsr Callback
  •  Windows 7 : Programming KMDF Hardware Driver - Support Device Interrupts (part 2) - Post-Interrupt Enable and Pre-Interrupt Disable Processing
  •  Windows 7 : Programming KMDF Hardware Driver - Support Device Interrupts (part 1) - Creating an Interrupt Object,Enabling and Disabling Interrupts
  •  Microsoft Exchange Server 2010 : Managing Data and Database Availability Groups - Content Indexing
  •  Microsoft Exchange Server 2010 : Creating and Managing Database Availability Groups (part 5) - Switching over Servers and Databases
  •  Microsoft Exchange Server 2010 : Creating and Managing Database Availability Groups (part 4) - Configuring Database Availability Group Properties
  •  Microsoft Exchange Server 2010 : Creating and Managing Database Availability Groups (part 3) - Managing Database Availability Group Networks
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us