Pro C# 2010 and the .NET 4 Platform [5 ed.] 1430225491, 9781430225492

The first edition of this book was released at the 2001 Tech-Ed conference in Atlanta, Georgia. At that time, the .NET p

443 25 11MB

English Pages 1752 [1753] Year 2010

Report DMCA / Copyright

DOWNLOAD FILE

Pro C# 2010 and the .NET 4 Platform [5 ed.]
 1430225491, 9781430225492

Table of contents :
Prelim......Page 1
Contents at a Glance......Page 7
Contents......Page 10
About the Author......Page 27
About the Technical Reviewer......Page 28
Acknowledgments......Page 29
Introduction......Page 30
An Overview of This Book......Page 31
Obtaining This Book’s Source Code......Page 39
Contacting Me......Page 40
Part 1: Introducing C# and the .NET Platform......Page 41
Understanding the Previous State of Affairs......Page 43
Life As a Visual Basic 6.0 Programmer......Page 44
Life As a COM Programmer......Page 45
The .NET Solution......Page 46
Introducing the Building Blocks of the .NET Platform (the CLR, CTS, and CLS)......Page 47
What C# Brings to the Table......Page 48
Additional .NET-Aware Programming Languages......Page 50
An Overview of .NET Assemblies......Page 52
The Role of the Common Intermediate Language......Page 54
Benefits of CIL......Page 56
The Role of .NET Type Metadata......Page 57
The Role of the Assembly Manifest......Page 58
CTS Class Types......Page 59
CTS Structure Types......Page 60
CTS Delegate Types......Page 61
Intrinsic CTS Data Types......Page 62
Understanding the Common Language Specification......Page 63
Understanding the Common Language Runtime......Page 65
The Assembly/Namespace/Type Distinction......Page 67
Accessing a Namespace Programmatically......Page 70
Referencing External Assemblies......Page 72
Exploring an Assembly Using ildasm.exe......Page 73
Viewing Type Metadata......Page 74
Exploring an Assembly Using Reflector......Page 75
Deploying the .NET Runtime......Page 76
The Platform-Independent Nature of .NET......Page 77
Summary......Page 79
The Role of the .NET Framework 4.0 SDK......Page 81
Building C# Applications Using csc.exe......Page 82
Specifying Input and Output Targets......Page 83
Referencing External Assemblies......Page 85
Compiling Multiple Source Files......Page 86
Working with C# Response Files......Page 87
The Default Response File (csc.rsp)......Page 88
Building .NET Applications Using Notepad++......Page 89
Building .NET Applications Using SharpDevelop......Page 90
Building a Simple Test Project......Page 91
Some Unique Features of Visual C# 2010 Express......Page 93
Building .NET Applications Using Visual Studio 2010......Page 94
Some Unique Features of Visual Studio 2010......Page 95
Using the Solution Explorer Utility......Page 96
Referencing External Assemblies......Page 97
The Class View Utility......Page 98
Integrated Support for Code Refactoring......Page 100
Code Expansions and Surround With Technology......Page 103
The Visual Class Designer......Page 104
The Integrated .NET Framework 4.0 SDK Documentation System......Page 107
Summary......Page 109
Part 2: Core C# Programming Constructs......Page 111
The Anatomy of a Simple C# Program......Page 113
Variations on the Main() Method......Page 115
Specifying an Application Error Code......Page 116
Processing Command-Line Arguments......Page 117
An Interesting Aside: Some Additional Members of the System.Environment Class......Page 119
The System.Console Class......Page 121
Basic Input and Output with the Console Class......Page 122
Formatting Console Output......Page 123
Formatting Numerical Data......Page 124
Formatting Numerical Data Beyond Console Applications......Page 125
System Data Types and C# Shorthand Notation......Page 126
Variable Declaration and Initialization......Page 128
Intrinsic Data Types and the new Operator......Page 129
The Data Type Class Hierarchy......Page 130
Members of Numerical Data Types......Page 132
Members of System.Char......Page 133
Parsing Values from String Data......Page 134
The .NET 4.0 System.Numerics Namespace......Page 135
Working with String Data......Page 137
Basic String Manipulation......Page 138
String Concatenation......Page 139
Escape Characters......Page 140
Defining Verbatim Strings......Page 141
Strings Are Immutable......Page 142
The System.Text.StringBuilder Type......Page 144
Narrowing and Widening Data Type Conversions......Page 146
Trapping Narrowing Data Conversions......Page 148
Setting Project-wide Overflow Checking......Page 150
The unchecked Keyword......Page 151
Understanding Implicitly Typed Local Variables......Page 152
Restrictions on Implicitly Typed Variables......Page 154
Implicit Typed Data Is Strongly Typed Data......Page 155
Usefulness of Implicitly Typed Local Variables......Page 156
The for Loop......Page 157
Use of var Within foreach Constructs......Page 158
Decision Constructs and the Relational/Equality Operators......Page 159
The if/else Statement......Page 160
The switch Statement......Page 161
Summary......Page 162
Methods and Parameter Modifiers......Page 165
The Default Parameter-Passing Behavior......Page 166
The out Modifier......Page 167
The ref Modifier......Page 168
The params Modifier......Page 170
Defining Optional Parameters......Page 171
Invoking Methods using Named Parameters......Page 173
Understanding Method Overloading......Page 175
Understanding C# Arrays......Page 177
C# Array Initialization Syntax......Page 178
Defining an Array of Objects......Page 179
Working with Multidimensional Arrays......Page 180
The System.Array Base Class......Page 182
Understanding the Enum Type......Page 184
Controlling the Underlying Storage for an Enum......Page 185
Declaring Enum Variables......Page 186
The System.Enum Type......Page 187
Dynamically Discovering an Enum’s Name/Value Pairs......Page 188
Understanding the Structure Type......Page 191
Creating Structure Variables......Page 192
Understanding Value Types and Reference Types......Page 194
Value Types, References Types, and the Assignment Operator......Page 195
Value Types Containing Reference Types......Page 197
Passing Reference Types by Value......Page 198
Passing Reference Types by Reference......Page 200
Final Details Regarding Value Types and Reference Types......Page 201
Understanding C# Nullable Types......Page 202
Working with Nullable Types......Page 203
The ?? Operator......Page 204
Summary......Page 205
Introducing the C# Class Type......Page 207
Understanding Constructors......Page 210
The Role of the Default Constructor......Page 211
Defining Custom Constructors......Page 212
The Default Constructor Revisited......Page 213
The Role of the this Keyword......Page 214
Chaining Constructor Calls Using this......Page 216
Observing Constructor Flow......Page 218
Revisiting Optional Arguments......Page 220
Defining Static Methods......Page 221
Defining Static Field Data......Page 222
Defining Static Constructors......Page 225
Defining Static Classes......Page 227
Defining the Pillars of OOP......Page 228
The Role of Inheritance......Page 229
The Role of Polymorphism......Page 231
C# Access Modifiers......Page 232
The Default Access Modifiers......Page 233
The First Pillar: C#’s Encapsulation Services......Page 234
Encapsulation Using Traditional Accessors and Mutators......Page 235
Encapsulation Using .NET Properties......Page 238
Using Properties within a Class Definition......Page 240
Internal Representation of Properties......Page 242
Read-Only and Write-Only Properties......Page 244
Static Properties......Page 245
Understanding Automatic Properties......Page 246
Regarding Automatic Properties and Default Values......Page 248
Understanding Object Initializer Syntax......Page 250
Calling Custom Constructors with Initialization Syntax......Page 252
Initializing Inner Types......Page 253
Working with Constant Field Data......Page 254
Understanding Read-Only Fields......Page 255
Static Read-Only Fields......Page 256
Understanding Partial Types......Page 257
Summary......Page 258
The Basic Mechanics of Inheritance......Page 259
Specifying the Parent Class of an Existing Class......Page 260
The sealed Keyword......Page 262
Revising Visual Studio Class Diagrams......Page 264
The Second Pillar of OOP: The Details of Inheritance......Page 266
Controlling Base Class Creation with the base Keyword......Page 268
Keeping Family Secrets: The protected Keyword......Page 270
Adding a Sealed Class......Page 271
Programming for Containment/Delegation......Page 272
Understanding Nested Type Definitions......Page 273
The Third Pillar of OOP: C#’s Polymorphic Support......Page 275
The virtual and override Keywords......Page 276
Overriding Virtual Members Using Visual Studio 2010......Page 278
Sealing Virtual Members......Page 279
Understanding Abstract Classes......Page 280
Understanding the Polymorphic Interface......Page 281
Understanding Member Shadowing......Page 285
Understanding Base Class/Derived Class Casting Rules......Page 287
The C# as Keyword......Page 289
The Master Parent Class: System.Object......Page 290
Overriding System.Object.Equals()......Page 294
Overriding System.Object.GetHashCode()......Page 295
Testing Your Modified Person Class......Page 296
The Static Members of System.Object......Page 297
Summary......Page 298
Ode to Errors, Bugs, and Exceptions......Page 299
The Role of .NET Exception Handling......Page 300
The System.Exception Base Class......Page 301
The Simplest Possible Example......Page 303
Throwing a General Exception......Page 305
Catching Exceptions......Page 306
Configuring the State of an Exception......Page 307
The StackTrace Property......Page 308
The HelpLink Property......Page 309
The Data Property......Page 310
System-Level Exceptions (System.SystemException)......Page 312
Building Custom Exceptions, Take One......Page 313
Building Custom Exceptions, Take Two......Page 315
Building Custom Exceptions, Take Three......Page 316
Processing Multiple Exceptions......Page 317
General catch Statements......Page 319
Rethrowing Exceptions......Page 320
Inner Exceptions......Page 321
Who Is Throwing What?......Page 322
The Result of Unhandled Exceptions......Page 323
Debugging Unhandled Exceptions Using Visual Studio......Page 324
A Brief Word Regarding Corrupted State Exceptions (CSE)......Page 325
Summary......Page 327
Classes, Objects, and References......Page 329
The Basics of Object Lifetime......Page 331
The CIL of new......Page 332
Setting Object References to null......Page 333
The Role of Application Roots......Page 334
Understanding Object Generations......Page 336
Background Garbage Collection under .NET 4.0......Page 337
The System.GC Type......Page 338
Forcing a Garbage Collection......Page 339
Building Finalizable Objects......Page 342
Overriding System.Object.Finalize()......Page 343
Building Disposable Objects......Page 345
Reusing the C# using Keyword......Page 348
Building Finalizable and Disposable Types......Page 349
A Formalized Disposal Pattern......Page 350
Understanding Lazy Object Instantiation......Page 353
Customizing the Creation of the Lazy Data......Page 355
Summary......Page 356
Part 3: Advanced C# Programming Constructs......Page 359
Understanding Interface Types......Page 361
Interface Types vs. Abstract Base Classes......Page 362
Defining Custom Interfaces......Page 365
Implementing an Interface......Page 367
Invoking Interface Members at the Object Level......Page 369
Obtaining Interface References: The is Keyword......Page 370
Interfaces As Parameters......Page 371
Interfaces As Return Values......Page 373
Arrays of Interface Types......Page 374
Implementing Interfaces Using Visual Studio 2010......Page 375
Resolving Name Clashes via Explicit Interface Implementation......Page 376
Designing Interface Hierarchies......Page 379
Multiple Inheritance with Interface Types......Page 381
Building Enumerable Types (IEnumerable and IEnumerator)......Page 383
Building Iterator Methods with the yield Keyword......Page 386
Building a Named Iterator......Page 387
Internal Representation of an Iterator Method......Page 388
Building Cloneable Objects (ICloneable)......Page 389
A More Elaborate Cloning Example......Page 391
Building Comparable Objects (IComparable)......Page 394
Specifying Multiple Sort Orders (IComparer)......Page 397
Custom Properties, Custom Sort Types......Page 398
Summary......Page 399
The Issues with Non-Generic Collections......Page 401
The Issue of Performance......Page 403
The Issue of Type Safety......Page 407
The Role of Generic Type Parameters......Page 411
Specifying Type Parameters for Generic Classes / Structures......Page 412
Specifying Type Parameters for Generic Interfaces......Page 414
The System.Collections.Generic Namespace......Page 416
Understanding Collection Initialization Syntax......Page 418
Working with the List Class......Page 419
Working with the Stack Class......Page 420
Working with the Queue Class......Page 422
Working with the SortedSet Class......Page 423
Creating Custom Generic Methods......Page 425
Inference of Type Parameters......Page 427
Creating Custom Generic Structures and Classes......Page 428
The default Keyword in Generic Code......Page 430
Generic Base Classes......Page 431
Constraining Type Parameters......Page 432
Examples Using the where Keyword......Page 433
The Lack of Operator Constraints......Page 434
Summary......Page 435
Understanding the .NET Delegate Type......Page 437
Defining a Delegate Type in C#......Page 438
The System.MulticastDelegate and System.Delegate Base Classes......Page 440
The Simplest Possible Delegate Example......Page 442
Investigating a Delegate Object......Page 444
Sending Object State Notifications using Delegates......Page 445
Enabling Multicasting......Page 448
Removing Targets from a Delegate’s Invocation List......Page 450
Method Group Conversion Syntax......Page 451
Understanding Delegate Covariance......Page 453
Understanding Generic Delegates......Page 455
Simulating Generic Delegates Without Generics......Page 457
Understanding C# Events......Page 458
The C# event Keyword......Page 459
Events under the Hood......Page 461
Listening to Incoming Events......Page 462
Simplifying Event Registration Using Visual Studio 2010......Page 463
Creating Custom Event Arguments......Page 464
The Generic EventHandler Delegate......Page 466
Understanding C# Anonymous Methods......Page 467
Accessing Local Variables......Page 469
Understanding Lambda Expressions......Page 470
Processing Arguments Within Multiple Statements......Page 473
Lambda Expressions with Multiple (or Zero) Parameters......Page 475
Retrofitting the CarEvents Example Using Lambda Expressions......Page 476
Summary......Page 477
Understanding Indexer Methods......Page 479
Indexing Data Using String Values......Page 481
Indexers with Multiple Dimensions......Page 483
Understanding Operator Overloading......Page 484
Overloading Binary Operators......Page 485
Overloading Unary Operators......Page 488
Overloading Equality Operators......Page 489
Overloading Comparison Operators......Page 490
The Internal Representation of Overloaded Operators......Page 491
Final Thoughts Regarding Operator Overloading......Page 493
Recall: Conversions Among Related Class Types......Page 494
Creating Custom Conversion Routines......Page 495
Defining Implicit Conversion Routines......Page 498
Understanding Extension Methods......Page 500
Defining Extension Methods......Page 501
Invoking Extension Methods on an Instance Level......Page 503
The Scope of an Extension Method......Page 504
Importing Types That Define Extension Methods......Page 505
The IntelliSense of Extension Methods......Page 506
Building and Using Extension Libraries......Page 507
Extending Interface Types via Extension Methods......Page 509
Understanding Partial Methods......Page 510
A First Look at Partial Methods......Page 511
Uses of Partial Methods......Page 512
Understanding Anonymous Types......Page 513
The Internal Representation of Anonymous Types......Page 514
The Semantics of Equality for Anonymous Types......Page 516
Anonymous Types Containing Anonymous Types......Page 518
Working with Pointer Types......Page 519
The unsafe Keyword......Page 521
Working with the * and & Operators......Page 522
An Unsafe (and Safe) Swap Function......Page 523
Field Access via Pointers (the -> Operator)......Page 524
Pinning a Type via the fixed Keyword......Page 525
The sizeof Keyword......Page 526
Summary......Page 527
LINQ Specific Programming Constructs......Page 529
Implicit Typing of Local Variables......Page 530
Lambda Expressions......Page 531
Extension Methods......Page 532
Understanding the Role of LINQ......Page 533
The Core LINQ Assemblies......Page 535
Applying LINQ Queries to Primitive Arrays......Page 536
Once Again, Without LINQ......Page 537
LINQ and Implicitly Typed Local Variables......Page 538
LINQ and Extension Methods......Page 540
The Role of Deferred Execution......Page 541
The Role of Immediate Execution......Page 542
Returning the Result of a LINQ Query......Page 543
Applying LINQ Queries to Collection Objects......Page 545
Accessing Contained Subobjects......Page 546
Applying LINQ Queries to Nongeneric Collections......Page 547
Investigating the C# LINQ Query Operators......Page 548
Basic Selection Syntax......Page 550
Obtaining Subsets of Data......Page 551
Projecting New Data Types......Page 552
Obtaining Counts Using Enumerable......Page 553
Sorting Expressions......Page 554
LINQ As a Better Venn Diagramming Tool......Page 555
LINQ Aggregation Operations......Page 556
The Internal Representation of LINQ Query Statements......Page 557
Building Query Expressions with Query Operators (Revisited)......Page 558
Building Query Expressions Using the Enumerable Type and Lambda Expressions......Page 559
Building Query Expressions Using the Enumerable Type and Anonymous Methods......Page 560
Building Query Expressions Using the Enumerable Type and Raw Delegates......Page 561
Summary......Page 562
Part 4: Programming with .NET Assemblies......Page 563
Defining Custom Namespaces......Page 565
Resolving Name Clashes with Fully Qualified Names......Page 567
Resolving Name Clashes with Aliases......Page 568
Creating Nested Namespaces......Page 570
The Default Namespace of Visual Studio 2010......Page 571
Assemblies Are Versionable Units......Page 572
Understanding the Format of a .NET Assembly......Page 573
The Windows File Header......Page 574
The CLR File Header......Page 575
Single-File and Multifile Assemblies......Page 576
Building and Consuming a Single-File Assembly......Page 578
Exploring the Manifest......Page 581
Exploring the Type Metadata......Page 584
Building a C# Client Application......Page 585
Building a Visual Basic Client Application......Page 587
Cross-Language Inheritance in Action......Page 589
Building and Consuming a Multifile Assembly......Page 590
Exploring the airvehicles.dll File......Page 591
Consuming a Multifile Assembly......Page 592
Understanding the Probing Process......Page 593
Configuring Private Assemblies......Page 594
Configuration Files and Visual Studio 2010......Page 596
Understanding Shared Assemblies......Page 598
Understanding Strong Names......Page 600
Generating Strong Names at the Command Line......Page 601
Generating Strong Names using Visual Studio 2010......Page 603
Installing Strongly Named Assemblies to the GAC......Page 605
Viewing the .NET 4.0 GAC using Windows Explorer......Page 606
Consuming a Shared Assembly......Page 607
Configuring Shared Assemblies......Page 609
Building Shared Assembly Version 2.0.0.0......Page 610
Dynamically Redirecting to Specific Versions of a Shared Assembly......Page 613
Understanding Publisher Policy Assemblies......Page 614
Disabling Publisher Policy......Page 615
Understanding the Element......Page 616
The System.Configuration Namespace......Page 617
Summary......Page 619
The Necessity of Type Metadata......Page 621
Viewing (Partial) Metadata for the EngineState Enumeration......Page 622
Viewing (Partial) Metadata for the Car Type......Page 623
Documenting Referenced Assemblies......Page 625
Understanding Reflection......Page 626
The System.Type Class......Page 627
Obtaining a Type Reference Using System.Object.GetType()......Page 628
Obtaining a Type Reference Using System.Type.GetType()......Page 629
Reflecting on Methods......Page 630
Reflecting on Implemented Interfaces......Page 631
Implementing Main()......Page 632
Reflecting on Method Parameters and Return Values......Page 634
Dynamically Loading Assemblies......Page 636
Reflecting on Shared Assemblies......Page 638
Understanding Late Binding......Page 640
The System.Activator Class......Page 641
Invoking Methods with No Parameters......Page 642
Invoking Methods with Parameters......Page 643
Understanding the Role of .NET Attributes......Page 644
Attribute Consumers......Page 645
Applying Attributes in C#......Page 646
C# Attribute Shorthand Notation......Page 647
The Obsolete Attribute in Action......Page 648
Building Custom Attributes......Page 649
Named Property Syntax......Page 650
Restricting Attribute Usage......Page 651
Assembly-Level (and Module-Level) Attributes......Page 652
The Visual Studio 2010 AssemblyInfo.cs File......Page 653
Reflecting on Attributes Using Early Binding......Page 654
Reflecting on Attributes Using Late Binding......Page 655
Putting Reflection, Late Binding, and Custom Attributes in Perspective......Page 657
Building an Extendable Application......Page 658
Building the C# Snap-In......Page 659
Building the Visual Basic Snap-In......Page 660
Building an Extendable Windows Forms Application......Page 661
Summary......Page 664
The Role of a Windows Process......Page 665
The Role of Threads......Page 666
Interacting with Processes Under the .NET Platform......Page 667
Enumerating Running Processes......Page 670
Investigating a Process’s Thread Set......Page 671
Investigating a Process’s Module Set......Page 674
Starting and Stopping Processes Programmatically......Page 675
Controlling Process Startup using the ProcessStartInfo Class......Page 676
Understanding .NET Application Domains......Page 677
The System.AppDomain Class......Page 678
Interacting with the Default Application Domain......Page 680
Enumerating Loaded Assemblies......Page 681
Creating New Application Domains......Page 683
Loading Assemblies into Custom Application Domains......Page 685
Programmatically Unloading AppDomains......Page 686
Understanding Object Context Boundaries......Page 688
Defining a Context-Bound Object......Page 689
Inspecting an Object’s Context......Page 690
Summary......Page 692
Reasons for Learning the Grammar of CIL......Page 693
Examining CIL Directives, Attributes, and Opcodes......Page 694
The CIL Opcode/CIL Mnemonic Distinction......Page 695
Pushing and Popping: The Stack-Based Nature of CIL......Page 696
Understanding Round-Trip Engineering......Page 698
The Role of CIL Code Labels......Page 701
Interacting with CIL: Modifying an *.il File......Page 702
Compiling CIL Code Using ilasm.exe......Page 703
Authoring CIL Code Using SharpDevelop......Page 705
Specifying Externally Referenced Assemblies in CIL......Page 706
Defining the Current Assembly in CIL......Page 707
Defining Class Types in CIL......Page 708
Defining Structures in CIL......Page 710
Defining Generics in CIL......Page 711
Compiling the CILTypes.il file......Page 712
.NET Base Class Library, C#, and CIL Data Type Mappings......Page 713
Defining Field Data in CIL......Page 714
Defining Type Constructors in CIL......Page 715
Defining Member Parameters......Page 716
Examining CIL Opcodes......Page 717
Declaring Local Variables in CIL......Page 720
Mapping Parameters to Local Variables in CIL......Page 721
Representing Iteration Constructs in CIL......Page 722
Building CILCars.dll......Page 723
Building CILCarClient.exe......Page 726
Understanding Dynamic Assemblies......Page 728
Exploring the System.Reflection.Emit Namespace......Page 729
The Role of the System.Reflection.Emit.ILGenerator......Page 730
Emitting a Dynamic Assembly......Page 731
Emitting the Assembly and Module Set......Page 733
The Role of the ModuleBuilder Type......Page 734
Emitting the HelloClass Type and the String Member Variable......Page 735
Emitting the Constructors......Page 736
Using the Dynamically Generated Assembly......Page 737
Summary......Page 738
The Role of the C# dynamic Keyword......Page 741
Calling Members on Dynamically Declared Data......Page 743
The Role of the Microsoft.CSharp.dll Assembly......Page 745
Limitations of the dynamic Keyword......Page 746
The Role of the Dynamic Language Runtime (DLR)......Page 747
The Role of Expression Trees......Page 748
Dynamic Runtime Lookup of Expression Trees......Page 749
Simplifying Late Bound Calls Using Dynamic Types......Page 750
Leveraging the dynamic Keyword to Pass Arguments......Page 751
Simplifying COM Interoperability using Dynamic Data......Page 754
The Role of Primary Interop Assemblies (PIAs)......Page 755
Embedding Interop Metadata......Page 756
Common COM Interop Pain Points......Page 757
COM Interop using C# 4.0 Language Features......Page 758
COM interop without C# 4.0 Language Features......Page 762
Summary......Page 763
Part 5: Introducing the .NET Base Class Libraries......Page 765
The Process/AppDomain/Context/Thread Relationship......Page 767
The Problem of Concurrency......Page 768
A Brief Review of the .NET Delegate......Page 769
The Asynchronous Nature of Delegates......Page 771
The System.IAsyncResult Interface......Page 772
Invoking a Method Asynchronously......Page 773
Synchronizing the Calling Thread......Page 774
The Role of the AsyncCallback Delegate......Page 776
Passing and Receiving Custom State Data......Page 778
The System.Threading Namespace......Page 779
The System.Threading.Thread Class......Page 781
Obtaining Statistics About the Current Thread......Page 782
The Name Property......Page 783
Programmatically Creating Secondary Threads......Page 784
Working with the ThreadStart Delegate......Page 785
Working with the ParameterizedThreadStart Delegate......Page 787
The AutoResetEvent Class......Page 788
Foreground Threads and Background Threads......Page 789
The Issue of Concurrency......Page 790
Synchronization Using the C# lock Keyword......Page 793
Synchronization Using the System.Threading.Monitor Type......Page 795
Synchronization Using the System.Threading.Interlocked Type......Page 796
Synchronization Using the [Synchronization] Attribute......Page 797
Programming with Timer Callbacks......Page 798
Understanding the CLR ThreadPool......Page 800
Parallel Programming under the .NET Platform......Page 801
The Task Parallel Library API......Page 802
Understanding Data Parallelism......Page 803
The Task Class......Page 805
Handling Cancelation Request......Page 806
Understanding Task Parallelism......Page 808
Parallel LINQ Queries (PLINQ)......Page 811
Canceling a PLINQ Query......Page 812
Summary......Page 814
Exploring the System.IO Namespace......Page 815
The Abstract FileSystemInfo Base Class......Page 817
Working with the DirectoryInfo Type......Page 818
Enumerating Files with the DirectoryInfo Type......Page 820
Creating Subdirectories with the DirectoryInfo Type......Page 821
Working with the Directory Type......Page 822
Working with the DriveInfo Class Type......Page 823
Working with the FileInfo Class......Page 825
The FileInfo.Open() Method......Page 826
The FileInfo.OpenRead() and FileInfo.OpenWrite() Methods......Page 828
Working with the File Type......Page 829
Additional File-centric Members......Page 830
The Abstract Stream Class......Page 832
Working with FileStreams......Page 833
Working with StreamWriters and StreamReaders......Page 834
Writing to a Text File......Page 835
Reading from a Text File......Page 836
Directly Creating StreamWriter/StreamReader Types......Page 837
Working with StringWriters and StringReaders......Page 838
Working with BinaryWriters and BinaryReaders......Page 839
Watching Files Programmatically......Page 841
Understanding Object Serialization......Page 844
The Role of Object Graphs......Page 845
Configuring Objects for Serialization......Page 846
Public Fields, Private Fields, and Public Properties......Page 847
Choosing a Serialization Formatter......Page 848
The IFormatter and IRemotingFormatter Interfaces......Page 849
Type Fidelity Among the Formatters......Page 850
Serializing Objects Using the BinaryFormatter......Page 851
Deserializing Objects Using the BinaryFormatter......Page 852
Serializing Objects Using the SoapFormatter......Page 853
Serializing Objects Using the XmlSerializer......Page 854
Controlling the Generated XML Data......Page 855
Serializing Collections of Objects......Page 856
Customizing the Soap/Binary Serialization Process......Page 858
A Deeper Look at Object Serialization......Page 859
Customizing Serialization Using ISerializable......Page 860
Customizing Serialization Using Attributes......Page 863
Summary......Page 864
A High-Level Definition of ADO.NET......Page 865
The Three Faces of ADO.NET......Page 866
Understanding ADO.NET Data Providers......Page 867
The Microsoft-Supplied ADO.NET Data Providers......Page 869
A Word Regarding System.Data.OracleClient.dll......Page 870
Additional ADO.NET Namespaces......Page 871
The Types of the System.Data Namespace......Page 872
The Role of the IDbConnection Interface......Page 873
The Role of the IDbDataParameter and IDataParameter Interfaces......Page 874
The Role of the IDbDataAdapter and IDataAdapter Interfaces......Page 875
The Role of the IDataReader and IDataRecord Interfaces......Page 876
Abstracting Data Providers Using Interfaces......Page 877
Increasing Flexibility Using Application Configuration Files......Page 879
Creating the Inventory Table......Page 880
Authoring the GetPetName() Stored Procedure......Page 883
Creating the Customers and Orders Tables......Page 884
Visually Creating Table Relationships......Page 886
The ADO.NET Data Provider Factory Model......Page 887
A Complete Data Provider Factory Example......Page 888
A Potential Drawback with the Provide Factory Model......Page 891
The Element......Page 892
Understanding the Connected Layer of ADO.NET......Page 893
Working with Connection Objects......Page 894
Working with ConnectionStringBuilder Objects......Page 896
Working with Command Objects......Page 898
Working with Data Readers......Page 899
Building a Reusable Data Access Library......Page 901
Adding the Insertion Logic......Page 903
Adding the Update Logic......Page 905
Adding the Selection Logic......Page 906
Specifying Parameters Using the DbParameter Type......Page 907
Executing a Stored Procedure......Page 909
Creating a Console UI–Based Front End......Page 911
Implementing the Main() Method......Page 912
Implementing the ShowInstructions() Method......Page 913
Implementing the ListInventory() Method......Page 914
Implementing the InsertNewCar() Method......Page 915
Implementing LookUpPetName()......Page 916
Understanding Database Transactions......Page 917
Key Members of an ADO.NET Transaction Object......Page 918
Adding a CreditRisks Table to the AutoLot Database......Page 919
Adding a Transaction Method to InventoryDAL......Page 920
Testing Your Database Transaction......Page 922
Summary......Page 923
Understanding the Disconnected Layer of ADO.NET......Page 925
Understanding the Role of the DataSet......Page 926
Key Properties of the DataSet......Page 927
Key Methods of the DataSet......Page 928
Working with DataColumns......Page 929
Building a DataColumn......Page 931
Adding DataColumn Objects to a DataTable......Page 932
Working with DataRows......Page 933
Understanding the RowState Property......Page 934
Understanding the DataRowVersion Property......Page 936
Working with DataTables......Page 937
Obtaining Data in a DataSet......Page 938
Processing DataTable Data Using DataTableReader Objects......Page 939
Serializing DataTable/DataSet Objects As XML......Page 941
Serializing DataTable/DataSet Objects in a Binary Format......Page 942
Binding DataTable Objects to Windows Forms GUIs......Page 943
Hydrating a DataTable from a Generic List......Page 944
Deleting Rows from a DataTable......Page 947
Selecting Rows Based on Filter Criteria......Page 948
Updating Rows Within a DataTable......Page 951
Working with the DataView Type......Page 952
Working with Data Adapters......Page 953
A Simple Data Adapter Example......Page 954
Mapping Database Names to Friendly Names......Page 956
Defining the Initial Class Type......Page 957
Configuring the Data Adapter Using the SqlCommandBuilder......Page 958
Setting Your Version Number......Page 959
Testing the Disconnected Functionality......Page 960
Multitabled DataSet Objects and Data Relationships......Page 961
Prepping the Data Adapters......Page 962
Updating the Database Tables......Page 964
Navigating Between Related Tables......Page 965
Visually Designing the DataGridView......Page 967
Examining the Strongly Typed DataSet......Page 972
Examining the Strongly Typed DataTable......Page 974
Examining the Strongly Typed DataRow......Page 975
Examining the Strongly Typed Data Adapter......Page 976
Completing the Windows Forms Application......Page 977
Isolating Strongly Typed Database Code into a Class Library......Page 978
Viewing the Generated Code......Page 979
Selecting Data with the Generated Code......Page 980
Inserting Data with the Generated Code......Page 981
Deleting Data with the Generated Code......Page 982
Programming with LINQ to DataSet......Page 983
The Role of the DataSet Extensions Library......Page 985
Obtaining a LINQ-Compatible DataTable......Page 986
Hydrating New DataTables from LINQ Queries......Page 988
Summary......Page 989
Understanding the Role of Entity Framework......Page 991
The Role of Entities......Page 993
The Building Blocks of the Entity Framework......Page 995
The Role of the Entity Client......Page 996
The Role of the ObjectContext and ObjectSet Classes......Page 998
All Together Now!......Page 1000
Generating the *.edmx File......Page 1001
Reshaping the Entity Data......Page 1005
Viewing the Mappings......Page 1007
Viewing the Generated *.edmx File Data......Page 1008
Viewing the Generated Source Code......Page 1010
Enhancing the Generated Source Code......Page 1012
Programming Against the Conceptual Model......Page 1013
Deleting a Record......Page 1014
Querying with LINQ to Entities......Page 1015
Querying with Entity SQL......Page 1017
Working with the Entity Client Data Reader Object......Page 1018
AutoLotDAL Version 4.0, Now with Entities......Page 1019
Mapping the Stored Procedure......Page 1020
The Role of Navigation Properties......Page 1022
Using Navigation Properties within LINQ to Entity Queries......Page 1024
Invoking a Stored Procedure......Page 1025
Data Binding Entities to Windows Forms GUIs......Page 1026
Adding the Data Binding Code......Page 1029
Summary......Page 1031
A Tale of Two XML APIs......Page 1033
LINQ to XML As a Better DOM......Page 1035
VB Literal Syntax As a Better LINQ to XML......Page 1036
Members of the System.Xml.Linq Namespace......Page 1037
The LINQ to XML Axis Methods......Page 1040
The Oddness of XName (and XNamespace)......Page 1041
Working with XElement and XDocument......Page 1042
Generating Documents from Arrays and Containers......Page 1044
Manipulating an in Memory XML Document......Page 1046
Import the Inventory.xml File......Page 1047
Defining a LINQ to XML Helper Class......Page 1048
Rigging up the UI to Your Helper Class......Page 1049
Summary......Page 1051
A Potpourri of Distributed Computing APIs......Page 1053
The Role of DCOM......Page 1054
The Role of MSMQ......Page 1055
The Role of XML Web Services......Page 1056
A .NET Web Service Example......Page 1057
The Role of WCF......Page 1059
An Overview of WCF Features......Page 1060
Tenet 4: Service Compatibility Is Based on Policy......Page 1061
Investigating the Core WCF Assemblies......Page 1062
The Visual Studio WCF Project Templates......Page 1063
The Basic Composition of a WCF Application......Page 1065
Understanding WCF Contracts......Page 1067
Understanding WCF Bindings......Page 1068
HTTP-Based Bindings......Page 1069
TCP-Based Bindings......Page 1070
Understanding WCF Addresses......Page 1071
Building a WCF Service......Page 1072
The [ServiceContract] Attribute......Page 1074
Service Types As Operational Contracts......Page 1075
Hosting the WCF Service......Page 1076
Establishing the ABCs Within an App.config File......Page 1077
Specifying Base Addresses......Page 1078
Details of the ServiceHost Type......Page 1080
Details of the Element......Page 1082
Enabling Metadata Exchange......Page 1083
Generating Proxy Code Using svcutil.exe......Page 1086
Generating Proxy Code Using Visual Studio 2010......Page 1087
Configuring a TCP-Based Binding......Page 1089
Simplifying Configuration Settings with WCF 4.0......Page 1090
Default Endpoints in WCF 4.0......Page 1091
Exposing a Single WCF Service Using Multiple Bindings......Page 1092
Changing Settings for a WCF Binding......Page 1093
The WCF 4.0 Default MEX Behavior Configuration......Page 1094
Refreshing the Client Proxy and Selecting the Binding......Page 1096
Building a Simple Math Service......Page 1097
Testing the WCF Service with WcfTestClient.exe......Page 1098
Altering Configuration Files Using SvcConfigEditor.exe......Page 1099
Hosting the WCF Service within a Windows Service......Page 1101
Specifying the ABCs in Code......Page 1102
Creating a Windows Service Installer......Page 1104
Installing the Windows Service......Page 1106
Invoking a Service Asynchronously from the Client......Page 1107
Designing WCF Data Contracts......Page 1110
Using the Web-Centric WCF Service Project Template......Page 1111
Implementing the Service Contract......Page 1113
The Role of the *.svc File......Page 1114
Testing the Service......Page 1115
Summary......Page 1116
Introducing Windows Workflow Foundation 4.0......Page 1117
The Role of WF 4.0......Page 1118
Building a (Painfully) Simple Workflow......Page 1119
Viewing the Underlying XAML......Page 1121
Hosting a Workflow using WorkflowInvoker......Page 1123
Defining Arguments using the Workflow Designer......Page 1124
Hosting a Workflow using WorkflowApplication......Page 1126
Examining the Workflow 4.0 Activities......Page 1128
Flowchart Activities......Page 1129
Messaging Activities......Page 1130
The Transaction Activities......Page 1131
The Collection and Error Handling Activities......Page 1132
Building a Flowchart Workflow......Page 1133
Working with the InvokeMethod Activity......Page 1134
Defining Workflow Wide Variables......Page 1135
Working with the FlowDecision Activity......Page 1136
Working with the TerminateWorkflow Activity......Page 1137
Building the “True” Condition......Page 1138
Working with the ForEach Activity......Page 1139
Completing the Application......Page 1140
Reflecting on What We Have Done......Page 1141
Defining the Initial Project......Page 1143
Defining the Workflow Arguments......Page 1145
Defining Workflow Variables......Page 1146
Working with the If and Switch Activities......Page 1147
Building a Custom Code Activity......Page 1149
Consuming the Workflow Library......Page 1152
Retrieving the Workflow Output Argument......Page 1153
Summary......Page 1154
Part 6: Building Desktop User Interfaces with WPF......Page 1155
The Motivation Behind WPF......Page 1157
Unifying Diverse APIs......Page 1158
Providing a Separation of Concerns via XAML......Page 1159
Simplifying Complex UI Programming......Page 1160
Traditional Desktop Applications......Page 1161
XBAP Applications......Page 1164
Investigating the WPF Assemblies......Page 1166
The Role of the Application Class......Page 1168
Constructing an Application Class......Page 1169
The Role of the Window Class......Page 1170
The Role of System.Windows.Controls.ContentControl......Page 1171
The Role of System.Windows.Controls.Control......Page 1172
The Role of System.Windows.FrameworkElement......Page 1173
The Role of System.Windows.Media.Visual......Page 1174
Building a WPF Application without XAML......Page 1175
Creating a Strongly Typed Window......Page 1177
Creating a Simple User Interface......Page 1178
Interacting with Application Level Data......Page 1179
Handling the Closing of a Window Object......Page 1181
Intercepting Mouse Events......Page 1182
Intercepting Keyboard Events......Page 1183
Building a WPF Application using Only XAML......Page 1184
Defining MainWindow in XAML......Page 1186
Defining the Application Object in XAML......Page 1187
Processing the XAML Files using msbuild.exe......Page 1188
Mapping the Window XAML Data to C# Code......Page 1190
The Role of BAML......Page 1191
XAML-to-Assembly Process Summary......Page 1193
Introducing Kaxaml......Page 1194
XAML XML Namespaces and XAML "Keywords"......Page 1196
Controlling Class and Member Variable Declarations......Page 1199
XAML Elements, XAML Attributes and Type Converters......Page 1200
Understanding XAML Property-Element Syntax......Page 1201
Understanding XAML Attached Properties......Page 1202
Understanding XAML Markup Extensions......Page 1203
Adding a Code File for the MainWindow Class......Page 1205
Processing the Code Files with msbuild.exe......Page 1206
Building WPF Applications Using Visual Studio 2010......Page 1207
The WPF Project Templates......Page 1208
Exploring the WPF Designer Tools......Page 1209
Designing the GUI of our Window......Page 1213
Implementing the Loaded Event......Page 1214
Implementing the Button’s Click Event......Page 1215
Testing the Application......Page 1217
Summary......Page 1218
A Survey of the Core WPF Controls......Page 1219
Working with WPF Controls Using Visual Studio 2010......Page 1221
The WPF Ink Controls......Page 1222
WPF Common Dialog Boxes......Page 1223
Controlling Content Layout Using Panels......Page 1224
Positioning Content Within Canvas Panels......Page 1226
Positioning Content Within WrapPanel Panels......Page 1228
Positioning Content Within StackPanel Panels......Page 1230
Positioning Content Within Grid Panels......Page 1231
Grids with GridSplitter Types......Page 1232
Positioning Content Within DockPanel Panels......Page 1233
Enabling Scrolling for Panel Types......Page 1234
Building a Window’s Frame Using Nested Panels......Page 1235
Building the Menu System......Page 1236
Building the ToolBar......Page 1237
Finalizing the UI Design......Page 1238
Implementing the MouseEnter/MouseLeave Event Handlers......Page 1239
Understanding WPF Control Commands......Page 1240
The Intrinsic Control Command Objects......Page 1241
Connecting Commands to the Command Property......Page 1242
Connecting Commands to Arbitrary Actions......Page 1243
Working with the Open and Save Commands......Page 1244
Getting to know the Key Aspects of the Blend IDE......Page 1247
Using the TabControl......Page 1253
Building the Ink API Tab......Page 1256
Designing the ToolBar......Page 1257
The RadioButton Control......Page 1260
The InkCanvas Control......Page 1262
The ComboBox Control......Page 1264
Saving, Loading, and Clearing InkCanvas Data......Page 1266
Block Elements and Inline Elements......Page 1267
Building the Documents Tab......Page 1268
Populating a FlowDocument using Blend......Page 1270
Populating a FlowDocument Using Code......Page 1271
Enabling Annotations and Sticky Notes......Page 1272
Saving and Loading a Flow Document......Page 1274
Introducing the WPF Data-Binding Model......Page 1275
Establishing Data Bindings using Blend......Page 1276
The DataContext Property......Page 1279
Data Conversion Using IValueConverter......Page 1280
Establishing Data Bindings in Code......Page 1281
Building the DataGrid Tab......Page 1282
Summary......Page 1284
Understanding WPF's Graphical Rendering Services......Page 1285
WPF Graphical Rendering Options......Page 1286
Rendering Graphical Data Using Shapes......Page 1287
Adding Rectangles, Ellipses, and Lines to a Canvas......Page 1289
Removing Rectangles, Ellipses, and Lines from a Canvas......Page 1292
Working with Polylines and Polygons......Page 1293
Working with Paths......Page 1294
The Path "Modeling Mini Language"......Page 1296
WPF Brushes and Pens......Page 1297
Configuring Brushes Using Visual Studio 2010......Page 1298
Configuring Brushes in Code......Page 1300
Configuring Pens......Page 1301
Applying Graphical Transformations......Page 1302
A First Look at Transformations......Page 1303
Transforming our Canvas Data......Page 1304
Selecting a Shape to Render from the Tool Palette......Page 1306
Converting Shapes to Paths......Page 1307
Combining Shapes......Page 1308
The Brush and Transformation Editors......Page 1309
Rendering Graphical Data Using Drawings and Geometries......Page 1311
Building a DrawingBrush using Geometries......Page 1312
Painting with the DrawingBrush......Page 1313
Containing Drawing Types in a DrawingImage......Page 1314
Exporting a Design Document to XAML......Page 1315
The Visual Base Class and Derived Child Classes......Page 1317
A First Look at using the DrawingVisual Class......Page 1318
Rendering Visual Data to a Custom Layout Manager......Page 1320
Responding to Hit Test Operations......Page 1322
Summary......Page 1324
Working with Binary Resources......Page 1325
Including Loose Resource Files in a Project......Page 1326
Configuring the Loose Resources......Page 1327
Programmatically Loading an Image......Page 1328
Embedding Application Resources......Page 1329
Defining Window-Wide Resources......Page 1332
The {StaticResource} Markup Extension......Page 1334
The {DynamicResource} Markup Extension......Page 1335
Application-Level Resources......Page 1336
Defining Merged Resource Dictionaries......Page 1338
Defining a Resource-Only Assembly......Page 1340
Extracting Resources in Expression Blend......Page 1341
Understanding WPF’s Animation Services......Page 1343
The Role of the Animation Class Types......Page 1344
The Role of the Timeline Base Class......Page 1345
Authoring an Animation in C# Code......Page 1346
Controlling the Pacing of an Animation......Page 1347
Reversing and Looping an Animation......Page 1348
Authoring Animations in XAML......Page 1349
The Role of Event Triggers......Page 1350
Animation Using Discrete Key Frames......Page 1351
Understanding the Role of WPF Styles......Page 1352
Defining and Applying a Style......Page 1353
Automatically Applying a Style with TargetType......Page 1354
Subclassing Existing Styles......Page 1355
The Role of Unnamed Styles......Page 1356
Defining Styles with Multiple Triggers......Page 1357
Animated Styles......Page 1358
Assigning Styles Programmatically......Page 1359
Working with Default Visual Styles......Page 1360
Summary......Page 1364
Understanding the Role of Dependency Properties......Page 1365
Examining an Existing Dependency Property......Page 1367
Important Notes Regarding CLR Property Wrappers......Page 1370
Building a Custom Dependency Property......Page 1371
Responding to the Property Change......Page 1375
Understanding Routed Events......Page 1377
The Role of Routed Bubbling Events......Page 1378
The Role of Routed Tunneling Events......Page 1379
Logical Trees, Visual Trees and Default Templates......Page 1381
Programmatically Inspecting a Logical Tree......Page 1382
Programmatically Inspecting a Visual Tree......Page 1383
Programmatically Inspecting a Control’s Default Template......Page 1384
Building a Custom Control Template with Visual Studio 2010......Page 1388
Templates as Resources......Page 1389
Incorporating Visual Cues using Triggers......Page 1391
The Role of {TemplateBinding} Markup Extension......Page 1392
Incorporating Templates into Styles......Page 1394
Creating a UserControl Library Project......Page 1396
Renaming the Initial UserControl......Page 1397
Designing the SpinControl......Page 1398
Defining an Animation using Blend......Page 1399
Programmatically Starting our Storyboard......Page 1403
Creating the Jackpot Deluxe WPF Application......Page 1404
Extracting a UserControl from a Drawing Geometry......Page 1405
The Role of .NET 4.0 Visual States......Page 1406
Defining Visual States for the StarButton Control......Page 1407
Defining State Transition Timings......Page 1408
Viewing the Generated XAML......Page 1409
Changing Visual States in Code using the VisualStateManager Class......Page 1410
Finalizing the Jackpot Deluxe Application......Page 1411
Summary......Page 1415
Part 7: Building Web Applications with ASP.NET......Page 1417
The Role of HTTP......Page 1419
Understanding Web Applications and Web Servers......Page 1420
The Role of IIS Virtual Directories......Page 1421
The Role of HTML......Page 1422
HTML Document Structure......Page 1423
The Visual Studio 2010 HTML Designer Tools......Page 1424
Building an HTML Form......Page 1426
The Role of Client-Side Scripting......Page 1428
A Client-Side Scripting Example......Page 1429
Posting Back to the Web Server......Page 1430
The Feature Set of the ASP.NET API......Page 1431
Major Features of ASP.NET 1.0-1.1......Page 1432
Major Features of ASP.NET 2.0......Page 1433
Major Features of ASP.NET 4.0......Page 1434
Building a Single File ASP.NET Web Page......Page 1435
Designing the UI......Page 1436
Adding the Data Access Logic......Page 1437
The Role of ASP.NET Directives......Page 1441
Analyzing the ASP.NET Control Declarations......Page 1443
Compilation Cycle for Single-File Pages......Page 1445
Building an ASP.NET Web Page using Code Files......Page 1446
Updating the Code File......Page 1449
Debugging and Tracing ASP.NET Pages......Page 1450
ASP.NET Web Sites and ASP.NET Web Applications......Page 1452
The ASP.NET Web Site Directory Structure......Page 1453
Referencing Assemblies......Page 1454
The Role of the App_Code Folder......Page 1455
The Inheritance Chain of the Page Type......Page 1456
Interacting with the Incoming HTTP Request......Page 1457
Access to Incoming Form Data......Page 1459
The IsPostBack Property......Page 1460
Interacting with the Outgoing HTTP Response......Page 1461
Redirecting Users......Page 1462
The Life Cycle of an ASP.NET Web Page......Page 1463
The Role of the AutoEventWireup Attribute......Page 1464
The Error Event......Page 1465
The Role of the Web.config File......Page 1467
Summary......Page 1468
Understanding the Nature of Web Controls......Page 1469
Understanding Server-Side Event Handling......Page 1470
The AutoPostBack Property......Page 1471
Enumerating Contained Controls......Page 1472
Dynamically Adding and Removing Controls......Page 1475
Interacting with Dynamically Created Controls......Page 1476
Functionality of the WebControl Base Class......Page 1477
Major Categories of ASP.NET Web Controls......Page 1478
A Brief Word Regarding System.Web.UI.HtmlControls......Page 1480
Building the ASP.NET Cars Web Site......Page 1481
Working with ASP.NET Master Pages......Page 1482
Working with the TreeView Control Site Navigation Logic......Page 1485
Working with the AdRotator......Page 1487
Defining the Default Content Page......Page 1488
Designing the Inventory Content Page......Page 1490
Enabling Sorting and Paging......Page 1493
Enabling In-Place Editing......Page 1494
Designing the Build-a-Car Content Page......Page 1495
The Role of the Validation Controls......Page 1497
The RequiredFieldValidator......Page 1499
The RangeValidator......Page 1500
The CompareValidator......Page 1501
Creating Validation Summaries......Page 1502
Defining Validation Groups......Page 1503
Working with Themes......Page 1505
Understanding *.skin Files......Page 1506
Applying Sitewide Themes......Page 1508
Assigning Themes Programmatically......Page 1509
Summary......Page 1511
The Issue of State......Page 1513
Understanding the Role of ASP.NET View State......Page 1516
Demonstrating View State......Page 1517
Adding Custom View State Data......Page 1518
The Role of the Global.asax File......Page 1519
The Global Last-Chance Exception Event Handler......Page 1521
The HttpApplication Base Class......Page 1522
Understanding the Application/Session Distinction......Page 1523
Maintaining Application-Level State Data......Page 1524
Modifying Application Data......Page 1526
Working with the Application Cache......Page 1528
Fun with Data Caching......Page 1529
Modifying the *.aspx File......Page 1531
Maintaining Session Data......Page 1533
Additional Members of HttpSessionState......Page 1536
Understanding Cookies......Page 1537
Creating Cookies......Page 1538
Reading Incoming Cookie Data......Page 1539
Storing Session Data in the ASP.NET Session State Server......Page 1540
Understanding the ASP.NET Profile API......Page 1542
The ASPNETDB.mdf Database......Page 1543
Defining a User Profile Within Web.config......Page 1544
Accessing Profile Data Programmatically......Page 1545
Grouping Profile Data and Persisting Custom Objects......Page 1547
Summary......Page 1549
Programming with Windows Forms......Page 1551
The Windows Forms Namespaces......Page 1552
Building a Simple Windows Forms Application......Page 1553
Populating the Controls Collection......Page 1555
The Role of System.EventArgs and System.EventHandler......Page 1557
The Visual Studio Windows Forms Project Template......Page 1558
The Visual Designer Surface......Page 1559
Dissecting the Initial Form......Page 1560
Dissecting the Program Class......Page 1561
Visually Building a Menu System......Page 1562
The Anatomy of a Form......Page 1565
The Functionality of the Control Class......Page 1566
The Functionality of the Form Class......Page 1569
The Life Cycle of a Form Type......Page 1571
Responding to Mouse and Keyboard Activity......Page 1574
Determining Which Mouse Button Was Clicked......Page 1575
Determining Which Key Was Pressed......Page 1576
Designing Dialog Boxes......Page 1578
The DialogResult Property......Page 1579
The Tab Order Wizard......Page 1580
Setting the Form’s Default Input Button......Page 1581
Displaying Dialog Boxes......Page 1582
Understanding Form Inheritance......Page 1583
Rendering Graphical Data Using GDI+......Page 1585
The System.Drawing Namespace......Page 1587
The Role of the Graphics Type......Page 1588
Obtaining a Graphics Object with the Paint Event......Page 1589
Building a Complete Windows Forms Application......Page 1591
Building the Main Menu System......Page 1592
Defining the ShapePickerDialog Type......Page 1593
Implementing the Tools Menu Functionality......Page 1595
Capturing and Rendering the Graphical Output......Page 1597
Implementing the Serialization Logic......Page 1598
Summary......Page 1600
The Platform-Independent Nature of .NET......Page 1601
The Role of the CLI......Page 1602
The Mainstream CLI Distributions......Page 1603
The Scope of Mono......Page 1604
Obtaining and Installing Mono......Page 1605
Examining Mono’s Directory Structure......Page 1607
Building Mono Applications using MonoDevelop......Page 1609
Microsoft-Compatible Mono Development Tools......Page 1610
Mono-Specific Development Tools......Page 1611
Building a Mono Code Library......Page 1612
Viewing the Updated Manifest with monodis......Page 1614
Installing Assemblies into the Mono GAC......Page 1615
Building a Console Application in Mono......Page 1616
Loading Your Client Application in the Mono Runtime......Page 1617
Building a Windows Forms Client Program......Page 1618
Executing Your Windows Forms Application Under Linux......Page 1620
Suggestions for Further Study......Page 1621
Summary......Page 1622
AND NUMERICS......Page 1623
¦A......Page 1625
¦B......Page 1636
¦C......Page 1640
¦D......Page 1655
¦E......Page 1665
¦F......Page 1670
¦G......Page 1673
¦H......Page 1677
¦I......Page 1679
¦L......Page 1686
¦M......Page 1690
¦N......Page 1698
¦O......Page 1701
¦P......Page 1704
¦Q......Page 1710
¦R......Page 1711
¦S......Page 1714
¦T......Page 1732
¦U......Page 1736
¦V......Page 1738
¦W......Page 1741
¦X......Page 1750
¦......Page 1752

Polecaj historie