Saturday, February 18, 2012

.Net Framework 3.0

.Net Framework 3.0
With the introduction of .net framework 2.0, application development has seen a huge upside in terms of look and feel and security.
The .NET Framework 3.0 (formerly known as WinFX) released in late 2006. Applications built on this new version of the Framework can be created with Visual Studio 2005, making it feel familiar to most Windows developers.
But the .NET Framework 3.0 is also an evolution, adding more to what version 2.0 of the Framework already provides. Framework 3.0 will be available for Windows Vista, Windows Server 2003, and Windows XP.
Most of the classes in the .NET Framework version 2.0 are unchanged in 3.0/3.5. The key differences for .NET 3.0 are new libraries that offer completely new sets of functionality.
 There are 4 major libraries in the .NET Framework 3.0, which are added to the existing 2.0 Framework libraries.
These 4 libraries are
1.       Windows Presentation Foundation (WPF)
2.       Windows Communication Foundation (WCF)
3.       Windows Workflow Foundation (WF - had to drop one of the W's for legal reasons)
4.       Windows CardSpace




Windows Presentation Foundation (WPF)

WPF gives you a way to differentiate your user experiences. We say UX rather than just UI, as we are talking about more than just a snappy interface. It's about a better user interaction with the application. WPF is also a better experience for developers that want cutting edge UI. Things like having a unified API mean you don't have to learn several APIs to blend media with documents and text, for example. Also, XAML provides a clean, declarative language to describe UI, and to offer designers and developers bridge to share content.

Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF) is a framework for building service-oriented applications. WCF offers a way to do secure, reliable, transacted services using a variety of protocols and bindings.  

Find more details on implementing and using WCF service in my next article on WCF (Sample).

Windows Workflow Foundation (WF)
It is an engine for building applications with workflow. WF serves as the kernel of workflow, handling threading, persistence and other plumbing tasks. WF brings a consistent, component-oriented philosophy to workflow and is already at the core of Microsoft's business in products like SharePoint.

There are two types of workflows provided by WWF.
·         Sequential Workflow
·         State-machine workflow
WWF is made up of the following components:
·         Base Activity Library
·         Runtime Engine
·         Runtime Services
·         Hosts




Windows CardSpace (WS)
Windows CardSpace, originally code-named "InfoCard" is an approach towards representing each identity as a distinct information card.
CardSpace is a solution that lets you pass authentication information around via encrypted tokens rather than typing UID and PWD all over the place. By using visual cueing for recognition, and explicitly differentiating between the relying party and the identity provider, it offers a quick way to effectively authenticate using the WS-* standards. It has a simple, easy to use UI as well. It virtually eliminates phishing problems, and keeps you from having to memorize more and more passwords.


Recourse:

Leia Mais…

.Net Framework 2.0 -----------The Evolution


.Net Framework ….. The Evolution
.net 1.0: Released in the year 2002. With basic support to web and windows development
The .net 2.0 framework is considered to the biggest step in itself. There is a basic question around our minds about the difference in the   .net framework till now.
This is simple effect to clear few of the confusions.

What’s new in .net 2.0 framework

Vs.

What’s new in ASP.net 2.0?????

Let’s first see few of the new features in .net 2.0 framework:
1.      64 bit support:

New support for 64-bit applications enables users to build managed code libraries or easily use unmanaged code libraries on 64-bit computer

2.      Access Control List Support :
An access control list (ACL) is used to grant or revoke permission to access a resource on a computer. New classes have been added to the .NET Framework that allows managed code to create and modify an ACL. New members that use an ACL have been added to the I/O, registry, and threading classes.

3.      ADO.NET
ü  User-defined types (UDT)
ü  Asynchronous database operations
ü  XML data types
ü  Large value types
ü  Snapshot isolation
For more details: What's New in ADO.NET.
4.      Console Class Additions

5.      Data Protection API
The new Data Protection API (DPAPI) includes four methods that allow applications to encrypt passwords, keys, connections strings, and so on, without calling platform invoke. You can also encrypt blocks of memory on computers running Windows Server 2003 or later operating systems.




6.      FTP Support
Applications can now access File Transfer Protocol resources using the WebRequest, WebResponse, and WebClient classes.

7.      Generics and Generic Collections

The .NET Framework 2.0 introduces generics to allow you to create flexible, reusable code. Language features collectively known as generics act as templates that allow classes, structures, interfaces, methods, and delegates to be declared and defined with unspecified, or generic type parameters instead of specific types. Actual types are specified later when the generic is used. Several namespaces, such as System Namespace and System.Collections.Generic, provide generic classes and methods. The new System.Collections.Generic namespace provides support for strongly typed collections. System.Nullable<T> is a standard representation of optional values. Generics are supported in three languages: Visual Basic, C#, and C++.

There are lot other new features like:
1.       I/O Enhancements
2.       .NET Framework Remoting
3.       Security Exceptions
4.       Threading Improvements
5.       XML-Related Features




What's New in ASP.NET 

The Microsoft .NET Framework version 2.0 includes significant enhancements to ASP.NET in virtually all areas. ASP.NET has been improved to provide out-of-the-box support for the most common Web application situations.
Specific areas in which ASP.NET has been improved are:

1.      Productivity.
 You can easily and quickly create ASP.NET Web pages and applications using new ASP.NET server controls and existing controls with new features. New areas such as membership, personalization, and themes provide system-level functionality that would normally require extensive developer coding. Core development scenarios, particularly data, have been addressed by new data controls, no-code binding, and smart data-display controls.

2.       Flexibility and extensibility. Many ASP.NET features are extensible so that you can easily incorporate custom features into applications. The ASP.NET provider model, for example, provides pluggable support for different data sources.

3.       Performance. Features such as precompilation, configurable caching, and SQL cache invalidation allow you to optimize the performance of your Web applications.
Security. It is now easier than ever to add authentication and authorization to your Web applications.

4.       Hosting. ASP.NET includes new features that make it easier to manage a hosting environment and create more opportunities for hosters to add value.
5.       Completeness. New and existing features work in concert to allow you to create end-to-end scenarios that address real-world Web development challenges.




The following sections of this topic describe changes made in different areas of ASP.NET:
1.       Web Site Management:  You can easily manage application settings using the Web Site Administration Tool.
                                                                                            I.            New Administration Features and Tools
                                                                                          II.            Reserved Folders for Special Functionality
                                                                                        III.            App_Code
                                                                                        IV.            App_Data
                                                                                          V.            Precompiling Web Sites for Error Checking and Deployment
                                                                                        VI.            Navigation
You can add site navigation to your Web sites by defining a site map (typically an XML file). You can then use new navigation controls such as the TreeView and SiteMapPath

2.       Page Design
                                                                                            I.            Consistent Layout using Master Pages
                                                                                          II.            Themes for Consistent Appearance
                                                                                        III.            New Code-Behind Model for Pages
                                                                                        IV.            User-Customizable Web Pages
                                                                                          V.            User-Specific Values
                                                                                        VI.            New Caching Features
                                                                                      VII.            Enhanced Client-Side Functionality

3.       Controls
ASP.NET features many improvements to Web server controls, including both enhancements to existing controls and a selection of new controls.

General Control Improvements

A major area of enhancement in ASP.NET 2.0 is in the controls you use to create ASP.NET Web pages. General improvements to controls include:
·         By default, controls now generate markup that is compatible with the XHMTL 1.1. standard.
·         All controls support adaptive rendering, and can emit markup that is appropriate for the requesting browser.
·         All data controls can use either the new data-binding model with data source controls, or can continue to use the model used in earlier versions of ASP.NET.
·         All controls support themes and skins so that you can customize their appearance using an ASP.NET theme.
·         You can use device filtering with many control properties, specifying different property values for different devices. When the control is rendered, the appropriate property value is set based on the requesting browser.
·         Validator controls can now be grouped, which allows you to selectively enable validation for some controls.
·         Improvements to individual controls such as the Label control, ListBox control, and others to add functionality often requested by developers.

New Controls

ASP.NET offers a greater selection of controls to help you create fully featured Web pages much more quickly. You can now take advantage of the following controls:
·         Data. The GridView control is a highly capable data grid that can display and edit data, page, and sort, all without code.
·         Navigation. You can add navigation paths (also known as breadcrumbs) to pages with the SiteMapPath control and display a site map using the TreeView control.
·         Security. You can authenticate users with a suite of login controls that allow you to get and validate user credentials, display custom output for logged-in users, and more. For more information, see Security.
·         Web Parts. A new set of Web Part controls allow you to create portal pages that users can personalize at run time. For example, you can create a Web Part that allows a user to enter a custom value such as a postal code and get localized weather reports.
·         Client behavior. New controls provide ASP.NET server control functionality for tasks that previously were handled only by HTML elements. These include the FileUpload control, ImageMap control, and the HiddenField control. The new Wizard control allow you to create a page with multiple panels that step the user through multi-part forms.

4.      Data

ASP.NET includes substantially improved support for working with data in your Web applications.

Data Source Controls

For binding data to controls on Web pages, you can now use data source controls, which encapsulate connections, query commands, and parameters into a single control.
ASP.NET includes data source controls that work with a variety of back-end data sources, including Microsoft SQL Server, Microsoft Access, XML files, Web services, FrontPage site maps, and business objects that return data sets. All data source controls support the same basic object model, giving you a consistent way to work with data regardless of its source.
Data source controls can automatically fetch data and manage it when the page runs. You no longer need to write code to execute commands and manage datasets for common data scenarios. However, if your application requires it, you still have access to the lower-level data functions exposed by ADO.NET.
To pass parameters to data source controls, you can configure the controls to draw parameters values from other controls, Session state, query strings, or cookies; in addition, you can set parameter values programmatically.

Middle-Tier Data Access

Data Display Controls

·         The GridView , DetailsView , FormView controls to display and edit data. (The GridView control supersedes the DataGrid control from previous versions of ASP.NET.)
·         The TreeView control to display hierarchical information from XML files, sitemap files, and relational data sources.
·         The SiteMapPath and Menu controls to provide data-bound support for navigation.

XML Support

·         You can use XML data in a variety of ways in ASP.NET. An XML data source control exposes

Connection String Storage

·         To enhance Web site security, you can store connection strings in a dedicated section of the configuration file.

5.      Security
New ASP.NET features provide built-in support for authenticating and authorizing users. ASP.NET membership manages authentication, providing facilities for validating user credentials and helping users manage their passwords.

I suggest everyone to have a look at the below link for more practical details

Guys please let me know if the post helped you in understanding or  re-gathering  your thoughts about .net 2.0

Leia Mais…

Monday, February 13, 2012

LINQ and Lambda expression


Hi All,
This is a simple application showing how to use LINQ and Lambda expression 

Step 1:
Create a simple Customer Class:
  public class Customer
        {
            public int Id;public string Name;public string City;
            public Customer(int id, string name, string city)
            {
                Id = id;Name = name;City = city;
            }
        }

Step 2:
Add few customers to the class as below:
List<Customer> customers = new List<Customer>();
            customers.Add(new Customer(1, "Dave", "Sarasota"));
            customers.Add(new Customer(2, "John", "Tampa"));
            customers.Add(new Customer(3, "Abe", "Miami"));

Next we try to write some test method which gets required customer on some condition.
Let’s name it as getCust

Sorry I am not following any naming conventions here J ……


The method looks as below:
This method tries to fetch the result from the list using the below:
·         FirstOtDefault
·         FindAll
·         Find
·         Where
·         select




public static Customer getCust(List<Customer> lcust)
        {
            Customer objcust = null;

            //using simple FirstOtDefault
            objcust = lcust.FirstOrDefault(c => c.Id == 1);

            //Using FindAll
            objcust = lcust.FindAll(c => c.Id == 1).FirstOrDefault();

            //using Predicate and using Find
            Predicate<Customer> pred = item => item.Id == 2;
            objcust = lcust.Find(pred);

            //using Func for Where
            Func<Customer, bool> whereFunc = delegate(Customer cutitemem)
            {
                return cutitemem.Id == 3;
            };

            objcust = lcust.Where(whereFunc).FirstOrDefault();

            //Using simple  LINQ
            var result = from c in lcust
                         where c.Id.Equals(1)
                         select c;
            objcust = result.ToList<Customer>().FirstOrDefault();

            return objcust;
        }
       
 
As you can see the above method shows  different techniques of  using LINQ and Lambda.

ok.. here is the full code :)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimpleLINQ_Lamda
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Customer> customers = new List<Customer>();
            customers.Add(new Customer(1, "Dave", "Sarasota"));
            customers.Add(new Customer(2, "John", "Tampa"));
            customers.Add(new Customer(3, "Abe", "Miami"));
            Customer abe = getCust(customers);
        }

        public static Customer getCust(List<Customer> lcust)
        {
            Customer objcust = null;
            //using simple FirstOtDefault
            objcust = lcust.FirstOrDefault(c => c.Id == 1);

            //Using FindAll
            objcust = lcust.FindAll(c => c.Id == 1).FirstOrDefault();

            //using Predicate and using Find
            Predicate<Customer> pred = item => item.Id == 2;
            objcust = lcust.Find(pred);

            //using Func for Where
            Func<Customer, bool> whereFunc = delegate(Customer cutitemem)
            {
                return cutitemem.Id == 3;
            };

            objcust = lcust.Where(whereFunc).FirstOrDefault();

            //Using simple  LINQ
            var result = from c in lcust
                         where c.Id.Equals(1)
                         select c;
            objcust = result.ToList<Customer>().FirstOrDefault();

            return objcust;
        }
       
        public class Customer
        {
            public int Id;public string Name;public string City;
            public Customer(int id, string name, string city)
            {
                Id = id;Name = name;City = city;
            }
        }
    }
}

Guys pls do comment n give suggestions on the post .. Thanks in adv

Leia Mais…

Using LINQ_Lamda


Leia Mais…