Home Page Icon
Home Page
Table of Contents for
Part IV: Advanced C# Programming
Close
Part IV: Advanced C# Programming
by Andrew Troelsen
Pro C# 5.0 and the .NET 4.5 Framework, Sixth Edition
Title
Dedication
Contents at a Glance
Contents
About the Author
About the Technical Reviewer
Acknowledgments
Introduction
Part I: Introducing C# and .NET Platform
Chapter 1: The Philosophy of .NET
An Initial Look at the .NET Platform
Introducing the Building Blocks of the .NET Platform (the CLR, CTS, and CLS)
Additional .NET-Aware Programming Languages
An Overview of .NET Assemblies
Understanding the Common Type System
Understanding the Common Language Specification
Understanding the Common Language Runtime
The Assembly/Namespace/Type Distinction
Exploring an Assembly Using ildasm.exe
The Platform-Independent Nature of .NET
A Brief Word Regarding Windows 8 Metro-Style Applications
Summary
Chapter 2: Building C# Applications
The Role of the .NET Framework 4.5 SDK
Building C# Applications Using csc.exe
Building .NET Applications Using Notepad++
Building .NET Applications Using SharpDevelop
Building .NET Applications Using Visual C# Express
Building .NET Applications Using Visual Studio
Summary
Part II: Core C# Programming
Chapter 3: Core C# Programming Constructs, Part I
The Anatomy of a Simple C# Program
An Interesting Aside: Some Additional Members of the System.Environment Class
The System.Console Class
System Data Types and Corresponding C# Keywords
Working with String Data
Narrowing and Widening Data Type Conversions
Understanding Implicitly Typed Local Variables
C# Iteration Constructs
Decision Constructs and the Relational/Equality Operators
Summary
Chapter 4: Core C# Programming Constructs, Part II
Methods and Parameter Modifiers
Understanding C# Arrays
Understanding the enum Type
Understanding the Structure Type
Understanding Value Types and Reference Types
Understanding C# Nullable Types
Summary
Part III: Object-Oriented Programming with C#
Chapter 5: Understanding Encapsulation
Introducing the C# Class Type
Understanding Constructors
The Role of the this Keyword
Understanding the static Keyword
Defining the Pillars of OOP
C# Access Modifiers
The First Pillar: C#’s Encapsulation Services
Understanding Automatic Properties
Understanding Object Initialization Syntax
Working with Constant Field Data
Understanding Partial Types
Summary
Chapter 6: Understanding Inheritance and Polymorphism
The Basic Mechanics of Inheritance
Revising Visual Studio Class Diagrams
The Second Pillar of OOP: The Details of Inheritance
Programming for Containment/Delegation
The Third Pillar of OOP: C#’s Polymorphic Support
Understanding Base Class/Derived Class Casting Rules
The Master Parent Class: System.Object
Testing Your Modified Person Class
Summary
Chapter 7: Understanding Structured Exception Handling
Ode to Errors, Bugs, and Exceptions
The Role of .NET Exception Handling
The Simplest Possible Example
Configuring the State of an Exception
System-Level Exceptions (System.SystemException)
Application-Level Exceptions (System.ApplicationException)
Processing Multiple Exceptions
Who Is Throwing What?
The Result of Unhandled Exceptions
Debugging Unhandled Exceptions Using Visual Studio
Summary
Chapter 8: Working with Interfaces
Understanding Interface Types
Defining Custom Interfaces
Implementing an Interface
Invoking Interface Members at the Object Level
Interfaces As Parameters
Interfaces As Return Values
Arrays of Interface Types
Implementing Interfaces Using Visual Studio
Explicit Interface Implementation
Designing Interface Hierarchies
The IEnumerable and IEnumerator Interfaces
The ICloneable Interface
The IComparable Interface
Summary
Part IV: Advanced C# Programming
Chapter 9: Collections and Generics
The Motivation for Collection Classes
The Problems of Nongeneric Collections
The Role of Generic Type Parameters
The System.Collections.Generic Namespace
The System.Collections.ObjectModel Namespace
Creating Custom Generic Methods
Creating Custom Generic Structures and Classes
Constraining Type Parameters
Summary
Chapter 10: Delegates, Events, and Lambda Expressions
Understanding the .NET Delegate Type
The Simplest Possible Delegate Example
Sending Object State Notifications Using Delegates
Understanding Generic Delegates
Understanding C# Events
Understanding C# Anonymous Methods
Understanding Lambda Expressions
Summary
Chapter 11: Advanced C# Language Features
Understanding Indexer Methods
Understanding Operator Overloading
Understanding Custom Type Conversions
Understanding Extension Methods
Understanding Anonymous Types
Working with Pointer Types
Summary
Chapter 12: LINQ to Objects
LINQ-Specific Programming Constructs
Understanding the Role of LINQ
Applying LINQ Queries to Primitive Arrays
Returning the Result of a LINQ Query
Applying LINQ Queries to Collection Objects
Investigating the C# LINQ Query Operators
The Internal Representation of LINQ Query Statements
Summary
Chapter 13: Understanding Object Lifetime
Classes, Objects, and References
The Basics of Object Lifetime
The Role of Application Roots
Understanding Object Generations
Concurrent Garbage Collection Under .NET 1.0–3.5
Background Garbage Collection Under .NET 4.0 and Greater
The System.GC Type
Building Finalizable Objects
Building Disposable Objects
Building Finalizable and Disposable Types
Understanding Lazy Object Instantiation
Summary
Part V: Programming with .NET Assemblies
Chapter 14: Building and Configuring Class Libraries
Defining Custom Namespaces
The Role of .NET Assemblies
Understanding the Format of a .NET Assembly
Building and Consuming Custom Class Library
Understanding Private Assemblies
Understanding Shared Assemblies
Consuming a Shared Assembly
Configuring Shared Assemblies
Understanding Publisher Policy Assemblies
Understanding the <codeBase> Element
The System.Configuration Namespace
The Configuration File Schema Documentation
Summary
Chapter 15: Type Reflection, Late Binding, and Attribute-Based Programming
The Necessity of Type Metadata
Understanding Reflection
Building a Custom Metadata Viewer
Dynamically Loading Assemblies
Reflecting on Shared Assemblies
Understanding Late Binding
Understanding the Role of .NET Attributes
Building Custom Attributes
Assembly-Level Attributes
Reflecting on Attributes Using Early Binding
Reflecting on Attributes Using Late Binding
Putting Reflection, Late Binding, and Custom Attributes in Perspective
Building an Extendable Application
Summary
Chapter 16: Dynamic Types and the Dynamic Language Runtime
The Role of the C# dynamic Keyword
The Role of the Dynamic Language Runtime (DLR)
Simplifying Late-Bound Calls Using Dynamic Types
Simplifying COM Interoperability Using Dynamic Data
COM Interop Using C# Dynamic Data
Summary
Chapter 17: Processes, AppDomains, and Object Contexts
The Role of a Windows Process
Interacting with Processes Under the .NET Platform
Understanding .NET Application Domains
Interacting with the Default Application Domain
Creating New Application Domains
Understanding Object Context Boundaries
Summarizing Processes, AppDomains, and Context
Summary
Chapter 18: Understanding CIL and the Role of Dynamic Assemblies
Reasons for Learning the Grammar of CIL
Examining CIL Directives, Attributes, and Opcodes
Pushing and Popping: The Stack-Based Nature of CIL
Understanding Round-Trip Engineering
Understanding CIL Directives and Attributes
.NET Base Class Library, C#, and CIL Data Type Mappings
Defining Type Members in CIL
Examining CIL Opcodes
Building a .NET Assembly with CIL
Understanding Dynamic Assemblies
Summary
Part VI: Introducing the .NET Base Class Libraries
Chapter 19: Multithreaded, Parallel, and Async Programming
The Process/AppDomain/Context/Thread Relationship
A Brief Review of the .NET Delegate
The Asynchronous Nature of Delegates
Invoking a Method Asynchronously
The System.Threading Namespace
The System.Threading.Thread Class
Manually Creating Secondary Threads
The Issue of Concurrency
Programming with Timer Callbacks
Understanding the CLR ThreadPool
Parallel Programming Using the Task Parallel Library
Parallel LINQ Queries (PLINQ)
Asynchronous Calls Under .NET 4.5
Summary
Chapter 20: File I/O and Object Serialization
Exploring the System.IO Namespace
The Directory(Info) and File(Info) Types
Working with the DirectoryInfo Type
Working with the Directory Type
Working with the DriveInfo Class Type
Working with the FileInfo Class
Working with the File Type
The Abstract Stream Class
Working with StreamWriters and StreamReaders
Working with StringWriters and StringReaders
Working with BinaryWriters and BinaryReaders
Watching Files Programmatically
Understanding Object Serialization
Configuring Objects for Serialization
Choosing a Serialization Formatter
Serializing Objects Using the BinaryFormatter
Serializing Objects Using the SoapFormatter
Serializing Objects Using the XmlSerializer
Serializing Collections of Objects
Customizing the Soap/Binary Serialization Process
Summary
Chapter 21: ADO.NET Part I: The Connected Layer
A High-Level Definition of ADO.NET
Understanding ADO.NET Data Providers
Additional ADO.NET Namespaces
The Types of the System.Data Namespace
Abstracting Data Providers Using Interfaces
Creating the AutoLot Database
The ADO.NET Data Provider Factory Model
Understanding the Connected Layer of ADO.NET
Working with Data Readers
Building a Reusable Data Access Library
Creating a Console UI–Based Front End
Understanding Database Transactions
Summary
Chapter 22: ADO.NET Part II: The Disconnected Layer
Understanding the Disconnected Layer of ADO.NET
Understanding the Role of the DataSet
Working with DataColumns
Working with DataRows
Working with DataTables
Binding DataTable Objects to Windows Forms GUIs
Working with Data Adapters
Adding Disconnection Functionality to AutoLotDAL.dll
Multitabled DataSet Objects and Data Relationships
The Windows Forms Database Designer Tools
Isolating Strongly Typed Database Code into a Class Library
Programming with LINQ to DataSet
Summary
Chapter 23: ADO.NET Part III: The Entity Framework
Understanding the Role of Entity Framework
Building and Analyzing Your First EDM
Programming Against the Conceptual Model
AutoLotDAL Version Four, Now with Entities
Data Binding Entities to Windows Forms GUIs
Going Forward with .NET Data-Access APIs
Summary
Chapter 24: Introducing LINQ to XML
A Tale of Two XML APIs
Members of the System.Xml.Linq Namespace
Working with XElement and XDocument
Manipulating an In-Memory XML Document
Summary
Chapter 25: Introducing Windows Communication Foundation
A Potpourri of Distributed Computing APIs
The Role of WCF
Investigating the Core WCF Assemblies
The Visual Studio WCF Project Templates
The Basic Composition of a WCF Application
The ABCs of WCF
Building a WCF Service
Hosting the WCF Service
Building the WCF Client Application
Simplifying Configuration Settings
Using the WCF Service Library Project Template
Hosting the WCF Service Within a Windows Service
Invoking a Service Asynchronously from the Client
Designing WCF Data Contracts
Summary
Chapter 26: Introducing Windows Workflow Foundation
Defining a Business Process
Building a Simple Workflow
The Workflow Runtime
Examining the Workflow Activities
Building a Flowchart Workflow
Building a Sequence Workflow (in a Dedicated DLL)
Consuming the Workflow Library
Summary
Part VII: Windows Presentation Foundation
Chapter 27: Introducing Windows Presentation Foundation and XAML
The Motivation Behind WPF
The Various Flavors of WPF
Investigating the WPF Assemblies
Building a WPF Application Without XAML
Building a WPF Application Using Only XAML
Transforming Markup into a .NET Assembly
Understanding the Syntax of WPF XAML
Building a WPF Application Using Code-Behind Files
Building WPF Applications Using Visual Studio
Building a Custom XAML Editor with Visual Studio
Summary
Chapter 28: Programming with WPF Controls
A Survey of the Core WPF Controls
A Brief Review of the Visual Studio WPF Designer
Controlling Content Layout Using Panels
Building a Window’s Frame Using Nested Panels
Understanding WPF Commands
A Deeper Look at WPF APIs and Controls
Building the Ink API Tab
Introducing the Documents API
Building the Documents Tab
Introducing the WPF Data-Binding Model
Summary
Chapter 29: WPF Graphics Rendering Services
Understanding WPF’s Graphical Rendering Services
Rendering Graphical Data Using Shapes
WPF Brushes and Pens
Applying Graphical Transformations
Working with the Visual Studio Transform Editor
Rendering Graphical Data Using Drawings and Geometries
The Role of Expression Design
Rendering Graphical Data Using the Visual Layer
Summary
Chapter 30: WPF Resources, Animations, and Styles
Understanding the WPF Resource System
Working with Object (Logical) Resources
Understanding WPF’s Animation Services
Authoring Animations in XAML
Understanding the Role of WPF Styles
Summary
Chapter 31: Dependency Properties, Routed Events, and Templates
Understanding the Role of Dependency Properties
Building a Custom Dependency Property
Understanding Routed Events
Logical Trees, Visual Trees, and Default Templates
Building a Control Template with the Trigger Framework
Summary
Part VIII: ASP.NET Web Forms
Chapter 32: Introducing ASP.NET Web Forms
The Role of HTTP
Understanding Web Applications and Web Servers
The Role of HTML
The Role of Client-Side Scripting
Posting Back to the Web Server
An Overview of the ASP.NET API
Building a Single-File ASP.NET Web Page
Building an ASP.NET Web Page Using Code Files
ASP.NET Web Sites vs. ASP.NET Web Applications
The ASP.NET Web Site Directory Structure
The Inheritance Chain of the Page Type
Interacting with the Incoming HTTP Request
Interacting with the Outgoing HTTP Response
The Life Cycle of an ASP.NET Web Page
The Role of the web.config File
Summary
Chapter 33: ASP.NET Web Controls, Master Pages, and Themes
Understanding the Nature of Web Controls
The Control and WebControl Base Classes
Major Categories of ASP.NET Web Controls
Building the ASP.NET Cars Web Site
The Role of the Validation Controls
Working with Themes
Summary
Chapter 34: ASP.NET State Management Techniques
The Issue of State
ASP.NET State Management Techniques
Understanding the Role of ASP.NET View State
The Role of the Global.asax File
Understanding the Application/Session Distinction
Working with the Application Cache
Maintaining Session Data
Understanding Cookies
The Role of the <sessionState> Element
Introducing the ASP.NET Profile API
Summary
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Chapter 8: Working with Interfaces
Next
Next Chapter
Chapter 9: Collections and Generics
P A R T IV
Advanced C# Programming
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset