Pages

Friday, March 1, 2013

Design patterns

Design patterns are mainly of three types 
 
 
Creational patterns
Creational patterns are ones that 
create objects for you, rather 
than having you instantiate objects directly. This gives your 
program more flexibility in deciding which 
objects need to be created for a given case.
 
Structural patterns
Structural patterns help you compose 
groups of objects into larger structures, 
such as complex user interfaces or 
accounting data.
 
Behavioral patterns
Behavioral patterns help you define the 
communication between objects in your 
system and how the flow is controlled in 
a complex program.
 
 
 
 

Sunday, February 24, 2013

Difference between Select and SelectMany in LINQ

The difference between select and selectMany can be seen when we are accessing data from multilevel classes.

Download Sample Code – 2.62 Kb

In the below example we shall see what exactly is the difference while accessing the properties.

When we access some data by using select it gives us the data that is grouped under the parent (i.e gives multiple arrays). To access the output we need to loop twice.

////This code shows how to use Select()             
var Query2 = Builders.Select(Build => Build.Locations);
 
// Notice that two foreach loops are required to iterate through
// the results because the query returns a collection of arrays.            
foreach (List<String> BuildList in Query2)
{
        foreach (string builds in BuildList)
        {
                Console.WriteLine(builds);
        }
 
        Console.WriteLine();
}

But using the same sample when we use select many it gives the selected items in one array(i.e it give the output as it is joining all the output from select command)

// Query using SelectMany().            
var query1 = Builders.SelectMany(Build => Build.Locations);
 
// Only one foreach loop is required to iterate through the
// results because it is a one-dimensional collection.
// Select many joins the output of all the sub collections in to one.            
foreach (string Loc in query1)
        Console.WriteLine(Loc);

 

Wednesday, February 20, 2013

WPF Architecture

For every new technology, it is very essential to have a clear idea about its architecture. So before beginning your application, you must grab a few concepts. If you would not like to know WPF in detail, please skip this section. As mentioned earlier, WPF is actually a set of assemblies that build up the entire framework. These assemblies can be categorized as:
Managed Layer
UnManaged Layer
Core API

Managed Layer: Managed layer of WPF is built using a number of assemblies. These assemblies build up the WPF framework, communicate with lower level unmanaged API to renderits  content. The few assemblies that comprise the WPF framework are:
PresentationFramework.dll: Creates the top level elements like layout panels, controls, windows, styles, etc.

PresentationCore.dll: It holds base types such as UIElement, Visual from which all shapes and controls are Derived in PresentationFramework.dll.

WindowsBase.dll: They hold even more basic elements which are capable of being used outside the WPF environment like Dispatcher object, Dependency Objects. I will discuss each of them later.

Unmanaged Layer (milcore.dll): The unmanaged layer of WPF is called milcore or Media Integration Library Core. It basically translates the WPF higher level objects like layoutpanels,buttons, animation, etc. into textures thatDirect3D expects. It is the main rendering engine of WPF.

WindowsCodecs.dll: This is another low level API which is used for imaging support in WPF applications.WindowsCodecs.dll comprises a number of codecs which encode / decode images into vector graphics that would be rendered into WPF screen.

Direct3D: It is the low level API in which the graphics of WPF is rendered.

User32: It is the primary core API which every program uses. It actually manages memory and process separation.

GDI & Device Drivers: GDI and Device Drivers are specific to the operating system which is also used from the application to access low level APIs.
indurotech.jp@gmail.com
In the above figure, you can see how different framework elements communicate between one another.