شروع دوره های تخصصی, پایتون | هوش مصنوعی 18 دی شروع دوره های تخصصی, پایتون | هوش مصنوعی 18 دی
ثبت نام
Andrew Troelsen

Pro C# 2008 and the .NET 3.5 Platform

نویسنده :Andrew Troelsen

    Contents
    About the Author. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
    About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
    Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii
    Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
    Part 1 n n n Introducing C# and the .NET Platform
    nCHAPTER 1 The Philosophy of .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
    Understanding the Previous State of Affairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
    The .NET Solution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
    Introducing the Building Blocks of the .NET Platform (the CLR, CTS,
    and CLS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
    Additional .NET-Aware Programming Languages. . . . . . . . . . . . . . . . . . . . . . . . . . . 9
    An Overview of .NET Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
    Understanding the Common Type System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
    Understanding the Common Language Specification . . . . . . . . . . . . . . . . . . . . . . 20
    Understanding the Common Language Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . 22
    The Assembly/Namespace/Type Distinction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
    Exploring an Assembly Using ildasm.exe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
    Exploring an Assembly Using Lutz Roeder’s Reflector. . . . . . . . . . . . . . . . . . . . . . 31
    Deploying the .NET Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
    The Platform-Independent Nature of .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
    nCHAPTER 2 Building C# Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
    The Role of the .NET Framework 3.5 SDK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
    Building C# Applications Using csc.exe. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
    Building .NET Applications Using TextPad. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
    Building .NET Applications Using Notepad++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
    Building .NET Applications Using SharpDevelop. . . . . . . . . . . . . . . . . . . . . . . . . . . 48
    Building .NET Applications Using Visual C# 2008 Express . . . . . . . . . . . . . . . . . . 50
    Building .NET Applications Using Visual Studio 2008 . . . . . . . . . . . . . . . . . . . . . . 52
    A Partial Catalog of Additional .NET Development Tools . . . . . . . . . . . . . . . . . . . . 64
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

    Part 2 n n n Core C# Programming Constructs
    nCHAPTER 3 Core C# Programming Constructs, Part I . . . . . . . . . . . . . . . . . . . . . . . . . 69
    The Anatomy of a Simple C# Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
    An Interesting Aside: Some Additional Members of the
    System.Environment Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
    The System.Console Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
    System Data Types and C# Shorthand Notation. . . . . . . . . . . . . . . . . . . . . . . . . . . 80
    Understanding the System.String Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
    Narrowing and Widening Data Type Conversions. . . . . . . . . . . . . . . . . . . . . . . . . . 95
    C# Iteration Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
    Decision Constructs and the Relational/Equality Operators. . . . . . . . . . . . . . . . . 102
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
    nCHAPTER 4 Core C# Programming Constructs, Part II . . . . . . . . . . . . . . . . . . . . . . . . 107
    Methods and Parameter Modifiers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
    Understanding Member Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
    Array Manipulation in C#. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
    Understanding the Enum Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
    Understanding the Structure Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
    Understanding Value Types and Reference Types . . . . . . . . . . . . . . . . . . . . . . . . 129
    Value and Reference Types: Final Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
    Understanding C# Nullable Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
    nCHAPTER 5 Defining Encapsulated Class Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
    Introducing the C# Class Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
    Understanding Class Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
    The Role of the this Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
    Understanding the static Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
    Defining the Pillars of OOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
    C# Access Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
    The First Pillar: C#’s Encapsulation Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
    Understanding Constant Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
    Understanding Read-Only Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
    Understanding Partial Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
    Documenting C# Source Code via XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
    Visualizing the Fruits of Our Labor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
    nCHAPTER 6 Understanding Inheritance and Polymorphism . . . . . . . . . . . . . . . . . . 185
    The Basic Mechanics of Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
    Revising Visual Studio Class Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
    The Second Pillar: The Details of Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
    Programming for Containment/Delegation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

    The Third Pillar: C#’s Polymorphic Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
    Understanding Base Class/Derived Class Casting Rules . . . . . . . . . . . . . . . . . . . 210
    The Master Parent Class: System.Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
    nCHAPTER 7 Understanding Structured Exception Handling. . . . . . . . . . . . . . . . . . . 219
    Ode to Errors, Bugs, and Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
    The Role of .NET Exception Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
    The Simplest Possible Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
    Configuring the State of an Exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
    System-Level Exceptions (System.SystemException) . . . . . . . . . . . . . . . . . . . . . 230
    Application-Level Exceptions (System.ApplicationException) . . . . . . . . . . . . . . . 231
    Processing Multiple Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
    The Finally Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
    Who Is Throwing What? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
    The Result of Unhandled Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
    Debugging Unhandled Exceptions Using Visual Studio . . . . . . . . . . . . . . . . . . . . 242
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
    nCHAPTER 8 Understanding Object Lifetime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
    Classes, Objects, and References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
    The Basics of Object Lifetime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
    The Role of Application Roots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
    Understanding Object Generations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
    The System.GC Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
    Building Finalizable Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
    Building Disposable Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
    Building Finalizable and Disposable Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
    Part 3 n n n Advanced C# Programming Constructs
    nCHAPTER 9 Working with Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
    Understanding Interface Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
    Defining Custom Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
    Implementing an Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
    Invoking Interface Members at the Object Level . . . . . . . . . . . . . . . . . . . . . . . . . 276
    Interfaces As Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
    Interfaces As Return Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
    Arrays of Interface Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
    Implementing Interfaces Using Visual Studio 2008 . . . . . . . . . . . . . . . . . . . . . . . 282
    Resolving Name Clashes via Explicit Interface Implementation . . . . . . . . . . . . . 283
    Designing Interface Hierarchies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
    Building Enumerable Types (IEnumerable and IEnumerator) . . . . . . . . . . . . . . . 289
    Building Cloneable Objects (ICloneable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

    Building Comparable Objects (IComparable). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
    Understanding Callback Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
    nCHAPTER 10 Collections and Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
    The Interfaces of the System.Collections Namespace . . . . . . . . . . . . . . . . . . . . . 309
    The Class Types of System.Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
    System.Collections.Specialized Namespace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
    The Boxing, Unboxing, and System.Object Relationship . . . . . . . . . . . . . . . . . . . 316
    The Issue of Type Safety and Strongly Typed Collections . . . . . . . . . . . . . . . . . . 319
    The System.Collections.Generic Namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
    Creating Custom Generic Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
    Creating Generic Structures and Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
    Creating a Custom Generic Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
    Creating Generic Base Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
    Creating Generic Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
    nCHAPTER 11 Delegates, Events, and Lambdas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
    Understanding the .NET Delegate Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
    Defining a Delegate in C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
    The System.MulticastDelegate and System.Delegate Base Classes . . . . . . . . . 344
    The Simplest Possible Delegate Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
    Retrofitting the Car Type with Delegates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
    A More Elaborate Delegate Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
    Understanding Delegate Covariance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
    Creating Generic Delegates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
    Understanding C# Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
    The Generic EventHandler<T> Delegate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
    Understanding C# Anonymous Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
    Understanding Method Group Conversions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
    The C# 2008 Lambda Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
    nCHAPTER 12 Indexers, Operators, and Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
    Understanding Indexer Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
    Understanding Operator Overloading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
    Understanding Custom Type Conversions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
    Working with Pointer Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
    C# Preprocessor Directives. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
    nCHAPTER 13 C# 2008 Language Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
    Understanding Implicitly Typed Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 415
    Understanding Automatic Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
    Understanding Extension Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

    Understanding Partial Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
    Understanding Object Initializer Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
    Understanding Anonymous Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
    nCHAPTER 14 An Introduction to LINQ. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
    Understanding the Role of LINQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
    A First Look at LINQ Query Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
    LINQ and Generic Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
    LINQ and Nongeneric Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
    The Internal Representation of LINQ Query Operators . . . . . . . . . . . . . . . . . . . . . 459
    Investigating the C# LINQ Query Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
    LINQ Queries: An Island unto Themselves?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
    PART 4 n n n Programming with .NET Assemblies
    nCHAPTER 15 Introducing .NET Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
    Defining Custom Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
    The Role of .NET Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
    Understanding the Format of a .NET Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . 482
    Building and Consuming a Single-File Assembly . . . . . . . . . . . . . . . . . . . . . . . . . 486
    Building and Consuming a Multifile Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
    Understanding Private Assemblies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
    Understanding Shared Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
    Consuming a Shared Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
    Configuring Shared Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
    Investigating the Internal Composition of the GAC . . . . . . . . . . . . . . . . . . . . . . . . 516
    Understanding Publisher Policy Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
    Understanding the <codeBase> Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
    The System.Configuration Namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
    The Machine Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
    nCHAPTER 16 Type Reflection, Late Binding, and Attribute-Based
    Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
    The Necessity of Type Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
    Understanding Reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
    Building a Custom Metadata Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
    Dynamically Loading Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
    Reflecting on Shared Assemblies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538
    Understanding Late Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539

    Understanding Attributed Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
    Building Custom Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
    Assembly-Level (and Module-Level) Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . 549
    Reflecting on Attributes Using Early Binding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550
    Reflecting on Attributes Using Late Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
    Putting Reflection, Late Binding, and Custom Attributes in Perspective . . . . . . 553
    Building an Extendable Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
    nCHAPTER 17 Processes, AppDomains, and Object Contexts . . . . . . . . . . . . . . . . . . . 561
    Reviewing Traditional Win32 Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
    Interacting with Processes Under the .NET Platform . . . . . . . . . . . . . . . . . . . . . . 563
    Understanding .NET Application Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
    Understanding Object Context Boundaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
    Summarizing Processes, AppDomains, and Context . . . . . . . . . . . . . . . . . . . . . . 581
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
    nCHAPTER 18 Building Multithreaded Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
    The Process/AppDomain/Context/Thread Relationship . . . . . . . . . . . . . . . . . . . . 583
    A Brief Review of the .NET Delegate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
    The Asynchronous Nature of Delegates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587
    Invoking a Method Asynchronously . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588
    The System.Threading Namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
    The System.Threading.Thread Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594
    Programmatically Creating Secondary Threads . . . . . . . . . . . . . . . . . . . . . . . . . . 597
    The Issue of Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
    Programming with Timer Callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609
    Understanding the CLR ThreadPool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610
    The Role of the BackgroundWorker Component. . . . . . . . . . . . . . . . . . . . . . . . . . 612
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616
    nCHAPTER 19 Understanding CIL and the Role of Dynamic Assemblies . . . . . . . . 617
    Reflecting on the Nature of CIL Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
    Examining CIL Directives, Attributes, and Opcodes . . . . . . . . . . . . . . . . . . . . . . . 618
    Pushing and Popping: The Stack-Based Nature of CIL . . . . . . . . . . . . . . . . . . . . 620
    Understanding Round-Trip Engineering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621
    Understanding CIL Directives and Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
    .NET Base Class Library, C#, and CIL Data Type Mappings . . . . . . . . . . . . . . . . 635
    Defining Type Members in CIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
    Examining CIL Opcodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
    Building a .NET Assembly with CIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
    Understanding Dynamic Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 648
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657

    Part 5 n n n Introducing the .NET Base Class Libraries
    nCHAPTER 20 File I/O and Isolated Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
    Exploring the System.IO Namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
    The Directory(Info) and File(Info) Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662
    Working with the DirectoryInfo Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663
    Working with the Directory Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667
    Working with the DriveInfo Class Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668
    Working with the FileInfo Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
    Working with the File Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673
    The Abstract Stream Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
    Working with StreamWriters and StreamReaders . . . . . . . . . . . . . . . . . . . . . . . . 677
    Working with StringWriters and StringReaders . . . . . . . . . . . . . . . . . . . . . . . . . . 680
    Working with BinaryWriters and BinaryReaders . . . . . . . . . . . . . . . . . . . . . . . . . . 682
    Programmatically “Watching” Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683
    Performing Asynchronous File I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
    Understanding the Role of Isolated Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687
    A Primer on Code Access Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688
    An Overview of Isolated Storage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698
    Obtaining a Store Using IsolatedStorageFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702
    Isolated Storage in Action: ClickOnce Deployment. . . . . . . . . . . . . . . . . . . . . . . . 707
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710
    nCHAPTER 21 Introducing Object Serialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
    Understanding Object Serialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
    Configuring Objects for Serialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
    Choosing a Serialization Formatter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
    Serializing Objects Using the BinaryFormatter . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
    Serializing Objects Using the SoapFormatter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719
    Serializing Objects Using the XmlSerializer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720
    Serializing Collections of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
    Customizing the Serialization Process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729
    nCHAPTER 22 ADO.NET Part I: The Connected Layer. . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
    A High-Level Definition of ADO.NET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
    Understanding ADO.NET Data Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
    Additional ADO.NET Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
    The Types of the System.Data Namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737
    Abstracting Data Providers Using Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
    Creating the AutoLot Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744
    The ADO.NET Data Provider Factory Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749
    Understanding the Connected Layer of ADO.NET. . . . . . . . . . . . . . . . . . . . . . . . . 755
    Working with Data Readers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 760
    Building a Reusable Data Access Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763

    Creating a Console UI–Based Front End . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 770
    Asynchronous Data Access Using SqlCommand . . . . . . . . . . . . . . . . . . . . . . . . . 775
    Understanding Database Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 781
    nCHAPTER 23 ADO.NET Part II: The Disconnected Layer . . . . . . . . . . . . . . . . . . . . . . . . 783
    Understanding the Disconnected Layer of ADO.NET . . . . . . . . . . . . . . . . . . . . . . 783
    Understanding the Role of the DataSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784
    Working with DataColumns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787
    Working with DataRows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789
    Working with DataTables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793
    Binding DataTable Objects to User Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . 798
    Filling DataSet/DataTable Objects Using Data Adapters . . . . . . . . . . . . . . . . . . . 808
    Revisiting AutoLotDAL.dll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 811
    Navigating Multitabled DataSet Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814
    The Data Access Tools of Visual Studio 2008. . . . . . . . . . . . . . . . . . . . . . . . . . . . 820
    Decoupling Autogenerated Code from the UI Layer . . . . . . . . . . . . . . . . . . . . . . . 831
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835
    nCHAPTER 24 Programming with the LINQ APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
    The Role of LINQ to ADO.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
    Programming with LINQ to DataSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838
    Programming with LINQ to SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 843
    Generating Entity Classes Using SqlMetal.exe . . . . . . . . . . . . . . . . . . . . . . . . . . . 848
    Building Entity Classes Using Visual Studio 2008. . . . . . . . . . . . . . . . . . . . . . . . . 854
    Manipulating XML Documents Using LINQ to XML. . . . . . . . . . . . . . . . . . . . . . . . 857
    Navigating an In-Memory Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 862
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 865
    nCHAPTER 25 Introducing Windows Communication Foundation. . . . . . . . . . . . . . . 867
    A Potpourri of Distributed Computing APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 867
    The Role of WCF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 873
    Investigating the Core WCF Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
    The Visual Studio WCF Project Templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 877
    The Basic Composition of a WCF Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879
    The ABCs of WCF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
    Building a WCF Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 885
    Hosting the WCF Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 888
    Building the WCF Client Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 896
    Using the WCF Service Library Project Template . . . . . . . . . . . . . . . . . . . . . . . . . 900
    Hosting the WCF Service As a Windows Service . . . . . . . . . . . . . . . . . . . . . . . . . 903
    Invoking a Service Asynchronously . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 908
    Designing WCF Data Contracts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 910
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 915

    nCHAPTER 26 Introducing Windows Workflow Foundation . . . . . . . . . . . . . . . . . . . . . 917
    Defining a Business Process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917
    The Building Blocks of WF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918
    WF Assemblies, Namespaces, and Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 924
    Building a Simple Workflow-Enabled Application. . . . . . . . . . . . . . . . . . . . . . . . . 926
    Examining the WF Engine Hosting Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 930
    Invoking Web Services Within Workflows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 934
    Building a Reusable WF Code Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 945
    A Brief Word Regarding Custom Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 951
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 952
    Part 6 n n n Desktop User Interfaces
    nCHAPTER 27 Programming with Windows Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 955
    The Windows Forms Namespaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 955
    Building a Simple Windows Forms Application (IDE-Free). . . . . . . . . . . . . . . . . . 956
    The Visual Studio Windows Forms Project Template . . . . . . . . . . . . . . . . . . . . . . 961
    The Anatomy of a Form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 968
    Responding to Mouse Activity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 975
    Responding to Keyboard Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 977
    Designing Dialog Boxes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 978
    Rendering Graphical Data Using GDI+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 985
    Building a Complete Windows Forms Application . . . . . . . . . . . . . . . . . . . . . . . . 990
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997
    nCHAPTER 28 Introducing Windows Presentation Foundation and XAML . . . . . . . 999
    The Motivation Behind WPF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 999
    The Various Flavors of WPF Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1002
    Investigating the WPF Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1004
    Building a (XAML-Free) WPF Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1011
    Additional Details of the Application Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1015
    Additional Details of the Window Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1017
    Building a (XAML-Centric) WPF Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1021
    Transforming Markup into a .NET Assembly. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1025
    Separation of Concerns Using Code-Behind Files . . . . . . . . . . . . . . . . . . . . . . . 1029
    The Syntax of XAML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031
    Building WPF Applications Using Visual Studio 2008. . . . . . . . . . . . . . . . . . . . . 1044
    Processing XAML at Runtime: SimpleXamlPad.exe . . . . . . . . . . . . . . . . . . . . . . 1048
    The Role of Microsoft Expression Blend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1052
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1053

    nCHAPTER 29 Programming with WPF Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055
    A Survey of the WPF Control Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055
    Declaring Controls in XAML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1058
    Understanding the Role of Dependency Properties . . . . . . . . . . . . . . . . . . . . . . 1060
    Understanding Routed Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1064
    Working with Button Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1068
    Working with CheckBoxes and RadioButtons . . . . . . . . . . . . . . . . . . . . . . . . . . . 1072
    Working with the ListBox and ComboBox Types . . . . . . . . . . . . . . . . . . . . . . . . 1075
    Working with Text Areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1081
    Controlling Content Layout Using Panels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1083
    Building a Window’s Frame Using Nested Panels . . . . . . . . . . . . . . . . . . . . . . . 1093
    Understanding WPF Control Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1099
    Understanding the WPF Data-Binding Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 1102
    Data Conversion Using IValueConverter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1106
    Binding to Custom Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1108
    Binding UI Elements to XML Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1112
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1116
    nCHAPTER 30 WPF 2D Graphical Rendering, Resources, and Themes . . . . . . . . . 1117
    The Philosophy of WPF Graphical Rendering Services. . . . . . . . . . . . . . . . . . . . 1117
    Exploring the Shape-Derived Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1124
    Working with WPF Brushes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1127
    Working with WPF Pens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1130
    Exploring the Drawing-Derived Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1130
    The Role of UI Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1135
    Understanding WPF’s Animation Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1136
    Understanding the WPF Resource System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1145
    Defining and Applying Styles for WPF Controls . . . . . . . . . . . . . . . . . . . . . . . . . 1147
    Altering a Control’s UI Using Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1156
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1160
    Part 7 n n n Building Web Applications with ASP.NET
    nCHAPTER 31 Building ASP.NET Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1163
    The Role of HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1163
    Understanding Web Applications and Web Servers . . . . . . . . . . . . . . . . . . . . . . 1164
    The Role of HTML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1167
    The Role of Client-Side Scripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1172
    Submitting the Form Data (GET and POST) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1174
    Building a Classic ASP Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1175
    Problems with Classic ASP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1177
    The ASP.NET Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1178
    The ASP.NET Web Page Code Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1179
    Details of an ASP.NET Website Directory Structure . . . . . . . . . . . . . . . . . . . . . . 1190
    The ASP.NET Page Compilation Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1192

    The Inheritance Chain of the Page Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1194
    Interacting with the Incoming HTTP Request . . . . . . . . . . . . . . . . . . . . . . . . . . . 1195
    Interacting with the Outgoing HTTP Response . . . . . . . . . . . . . . . . . . . . . . . . . . 1198
    The Life Cycle of an ASP.NET Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1200
    The Role of the Web.config File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1203
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1206
    nCHAPTER 32 ASP.NET Web Controls, Themes, and Master Pages . . . . . . . . . . . . 1207
    Understanding the Nature of Web Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1207
    The System.Web.UI.Control Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1209
    The System.Web.UI.WebControls.WebControl Type. . . . . . . . . . . . . . . . . . . . . . 1213
    Major Categories of ASP.NET Web Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1213
    Building a Feature-Rich ASP.NET Website . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1215
    The Role of the Validation Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1231
    Working with Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1237
    Positioning Controls Using HTML Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1243
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1244
    nCHAPTER 33 ASP.NET State Management Techniques . . . . . . . . . . . . . . . . . . . . . . . 1245
    The Issue of State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1245
    ASP.NET State Management Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1247
    Understanding the Role of ASP.NET View State . . . . . . . . . . . . . . . . . . . . . . . . . 1248
    The Role of the Global.asax File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1251
    Understanding the Application/Session Distinction . . . . . . . . . . . . . . . . . . . . . . 1254
    Working with the Application Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1259
    Maintaining Session Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1263
    Understanding Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1267
    The Role of the <sessionState> Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1269
    Understanding the ASP.NET Profile API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1272
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1279
    Part 8 n n n Appendixes
    nAPPENDIX A COM and .NET Interoperability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1283
    The Scope of .NET Interoperability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1283
    A Simple Example of .NET to COM Interop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1284
    Investigating a .NET Interop Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1287
    Understanding the Runtime Callable Wrapper . . . . . . . . . . . . . . . . . . . . . . . . . . 1289
    The Role of COM IDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1292
    Using a Type Library to Build an Interop Assembly . . . . . . . . . . . . . . . . . . . . . . 1296
    Building a More Elaborate COM Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1299
    Examining the Interop Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1301
    Understanding COM to .NET Interoperability. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1305
    The Role of the CCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1306
    The Role of the .NET Class Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1307
    Building Your .NET Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1308
    Generating the Type Library and Registering the .NET Types. . . . . . . . . . . . . . 1310
    Examining the Exported Type Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1311
    Building a Visual Basic 6.0 Test Client. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1312
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1313
    nAPPENDIX B Platform-Independent .NET Development with Mono . . . . . . . . . . . 1315
    The Platform-Independent Nature of .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1315
    Obtaining and Installing Mono . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1318
    The Mono Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1321
    Building .NET Applications with Mono . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1323
    Suggestions for Further Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1330
    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1331
    nINDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1333

1394/07/27 4902 370
رمز عبور : tahlildadeh.com یا www.tahlildadeh.com
کتاب های مرتبط
آموزش کار با رشته ها در سی شارپ

آموزش مقدماتی سی شارپ 2008

برای دانلود کتاب روی عنوان کتاب کلیک کنید

نویسنده: Christian Gross

زبان: انگلیسی

مشاهده کتاب و دانلود
آموزش کار با رشته ها در سی شارپ

کتاب آموزش پایگاه داده C# 2005 از مقدماتی تا پیشرفته

نویسنده: James Huddleston

زبان: انگلیسی

مشاهده کتاب و دانلود
آموزش کار با رشته ها در سی شارپ

کتاب آموزش پایگاه داده در C# 2008 از مقدماتی تا پیشرفته

نویسنده: Vidya Vrat Agarwal و James Huddleston

زبان: انگلیسی

مشاهده کتاب و دانلود
نظرات شما

نظرات خود را ثبت کنید...