Search and Find
Service
Title Page
1
Copyright Page
2
Contents at a Glance
4
Table of Contents
6
About the Authors
54
About the Technical Reviewer
55
Acknowledgments
56
Introduction
57
We’re a Team, You and I
57
An Overview of This Book
58
Chapter 1: Introducing VB 2010
58
Chapter 2: Building Visual Basic 2010 Applications
58
Chapter 3: Core VB 2010 Programming Constructs, Part I
58
Chapter 4: Core VB Programming Constructs, Part II
58
Chapter 5: Defining Encapsulated Class Types
59
Chapter 6: Understanding Inheritance and Polymorphism
59
Chapter 7: Understanding Structured Exception Handling
59
Chapter 8: Understanding Object Lifetime
59
Chapter 9: Working with Interfaces
59
Chapter 10: Understanding Generics
60
Chapter 11: Delegates, Events, and Lambdas
60
Chapter 12: Advanced VB 2010 Language Features
60
Chapter 13: LINQ to Objects
60
Chapter 14: Configuring .NET Assemblies
60
Chapter 15: Type Reflection, Late Binding, and Attribute-BasedProgramming
61
Chapter 16: Processes, AppDomains, and Object Contexts
61
Chapter 17: Understanding CIL and the Role of DynamicAssemblies
61
Chapter 18: Dynamic Types and the Dynamic Language Runtime
61
Chapter 19: Multithreaded and Parallel Programming
61
Chapter 20: File I/O and Object Serialization
62
Chapter 21: ADO.NET Part I: The Connected Layer
62
Chapter 22: ADO.NET Part II: The Disconnected Layer
62
Chapter 23: ADO.NET Part III: The Entity Framework
62
Chapter 24: Introducing LINQ to XML
63
Chapter 25: Introducing Windows Communication Foundation
63
Chapter 26: Introducing Windows Workflow Foundation
63
Chapter 27: Introducing Windows Presentation Foundation andXAML
63
Chapter 28: Programming with WPF Controls
64
Chapter 29: WPF Graphical Rendering Services
64
Chapter 30: WPF Resources, Animations, and Styles
64
Chapter 31: WPF Control Templates and UserControls
64
Chapter 32: Building ASP.NET Web Pages
64
Chapter 33: ASP.NET Web Controls, Master Pages, and Themes
65
Chapter 34: ASP.NET State Management Techniques
65
Appendix A: Programming with Windows Forms
65
Appendix B: Platform-Independent .NET Development with Mono
65
Obtaining This Book’s Source Code
65
Obtaining Updates for This Book
66
Chapter 1: Introducing VB 2010
67
Understanding the Previous State of Affairs
67
Life As a C/Windows API Programmer
67
Life As a C++/MFC Programmer
68
Life As a Visual Basic 6.0 Programmer
68
Life As a Java Programmer
69
Life As a COM Programmer
69
The Complexity of COM Data Type Representation
70
The .NET Solution
70
Introducing the Building Blocks of the .NET Platform (the CLR, CTS, and CLS)
71
The Role of the Base Class Libraries
72
What Visual Basic 2010 Brings to the Table
72
Additional .NET-Aware Programming Languages
74
Life in a Multi-Language World
76
An Overview of .NET Assemblies
76
Single-File and Multi-File Assemblies
78
The Role of the Common Intermediate Language
78
Benefits of CIL
81
Compiling CIL to Platform-Specific Instructions
81
The Role of .NET Type Metadata
81
The Role of the Assembly Manifest
83
Understanding the Common Type System
84
CTS Class Types
84
CTS Interface Types
85
CTS Structure Types
85
CTS Enumeration Types
86
CTS Delegate Types
86
CTS Type Members
87
Intrinsic CTS Data Types
87
Understanding the Common Language Specification
88
Ensuring CLS Compliance
90
Understanding the Common Language Runtime
90
The Assembly/Namespace/Type Distinction
92
The Role of the Microsoft Root Namespace
95
Accessing a Namespace Programmatically
95
Referencing External Assemblies
97
Exploring an Assembly Using ildasm.exe
98
Viewing CIL Code
99
Viewing Type Metadata
100
Viewing Assembly Metadata (aka the Manifest)
100
Exploring an Assembly Using Reflector
101
Deploying the .NET Runtime
103
The .NET Client Profile Runtime
103
The Platform-Independent Nature of .NET
103
Summary
105
Chapter 2: Building Visual Basic 2010 Applications
106
The Role of the .NET Framework 4.0 SDK
106
The Visual Studio 2010 Command Prompt
107
Building VB 2010 Applications Using vbc.exe
108
Specifying Input and Output Targets
109
Referencing External Assemblies
110
Referencing Multiple External Assemblies
111
Compiling Multiple Source Files
111
Working with VB 2010 Response Files
112
The Default Response File (vbc.rsp)
113
Building .NET Applications Using Notepad++
114
Building .NET Applications Using Visual Basic 2010 Express
115
Some Unique Features of Visual Basic 2010 Express
116
Building .NET Applications Using Visual Studio 2010
117
Some Unique Features of Visual Studio 2010
118
Targeting the .NET Framework Using the New Project Dialog Box
118
Using the Solution Explorer Utility
119
Referencing External Assemblies
120
Viewing Project Properties
121
The Class View Utility
122
The Object Browser Utility
123
Integrated Support for Code Refactoring
124
Code Expansions Techniques
126
The Visual Class Designer
127
The Integrated .NET Framework 4.0 SDK Documentation System
133
Summary
135
Chapter 3: Core VB 2010 Programming Constructs, Part I
136
The Role of the Module Type
136
Projects with Multiple Modules
138
Modules Are Not Creatable
139
Renaming Your Initial Module
140
Members of Modules
140
The Anatomy of a Simple VB 2010 Program
141
Variations on the Main() Method
142
Specifying an Application Error Code
143
Processing Command-Line Arguments
145
Specifying Command-Line Arguments with Visual Studio 2010
146
An Interesting Aside: Some Additional Members of the System.Environment Class
147
The System.Console Class
149
Basic Input and Output with the Console Class
150
Formatting Console Output
151
Formatting Numerical Data
151
Formatting Numerical Data Beyond Console Applications
153
System Data Types and VB 2010 Shorthand Notation
154
Variable Declaration and Initialization
156
Intrinsic Data Types and the New Operator
157
The Data Type Class Hierarchy
158
Members of Numerical Data Types
160
Members of System.Boolean
161
Members of System.Char
161
Parsing Values from String Data
162
System.DateTime and System.TimeSpan
163
The .NET 4.0 System.Numerics Namespace
163
Working with String Data
165
Basic String Manipulation
166
String Concatenation
167
Special Character Constants
168
End SubStrings and Equality
169
Strings Are Immutable
170
The System.Text.StringBuilder Type
171
Narrowing and Widening Data Type Conversions
173
Trapping Narrowing Data Conversions
176
Understanding Option Strict
177
Setting Project-wide Overflow Checking
178
The Role of System.Convert
179
Understanding Implicitly Typed Local Variables
180
Restrictions on Implicitly Typed Variables
181
Implicit Typed Data Is Strongly Typed Data
182
Usefulness of Implicitly Typed Local Variables
183
VB 2010 Iteration Constructs
183
The For Loop
184
The For Each Loop
184
Use of Implicitly Typed Variables Within For Each Constructs
185
The While and Do/While Looping Constructs
185
Decision Constructs and the Relational/Equality Operators
186
The If/Then/Else Statement
186
The Select/Case Statement
188
Summary
189
Chapter 4: Core VB 2010 Programming Constructs, Part II
190
Methods and Parameter Modifiers
190
The ByVal Parameter Modifier
191
The ByRef Modifier
193
The
Attribute 194
The ParamArray Modifier
195
Defining Optional Parameters
197
Invoking Methods using Named Parameters
198
Understanding Method Overloading
200
Understanding VB 2010 Arrays
203
VB 2010 Array Initialization Syntax
204
Implicitly Typed Local Arrays
204
Defining an Array of Objects
205
Working with Multidimensional Arrays
206
Arrays As Arguments or Return Values
208
The System.Array Base Class
209
Understanding the Enum Type
211
Controlling the Underlying Storage for an Enum
212
Declaring Enum Variables
212
The System.Enum Type
213
Dynamically Discovering an Enum’s Name/Value Pairs
214
Understanding the Structure Type
217
Creating Structure Variables
218
Understanding Value Types and Reference Types
220
Value Types, References Types, and the Assignment Operator
221
Value Types Containing Reference Types
223
Passing Reference Types by Value
225
Passing Reference Types by Reference
227
Final Details Regarding Value Types and Reference Types
228
Understanding VB 2010 Nullable Types
229
Working with Nullable Types
230
The Nullable If Operator
231
Summary
232
Chapter 5: Defining Encapsulated Class Types
233
Introducing the VB 2010 Class Type
233
Allocating Objects with the New Keyword
236
Understanding Constructors
237
The Role of the Default Constructor
237
Defining Custom Constructors
238
The Default Constructor Revisited
239
The Role of the Me Keyword
240
Chaining Constructor Calls Using Me
242
Observing Constructor Flow
245
Revisiting Optional Arguments
247
Understanding the Shared Keyword
248
Defining Shared Methods
248
Defining Shared Field Data
249
Defining Shared Constructors
252
Defining Modules in VB 2010
254
Defining the Pillars of OOP
257
The Role of Encapsulation
257
The Role of Inheritance
258
The Role of Polymorphism
259
VB 2010 Access Modifiers
261
The Default Access Modifiers
261
Access Modifiers and Nested Types
262
The First Pillar: VB 2010 Encapsulation Services
262
Encapsulation Using Traditional Accessors and Mutators
263
Encapsulation Using .NET Properties
266
Using Properties within a Class Definition
270
Internal Representation of Properties
271
Controlling Visibility Levels of Property Get/Set Statements
274
Read-Only and Write-Only Properties
274
Shared Properties
275
Understanding Automatic Properties
277
Interacting with Automatic Properties
278
Regarding Automatic Properties and Default Values
279
Understanding Object Initializer Syntax
281
Calling Custom Constructors with Initialization Syntax
282
Nested Objects
284
Working with Constant Field Data
285
Understanding Read-Only Fields
286
Shared Read-Only Fields
287
Understanding Partial Types
288
Summary
289
Chapter 6: Understanding Inheritance and Polymorphism
291
The Basic Mechanics of Inheritance
291
Specifying the Parent Class of an Existing Class
292
Regarding Multiple Base Classes
294
The NotInheritable Keyword
294
Revising Visual Studio Class Diagrams
296
The Second Pillar of OOP: The Details of Inheritance
299
Controlling Base Class Creation with the MyBase Keyword
301
Keeping Family Secrets: The Protected Keyword
303
Adding a NotInheritable Class
304
Programming for Containment/Delegation
305
Understanding Nested Type Definitions
307
The Third Pillar of OOP: VB’s Polymorphic Support
309
The Overridable and Overrides Keywords
310
Overriding Overridable Members Using Visual Studio 2010
313
NotOverridable Members
314
Understanding Abstract Classes and the MustInherit Keyword
314
Understanding the Polymorphic Interface
316
Understanding Member Shadowing
321
Understanding Base Class/Derived Class Casting Rules
323
The VB TryCast Keyword
326
The VB Is Keyword
326
The Master Parent Class: System.Object
327
Overriding System.Object.ToString()
331
Overriding System.Object.Equals()
332
Overriding System.Object.GetHashCode()
333
Testing Your Modified Person Class
334
The Shared Members of System.Object
335
Summary
336
Chapter 7: Understanding Structured Exception Handling
337
Ode to Errors, Bugs, and Exceptions
337
The Role of .NET Exception Handling
338
The Atoms of .NET Exception Handling
339
The System.Exception Base Class
340
The Simplest Possible Example
341
Throwing a General Exception
344
Catching Exceptions
345
Configuring the State of an Exception
347
The TargetSite Property
347
The StackTrace Property
348
The HelpLink Property
348
The Data Property
349
System-Level Exceptions (System.SystemException)
352
Application-Level Exceptions (System.ApplicationException)
352
Building Custom Exceptions, Take One
353
Building Custom Exceptions, Take Two
355
Building Custom Exceptions, Take Three
356
Processing Multiple Exceptions
357
General Catch Statements
359
Rethrowing Exceptions
360
Inner Exceptions
360
The Finally Block
361
Who Is Throwing What?
362
The Result of Unhandled Exceptions
362
Debugging Unhandled Exceptions Using Visual Studio
363
A Brief Word Regarding Corrupted State Exceptions (CSE)
364
Summary
366
Chapter 8: Understanding Object Lifetime
367
Classes, Objects, and References
367
The Basics of Object Lifetime
369
The CIL of new
370
Setting Object References to Nothing
371
The Role of Application Roots
372
Understanding Object Generations
374
Concurrent Garbage Collection under .NET 1.0 - 3.5
375
Background Garbage Collection under .NET 4.0
375
The System.GC Type
376
Forcing a Garbage Collection
377
Building Finalizable Objects
380
Overriding System.Object.Finalize()
381
Detailing the Finalization Process
383
Building Disposable Objects
384
Using Keyword with VB 2010
386
Building Finalizable and Disposable Types
388
A Formalized Disposal Pattern
389
Understanding Lazy Object Instantiation
391
Customizing the Creation of the Lazy Data
394
Summary
395
Chapter 9: Working with Interfaces
396
Understanding Interface Types
396
Interface Types vs. Abstract Base Classes
398
Defining Custom Interfaces
400
Implementing an Interface
402
Invoking Interface Members at the Object Level
405
Obtaining Interface References: The TryCast Keyword
406
Obtaining Interface References: The Is Keyword
406
Interfaces As Parameters
408
Interfaces As Return Values
411
Arrays of Interface Types
411
Implementing Interfaces Using Visual Studio 2010
413
Resolving Name Clashes via Explicit Interface Implementation
414
Designing Interface Hierarchies
417
Multiple Inheritance with Interface Types
419
Building Enumerable Types (IEnumerable and IEnumerator)
421
Building Cloneable Objects (ICloneable)
424
A More Elaborate Cloning Example
426
Building Comparable Objects (IComparable)
430
Specifying Multiple Sort Orders (IComparer)
434
Custom Properties, Custom Sort Types
436
Summary
436
Chapter 10: Understanding Generics
438
The Issues with Non-Generic Collections
438
The Issue of Performance
440
The Issue of Type Safety
444
The Role of Generic Type Parameters
449
Specifying Type Parameters for Generic Classes / Structures
450
Specifying Type Parameters for Generic Members
452
Specifying Type Parameters for Generic Interfaces
452
The System.Collections.Generic Namespace
454
Understanding Collection Initialization Syntax
455
Working with the List(Of T) Class
457
Working with the Stack(Of T) Class
460
Working with the Queue(Of T) Class
461
Working with the SortedSet(Of T) Class
463
Creating Custom Generic Methods
465
Inference of Type Parameters
468
Creating Custom Generic Structures and Classes
469
The Nothing Keyword in Generic Code
470
Generic Base Classes
472
Constraining Type Parameters
473
Examples Using the As Keyword
474
The Lack of Operator Constraints
475
Summary
476
Chapter 11: Delegates, Events, and Lambdas
478
Understanding the .NET Delegate Type
478
Defining a Delegate Type in VB 2010
479
The System.MulticastDelegate and System.Delegate Base Classes
482
The Simplest Possible Delegate Example
484
Investigating a Delegate Object
485
Sending Object State Notifications Using Delegates
487
Enabling Multicasting
491
Removing Targets from a Delegate’s Invocation List
492
Method Group Conversion Syntax
494
Understanding Delegate Covariance
495
Understanding Generic Delegates
498
Simulating Generic Delegates Without Generics
499
Understanding VB 2010 Events
500
The VB 2010 Event Keyword
502
Events under the Hood
503
Listening to Incoming Events
505
Simplifying Event Registration Using Visual Studio 2010
507
Creating Custom Event Arguments
508
The Generic EventHandler(Of T) Delegate
509
Understanding VB 2010 Anonymous Methods
510
Accessing Local Variables
512
Understanding Lambda Expressions
513
Dissecting a Lambda Expression
516
Processing Arguments Within Multiple Statements
517
Lambda Expressions with Multiple (or Zero) Parameters
519
Retrofitting the CarEvents Example Using Lambda Expressions
520
Summary
522
Chapter 12: Advanced VB 2010 Language Features
523
Understanding Indexer Methods
523
Indexing Data Using String Values
526
Overloading Indexer Methods
527
Indexers with Multiple Dimensions
528
Indexer Definitions on Interface Types
529
Understanding Operator Overloading
529
Overloading Binary Operators
530
And What of the += and –= Operators?
532
Overloading Unary Operators
533
Overloading Equality Operators
534
Overloading Comparison Operators
535
The Internal Representation of Overloaded Operators
536
Final Thoughts Regarding Operator Overloading
538
Understanding Custom Type Conversions
539
Recall: Numerical Conversions
539
Recall: Conversions Among Related Class Types
540
Creating Custom Conversion Routines
541
Additional Explicit Conversions for the Square Type
544
Defining Implicit Conversion Routines
544
The Internal Representation of Custom Conversion Routines
546
Understanding Extension Methods
547
Defining Extension Methods
547
Invoking Extension Methods on an Instance Level
549
Invoking Extension Methods as Shared Methods
550
The Scope of an Extension Method
551
Importing Types That Define Extension Methods
552
The IntelliSense of Extension Methods
553
Building and Using Extension Libraries
554
Extending Interface Types via Extension Methods
556
Understanding Partial Methods
558
A First Look at Partial Methods
558
Uses of Partial Methods
560
Understanding Anonymous Types
560
The Internal Representation of Anonymous Types
562
The Implementation of ToString() and GetHashCode()
564
The Semantics of Equality for Anonymous Types
564
Anonymous Types Containing Anonymous Types
566
Summary
567
Chapter 13: LINQ to Objects
568
LINQ Specific Programming Constructs
568
Implicit Typing of Local Variables
569
Object and Collection Initialization Syntax
570
Lambda Expressions
570
Extension Methods
571
Anonymous Types
572
Understanding the Role of LINQ
572
LINQ Expressions Are Strongly Typed
574
The Core LINQ Assemblies
574
Applying LINQ Queries to Primitive Arrays
575
Once Again, Without LINQ
576
Reflecting Over a LINQ Result Set
577
LINQ and Implicitly Typed Local Variables
578
LINQ and Extension Methods
580
The Role of Deferred Execution
581
The Role of Immediate Execution
582
Returning the Result of a LINQ Query
583
Returning LINQ Results via Immediate Execution
584
Applying LINQ Queries to Collection Objects
585
Accessing Contained Subobjects
586
Applying LINQ Queries to Nongeneric Collections
587
Filtering Data Using OfType(Of T)()
588
Investigating the VB 2010 LINQ Query Operators
588
Basic Selection Syntax
590
Obtaining Subsets of Data
591
Projecting New Data Types
592
Obtaining Counts Using Enumerable
593
Reversing Result Sets
594
Sorting Expressions
594
LINQ As a Better Venn Diagramming Tool
595
Removing Duplicates
597
LINQ Aggregation Operations
597
The Internal Representation of LINQ Query Statements
598
Building Query Expressions with Query Operators (Revisited)
599
Building Query Expressions Using the Enumerable Type and Lambda Expressions
599
Building Query Expressions Using the Enumerable Type and Anonymous Methods
601
Building Query Expressions Using the Enumerable Type and Raw Delegates
602
Summary
603
Chapter 14: Configuring .NET Assemblies
604
Observing the Root Namespace
604
Defining Namespaces Beyond the Root
605
Defining Custom Namespaces
606
Resolving Name Clashes with Fully Qualified Names
608
Resolving Name Clashes with Aliases
609
Creating Nested Namespaces
611
The Role of .NET Assemblies
612
Assemblies Promote Code Reuse
612
Assemblies Establish a Type Boundary
613
Assemblies Are Versionable Units
613
Assemblies Are Self-Describing
613
Assemblies Are Configurable
613
Understanding the Format of a .NET Assembly
614
The Windows File Header
614
The CLR File Header
616
CIL Code, Type Metadata, and the Assembly Manifest
617
Optional Assembly Resources
618
Single-File and Multifile Assemblies
618
Building and Consuming a Single-File Assembly
620
Exploring the Manifest
624
Exploring the CIL
627
Exploring the Type Metadata
628
Building a VB 2010 Client Application
629
Building a C# Client Application
631
Cross-Language Inheritance in Action
632
Building and Consuming a Multifile Assembly
633
Exploring the ufo.netmodule File
634
Exploring the airvehicles.dll File
634
Consuming a Multifile Assembly
635
Understanding Private Assemblies
636
The Identity of a Private Assembly
637
Understanding the Probing Process
637
Configuring Private Assemblies
638
Configuration Files and Visual Studio 2010
640
Understanding Shared Assemblies
643
Understanding Strong Names
644
Generating Strong Names at the Command Line
646
Generating Strong Names using Visual Studio 2010
648
Installing Strongly Named Assemblies to the GAC
649
Consuming a Shared Assembly
652
Exploring the Manifest of SharedCarLibClient
653
Configuring Shared Assemblies
654
Freezing the Current Shared Assembly
654
Building Shared Assembly Version 2.0.0.0
655
Dynamically Redirecting to Specific Versions of a Shared Assembly
659
Understanding Publisher Policy Assemblies
660
Disabling Publisher Policy
661
Understanding the
Element 661
The System.Configuration Namespace
664
Summary
665
Chapter 15: Type Reflection, Late Binding, and Attribute-Based Programming
666
The Necessity of Type Metadata
666
Viewing (Partial) Metadata for the EngineState Enumeration
667
Viewing (Partial) Metadata for the Car Type
668
Examining a TypeRef
670
Documenting the Defining Assembly
670
Documenting Referenced Assemblies
670
Documenting String Literals
671
Understanding Reflection
672
The System.Type Class
673
Obtaining a Type Reference Using System.Object.GetType()
674
Obtaining a Type Reference Using System.Type.GetType()
674
Obtaining a Type Reference Using GetType()
675
Building a Custom Metadata Viewer
675
Reflecting on Methods
675
Reflecting on Fields and Properties
676
Reflecting on Implemented Interfaces
677
Displaying Various Odds and Ends
677
Implementing Main()
678
Reflecting on Generic Types
680
Reflecting on Method Parameters and Return Values
680
Dynamically Loading Assemblies
682
Reflecting on Shared Assemblies
686
Understanding Late Binding
687
The System.Activator Class
688
Invoking Methods with No Parameters
689
Invoking Methods with Parameters
690
Understanding the Role of .NET Attributes
691
Attribute Consumers
692
Applying Attributes in VB 2010
693
VB 2010 Attribute Shorthand Notation
695
Specifying Constructor Parameters for Attributes
695
The Obsolete Attribute in Action
695
Building Custom Attributes
696
Applying Custom Attributes
697
Named Property Syntax
697
Restricting Attribute Usage
698
Assembly-Level (and Module-Level) Attributes
699
The Visual Studio 2010 AssemblyInfo.vb File
700
Reflecting on Attributes Using Early Binding
701
Reflecting on Attributes Using Late Binding
702
Putting Reflection, Late Binding, and Custom Attributes in Perspective
704
Building an Extendable Application
705
Building CommonSnappableTypes.dll
706
Building the VB 2010 Snap-In
706
Building the C# Snap-In
707
Building an Extendable Windows Forms Application
707
Summary
712
Chapter 16: Processes, AppDomains, and Object Contexts
713
The Role of a Windows Process
713
The Role of Threads
714
Interacting with Processes Under the .NET Platform
716
Enumerating Running Processes
718
Investigating a Specific Process
720
Investigating a Process’s Thread Set
720
Investigating a Process’s Module Set
723
Starting and Stopping Processes Programmatically
726
Controlling Process Startup Using the ProcessStartInfo Class
726
Understanding .NET Application Domains
728
The System.AppDomain Class
728
Interacting with the Default Application Domain
731
Enumerating Loaded Assemblies
732
Receiving Assembly Load Notifications
734
Creating New Application Domains
734
Loading Assemblies into Custom Application Domains
737
Programmatically Unloading AppDomains
738
Understanding Object Context Boundaries
740
Context-Agile and Context-Bound Types
741
Defining a Context-Bound Object
741
Inspecting an Object’s Context
742
Summarizing Processes, AppDomains, and Context
744
Summary
745
Chapter 17: Understanding CIL and the Role of Dynamic Assemblies
746
Reasons for Learning the Grammar of CIL
746
Examining CIL Directives, Attributes, and Opcodes
747
The Role of CIL Directives
748
The Role of CIL Attributes
748
The Role of CIL Opcodes
748
The CIL Opcode/CIL Mnemonic Distinction
749
Pushing and Popping: The Stack-Based Nature of CIL
749
Understanding Round-Trip Engineering
751
The Role of CIL Code Labels
754
Interacting with CIL: Modifying an *.il File
755
Compiling CIL Code Using ilasm.exe
756
Authoring CIL Code Using SharpDevelop
760
The Role of peverify.exe
762
Understanding CIL Directives and Attributes
762
Specifying Externally Referenced Assemblies in CIL
762
Defining the Current Assembly in CIL
763
Defining Namespaces in CIL
764
Defining Class Types in CIL
764
Defining and Implementing Interfaces in CIL
766
Defining Structures in CIL
767
Defining Enums in CIL
767
Defining Generics in CIL
768
Compiling the CILTypes.il file
768
.NET Base Class Library, VB 2010, and CIL Data Type Mappings
770
Defining Type Members in CIL
771
Defining Field Data in CIL
771
Defining Type Constructors in CIL
772
Defining Properties in CIL
772
Defining Member Parameters
773
Examining CIL Opcodes
774
The .maxstack Directive
777
Declaring Local Variables in CIL
777
Mapping Parameters to Local Variables in CIL
778
The Hidden Me Reference
779
Representing Iteration Constructs in CIL
779
Building a .NET Assembly with CIL
780
Building CILCars.dll
780
Building CILCarClient.exe
783
Understanding Dynamic Assemblies
786
Exploring the System.Reflection.Emit Namespace
786
The Role of the System.Reflection.Emit.ILGenerator
787
Emitting a Dynamic Assembly
788
Emitting the Assembly and Module Set
791
The Role of the ModuleBuilder Type
792
Emitting the HelloClass Type and the String Member Variable
793
Emitting the Constructors
794
Emitting the SayHello() Method
795
Using the Dynamically Generated Assembly
795
Summary
797
Chapter 18: Dynamic Types and the Dynamic Language Runtime
798
Basics of Dynamic Typing in VB 2010
798
The Role of Dynamic Typing in VB 2010
799
Calling Members on Dynamically Declared Data
801
The Role of the Microsoft.VisualBasic.dll Assembly
802
The Scope of the Dynamic Objects
803
Limitations of the Dynamic Type
804
Practical Uses of the Dynamic Types
805
The Role of the Dynamic Language Runtime (DLR)
805
The Role of Expression Trees
806
The Role of the System.Dynamic Namespace
806
Dynamic Runtime Lookup of Expression Trees
807
Simplifying Late Bound Calls Using Dynamic Typing
807
Leveraging the Dynamic Typing to Pass Arguments
808
Simplifying COM Interoperability using Dynamic Data
810
The Role of Primary Interop Assemblies (PIAs)
812
Embedding Interop Metadata
813
Common COM Interop Pain Points
814
COM Interop using VB 2010 Language Features
815
COM Interop without VB 2010 Language Features
819
Summary
821
Chapter 19: Multithreaded and Parallel Programming
823
The Process/AppDomain/Context/Thread Relationship
823
The Problem of Concurrency
825
The Role of Thread Synchronization
825
A Brief Review of the .NET Delegate
825
The Asynchronous Nature of Delegates
828
The BeginInvoke() and EndInvoke() Methods
828
The System.IAsyncResult Interface
829
Invoking a Method Asynchronously
829
Synchronizing the Calling Thread
830
The Role of the AsyncCallback Delegate
832
The Role of the AsyncResult Class
834
Passing and Receiving Custom State Data
835
The System.Threading Namespace
836
The System.Threading.Thread Class
837
Obtaining Statistics About the Current Thread
839
The Name Property
840
The Priority Property
841
Programmatically Creating Secondary Threads
841
Working with the ThreadStart Delegate
842
Working with the ParameterizedThreadStart Delegate
844
The AutoResetEvent Class
845
Foreground Threads and Background Threads
846
The Issue of Concurrency
848
Synchronization Using the VB 2010 SyncLock Keyword
851
Synchronization Using the System.Threading.Monitor Type
854
Synchronization Using the System.Threading.Interlocked Type
855
Synchronization Using the
Attribute 856
Programming with Timer Callbacks
856
Understanding the CLR ThreadPool
858
Parallel Programming under the .NET Platform
860
The Task Parallel Library API
860
The Role of the Parallel Class
862
Understanding Data Parallelism
862
The Task Class
864
Handling Cancelation Request
865
Understanding Task Parallelism
866
Parallel LINQ Queries (PLINQ)
870
Opting in to a PLINQ Query
871
Canceling a PLINQ Query
872
Summary
873
Chapter 20: File I/O and Object Serialization
874
Exploring the System.IO Namespace
874
The Directory(Info) and File(Info) Types
876
The MustInherit FileSystemInfo Base Class
876
Working with the DirectoryInfo Type
877
Enumerating Files with the DirectoryInfo Type
879
Creating Subdirectories with the DirectoryInfo Type
880
Working with the Directory Type
881
Working with the DriveInfo Class Type
882
Working with the FileInfo Class
884
The FileInfo.Create() Method
885
The FileInfo.Open() Method
886
The FileInfo.OpenRead() and FileInfo.OpenWrite() Methods
887
The FileInfo.OpenText() Method
888
The FileInfo.CreateText() and FileInfo.AppendText() Methods
888
Working with the File Type
889
Additional File-centric Members
890
The MustInherit Stream Class
891
Working with FileStreams
892
Working with StreamWriters and StreamReaders
894
Writing to a Text File
895
Reading from a Text File
896
Directly Creating StreamWriter/StreamReader Types
897
Working with StringWriters and StringReaders
897
Working with BinaryWriters and BinaryReaders
899
Watching Files Programmatically
901
Understanding Object Serialization
903
The Role of Object Graphs
905
Configuring Objects for Serialization
906
Defining Serializable Types
906
Public Fields, Private Fields, and Public Properties
907
Choosing a Serialization Formatter
908
The IFormatter and IRemotingFormatter Interfaces
908
Type Fidelity Among the Formatters
909
Serializing Objects Using the BinaryFormatter
910
Deserializing Objects Using the BinaryFormatter
912
Serializing Objects Using the SoapFormatter
912
Serializing Objects Using the XmlSerializer
914
Controlling the Generated XML Data
915
Serializing Collections of Objects
916
Customizing the Soap/Binary Serialization Process
918
A Deeper Look at Object Serialization
919
Customizing Serialization Using ISerializable
919
Customizing Serialization Using Attributes
923
Summary
924
Chapter 21: ADO.NET Part I: The Connected Layer
925
A High-Level Definition of ADO.NET
925
The Three Faces of ADO.NET
927
Understanding ADO.NET Data Providers
927
The Microsoft-Supplied ADO.NET Data Providers
929
A Word Regarding System.Data.OracleClient.dll
931
Obtaining Third-Party ADO.NET Data Providers
931
Additional ADO.NET Namespaces
931
The Types of the System.Data Namespace
932
The Role of the IDbConnection Interface
934
The Role of the IDbTransaction Interface
934
The Role of the IDbCommand Interface
935
The Role of the IDbDataParameter and IDataParameter Interfaces
935
The Role of the IDbDataAdapter and IDataAdapter Interfaces
936
The Role of the IDataReader and IDataRecord Interfaces
936
Abstracting Data Providers Using Interfaces
937
Increasing Flexibility Using Application Configuration Files
939
Creating the AutoLot Database
941
Creating the Inventory Table
941
Authoring the GetPetName() Stored Procedure
944
Creating the Customers and Orders Tables
945
Visually Creating Table Relationships
947
The ADO.NET Data Provider Factory Model
948
A Complete Data Provider Factory Example
949
A Potential Drawback with the Provide Factory Model
953
The
Element 953
Understanding the Connected Layer of ADO.NET
955
Working with Connection Objects
956
Working with ConnectionStringBuilder Objects
958
Working with Command Objects
959
Working with Data Readers
960
Obtaining Multiple Result Sets Using a Data Reader
962
Building a Reusable Data Access Library
963
Adding the Connection Logic
964
Adding the Insertion Logic
965
Adding the Deletion Logic
966
Adding the Update Logic
967
Adding the Selection Logic
967
Working with Parameterized Command Objects
968
Specifying Parameters Using the DbParameter Type
968
Executing a Stored Procedure
970
Creating a Console UI–Based Front End
972
Implementing the Main() Method
973
Implementing the ShowInstructions() Method
974
Implementing the ListInventory() Method
974
Implementing the DeleteCar() Method
975
Implementing the InsertNewCar() Method
976
Implementing the UpdateCarPetName() Method
977
Implementing LookUpPetName()
977
Understanding Database Transactions
979
Key Members of an ADO.NET Transaction Object
980
Adding a CreditRisks Table to the AutoLot Database
981
Adding a Transaction Method to InventoryDAL
982
Testing Your Database Transaction
984
Summary
985
Chapter 22: ADO.NET Part II: The Disconnected Layer
986
Understanding the Disconnected Layer of ADO.NET
986
Understanding the Role of the DataSet
987
Key Properties of the DataSet
988
Key Methods of the DataSet
989
Building a DataSet
990
Working with DataColumns
990
Building a DataColumn
992
Enabling Autoincrementing Fields
992
Adding DataColumn Objects to a DataTable
993
Working with DataRows
993
Understanding the RowState Property
995
Understanding the DataRowVersion Property
997
Working with DataTables
998
Inserting DataTables into DataSets
999
Obtaining Data in a DataSet
999
Processing DataTable Data Using DataTableReader Objects
1000
Serializing DataTable/DataSet Objects As XML
1002
Serializing DataTable/DataSet Objects in a Binary Format
1003
Binding DataTable Objects to Windows Forms GUIs
1004
Hydrating a DataTable from a Generic List(Of T)
1006
Deleting Rows from a DataTable
1008
Selecting Rows Based on Filter Criteria
1010
Updating Rows Within a DataTable
1013
Working with the DataView Type
1013
Working with Data Adapters
1015
A Simple Data Adapter Example
1016
Mapping Database Names to Friendly Names
1018
Adding Disconnection Functionality to AutoLotDAL.dll
1019
Defining the Initial Class Type
1019
Configuring the Data Adapter Using the SqlCommandBuilder
1020
Implementing GetAllInventory()
1021
Implementing UpdateInventory()
1021
Setting Your Version Number
1022
Testing the Disconnected Functionality
1022
Multitabled DataSet Objects and Data Relationships
1023
Prepping the Data Adapters
1024
Building the Table Relationships
1026
Updating the Database Tables
1026
Navigating Between Related Tables
1027
The Windows Forms Database Designer Tools
1030
Visually Designing the DataGridView
1030
The Generated app.config File
1035
Examining the Strongly Typed DataSet
1035
Examining the Strongly Typed DataTable
1037
Examining the Strongly Typed DataRow
1038
Examining the Strongly Typed Data Adapter
1039
Completing the Windows Forms Application
1040
Isolating Strongly Typed Database Code into a Class Library
1041
Viewing the Generated Code
1043
Selecting Data with the Generated Code
1044
Inserting Data with the Generated Code
1045
Deleting Data with the Generated Code
1046
Invoking a Stored Procedure using the Generated Code
1047
Programming with LINQ to DataSet
1047
The Role of the DataSet Extensions Library
1049
Obtaining a LINQ-Compatible DataTable
1049
The Role of the DataRowExtensions.Field(Of T)() Extension Method
1051
Hydrating New DataTables from LINQ Queries
1051
Summary
1052
Chapter 23: ADO.NET Part III: The Entity Framework
1053
Understanding the Role of Entity Framework
1053
The Role of Entities
1055
The Building Blocks of the Entity Framework
1057
The Role of Object Services
1058
The Role of the Entity Client
1059
The Role of the *.edmx File (and Friends)
1060
The Role of the ObjectContext and ObjectSet(Of T) Classes
1060
All Together Now!
1062
Building and Analyzing your First EDM
1064
Generating the *.edmx File
1064
Reshaping the Entity Data
1068
Viewing the Mappings
1070
Viewing the Generated *.edmx File Data
1071
Viewing the Generated Source Code
1073
Enhancing the Generated Source Code
1075
Programming Against the Conceptual Model
1076
Deleting a Record
1077
Updating a Record
1078
Querying with LINQ to Entities
1078
Querying with Entity SQL
1080
Working with the Entity Client Data Reader Object
1081
AutoLotDAL Version 4.0, Now with Entities
1082
Mapping the Stored Procedure
1083
The Role of Navigation Properties
1085
Using Navigation Properties within LINQ to Entity Queries
1087
Invoking a Stored Procedure
1088
Data Binding Entities to Windows Forms GUIs
1089
Adding the Data Binding Code
1092
Summary
1094
Chapter 24: Introducing LINQ to XML
1095
A Tale of Two XML APIs
1095
LINQ to XML As a Better DOM
1097
VB 2010 Literal Syntax As a Better LINQ to XML
1098
Members of the System.Xml.Linq Namespace
1099
The LINQ to XML Axis Methods
1102
The Oddness of XName (and XNamespace)
1103
Working with XElement and XDocument
1104
Generating Documents from Arrays and Containers
1107
Loading and Parsing XML Content
1108
Manipulating an in Memory XML Document
1109
Building the UI of the LINQ to XML App
1109
Import the Inventory.xml File
1110
Defining a LINQ to XML Helper Class
1111
Rigging up the UI to Your Helper Class
1112
Summary
1113
Chapter 25: Introducing Windows Communication Foundation
1114
A Potpourri of Distributed Computing APIs
1114
The Role of DCOM
1115
The Role of COM+/Enterprise Services
1116
The Role of MSMQ
1116
The Role of .NET Remoting
1117
The Role of XML Web Services
1117
A .NET Web Service Example
1118
Web Service Standards
1120
Named Pipes, Sockets, and P2P
1120
The Role of WCF
1120
An Overview of WCF Features
1121
An Overview of Service-Oriented Architecture
1121
Tenet 1: Boundaries Are Explicit
1122
Tenet 2: Services Are Autonomous
1122
Tenet 3: Services Communicate via Contract, Not Implementation
1122
Tenet 4: Service Compatibility Is Based on Policy
1122
WCF: The Bottom Line
1123
Investigating the Core WCF Assemblies
1123
The Visual Studio WCF Project Templates
1124
The WCF Service Website Project Template
1126
The Basic Composition of a WCF Application
1126
The ABCs of WCF
1128
Understanding WCF Contracts
1128
Understanding WCF Bindings
1129
HTTP-Based Bindings
1130
TCP-Based Bindings
1131
MSMQ-Based Bindings
1131
Understanding WCF Addresses
1132
Building a WCF Service
1133
The
Attribute 1134
The
Attribute 1135
Service Types As Operational Contracts
1136
Hosting the WCF Service
1137
Establishing the ABCs Within an App.config File
1137
Coding Against the ServiceHost Type
1138
Specifying Base Addresses
1139
Details of the ServiceHost Type
1140
Details of the
Element 1142
Enabling Metadata Exchange
1143
Building the WCF Client Application
1147
Generating Proxy Code Using svcutil.exe
1147
Generating Proxy Code Using Visual Studio 2010
1148
Configuring a TCP-Based Binding
1150
Simplifying Configuration Settings with WCF 4.0
1152
Default Endpoints in WCF 4.0
1152
Exposing a Single WCF Service Using Multiple Bindings
1154
Changing Settings for a WCF Binding
1155
The WCF 4.0 Default MEX Behavior Configuration
1157
Refreshing the Client Proxy and Selecting the Binding
1158
Using the WCF Service Library Project Template
1160
Building a Simple Math Service
1160
Testing the WCF Service with WcfTestClient.exe
1161
Altering Configuration Files Using SvcConfigEditor.exe
1162
Hosting the WCF Service within a Windows Service
1163
Specifying the ABCs in Code
1165
Enabling MEX
1166
Creating a Windows Service Installer
1167
Installing the Windows Service
1169
Invoking a Service Asynchronously from the Client
1170
Designing WCF Data Contracts
1172
Using the Web-Centric WCF Service Project Template
1173
Implementing the Service Contract
1175
The Role of the *.svc File
1176
Examining the Web.config File
1176
Testing the Service
1177
Summary
1178
Chapter 26: Introducing Windows Workflow Foundation 4.0
1179
Defining a Business Process
1180
The Role of WF 4.0
1180
Building a (Painfully) Simple Workflow
1181
Viewing the Underlying XAML
1183
The WF 4.0 Runtime
1185
Hosting a Workflow using WorkflowInvoker
1185
Passing Arguments to your Workflow using WorkflowInvoker
1186
Defining Arguments Using the Workflow Designer
1186
Hosting a Workflow using WorkflowApplication
1188
Recap of your First Workflow
1190
Examining the Workflow 4.0 Activities
1190
Control Flow Activities
1190
Flowchart Activities
1191
Messaging Activities
1192
The Runtime and Primitives Activities
1193
The Transaction Activities
1193
The Collection and Error Handling Activities
1194
Building a Flowchart Workflow
1194
Connecting Activities in a Flowchart
1195
Working with the InvokeMethod Activity
1196
Defining Workflow Wide Variables
1197
Working with the FlowDecision Activity
1197
Working with the TerminateWorkflow Activity
1198
Building the “True” Condition
1199
Working with the ForEach
Activity 1200
Completing the Application
1202
Reflecting on What We Have Done
1203
Isolating Workflows into Dedicated Libraries
1205
Defining the Initial Project
1205
Importing Assemblies and Namespaces
1207
Defining the Workflow Arguments
1207
Defining Workflow Variables
1208
Working with the Assign Activity
1209
Working with the If and Switch Activities
1209
Building a Custom Code Activity
1211
Consuming the Workflow Library
1214
Retrieving the Workflow Output Argument
1214
Summary
1216
Chapter 27: Introducing Windows Presentation Foundation and XAML
1217
The Motivation Behind WPF
1217
Unifying Diverse APIs
1218
Providing a Separation of Concerns via XAML
1219
Providing an Optimized Rendering Model
1220
Simplifying Complex UI Programming
1220
The Various Flavors of WPF
1221
Traditional Desktop Applications
1221
Navigation-Based WPF Applications
1224
XBAP Applications
1224
The WPF/Silverlight Relationship
1226
Investigating the WPF Assemblies
1226
The Role of the Application Class
1228
Constructing an Application Class
1229
Enumerating the Application.Windows collection
1230
The Role of the Window Class
1230
The Role of System.Windows.Controls.ContentControl
1231
The Role of System.Windows.Controls.Control
1233
The Role of System.Windows.FrameworkElement
1233
The Role of System.Windows.UIElement
1234
The Role of System.Windows.Media.Visual
1235
The Role of System.Windows.DependencyObject
1235
The Role of System.Windows.Threading.DispatcherObject
1235
Building a WPF Application without XAML
1236
Creating a Strongly Typed Window
1238
Creating a Simple User Interface
1238
Interacting with Application Level Data
1240
Handling the Closing of a Window Object
1241
Intercepting Mouse Events
1242
Intercepting Keyboard Events
1243
Building a WPF Application using Only XAML
1245
Defining MainWindow in XAML
1246
Defining the Application Object in XAML
1247
Processing the XAML Files using msbuild.exe
1248
Transforming Markup into a .NET Assembly
1250
Mapping the Window XAML Data to VB 2010 Code
1250
The Role of BAML
1252
Mapping the Application XAML Data to VB 2010 Code
1253
XAML-to-Assembly Process Summary
1254
Understanding The Syntax of WPF XAML
1255
Introducing Kaxaml
1255
XAML XML Namespaces and XAML "Keywords"
1256
Controlling Class and Member Variable Declarations
1259
XAML Elements, XAML Attributes and Type Converters
1260
Understanding XAML Property-Element Syntax
1261
Understanding XAML Attached Properties
1262
Understanding XAML Markup Extensions
1263
Building a WPF Application using Code-Behind Files
1265
Adding a Code File for the MainWindow Class
1265
Adding a Code File for the MyApp Class
1266
Processing the Code Files with msbuild.exe
1267
Building WPF Applications Using Visual Studio 2010
1268
The WPF Project Templates
1268
Exploring the WPF Designer Tools
1269
Designing the GUI of our Window
1273
Implementing the Loaded Event
1274
Implementing the Button’s Click Event
1275
Implementing the Closed Event
1276
Testing the Application
1277
Summary
1278
Chapter 28: Programming with WPF Controls
1279
A Survey of the Core WPF Controls
1279
Working with WPF Controls Using Visual Studio 2010
1281
The WPF Ink Controls
1283
The WPF Document Controls
1284
WPF Common Dialog Boxes
1284
The Details Are in the Documentation
1284
Controlling Content Layout Using Panels
1285
Positioning Content Within Canvas Panels
1287
Positioning Content Within WrapPanel Panels
1289
Positioning Content Within StackPanel Panels
1291
Positioning Content Within Grid Panels
1292
Grids with GridSplitter Types
1293
Positioning Content Within DockPanel Panels
1294
Enabling Scrolling for Panel Types
1295
Building a Window’s Frame Using Nested Panels
1296
Building the Menu System
1297
Building the ToolBar
1299
Building the StatusBar
1299
Finalizing the UI Design
1299
Implementing the MouseEnter/MouseLeave Event Handlers
1300
Implementing the Spell Checking Logic
1301
Understanding WPF Control Commands
1302
The Intrinsic Control Command Objects
1302
Connecting Commands to Arbitrary Actions
1303
Working with the Open and Save Commands
1304
Building a WPF User Interface with Expression Blend
1308
Getting to know the Key Aspects of the Blend IDE
1308
Using the TabControl
1314
Building the Ink API Tab
1317
Designing the ToolBar
1318
The RadioButton Control
1321
The InkCanvas Control
1323
The ComboBox Control
1326
Saving, Loading, and Clearing InkCanvas Data
1328
Introducing the Documents API
1328
Block Elements and Inline Elements
1329
Document Layout Managers
1329
Building the Documents Tab
1330
Populating a FlowDocument using Blend
1331
Populating a FlowDocument Using Code
1333
Enabling Annotations and Sticky Notes
1334
Saving and Loading a Flow Document
1336
Introducing the WPF Data-Binding Model
1337
Building the Data Binding Tab
1338
Establishing Data Bindings using Blend
1338
The DataContext Property
1341
Data Conversion Using IValueConverter
1342
Establishing Data Bindings in Code
1343
Building the DataGrid Tab
1344
Summary
1346
Chapter 29: WPF Graphics Rendering Services
1347
Understanding WPF’s Graphical Rendering Services
1347
WPF Graphical Rendering Options
1348
Rendering Graphical Data Using Shapes
1349
Adding Rectangles, Ellipses, and Lines to a Canvas
1351
Removing Rectangles, Ellipses, and Lines from a Canvas
1354
Working with Polylines and Polygons
1356
Working with Paths
1356
The Path “Modeling Mini Language”
1358
WPF Brushes and Pens
1360
Configuring Brushes Using Visual Studio 2010
1361
Configuring Brushes in Code
1362
Configuring Pens
1364
Applying Graphical Transformations
1364
A First Look at Transformations
1365
Transforming our Canvas Data
1366
Working with Shapes using Expression Blend
1368
Selecting a Shape to Render from the Tool Palette
1368
Converting Shapes to Paths
1370
Combining Shapes
1370
The Brush and Transformation Editors
1371
Rendering Graphical Data Using Drawings and Geometries
1373
Building a DrawingBrush using Geometries
1374
Painting with the DrawingBrush
1375
Containing Drawing Types in a DrawingImage
1376
Generating Complex Vector Graphics using Expression Design
1377
Exporting a Design Document to XAML
1378
Rendering Graphical Data Using the Visual Layer
1379
The Visual Base Class and Derived Child Classes
1379
A First Look at using the DrawingVisual Class
1380
Rendering Visual Data to a Custom Layout Manager
1382
Responding to Hit Test Operations
1385
Summary
1386
Chapter 30: WPF Resources, Animations, and Styles
1387
Understanding the WPF Resource System
1387
Working with Binary Resources
1388
Including Loose Resource Files in a Project
1389
Configuring the Loose Resources
1389
Programmatically Loading an Image
1391
Embedding Application Resources
1392
Working with Object (Logical) Resources
1394
The Role of the Resources Property
1395
Defining Window-Wide Resources
1395
The {StaticResource} Markup Extension
1397
Changing a Resource after Extraction
1398
The {DynamicResource} Markup Extension
1398
Application-Level Resources
1399
Defining Merged Resource Dictionaries
1401
Defining a Resource-Only Assembly
1402
Extracting Resources in Expression Blend
1404
Understanding WPF’s Animation Services
1406
The Role of the Animation Class Types
1407
The To, From, and By Properties
1408
The Role of the Timeline Base Class
1408
Authoring an Animation in VB 2010 Code
1409
Controlling the Pacing of an Animation
1410
Reversing and Looping an Animation
1411
Authoring Animations in XAML
1412
The Role of Storyboards
1413
The Role of Event Triggers
1414
Animation Using Discrete Key Frames
1414
Understanding the Role of WPF Styles
1415
Defining and Applying a Style
1416
Overriding Style Settings
1417
Automatically Applying a Style with TargetType
1417
Subclassing Existing Styles
1418
The Role of Unnamed Styles
1419
Defining Styles with Triggers
1420
Defining Styles with Multiple Triggers
1421
Animated Styles
1421
Assigning Styles Programmatically
1422
Generating Styles with Expression Blend
1423
Working with Default Visual Styles
1424
Summary
1427
Chapter 31: WPF Control Templates and UserControls
1428
Understanding the Role of Dependency Properties
1428
Examining an Existing Dependency Property
1430
Important Notes Regarding CLR Property Wrappers
1433
Building a Custom Dependency Property
1434
Adding a Data Validation Routine
1437
Responding to the Property Change
1437
Understanding Routed Events
1439
The Role of Routed Bubbling Events
1440
Continuing or Halting Bubbling
1440
The Role of Routed Tunneling Events
1441
Logical Trees, Visual Trees and Default Templates
1443
Programmatically Inspecting a Logical Tree
1443
Programmatically Inspecting a Visual Tree
1445
Programmatically Inspecting a Control’s Default Template
1446
Building a Custom Control Template with Visual Studio 2010
1450
Templates as Resources
1451
Incorporating Visual Cues using Triggers
1452
The Role of {TemplateBinding} Markup Extension
1453
The Role of ContentPresenter
1455
Incorporating Templates into Styles
1456
Building Custom UserControls with Blend
1457
Creating a UserControl Library Project
1458
Renaming the Initial UserControl
1458
Designing the SpinControl
1459
Adding the Initial VB 2010 Code
1460
Defining an Animation using Blend
1461
Programmatically Starting our Storyboard
1464
Creating the Jackpot Deluxe WPF Application
1466
Extracting a UserControl from a Drawing Geometry
1466
The Role of .NET 4.0 Visual States
1468
Defining Visual States for the StarButton Control
1469
Defining State Transition Timings
1470
Viewing the Generated XAML
1471
Changing Visual States in Code using the VisualStateManager Class
1472
Finalizing the Jackpot Deluxe Application
1472
Summary
1477
Chapter 32: Building ASP.NET Web Pages
1478
The Role of HTTP
1478
The HTTP Request/Response Cycle
1479
HTTP Is a Stateless Protocol
1479
Understanding Web Applications and Web Servers
1480
The Role of IIS Virtual Directories
1480
The ASP.NET Development Web Server
1481
The Role of HTML
1481
HTML Document Structure
1482
The Role of an HTML Form
1483
The Visual Studio 2010 HTML Designer Tools
1484
Building an HTML Form
1486
The Role of Client-Side Scripting
1487
A Client-Side Scripting Example
1489
Posting Back to the Web Server
1490
Postbacks under ASP.NET
1490
The Feature Set of the ASP.NET API
1491
Major Features of ASP.NET 1.0-1.1
1491
Major Features of ASP.NET 2.0
1492
Major Features of ASP.NET 3.5 (and .NET 3.5 SP1)
1493
Major Features of ASP.NET 4.0
1494
Building a Single File ASP.NET Web Page
1494
Referencing AutoLotDAL.dll
1496
Designing the UI
1496
Adding the Data Access Logic
1497
The Role of ASP.NET Directives
1501
Analyzing the “Script” Block
1502
Analyzing the ASP.NET Control Declarations
1503
Compilation Cycle for Single-File Pages
1504
Building an ASP.NET Web Page using Code Files
1505
Referencing the AutoLotDAL.dll Assembly
1508
Updating the Code File
1508
Compilation Cycle for Multifile Pages
1509
Debugging and Tracing ASP.NET Pages
1509
ASP.NET Web Sites and ASP.NET Web Applications
1511
The ASP.NET Web Site Directory Structure
1512
Referencing Assemblies
1513
The Role of the App_Code Folder
1514
The Inheritance Chain of the Page Type
1515
Interacting with the Incoming HTTP Request
1516
Obtaining Brower Statistics
1518
Access to Incoming Form Data
1518
The IsPostBack Property
1519
Interacting with the Outgoing HTTP Response
1519
Emitting HTML Content
1521
Redirecting Users
1521
The Life Cycle of an ASP.NET Web Page
1522
The Error Event
1523
The Role of the Web.config File
1525
The ASP.NET Website Administration Utility
1526
Summary
1527
Chapter 33: ASP.NET Web Controls, Master Pages, and Themes
1528
Understanding the Nature of Web Controls
1528
Understanding Server-Side Event Handling
1529
The AutoPostBack Property
1530
The Control and WebControl Base Classes
1531
Enumerating Contained Controls
1531
Dynamically Adding and Removing Controls
1535
Interacting with Dynamically Created Controls
1535
Functionality of the WebControl Base Class
1536
Major Categories of ASP.NET Web Controls
1537
A Brief Word Regarding System.Web.UI.HtmlControls
1539
Web Control Documentation
1540
Building the ASP.NET Cars Web Site
1540
Working with ASP.NET Master Pages
1541
Working with the TreeView Control Site Navigation Logic
1544
Establishing Bread Crumbs with the SiteMapPath Type
1547
Working with the AdRotator
1547
Defining the Default Content Page
1548
Designing the Inventory Content Page
1550
Enabling Sorting and Paging
1553
Enabling In-Place Editing
1554
Designing the Build-a-Car Content Page
1555
The Role of the Validation Controls
1557
The RequiredFieldValidator
1560
The RegularExpressionValidator
1560
The RangeValidator
1561
The CompareValidator
1561
Creating Validation Summaries
1562
Defining Validation Groups
1563
Working with Themes
1565
Understanding *.skin Files
1566
Applying Sitewide Themes
1568
Applying Themes at the Page Level
1569
The SkinID Property
1569
Assigning Themes Programmatically
1570
Summary
1572
Chapter 34: ASP.NET State Management Techniques
1573
The Issue of State
1573
ASP.NET State Management Techniques
1576
Understanding the Role of ASP.NET View State
1576
Demonstrating View State
1577
Adding Custom View State Data
1578
The Role of the Global.asax File
1579
The Global Last-Chance Exception Event Handler
1581
The HttpApplication Base Class
1582
Understanding the Application/Session Distinction
1583
Maintaining Application-Level State Data
1584
Modifying Application Data
1586
Handling Web Application Shutdown
1588
Working with the Application Cache
1588
Fun with Data Caching
1589
Modifying the *.aspx File
1591
Maintaining Session Data
1593
Additional Members of HttpSessionState
1596
Understanding Cookies
1597
Creating Cookies
1597
Reading Incoming Cookie Data
1599
The Role of the
Element 1599
Storing Session Data in the ASP.NET Session State Server
1599
Storing Session Data in a Dedicated Database
1601
Understanding the ASP.NET Profile API
1601
The ASPNETDB.mdf Database
1602
Defining a User Profile Within Web.config
1603
Accessing Profile Data Programmatically
1604
Grouping Profile Data and Persisting Custom Objects
1607
Summary
1609
Appendix A: Programming with Windows Forms
1610
The Windows Forms Namespaces
1611
Building a Simple Windows Forms Application
1612
Populating the Controls Collection
1614
The Role of System.EventArgs and System.EventHandler
1617
The Visual Studio Windows Forms Project Template
1618
The Visual Designer Surface
1618
Dissecting the Initial Form
1620
Visually Building a Menu System
1621
The System.EventHandler Delegate
1624
The Anatomy of a Form
1625
The Functionality of the Control Class
1626
The Functionality of the Form Class
1629
The Life Cycle of a Form Type
1631
Responding to Mouse and Keyboard Activity
1634
Determining Which Mouse Button Was Clicked
1635
Determining Which Key Was Pressed
1636
Designing Dialog Boxes
1638
The DialogResult Property
1639
Configuring the Tab Order
1640
The Tab Order Wizard
1641
Setting the Form’s Default Input Button
1641
Displaying Dialog Boxes
1642
Understanding Form Inheritance
1643
Rendering Graphical Data Using GDI+
1645
The System.Drawing Namespace
1647
The Role of the Graphics Type
1648
Obtaining a Graphics Object with the Paint Event
1649
Invalidating the Form’s Client Area
1651
Building a Complete Windows Forms Application
1652
Building the Main Menu System
1652
Defining the ShapeData Type
1654
Defining the ShapePickerDialog Type
1655
Adding Infrastructure to the MainWindow Type
1656
Implementing the Tools Menu Functionality
1657
Capturing and Rendering the Graphical Output
1658
Implementing the Serialization Logic
1660
Summary
1661
Appendix B: Platform-Independent .NET Development with Mono
1662
The Platform-Independent Nature of .NET
1662
The Role of the CLI
1663
The Mainstream CLI Distributions
1664
The Scope of Mono
1665
Obtaining and Installing Mono
1666
Examining Mono’s Directory Structure
1668
The Mono Development Languages
1670
Working with the VB 2010 Compiler
1670
Building Mono Applications using MonoDevelop
1671
Microsoft-Compatible Mono Development Tools
1671
Mono-Specific Development Tools
1672
Using monop
1673
Building .NET Applications with Mono
1674
Building a Mono Code Library
1674
Assigning CoreLibDumper.dll a Strong Name
1675
Viewing the Updated Manifest with monodis
1675
Installing Assemblies into the Mono GAC
1676
Building a Console Application in Mono
1677
Loading Your Client Application in the Mono Runtime
1678
Executing Your Windows Forms Application Under Linux
1679
Who is Using Mono?
1680
Suggestions for Further Study
1680
Summary
1682
Index
1683
All prices incl. VAT