Tuesday, November 30, 2010

Microsoft .Net for Programmers












contents
preface xiii
acknowledgments xviii
author online xix
about the cover illustration xx
1 Introduction 1
1.1 Developing for the .NET platform 2
A language-independent platform 2 ✦ .NET and managed code 3
1.2 A first .NET program 4
Compiling the C# Hello program 5 ✦ A Visual Basic .NET Hello program 5
1.3 The platform vs. the programming language 6
1.4 Exploring the . NET Framework class library 7
An overview of imprtant namespaces 7 ✦ Programming with the .NET
Framework classes 9 ✦ What happened to ASP and ADO? 10
1.5 Putting .NET to work 11
1.6 Summary 14
2 Understanding types and assemblies 15
2.1 Introducing types 16
2.2 Value vs. reference types 18
The C# struct 19 ✦ Boxing and unboxing 20
2.3 Exploring System.Object 21
Overriding System.Object methods 22
2.4 Understanding finalization 23
Coding a finalizer 23
Finalization and the Dispose method 24
2.5 Introducing assemblies 26
Creating a multifile assembly 26 ✦ Disassembling with ILDASM 28
viii CONTENTS
2.6 Private vs. shared assemblies 29
Shared assemblies and versioning 29 ✦ Generating a strong name for
a shared assembly 30 ✦ Installing shared assemblies into the global
assembly cache 32 ✦ Creating an application configuration file 33
2.7 Downloading assemblies 35
Downloading the Person assembly from the Web 36
2.8 Programming in IL 37
Inspecting generated IL 37 ✦ Boxing and unboxing in IL 38
Coding IL programs 39 ✦ Generating native images 41
2.9 Types, assemblies, and reflection 41
An example of reflection 41 ✦ The System.Reflection.Emit namespace 43
2.10 Building a simple compiler 44
The AL language 44 ✦ Translating AL to IL 45 ✦ Dynamically
generating an assembly 46 ✦ Coding the AL compiler 46 ✦ Building
and testing the AL compiler 54
2.11 Summary 54
3 Case study: a video poker machine 55
3.1 Playing video poker 56
Winning poker hands 57 ✦ A profitable video poker machine 58
3.2 The Poker.Card class 58
Designing the Card class 58 ✦ Coding the Card class 59
3.3 The Poker.Hand class 61
Designing the Hand class 61 ✦ Coding the Hand class 61
3.4 SimPok: a simple poker game 68
The Poker.SimpleMachine class 68 ✦ The SimPok console interface 69
3.5 ComPok: a COM-based poker game 70
Registering the poker assembly as a COM object 70 ✦ Console poker
using COM and VBScript 71 ✦ RegAsm and the registry 72
3.6 IEPok: an Internet Explorer poker game 73
Downloading assemblies using Internet Explorer 73
Coding the IEPok application 74
3.7 Designing a complete game 76
Video poker: the poker engine and its interfaces 76
3.8 Summary 77
4 Working with ADO.NET and databases 78
4.1 The ADO.NET namespaces 79
The OLE DB and SQL Server managed providers 79
4.2 The ADO.NET DataSet 80
Creating and using a DataSet 80 ✦ A simple example 81
4.3 DataSets and XML 83
The DataSet’s GetXml and GetXmlSchema methods 83
4.4 Updating the database using a DataSet 85
Committing changes 86
4.5 Updating the database directly 87
4.6 The DataReader 88
4.7 The Poker.Bank class 89
Logging errors and warnings 91 ✦ Creating the Poker.Bank class 92
Testing the Bank class 99
4.8 Using XML serialization to create a report 101
Serializing an object to an XML document 102 ✦ Performing an
XSL transformation 103 ✦ The XmlRep program 106
4.9 The Poker.Machine class 109
4.10 The Poker.Bet class 112
4.11 Building the poker DLL 113
4.12 ConPok: 3-tier client/server poker 114
4.13 Summary 116
5 Developing remote services 117
5.1 Introduction to remoting 118
Remoting and application domains 118 ✦ Marshaling objects 118
Hosting remote objects 119 ✦ Creating a remote service 119
Creating the client 121 ✦ Testing the service 122
5.2 Implementing server-activated remote objects 123
Coding a SingleCall HelloService 123 ✦ Testing the SingleCall HelloService 124
5.3 Configuring remoting 124
Using remoting configuration files 124 ✦ Coding HelloService 125
Coding the new client 126
5.4 Implementing client-activated remote objects 127
Configuring the service for client activation 127 ✦ Configuring the client
for client activation 128 ✦ Coding the new client 129 ✦ Testing the
client-activated service 129
5.5 Client activation and leasing 130
Understanding leasing 131 ✦ Amending the lease 133
Using a sponsor to amend lease duration 133
5.6 Handling remote events 136
The EchoObj class 136 ✦ The EchoService class 137 ✦ The EchoClient
class 137 ✦ Testing the EchoService 138
5.7 Hosting objects in Internet Information Server 140
Providing a public interface for a remote service 140 ✦ Coding the
RemoteEncoder.Base64Service class 140 ✦ Coding the client 141
x CONTENTS
Compiling the Base64 string encoding application 142 ✦ Deploying the
StringEncoder service on IIS 142 ✦ Testing the IIS-hosted encoder 143
5.8 RemPok: a remote poker game 144
Developing the remote poker service 144 ✦ The remote poker machine
configuration file 145 ✦ The RemPok poker client 146 ✦ Testing
the remote poker machine 148
5.9 SvcPok: a remote poker game as a Windows service 149
Coding the poker Windows service 150 ✦ Installing the poker Windows
service 153 ✦ Creating the client 154
5.10 QuePok: a message queue-based poker game 155
Designing an MSMQ-based poker service 157 ✦ Creating the PokMsg and
PokerQueue classes 158 ✦ Creating the QuePokService service 159
Creating the QuePok client 160 ✦ Compiling and testing the QuePok service 161
5.11 Summary 163
6 Developing XML Web services 164
6.1 Introduction to XML Web services 165
6.2 Creating a first Web service 165
Creating the service 165 ✦ Testing the service 167
6.3 Creating an HTTP GET client 169
6.4 Using WSDL to describe a Web service 170
WSDL types 170 ✦ WSDL messages 171 ✦ WSDL portTypes 172
WSDL bindings 172 ✦ WSDL services 173
6.5 Coding a SOAP client 173
Generating the Web service proxy 175 ✦ Coding the client 177
Compiling and executing the client 178 ✦ Creating an asynchronous client 178
6.6 The WebMailService example 179
6.7 Managing service state 181
Creating a stateful Web service 181 ✦ Creating the stateful client 184
Testing the stateful service 185 ✦ Example: logging into a Web service 186
Maintaining state without cookies 188 ✦ Emulating singleton activation 189
6.8 Enabling Web service discovery 190
Generating a DISCO document 191 ✦ Creating a default.disco file 192
Processing a default.disco file 193
6.9 Using UDDI to advertise a Web service 194
Searching the UDDI registry 195 ✦ Installing the UDDI SDK and test
registry 197 ✦ Creating a simple inquiry client using the UDDI SDK 197
More on UDDI 198
6.10 WSPok: the Web service-based poker game 199
Creating the WSPokService poker Web service 199 ✦ Creating the
WSPok client 200 ✦ Testing the poker Web service 201
6.11 Summary 202
7 Creating the Windows Forms user interface 203
7.1 Beginning Windows Forms development 204
Creating a simple form 204 ✦ Adding controls to a form 205
Anchoring and docking controls 207 ✦ Handling form events 207
7.2 Understanding the Windows Forms programming model 208
The Component class 209 ✦ The Control class 211 ✦ The ScrollableControl
class 213 ✦ The ContainerControl class 214 ✦ The Form class 214
7.3 WinPok: the Windows Forms-based poker game 215
The WinPok program structure 215 ✦ Setting up the form 217
Creating the menu 218 ✦ Creating buttons 220 ✦ Creating labels 221
Creating text boxes 223 ✦ Creating check boxes 224 ✦ Displaying a status
bar 225 ✦ Creating picture boxes 226 ✦ Starting play 228 ✦ Dealing cards 230
Drawing cards 232 ✦ Accessing the Win32 API 233 ✦ Ending the application 233
7.4 Creating Windows Forms applications using Visual Studio .NET 234
Creating a Visual Studio .NET project 234 ✦ Designing a form 236
Adding code to the form 237
7.5 Overriding WndProc 238
7.6 Summary 240
8 Creating the Web Forms user interface 241
8.1 Comparing ASP.NET to ASP 242
A simple ASP application 242 ✦ A simple ASP.NET application 244
8.2 The System.Web.UI.Page class 245
The Page.Request and Page.Response properties 245 ✦ The Page lifecycle 246
8.3 Working with Web Forms and server controls 248
The anatomy of the Web Form 248 ✦ The System.Web.UI.WebControls and
System.Web.UI.HtmlControls namespaces 252 ✦ Using the Calendar Web control 253
Using the DataGrid Web control 254 ✦ Using the HtmlTable control 256
8.4 Creating user controls 258
8.5 Validating user input 261
8.6 Configuring and customizing ASP.NET applications 265
Creating a custom HTTP module 266 ✦ Creating a custom HTTP handler 268
8.7 Tracing ASP.NET applications 269
8.8 Managing application and session state 272
Application state and the Global.Asax file 272 ✦ Managing session state 274
8.9 Creating Web Forms using Visual Studio .NET 275
Creating a Web application using Visual Studio .NET 275 ✦ Using the toolbox to design
a Web Form 276
8.10 Manually creating code-behind Web Forms 278
8.11 WebPok: the Web Forms-based poker machine 279
8.12 MobPok: the mobile Internet-based poker machine 286
8.13 Summary 288
appendix a Introduction to C# 289
appendix b The Poker.dll class listings 321
appendix c The WinPok.cs listing 335
index 347

Download
Another .NET Books

No comments:

Post a Comment

Related Posts with Thumbnails

Put Your Ads Here!