overview of next-gen technologies raimond brookman it architect info support...
Post on 15-Jan-2016
218 Views
Preview:
TRANSCRIPT
Overview of Overview of Next-gen technologiesNext-gen technologies
Raimond BrookmanRaimond BrookmanIT ArchitectIT ArchitectInfo SupportInfo Supportraimondb@infosupport.comraimondb@infosupport.comhttp://blogs.infosupport.com/raimondbhttp://blogs.infosupport.com/raimondb
2
WWF
5 Pillars of Connected Systems5 Pillars of Connected Systems
WCFInfocard
ADASP.NET 2.0Atlas / WPF
LINQWinFS
3
AgendaAgenda
IntroductionIntroduction
Windows Presentation Foundation Windows Presentation Foundation (WPF)(WPF)
ASP.NET AtlasASP.NET Atlas
Windows Communication Foundation Windows Communication Foundation (WCF)(WCF)
Windows Workflow Foundation (WWF)Windows Workflow Foundation (WWF)
C# 3.0, LINQ, DLINQ & XLINQC# 3.0, LINQ, DLINQ & XLINQ
Q&AQ&A
4
Windows Presentation Windows Presentation FoundationFoundation
5
User Experience Matters User Experience Matters Consumer SoftwareConsumer Software
HTML DHTML WinFX
6
Developer ArtDeveloper Art
7
Windows Presentation Windows Presentation FoundationFoundation
BUILD THE APPLICATIONS YOUALWAYS DREAMED OF
BUILD THE APPLICATIONS YOUALWAYS DREAMED OF
8
WPF CapabilitiesWPF Capabilities
Media Integration LayerMedia Integration Layer
2D2D
3D3D
AudioAudioImagingImagingTextText
VideoVideoEffectsEffects
Composition EngineComposition Engine
AnimationAnimation
Base ServicesBase Services
XAMLXAML
AccessibilityAccessibility
Property SystemProperty System
Input & EventingInput & Eventing
Document ServicesDocument Services
XPS DocumentsXPS Documents
Packaging Services
Packaging Services
User Interface ServicesUser Interface Services
Application ServicesApplication Services
Deployment Services
Deployment Services
ControlsControls
LayoutLayout
Databinding
Databinding
9
WPF: User Interface WPF: User Interface ServicesServices
Layout & Databinding<StackPanel>
<Label>Select A Customer</Label><ListBox
Name="myListBox"Background="HoneyDew"ItemsSource="{Binding
{StaticResource myDataSource}}" </ListBox>
</StackPanel>
User Interface ServicesUser Interface Services
Application ServicesApplication Services
Deployment Services
Deployment Services
ControlsControls
LayoutLayout
Databinding
Databinding
10
Window1.xaml.csWindow1.xaml.cs
Contains:Contains:Application logicApplication logic
Created by:Created by:Application Application developerdeveloper
Window1.xamlWindow1.xaml
Contains:Contains:Principal UIPrincipal UI
(controls, layout, (controls, layout, etc.)etc.)
Created by:Created by:Application Application
developer developer oror designerdesigner
Design Design Experience:Experience:
By hand or using a By hand or using a visual toolvisual tool
Styles.xamlStyles.xaml
Contains:Contains:Application “style”Application “style”(visual description (visual description
of UI elements)of UI elements)
Created by:Created by:Application Application designerdesigner
Design Design Experience:Experience:
By hand or using a By hand or using a visual toolvisual tool
projectproject structurestructure
Data model, event names, Data model, event names, element names, etc.element names, etc.
Resource names and Resource names and element types.element types.
11
ASP.NET: Future Directions ASP.NET: Future Directions Developing Rich Web Applications Developing Rich Web Applications With “Atlas”With “Atlas”
12
ASP.NET “Atlas” GoalsASP.NET “Atlas” Goals
Increased productivityIncreased productivityFewer concepts, fewer lines of codeFewer concepts, fewer lines of codeApplication and UI building blocks for common scenariosApplication and UI building blocks for common scenarios
Easier to author, debug, and maintainEasier to author, debug, and maintainClean separation of content, style, behavior, and codeClean separation of content, style, behavior, and codeWell integrated with design and development toolsWell integrated with design and development tools
Seamlessly integrated application modelSeamlessly integrated application modelWorks with ASP.NET pages and server controlsWorks with ASP.NET pages and server controlsAllows access to ASP.NET-hosted web services and Allows access to ASP.NET-hosted web services and componentscomponents
Works everywhere – cross-browser, standards Works everywhere – cross-browser, standards basedbased
A FRAMEWORK FOR BUILDING RICHER, MORE INTERACTIVE,
MORE PERSONALIZED WEB EXPERIENCES
A FRAMEWORK FOR BUILDING RICHER, MORE INTERACTIVE,
MORE PERSONALIZED WEB EXPERIENCES
13
““Atlas” ArchitectureAtlas” Architecture
‘Atlas” Client Script Library‘Atlas” Client Script Library
Built-in Controls and
Behaviors
Built-in Controls and
Behaviors
Script CoreScript Core
Base Class LibraryBase Class Library
Component and UI Model
Component and UI Model
Browser CompatibilityBrowser Compatibility
“Atlas” Client Application Services
“Atlas” Client Application Services
Local StoreLocal Store
BrowserIntegration
BrowserIntegration
ASP.NET “Atlas” Server ExtensionsASP.NET “Atlas” Server Extensions
“Atlas” Server
Controls
“Atlas” Server
Controls
ASP.NET “Atlas” Application
Services
ASP.NET “Atlas” Application
Services
“Atlas” Web Services
Bridge
“Atlas” Web Services
Bridge
ASP.NET 2.0ASP.NET 2.0
ASP.NETApplication
Services
ASP.NETApplication
Services
Page Framework
AndServer Controls
Page Framework
AndServer Controls
““Atlas”-enabled Atlas”-enabled ASP.NET PagesASP.NET Pages
““Atlas”-enabled Atlas”-enabled ASP.NET PagesASP.NET Pages ASP.NET-hostedASP.NET-hosted
Web ServicesWeb Services(ASMX or WCF)(ASMX or WCF)
ASP.NET-hostedASP.NET-hostedWeb ServicesWeb Services(ASMX or WCF)(ASMX or WCF)
ASP.NET “Atlas” ServerASP.NET “Atlas” Server
““Atlas” HTML Atlas” HTML PagePage
““Atlas” HTML Atlas” HTML PagePage ““Atlas”Atlas”
ServiceServiceProxiesProxies
““Atlas”Atlas”ServiceServiceProxiesProxies
“Atlas” Client“Atlas” Client
14
Script-Based Type SystemScript-Based Type System
Scenario:Scenario:Script code can be ad-hoc, unmaintainable, etc.Script code can be ad-hoc, unmaintainable, etc.
Solution:Solution:Encapsulate data and logic into classes and Encapsulate data and logic into classes and componentscomponentsExpose intuitive object modelExpose intuitive object model
““Atlas” OOP constructs built on top of Atlas” OOP constructs built on top of standard script constructs and techniquesstandard script constructs and techniques
NamespacesNamespacesClasses, Interfaces, and inheritanceClasses, Interfaces, and inheritance
Properties, methods, eventsProperties, methods, eventsPrivate and public membersPrivate and public members
DelegatesDelegatesEnumerations and FlagsEnumerations and Flags
15
API SamplesAPI Samplesvar myArray = new Array(‘abc’, ‘ghi’);myArray.push(‘jkl’);myArray.splice(1, 0, ‘def’);
var myObject = ...;var s = ‘’;for (var name in myObject) { var value = myObject[name]; s += name + ‘ = ‘ + value + ‘\r\n’;}
var myArray = new Array(‘abc’, ‘ghi’);var myArray = new Array(‘abc’, ‘ghi’);myArray.add(‘jkl’);myArray.add(‘jkl’);myArray.insert(1, ‘def’);myArray.insert(1, ‘def’);
var myObject = ...;var myObject = ...;var s = ‘’;var s = ‘’;for (var name in myObject) {for (var name in myObject) { var value = myObject[name];var value = myObject[name]; s += String.Format(‘{0} = {1}\r\n’,s += String.Format(‘{0} = {1}\r\n’, name, value, value.length);name, value, value.length);}}
var myObject = ‘...’;var myObject = ‘...’;var sb = new Web.StringBuilder();var sb = new Web.StringBuilder();for (var name in myObject) {for (var name in myObject) { var value = myObject[name];var value = myObject[name]; sb.append(name);sb.append(name); sb.append(‘ = ‘);sb.append(‘ = ‘); sb.appendLine(value);sb.appendLine(value);}}var s = sb.toString();var s = sb.toString();
16
““Atlas” NetworkingAtlas” NetworkingClient networking stack layered on XMLHTTPClient networking stack layered on XMLHTTP
WebRequestWebRequest, , WebResponseWebResponse, , MethodRequestMethodRequest classes classes
ASP.NET “Atlas” Web Services BridgeASP.NET “Atlas” Web Services BridgeAccess to ASP.NET-hosted and serviced componentsAccess to ASP.NET-hosted and serviced components
ASMX and WCF services, .NET objects, ASP.NET page-level ASMX and WCF services, .NET objects, ASP.NET page-level servicesservices
Automatic client proxy generation Automatic client proxy generation <script src=“MyService.asmx/js” /><script src=“MyService.asmx/js” />
Integrated with ASP.NET intrinsicsIntegrated with ASP.NET intrinsics
Wire format: Javascript object notationWire format: Javascript object notationpublic class Location {public class Location { public Point Coordinates;public Point Coordinates; public String Name;public String Name;}}
public class Location {public class Location { public Point Coordinates;public Point Coordinates; public String Name;public String Name;}}
{ Coordinates : { X: 2.17, Y: 48.51 },{ Coordinates : { X: 2.17, Y: 48.51 },
Name : Name : ""Eiffel Tower" }Eiffel Tower" }
{ Coordinates : { X: 2.17, Y: 48.51 },{ Coordinates : { X: 2.17, Y: 48.51 },
Name : Name : ""Eiffel Tower" }Eiffel Tower" }
17
Introduction to the Windows Introduction to the Windows Communication FoundationCommunication Foundation
18
Windows Communication Windows Communication Foundation – Why?Foundation – Why?
WindowsWindowsCommunicationCommunication
FoundationFoundation
ASMXASMX[ with WSE ][ with WSE ] .NET Remoting.NET Remoting COM+COM+
Enterprise ServicesEnterprise Services
Simple ConfigurationSimple ConfigurationOpen StandardsOpen StandardsService-OrientedService-Oriented
AttributesAttributesTransactionsTransactionsComponentsComponents
ExtensibleExtensibleObject-OrientedObject-Oriented
MSMQMSMQSystem.MessagingSystem.Messaging
MessagesMessagesReliableReliable
19
Unifies today’s distributed technology Unifies today’s distributed technology stacksstacksAppropriate for use on-machine, cross Appropriate for use on-machine, cross machine, and cross Internetmachine, and cross Internet
The unified programming model for rapidly building The unified programming model for rapidly building service-oriented applications on the Windows platformservice-oriented applications on the Windows platform
Interoperates with applications running on Interoperates with applications running on other platformsother platformsIntegrates with our own distributed stacksIntegrates with our own distributed stacks
UnificationUnification
IntegrationIntegration
• Codifies best practices for building Codifies best practices for building distributed applicationsdistributed applications
ServiceServiceOrientationOrientation
Windows Communication Windows Communication FoundationFoundation
20
Client Service
Clients and ServicesClients and Services
Message
21
Client Service
EndpointsEndpoints
EndpointEndpoint
Endpoint
EndpointMessage
22
Service
CBA
CBA
Client
Address, Binding, ContractAddress, Binding, Contract
ABC
AddressWhere?
ContractWhat?
BindingHow?
EndpointEndpoint
CBAMessage
23
ServiceHost
Client Service
Creating EndpointsCreating Endpoints
ClientChannel
Message
ABC CBA
CBA
CBA
24
Inside BindingsInside Bindings
Transport
IPCMSMQ
Custom
TCP HTTP
ProtocolEncoders
Binary
Text
Custom
.NETTX
Custom
Security RM
BindingHTTP Text TXSecurity RM
25
Standard BindingsStandard Bindings
Inte
rop
Inte
rop
Secu
rityS
ecu
rity
Sessio
nS
essio
n
Tra
nsa
ction
Tra
nsa
ction
ss Du
ple
xD
uple
x
Stre
am
ing
Stre
am
ing
BasicHttpBindingBasicHttpBinding BP BP 1.11.1
TT
WsHttpBindingWsHttpBinding WSWS T | ST | S XX XX
WsDualHttpBindingWsDualHttpBinding WSWS T | ST | S XX XX XX
NetTcpBindingNetTcpBinding .NET.NET T | ST | S XX XX XX OONetNamedPipesBindingNetNamedPipesBinding .NET.NET T | ST | S XX XX XX OONetMsmqBindingNetMsmqBinding .NET.NET T | ST | S XX XX
NetPeerTcpBindingNetPeerTcpBinding .NET.NET T | ST | S XXT = Transport Security T = Transport Security || S = WS-Security | O = One-Way Only S = WS-Security | O = One-Way Only
26
ASMX/WSE3ASMX/WSE3 WCFWCF
WCFWCF ASMX/WSE3ASMX/WSE3
Integration using BindingsIntegration using Bindings
MSMQMSMQ WCFWCF
WCFWCF MSMQMSMQ
WS-* ProtocolsWS-* Protocols
WS-* ProtocolsWS-* Protocols
MSMQ MSMQ ProtocolProtocol
MSMQ MSMQ ProtocolProtocol
MSMQBinding
MSMQBinding
Http/WSBinding
Http/WSBinding
JavaJava WCFWCF
WCFWCF JavaJava
WS-* ProtocolsWS-* Protocols
WS-* ProtocolsWS-* Protocols
Http/WSBinding
Http/WSBinding
WCFWCF WCFWCFWS-* ProtocolsWS-* Protocols *Binding
*Binding
27
Windows Workflow Windows Workflow FoundationFoundation
28
The The workflow framework & toolsworkflow framework & tools for for Microsoft products and Microsoft products and
partner/customer ecosystempartner/customer ecosystem
Windows Workflow Foundation Windows Workflow Foundation
Single workflow technologySingle workflow technology for Windows for WindowsBase for Microsoft products and ISV/customer solutionsBase for Microsoft products and ISV/customer solutions
One technology for human and system workflow scenariosOne technology for human and system workflow scenarios
A A frameworkframework for building workflow into applications for building workflow into applicationsA framework to build on - not an application or serverA framework to build on - not an application or server
Exposed to developers via WinFXExposed to developers via WinFX
Brings workflow to Brings workflow to mainstreammainstream .NET .NET developmentdevelopment
Transform workflow from niche to mainstream paradigmTransform workflow from niche to mainstream paradigm
Build strong partner & solution ecosystemBuild strong partner & solution ecosystem
29
What Is A Workflow?What Is A Workflow?A set of A set of activitiesactivities that coordinate that coordinate
peoplepeopleand / or software...and / or software...
EscalateToManagerExample activities…. Example activities…. CheckInventory
Like a flowchart…. Like a flowchart….
……organized into a organized into a workflowworkflow..
Or a state diagram…. Or a state diagram….
30
Workflow Scenario SpectrumWorkflow Scenario Spectrum
ParticipantsParticipants: people, roles: people, roles
Flow style:Flow style: flexible, dynamic flexible, dynamic
Data:Data: unstructured, unstructured, documentsdocuments
Participants:Participants: apps, services apps, services
Flow style:Flow style: prescriptive, protocols prescriptive, protocols
Data:Data: structured, transactional structured, transactional
Information Worker• Document Review…Information Worker• Document Review…
System WorkflowSystem WorkflowSystem WorkflowSystem WorkflowHuman Human WorkflowWorkflowHuman Human
WorkflowWorkflow
Windows Workflow FoundationWindows Workflow Foundation
Business to Business• Supply Chain Mgmt…Business to Business• Supply Chain Mgmt…
Line of Business Apps• Quote to Cash, Sales Automation…
Line of Business Apps• Quote to Cash, Sales Automation…CRM ERP
IT Management• New Hire Provisioning, Trouble Ticket,…
IT Management• New Hire Provisioning, Trouble Ticket,…
.NET Developer• Pageflow, Service Coordination…
.NET Developer• Pageflow, Service Coordination…
31WinFXWinFX
Workflow And BizTalk Workflow And BizTalk ServerServer
Windows Windows Workflow Workflow
FoundationFoundation
MessagingMessagingDesigDesig
nnToolsTools
BusineBusinessss
ActivityActivityMonitoMonito
rrAndAnd
AdminAdminToolsTools
OrchestratioOrchestrationn
TransformatiTransformationon
AdaptersAdapters
BizTalk ServerAcceleratorsAccelerators
• Premium BPM serverPremium BPM server• Distinct server productDistinct server product• Use in B2B, EAI, BPM scenariosUse in B2B, EAI, BPM scenarios• Deployable solutionsDeployable solutions• Manageability, Scale-outManageability, Scale-out
• Workflow frameworkWorkflow framework• Exposed via WinFX Exposed via WinFX • Broad set of scenarios Broad set of scenarios • Used to build solutionsUsed to build solutions• Enables manageabilityEnables manageabilityand scale-out in solutionsand scale-out in solutions• Use for building workflow Use for building workflow into apps or workflow-enabled into apps or workflow-enabled serversservers
Visual Studio DesignerVisual Studio Designer
• Future version will migrate to Future version will migrate to Windows Workflow Foundation Windows Workflow Foundation for orchestrationfor orchestration
WorkflowWorkflow
32
Windows Workflow FoundationWindows Workflow Foundation
Key ConceptsKey Concepts
Host Process
WindowsWorkflow Foundation
Runtime Engine
A Workflow
An Activity
Runtime Services
Base Activity Library
Custom Activity Library
Visual Designer
Visual Designer:Visual Designer: Graphical and code-Graphical and code-based constructionbased construction
WorkflowsWorkflows are a set of are a set of ActivitiesActivities
Workflows run within a Workflows run within a Host Host Process: Process: any application or serverany application or serverDevelopers can build their own Developers can build their own Custom Activity LibrariesCustom Activity Libraries
ComponentsComponents
Base Activity Library:Base Activity Library: Out-of-box Out-of-box activities and base for custom activitiesactivities and base for custom activities
Runtime Engine:Runtime Engine: Workflow execution Workflow execution and state managementand state management
Runtime Services:Runtime Services: Hosting flexibility Hosting flexibility and communicationand communication
33
Visual DesignerVisual Designer
DesignDesign
DebugDebug
34
The .NET LanguageThe .NET LanguageC# 3.0 Integrated Query C# 3.0 Integrated Query ProjectProject
35
Getting productiveGetting productive
Today we program against relational Today we program against relational and hierarchical data using a and hierarchical data using a language that does not support this language that does not support this nativelynatively
Data != ObjectsData != Objects
We are busy describing how things We are busy describing how things need to get done in stead of what we need to get done in stead of what we wantwant
36
C# 3.0 Design GoalsC# 3.0 Design Goals
Integrate objects, relational, and XMLIntegrate objects, relational, and XML
Build on foundation laid in C# 1.0 and Build on foundation laid in C# 1.0 and
2.02.0
Run on the .NET 2.0 (“Whidbey”) CLRRun on the .NET 2.0 (“Whidbey”) CLR
Remain 100% backwards compatibleRemain 100% backwards compatible
37
The LINQ ProjectThe LINQ Project
StandardStandardQueryQuery
OperatorsOperators
ObjectsObjects
DLinqDLinq(ADO.NET)(ADO.NET)
XLinqXLinq(System.Xml)(System.Xml)
<book> <title/> <author/> <year/> <price/></book>
XMLXML
.NET Language Integrated Query.NET Language Integrated Query
C# 3.0C# 3.0 VB 9.0VB 9.0 Others…Others…
SQLSQL WinFWinFSS
38
LINQ Style programmingLINQ Style programming
var contacts =var contacts = from c in customersfrom c in customers where c.State == "WA"where c.State == "WA" select new { c.Name, c.Phone };select new { c.Name, c.Phone };
class Contact { … };class Contact { … };List<Contact> contacts = new List<Contacts>();List<Contact> contacts = new List<Contacts>();foreach(Customer c in customers) foreach(Customer c in customers) {{
if(c.State == “WA”) if(c.State == “WA”) {{ Contact ct = new Contact();Contact ct = new Contact(); ct.Name = c.Name;ct.Name = c.Name; ct.Phone = c.Phone;ct.Phone = c.Phone; contacts.Add(ct);contacts.Add(ct);}}
}}
39
Query ExpressionsQuery Expressions
Language integrated query syntaxLanguage integrated query syntax
fromfrom idid inin sourcesource{ { fromfrom idid inin sourcesource | | wherewhere conditioncondition } }[ [ orderbyorderby orderingordering, , orderingordering, … ], … ]selectselect exprexpr | | groupgroup exprexpr byby keykey[ [ intointo idid queryquery ] ]
40
C# 3.0 Language C# 3.0 Language InnovationsInnovations
var contacts =var contacts = from c in customersfrom c in customers where c.State == "WA"where c.State == "WA" select new { c.Name, c.Phone };select new { c.Name, c.Phone };
var contacts =var contacts = customerscustomers .Where(c => c.State == "WA").Where(c => c.State == "WA") .Select(c => new { c.Name, c.Phone });.Select(c => new { c.Name, c.Phone });
Extension Extension methodsmethods
Lambda Lambda expressionsexpressions
Query Query expressionsexpressions
Object Object initializersinitializers
Anonymous Anonymous typestypes
Local Local variable type variable type
inferenceinference
41
Standard Query OperatorsStandard Query OperatorsRestrictionRestriction WhereWhere
ProjectionProjection Select, SelectManySelect, SelectMany
OrderingOrdering OrderBy, ThenByOrderBy, ThenBy
GroupingGrouping GroupByGroupBy
QuantifiersQuantifiers Any, AllAny, All
PartitioningPartitioning Take, Skip, TakeWhile, SkipWhileTake, Skip, TakeWhile, SkipWhile
SetsSets Distinct, Union, Intersect, ExceptDistinct, Union, Intersect, Except
ElementsElements First, FirstOrDefault, ElementAtFirst, FirstOrDefault, ElementAt
AggregationAggregation Count, Sum, Min, Max, AverageCount, Sum, Min, Max, Average
ConversionConversion ToArray, ToList, ToDictionaryToArray, ToList, ToDictionary
CastingCasting OfType<T>OfType<T>
42
DLinq For Relational DataDLinq For Relational Data
SqlConnection c = new SqlConnection(…);SqlConnection c = new SqlConnection(…);c.Open();c.Open();SqlCommand cmd = new SqlCommand(SqlCommand cmd = new SqlCommand( @"SELECT c.Name, c.Phone@"SELECT c.Name, c.Phone FROM Customers cFROM Customers c WHERE c.City = @p0");WHERE c.City = @p0");cmd.Parameters.AddWithValue("@p0", cmd.Parameters.AddWithValue("@p0", "London“);"London“);DataReader dr = c.Execute(cmd);DataReader dr = c.Execute(cmd);while (dr.Read()) {while (dr.Read()) { string name = dr.GetString(0);string name = dr.GetString(0); string phone = dr.GetString(1);string phone = dr.GetString(1); DateTime date = dr.GetDateTime(2);DateTime date = dr.GetDateTime(2);}}dr.Close();dr.Close();
Accessing data todayAccessing data todayQueries in Queries in
quotesquotes
Loosely Loosely bound bound
argumentsarguments
Loosely Loosely typed result typed result
setssets
No compile No compile time checkstime checks
43
public class Customer { … }public class Customer { … }
public class Northwind: DataContextpublic class Northwind: DataContext{{ public Table<Customer> Customers;public Table<Customer> Customers; … …}}
Northwind db = new Northwind(…);Northwind db = new Northwind(…);var contacts =var contacts = from c in db.Customersfrom c in db.Customers where c.City == "London"where c.City == "London" select new { c.Name, c.Phone };select new { c.Name, c.Phone };
DLinq For Relational DataDLinq For Relational Data
Accessing data with DLinqAccessing data with DLinqClasses Classes
describe datadescribe data
Strongly Strongly typed typed
connectionconnection
Integrated Integrated query syntaxquery syntax
Strongly Strongly typed resultstyped results
Tables are Tables are like like
collectionscollections
44
XLinq For XML DataXLinq For XML Data
XmlDocument doc = new XmlDocument();XmlDocument doc = new XmlDocument();XmlElement contacts = doc.CreateElement("contacts");XmlElement contacts = doc.CreateElement("contacts");foreach (Customer c in customers)foreach (Customer c in customers) if (c.Country == "USA") {if (c.Country == "USA") { XmlElement e = doc.CreateElement("contact");XmlElement e = doc.CreateElement("contact"); XmlElement name = doc.CreateElement("name");XmlElement name = doc.CreateElement("name"); name.InnerText = c.CompanyName;name.InnerText = c.CompanyName; e.AppendChild(name);e.AppendChild(name); XmlElement phone = doc.CreateElement("phone");XmlElement phone = doc.CreateElement("phone"); phone.InnerText = c.Phone;phone.InnerText = c.Phone; e.AppendChild(phone);e.AppendChild(phone); contacts.AppendChild(e);contacts.AppendChild(e); }}doc.AppendChild(contacts);doc.AppendChild(contacts);
Programming XML todayProgramming XML today
<contacts><contacts> <contact><contact> <name>Great Lakes <name>Great Lakes Food</name>Food</name> <phone>(503) <phone>(503) 555-7123</phone>555-7123</phone> </contact></contact> … …</contacts></contacts>
Imperative Imperative modelmodel
Document Document centriccentric
No integrated No integrated queriesqueries
Memory Memory intensiveintensive
45
XLinq For XML DataXLinq For XML Data
XElement contacts = new XElement("contacts",XElement contacts = new XElement("contacts", from c in customersfrom c in customers where c.Country == "USA"where c.Country == "USA" select new XElement("contact",select new XElement("contact", new XElement("name", c.CompanyName),new XElement("name", c.CompanyName), new XElement("phone", c.Phone)new XElement("phone", c.Phone) ))););
Programming XML with XLinqProgramming XML with XLinqDeclarative Declarative
modelmodel
<contacts><contacts> <contact><contact> <name>Great Lakes <name>Great Lakes Food</name>Food</name> <phone>(503) <phone>(503) 555-7123</phone>555-7123</phone> </contact></contact> … …</contacts></contacts>
ElementElementcentriccentric
Integrated Integrated queriesqueries
Smaller and Smaller and fasterfaster
46
XLinq For XML DataXLinq For XML Data
Language integrated query for XMLLanguage integrated query for XMLExpressive power of XPath / XQueryExpressive power of XPath / XQuery
But with C# or VB as programming But with C# or VB as programming languagelanguage
Leverages experience with DOMLeverages experience with DOMElement centric, not document centricElement centric, not document centric
Functional constructionFunctional construction
Text nodes are just stringsText nodes are just strings
Simplified XML namespace supportSimplified XML namespace support
Faster and smallerFaster and smaller
47
Benefits Of LINQBenefits Of LINQ
Unified querying of objects, relational, XMLUnified querying of objects, relational, XML
Type checking and IntelliSense for queries Type checking and IntelliSense for queries
SQL and XQuery-like power in C# and VBSQL and XQuery-like power in C# and VB
Extensibility model for languages / APIsExtensibility model for languages / APIs
Describe What, not how boosts Describe What, not how boosts
productivityproductivity
48
Questions?Questions?
top related