1031 pro c 2010 and the NET 4 platform, 5th edition

1.8K 422 0
1031 pro c 2010 and the  NET 4 platform, 5th edition

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

  CYAN   MAGENTA   YELLOW   BLACK   PANTONE 123 C BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® Pro C# 2010 and the NET Platform, FIFTH EDITION Pro VB 2008 and the NET 3.5 Platform COM and NET Interoperability Expert ASP.NET 2.0 Advanced Application Design Developer’s Workshop to COM and ATL 3.0 • the Dynamic Language Runtime (DLR) • the Task Parallel Library (TPL, including PLINQ) • the ADO.NET Entity Framework (as well as LINQ to EF) • expanded coverage of the Windows Presentation Foundation (WPF) API • improved support for COM interop Andrew Troelsen Microsoft MVP, Visual Developer—Visual C#; Microsoft Certified Trainer (MCT) Companion eBook THE APRESS ROADMAP Introducing NET 4.0 See last page for details on $10 eBook version Accelerated C# 2010 Pro C# 2010 and the NET Platform Visual C# 2010 Recipes Pro ASP.NET in C# 2010 Pro Windows Azure Pro WPF in C# 2010 Pro Dynamic NET 4.0 Applications www.apress.com ISBN 978-1-4302-2549-2 59 9 US $59.99 C# 2010 and the NET 4 Platform Exploring the NET universe using curly brackets FIFTH EDITION FIFTH EDITION Troelsen SOURCE CODE ONLINE Pro and the If you’re checking out this book for the first time, understand that it targets experienced software professionals and students of computer science—so please don’t expect three chapters devoted to “variable scope” here! The mission of this text is to provide you with a rock-solid foundation in the C# programming language (including a full discussion of OOP) and the critical aspects of the NET platform Once you digest the information presented in the book you hold in your hands, you’ll be in a perfect position to apply this knowledge to your specific programming assignments, and you’ll be well-equipped to explore the NET universe on your own terms Pro C# 2010 Andrew Troelsen, author of The C# language and the NET platform have existed for quite some time and have become a mainstay of modern software development As expected, NET brings a wealth of new APIs to the base class libraries and several new syntactical constructs to C# For example, it is now possible to create C# methods that support optional and named arguments As well, you are able to resolve types completely at runtime using the new dynamic keyword As far as APIs are concerned, this edition of Pro C# 2010 and the NET Platform will cover a number of new details, including: Companion eBook Available NET Platform Dear Reader, THE EXPERT’S VOICE ® IN NET Andrew Troelsen Shelve in: Programming | C# User level: Intermediate–Advanced 781430 225492 www.it-ebooks.info this print for content only—size & color not accurate 7.5 x 9.25 spine = 3.28125" 1752 page count 544ppi Pro C# 2010 and the NET Platform Fifth Edition ■■■ Andrew Troelsen www.it-ebooks.info Pro C# 2010 and the NET Platform, Fifth Edition Copyright © 2010 by Andrew Troelsen All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher ISBN-13 (pbk): 978-1-4302-2549-2 ISBN-13 (electronic): 978-1-4302-2550-8 Printed and bound in the United States of America Trademarked names may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark President and Publisher: Paul Manning Lead Editor: Ewan Buckingham Technical Reviewer: Andy Olsen Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Debra Kelly Copy Editors: Patrick Meader, Katie Stence, and Sharon Terdeman Compositor: folio Indexer: Potomac Indexers Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013 Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com For information on translations, please e-mail rights@apress.com, or visit www.apress.com Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales The information in this book is distributed on an “as is” basis, without warranty Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work The source code for this book is available to readers at www.apress.com www.it-ebooks.info Contents at a Glance Contents viii About the Author xxv About the Technical Reviewer xxvi Acknowledgments xxvii Introduction xxviii ■ ■ ■ Part 1: Introducing C# and the NET Platform .1 ■ Chapter 1: The Philosophy of NET ■ Chapter 2: Building C# Applications .41 ■ ■ ■ Part 2: Core C# Programming Constructs 71 ■ Chapter 3: Core C# Programming Constructs, Part I 73 ■ Chapter 4: Core C# Programming Constructs, Part II .125 ■ Chapter 5: Defining Encapsulated Class Types 167 ■ Chapter 6: Understanding Inheritance and Polymorphism .219 ■ Chapter 7: Understanding Structured Exception Handling 259 ■ Chapter 8: Understanding Object Lifetime 289 ■ ■ ■ Part 3: Advanced C# Programming Constructs 319 ■ Chapter 9: Working with Interfaces 321 ■ Chapter 10: Understanding Generics 361 v www.it-ebooks.info ■ CONTENTS AT A GLANCE ■ Chapter 11: Delegates, Events, and Lambdas 397 ■ Chapter 12: Advanced C# Language Features 439 ■ Chapter 13: LINQ to Objects 489 ■ ■ ■ Part 4: Programming with NET Assemblies .523 ■ Chapter 14: Configuring NET Assemblies 525 ■ Chapter 15: Type Reflection, Late Binding, and Attribute-Based Programming 581 ■ Chapter 16: Processes, AppDomains, and Object Contexts 625 ■ Chapter 17: Understanding CIL and the Role of Dynamic Assemblies 653 ■ Chapter 18: Dynamic Types and the Dynamic Language Runtime .701 ■ ■ ■ Part 5: Introducing the NET Base Class Libraries 725 ■ Chapter 19: Multithreaded and Parallel Programming .727 ■ Chapter 20: File I/O and Object Serialization 775 ■ Chapter 21: ADO.NET Part I: The Connected Layer 825 ■ Chapter 22: ADO.NET Part II: The Disconnected Layer 885 ■ Chapter 23: ADO.NET Part III: The Entity Framework 951 ■ Chapter 24: Introducing LINQ to XML 993 ■ Chapter 25: Introducing Windows Communication Foundation .1013 ■ Chapter 26: Introducing Windows Workflow Foundation 4.0 1077 ■ ■ ■ Part 6: Building Desktop User Interfaces with WPF 1115 ■ Chapter 27: Introducing Windows Presentation Foundation and XAML 1117 ■ Chapter 28: Programming with WPF Controls 1179 ■ Chapter 29: WPF Graphics Rendering Services 1245 ■ Chapter 30: WPF Resources, Animations, and Styles .1285 ■ Chapter 31: WPF Control Templates and UserControls 1325 vi www.it-ebooks.info ■ CONTENTS AT A GLANCE ■ ■ ■ Part 7: Building Web Applications with ASP.NET 1377 ■ Chapter 32: Building ASP.NET Web Pages 1379 ■ Chapter 33: ASP.NET Web Controls, Master Pages and Themes 1429 ■ Chapter 34: ASP.NET State Management Techniques .1473 ■ Appendix A: Programming with Windows Forms .1511 ■ Appendix B: Platform-Independent NET Development with Mono 1561 ■ Index .1583 vii www.it-ebooks.info ■ CONTENTS Contents About the Author xxv About the Technical Reviewer xxvi Acknowledgments xxvii Introduction xxviii ■ ■ ■ Part 1: Introducing C# and the NET Platform .1 ■ Chapter 1: The Philosophy of NET Understanding the Previous State of Affairs The NET Solution Introducing the Building Blocks of the NET Platform (the CLR, CTS, and CLS) .7 Additional NET-Aware Programming Languages 10 An Overview of NET Assemblies .12 Understanding the Common Type System .19 Understanding the Common Language Specification 23 Understanding the Common Language Runtime .25 The Assembly/Namespace/Type Distinction 27 Exploring an Assembly Using ildasm.exe 33 Exploring an Assembly Using Reflector 35 Deploying the NET Runtime 36 viii www.it-ebooks.info ■ CONTENTS The Platform-Independent Nature of NET .37 Summary 39 ■ Chapter 2: Building C# Applications .41 The Role of the NET Framework 4.0 SDK .41 Building C# Applications Using csc.exe 42 Building NET Applications Using Notepad++ 49 Building NET Applications Using SharpDevelop 50 Building NET Applications Using Visual C# 2010 Express 53 Building NET Applications Using Visual Studio 2010 54 Summary 69 ■ ■ ■ Part 2: Core C# Programming Constructs 71 ■ Chapter 3: Core C# Programming Constructs, Part I 73 The Anatomy of a Simple C# Program 73 An Interesting Aside: Some Additional Members of the System.Environment Class .79 The System.Console Class .81 System Data Types and C# Shorthand Notation 86 Working with String Data .97 Narrowing and Widening Data Type Conversions 106 Understanding Implicitly Typed Local Variables 112 C# Iteration Constructs 117 Decision Constructs and the Relational/Equality Operators 119 Summary .122 ■ Chapter 4: Core C# Programming Constructs, Part II .125 Methods and Parameter Modifiers 125 Understanding C# Arrays .137 Understanding the Enum Type .144 ix www.it-ebooks.info ■ CONTENTS Understanding the Structure Type .151 Understanding Value Types and Reference Types .154 Understanding C# Nullable Types 162 Summary .165 ■ Chapter 5: Defining Encapsulated Class Types 167 Introducing the C# Class Type .167 Understanding Constructors 170 The Role of the this Keyword .174 Understanding the static Keyword .181 Defining the Pillars of OOP 188 C# Access Modifiers 192 The First Pillar: C#’s Encapsulation Services .194 Understanding Automatic Properties 206 Understanding Object Initializer Syntax .210 Working with Constant Field Data 214 Understanding Partial Types 217 Summary .218 ■ Chapter 6: Understanding Inheritance and Polymorphism .219 The Basic Mechanics of Inheritance 219 Revising Visual Studio Class Diagrams 224 The Second Pillar of OOP: The Details of Inheritance 226 Programming for Containment/Delegation 232 The Third Pillar of OOP: C#’s Polymorphic Support .235 Understanding Base Class/Derived Class Casting Rules .247 The Master Parent Class: System.Object .250 Summary .258 x www.it-ebooks.info ■ CONTENTS ■ Chapter 7: Understanding Structured Exception Handling 259 Ode to Errors, Bugs, and Exceptions .259 The Role of NET Exception Handling 260 The Simplest Possible Example .263 Configuring the State of an Exception 267 System-Level Exceptions (System.SystemException) 272 Application-Level Exceptions (System.ApplicationException) .273 Processing Multiple Exceptions .277 Who Is Throwing What? 282 The Result of Unhandled Exceptions .283 Debugging Unhandled Exceptions Using Visual Studio 284 A Brief Word Regarding Corrupted State Exceptions (CSE) 285 Summary .287 ■ Chapter 8: Understanding Object Lifetime 289 Classes, Objects, and References 289 The Basics of Object Lifetime 291 The Role of Application Roots 294 Understanding Object Generations 296 Concurrent Garbage Collection under NET 1.0 - 3.5 .297 Background Garbage Collection under NET 4.0 297 The System.GC Type 298 Building Finalizable Objects 302 Building Disposable Objects 305 Building Finalizable and Disposable Types 309 Understanding Lazy Object Instantiation .313 Summary .316 xi www.it-ebooks.info INDEX ■ XAML, declarations, 1159 Variables aspect, 1095 Variables button, 1095, 1098, 1106 Variant data types, 115, 717, 718, 722 VB (Visual Basic) literal syntax, 996—997 VB code, 1097 VB statements, 1094 VB6 Component Object Model (COM) developers, 261 vbc.exe compiler, 24 vbc.exe file, 16 vbnc compiler, Mono, 1569 VBScript language, 1389 VbSnapIn library, 620 VbSnapIn.dll assembly, 618, 623 VbSnapIn.dll library, 621 vector graphics, generating using expression design, 1275—1276 [VehicleDescription] attribute, 610, 612 VehicleDescriptionAttribute attribute, 609, 610 VehicleDescriptionAttribute class, 615 VehicleDescriptionAttributeReader application, 614 Venn diagramming operations, 1268 Venn diagramming tool, LINQ as, 515—516 ver directives, 542, 666 ver token, 542, 562 verbatim strings, 101—102 VerifyDuplicates( ) method, 471, 472, 473 version numbers, setting, 919 Version type, 693 element, 48 Vertical split button, 1170 Vertical value, 1189 VerticalAlignment property, FrameworkElement type, 1133 VerticalContentAlignment property, Control Type, 1133 VeryComplexQueryExpression class, 521 VeryDynamicClass, 706 VES (Virtual Execution System), 37 VideoDrawing object, 1258 VideoDrawing type, 1272 View Class Diagram button, 64, 225, 932 View Code menu option, 1081, 1104, 1554 View Code option, 621, 933, 1513, 1520 View Detail link, 285 View In Browser menu option, 1387, 1388, 1399, 1465 View Inventory menu item, 1452 View Inventory node, 1446 View menu, 56, 58, 60, 65, 223, 568, 608, 939, 1169, 1450 View Source, 1477 view state adding custom data, 1478—1479 demonstrating, 1477—1478 overview, 1476 Viewport3DVisual class, 1277 Viewport3DVisual object, 1258 ViewState property, 1478, 1485 ViewStateApp project, 1477 virtual, 22 virtual directories, IIS, 1381 virtual execution stack, 656 Virtual Execution System (VES), 37 virtual keyword, 125, 236—238, 243 virtual members overriding using Visual Studio 2010, 238—239 sealing, 239 virtual methods, 236, 243, 493 Visibility property, UIElement type, 1134 visibility trait, 22 Visible property, 1432, 1433, 1527, 1529 visual base class and derived child classes, 1277 Visual Basic (VB) literal syntax, 996—997 Visual Basic 6.0, programming language comparison, Visual Basic, building client application, 547—549 Visual Basic compiler, 16, 1565, 1569 Visual Basic Snap-In, 620 Visual C# 2010 Express and Visual C++ 2010 Express, 53 Visual C# 2010 Express, building C# applications with, 53—54 Visual class, 1134, 1258, 1277, 1283 1699 www.it-ebooks.info INDEX ■ Visual Class Designer, Visual Studio 2010, 64—67 visual designer surface, 1519—1520 visual layer, rendering graphical data using DrawingVisual class, 1278—1279 overview, 1277 rendering to custom layout manager, 1280—1282 responding to hit test operations, 1282— 1284 visual base class and derived child classes, 1277 Visual object, 1258 visual state groups, 1366 Visual State Manager (VSM), NET 4.0, 1356, 1366 Visual Studio 2010 AssemblyInfo.cs file, 613 class diagrams, revising, 224—225 Class View utility, 58—59 code expansions, 63—64 configuration files and, 556—558 configuring brushes using, 1258—1260 default namespace of, 531 generating proxy code using, 1047—1048 generating strong names using, 563— 564 HTML designer tools, 1384—1386 implementing interfaces using, 335—336 integrated NET Framework 4.0 documentation, 67—69 New Project dialog box, 56 Object Browser utility, 60 overriding virtual members using, 238— 239 overview, 54 project templates, 1023—1025 refactoring code, 60—63 Solution Explorer Utility overview, 56 referencing external assemblies, 57 viewing Project Properties, 58 unique features of, 55 Visual Class Designer, 64—67 WPF applications, building using Button Click event, implementing, 1175—1176 Closed event, implementing, 1177 designer tools, 1169—1172 GUI, designing, 1173—1174 Loaded event, implementing, 1174 overview, 1167 project templates, 1168 testing, 1177—1178 WPF control templates, building custom {TemplateBinding} markup extension, 1352—1353 ContentPresenter class, 1354 incorporating into styles, 1354—1355 incorporating visual cues using triggers, 1351—1352 overview, 1348 as resources, 1349—1351 WPF controls, 1181—1182 Visual Studio debugger, 284—285 Visual Studio Windows Forms project template initial Form, 1520—1521 overview, 1518 Program class, 1521—1522 visual designer surface, 1519—1520 visually building menu systems, 1522— 1524 visual trees, 1252, 1278, 1341—1348 Visual type, 1135, 1277 Visual Web Developer 2010 Express, 53 VisualBasicCarClient project, 549 VisualBasicCarClient.exe file, 553 VisualBrush class, 1258 VisualBrush type, 1258 VisualChildrenCount property, 1281 VisualCollection container, 1282 VisualCollection variable, 1280, 1281 VisualStateGroup class, 1367 VisualStateManager class, 1367, 1370 VisualTreeHelper class, 1252, 1343 VisualTreeHelper.HitTest( ) method, 1252, 1253, 1283 void return value, 75, 76, 77 1700 www.it-ebooks.info INDEX ■ void value, 127, 171 Vs2010Example application, 56 VSM (Visual State Manager), NET 4.0, 1356, 1366 ■W W3C (World Wide Web Consortium), 995, 1019 WaitCallback delegate, 760 WaitForPendingFinalizers( ) method, System.GC class, 298 WaitHandle class, 735 WaitHandle.WaitOne( ) method, 735 WaitOne( ) method, 735, 748 WaitReason member, ProcessThread type, 633 WAS (Windows Activation Service), 1026 WCF See Windows Communication Foundation WCF (core assemblies of Windows Communication Foundation), 1022 WcfMathService.MyCalc class, 1054 WcfTestClient.exe, 1024, 1058—1059, 1075 web application, 1412 Web Application model, 1413 web application shutdown, handling, 1488 Web Application Templates, Visual Studio, 1412 Web applications, 1412—1413 Web applications and servers ASP.NET development web server, 1382 IIS virtual directories, 1381 overview, 1380 web controls categories of, 1438 data centric, 1439 security, 1440 standard, 1439 web controls, ASP.NET See ASP.NET web controls Web Form, 1408, 1473, 1477, 1485, 1489, 1498 Web Form controls, 1416, 1429 Web Form icon, Solution Explorer, 1408 web method, 1018 Web pages building single file adding data access logic, 1397—1401 ASP.NET control declarations, 1403— 1404 ASP.NET directives, 1401—1403 compilation cycle for single-file pages, 1405—1406 designing UI, 1396—1397 overview, 1395 referencing AutoLotDAL.dll, 1396 "script" block, 1403 building using code files, 1406—1411 Web Parts, 1393 Web servers, posting back to, 1390—1391 Web Service Definition Language (WSDL), 1019, 1021, 1034, 1044, 1055, 1072, 1073 web service specifications (WS-*), 1020 Web Services Addressing (WS-Addressing), 1029 Web Services Basic (WS-Basic), 1029 Web Services Enhancements (WSE), 1019 Web Services Federation (WS-Federation), 1029 Web Services Interoperability Organization (WS-I), 1019, 1029 Web Services Reliability (WS-Reliability), 1028 Web Services SecureConversation (WSSecureConversation), 1030 Web Services Security (WS-Security), 1028, 1030 Web Services Transactions (WSTransactions), 1028 Web Services Trust (WS-Trust), 1030 Web Site dialog box, 1017 Web site directory structure App_Code folder, 1415 overview, 1413 referencing assemblies, 1414—1415 Web sites applications, 1412—1413 1701 www.it-ebooks.info INDEX ■ web User Interface (UI), 1474 Web-Centric service project templates, 1071—1073 WebClient class, 768 Web.config files, 1075, 1427—1428, 1504— 1505 WebControl class, 1404, 1430, 1437, 1438 WebControl types, 1432 webdev.webserver.exe utility, Microsoft NET, 1571 [WebMethod] attribute, 605, 606, 1016, 1018 directive, 1018 website administration utility, ASP.NET, 1428 Website option, 1409 Web.sitemap file, 1445, 1446 Welcome dialog box, 1207 where clauses, 393, 394 where keyword, constraining type parameters using, 393—394 Where( ) method, 517, 519, 520 where operator, 497, 509, 511, 517, 518 where T : class constraint, 392 where T : NameOfBaseClass constraint, 393 where T : NameOfInterface constraint, 393 where T : new( ) constraint, 392 where T : struct constraint, 392 WhereArrayIterator class, 499 While activity, WF 4.0, 1089 while keyword, 682 while loop, 117, 119 widening operation, 106 Width attribute, 1146 Width property, 1133, 1145, 1152, 1187, 1193, 1219, 1304, 1326, 1438, 1527 Width value, 1188, 1189, 1193 wildcard character (*), 47 wildcard token, 562 \Assembly directory, 1578 Window and control adornments, WPF, 1180 Window class overview, 1130 System.Windows.Controls.ContentCon trol, 1131—1132 System.Windows.Controls.Control, 1132 System.Windows.DependencyObject, 1135 System.Windows.FrameworkElement, 1133 System.Windows.Media.Visual, 1134— 1135 System.Windows.Threading.Dispatcher Object, 1135 System.Windows.UIElement, 1134 Window construction, 1138 Window designer, WPF, 1170 window, dirty, 1549 Window menu, 1303 Window objects, 1130, 1135, 1137, 1138, 1155, 1173 Window type, 1121, 1130, 1135, 1137, 1146, 1173, 1175, 1177, 1196, 1204 element, 1155, 1156, 1158, 1159, 1160, 1173, 1175, 1185, 1205, 1232 WindowCollection type, 1129 scope, 1205 Window-derived class, 1137, 1146 Window-derived object, 1138 WindowHeight property, System.Console class, 82 WindowLeft property, System.Console class, 82 scope, 1294 windows closing, 1141—1142 mapping data to C# code, 1150—1151 naturally dirty, 1551 strongly typed, 1137—1138 Windows Activation Service (WAS), 1026 Windows Application Programming Interface (API), 260, 285, 286, 729 Windows Communication Foundation (WCF) 1702 www.it-ebooks.info INDEX ■ addresses, bindings, and contracts (ABCs) addresses, 1031—1032 bindings, 1028—1031 contracts, 1027 building client applications configuring TCP-based binding, 1049—1050 generating proxy code using svcutil.exe, 1046—1047 generating proxy code using Visual Studio 2010, 1047—1048 building services [OperationContract] attributes, 1035 [ServiceContract] attributes, 1034 overview, 1032 service types as operational contracts, 1035—1036 composition of applications, 1025—1027 core assemblies of, 1022 data in one process, 625 designing data contracts examining Web.config files, 1075 implementing service contracts, 1073—1074 overview, 1070 role of *.svc files, 1074 testing services, 1075—1076 using Web-Centric service project templates, 1071—1073 distributed computing APIs NET remoting, 1016 COM+/Enterprise Services, 1015 Distributed Component Object Model (DCOM), 1014—1015 Microsoft Message Queuing (MSMQ), 1015—1016 named pipes, sockets, and P2P, 1019 overview, 1013 XML web services, 1016—1019 features, 1020 hosting services element, 1042 coding against ServiceHost type, 1038 enabling metadata exchange, 1043— 1045 establishing ABCs within App.config files, 1037 ServiceHost type, 1040—1041 specifying base addresses, 1038— 1040 hosting services within Windows services creating Windows service installer, 1064—1065 enabling MEX, 1064 installing Windows service, 1066— 1067 overview, 1061 specifying ABCs in code, 1062—1063 invoking services asynchronously from clients, 1067—1069 overview, 1013 service-oriented architecture (SOA) tenets, 1021—1022 simplifying configuration settings with WCF 4.0 changing settings for bindings, 1053—1054 default endpoints in, 1051—1052 default MEX behavior configuration, 1054—1055 exposing single services using multiple bindings, 1052—1053 overview, 1050 refreshing client proxy and selecting bindings, 1056—1057 using Service Library project templates altering configuration files using SvcConfigEditor.exe, 1059—1061 building simple math services, 1057—1058 testing with WcfTestClient.exe, 1058—1059 Visual Studio project templates, 1023— 1025 Windows control, 1292 1703 www.it-ebooks.info INDEX ■ Windows Explorer, viewing NET 4.0 GAC using, 566 Windows file header, 534—535 Windows Forms applications completing, 937 executing under Linux, 1580 extendable, 621—624 Windows Forms Client program, building, 1578—1580 Windows Forms database designer tools app.config files, 932 completing Windows Forms applications, 937 DataGridView control, 927—932 strongly typed data adapters, 936—937 strongly typed DataRows, 935 strongly typed DataSets, 932—934 strongly typed DataTables, 934 Windows Forms Graphics object, 1279 Windows Forms GUI toolkit, 903, 904, 906, 907, 913, 918, 920, 921, 927, 931 Windows Forms GUIs binding DataTable objects to DataView type, 912—913 deleting rows from DataTables, 907— 908 hydrating DataTables from generic List, 904—906 selecting rows based on filter criteria, 908—911 updating rows within DataTables, 911 data binding entities to, 986—989 Windows Forms message box, 540 Windows Forms, programming with building applications overview, 1513 populating controls collection, 1515—1517 System.EventArgs and System.EventHandler, 1517—1518 building complete applications adding infrastructure to MainWindow type, 1555 capturing and rendering graphical output, 1557 implementing serialization logic, 1558—1560 implementing Tools menu functionality, 1555—1556 main menu system, 1552—1553 overview, 1551 ShapeData type, 1553 ShapePickerDialog type, 1553—1555 designing dialog boxes configuring tab order, 1540 DialogResult property, 1539 displaying dialog boxes, 1542—1543 overview, 1538 setting form's default input button, 1541 Tab Order Wizard, 1540—1541 understanding form inheritance, 1543—1545 Form type Control class, 1526—1529 Form class, 1529—1530 life cycle, 1531—1533 overview, 1525 mouse and keyboard activity determining which button was clicked, 1535—1536 determining which key was pressed, 1536—1537 overview, 1534 namespaces, 1512—1513 overview, 1511 rendering graphical data using GDI+ Graphics type, 1548—1549 invalidating form's client area, 1551 obtaining Graphics object with Paint event, 1549—1550 overview, 1545—1546 System.Drawing namespace, 1547 Visual Studio Windows Forms project template initial Form, 1520—1521 overview, 1518 Program class, 1521—1522 1704 www.it-ebooks.info INDEX ■ visual designer surface, 1519—1520 visually building menu systems, 1522—1524 Windows Forms properties, 1392 Windows header information, 534 Windows help file, 269 Windows Management Instrumentation (WMI), 1043 Windows menu, 1363 Windows network identity, 1507 Windows Open dialog box, 621 Windows Presentation Foundation (WPF), 1285—1324, 1325—1375 animation Animation class types, 1304—1305 authoring in C# code, 1306—1307 authoring in XAML, 1309—1312 looping, 1308—1309 overview, 1303 pacing of, controlling, 1307—1308 To property, 1305 By property, 1305 From property, 1305 reversing, 1308—1309 Timeline Base class, 1305 control templates building custom with Visual Studio 2010, 1348—1355 default, 1341—1348 default, programmatically inspecting, 1344—1348 dependency properties building custom, 1331—1336 CLR property wrappers, 1330 examining existing, 1327—1330 overview, 1325 Jackpot Deluxe WPF application NET 4.0 visual states, 1366—1370 extracting UserControl from drawing geometry, 1365—1366 finalizing, 1371—1375 overview, 1364 logical trees overview, 1341 programmatically inspecting, 1342— 1343 resource system binary resources, 1285—1291 object (logical) resources, 1292—1303 routed events overview, 1337 routed bubbling events, 1338—1339 routed tunneling events, 1339—1341 styles animated, 1318 assigning programmatically, 1319— 1320 automatically applying with TargetType, 1314—1315 defining and applying, 1313—1314 defining with multiple triggers, 1317 defining with triggers, 1317 generating with Expression Blend, 1320—1324 overriding settings, 1314 overview, 1312 subclassing existing, 1315 unnamed, 1316 UserControls, building custom with Blend animation, defining, 1359—1362 initial C# code, 1359 overview, 1356 programmatically starting storyboard, 1363—1364 renaming initial, 1357—1358 SpinControl, 1358 visual trees overview, 1341—1342 programmatically inspecting, 1343— 1344 Windows Presentation Foundation (WPF) applications assemblies Application class, 1128—1130 overview, 1126—1127 Window class, 1130—1135 building using code-behind files 1705 www.it-ebooks.info INDEX ■ MainWindow class, adding code file for, 1165 MyApp class, adding code file for, 1166 processing files with msbuild.exe, 1166—1167 building using only XAML application object, defining, 1147 MainWindow class, defining, 1146— 1147 overview, 1144—1145 processing files with msbuild.exe, 1148—1150 building using Visual Studio 2010 Button Click event, implementing, 1175—1176 Closed event, implementing, 1177 designer tools, 1169—1172 GUI, designing, 1173—1174 Loaded event, implementing, 1174 overview, 1167 project templates, 1168 testing, 1177—1178 building without XAML application level data, interacting with, 1139—1140 closing window, 1141—1142 keyboard events, intercepting, 1143— 1144 mouse events, intercepting, 1142— 1143 overview, 1135—1136 strongly typed window, 1137—1138 user interface, 1138—1139 flavors of desktop applications, 1121—1123 navigation-based applications, 1124 WPF/Silverlight relationship, 1126 XBAP applications, 1124—1125 motivation behind optimized rendering model, 1120 overview, 1117 separation of concerns, 1119 simplifying UI programming, 1120— 1121 unifying APIs, 1118—1119 syntax of attached properties, 1162 class and member variable declarations, controlling, 1159 kaxaml, 1154—1156 kaxamlXAML XML namespaces and XAML, 1156—1159 markup extensions, 1163—1165 property-element syntax, 1161 XAML elements, XAML attributes and type converters, 1160—1161 transforming markup into NET assembly BAML, 1151—1152 mapping application data to C# code, 1153 mapping window data to C# code, 1150—1151 overview, 1150 XAML-to-assembly process, 1153— 1154 Windows Presentation Foundation (WPF) controls commands connecting to arbitrary actions, 1203—1204 connecting to Command property, 1202—1203 intrinsic control command objects, 1201 Open command, 1204—1206 overview, 1200 Save command, 1204—1206 core, 1179—1181 data-binding model Data Binding tab, 1236 DataContext property, 1239 DataGrid tab, 1242—1244 establishing data bindings, 1236— 1238, 1241—1242 IValueConverter interface, data conversion using, 1240—1241 overview, 1235 dialog boxes, 1183 1706 www.it-ebooks.info INDEX ■ document controls, 1183 Documents API block elements, 1227 document layout managers, 1228 inline elements, 1227 Documents tab, building annotations, enabling, 1232—1234 loading FlowDocument, 1234—1235 overview, 1228 populating FlowDocument, 1230— 1232 saving FlowDocument, 1234—1235 sticky notes, enabling, 1232—1234 Expression Blend, building user interface with key aspects of, 1207—1213 TabControl control, 1213—1215 Ink API tab, building ComboBox control, 1224—1226 InkCanvas control, 1222—1227 overview, 1216 RadioButton control, 1220—1222 ToolBar, 1217—1219 ink controls, 1182—1183 overview, 1179 panels enabling scrolling for, 1194—1195 nested, building window frame using, 1195—1200 overview, 1184—1185 positioning content within, 1186— 1194 using Visual Studio 2010, 1181—1182 Windows Presentation Foundation (WPF) graphics rendering services applying graphical transformations, 1262—1266 brushes configuring in code, 1260—1261 configuring using Visual Studio 2010, 1258—1260 generating complex vector graphics using expression design, 1275— 1276 options, 1246—1247 overview, 1245 pens, 1261—1262 rendering graphical data using drawings and geometries building DrawingBrush using geometries, 1272—1273 containing drawing types in DrawingImage, 1274—1275 overview, 1271 painting with DrawingBrush, 1273— 1274 rendering graphical data using visual layer DrawingVisual class, 1278—1279 rendering to custom layout manager, 1280—1282 responding to hit test operations, 1282—1284 visual base class and derived child classes, 1277 shapes adding rectangles, ellipses, and lines to canvas, 1249—1252 overview, 1247—1248 paths, 1254—1257 polylines and polygons, 1253—1254 removing rectangles, ellipses, and lines from canvas, 1252—1253 working with using Expression Blend, 1266—1271 Windows property, 1129, 1130 Windows services creating installer, 1064—1065 hosting services within creating Windows service installer, 1064—1065 enabling MEX, 1064 installing Windows service, 1066— 1067 overview, 1061 specifying ABCs in code, 1062—1063 installing, 1066—1067 Windows Start button, 1572 Windows Task Manager utility, 625 Windows thread scheduler, 728 1707 www.it-ebooks.info INDEX ■ Windows Workflow Foundation 4.0 (WF) activities collection, 1092—1093 control flow, 1089 error handling, 1092—1093 flowchart, 1089—1090 messaging, 1090—1091 overview, 1088 primitives, 1091 runtime, 1091 transaction, 1091—1092 business process, defining, 1078 overview, 1077 runtime engine WorkflowApplication class, hosting workflows using, 1086—1088 WorkflowInvoker class, hosting workflows using, 1083—1086 workflows consuming libraries, 1112—1114 flowchart, 1093—1103 isolating into dedicated libraries, 1103—1111 simple, 1079—1083 WindowsBase.dll assembly, 1127, 1135, 1157, 1168 WindowsFormsDataBinding application, 904 WindowsFormsDataBinding project, 904, 913 scope, 1297 WindowsStartupLocation attribute, 1146 WindowState property, 1530 WindowTop property, System.Console class, 82 window-wide resources, defining, 1292— 1294 WindowWidth property, System.Console class, 82 WinFormsClientApp.cs, 1578 WinFormsClientApp.rsp, 1579 Winnebago class, 611 WithCancellation( ) method, 771 WithCancellation( )method, 773 Wizard control, 1439, 1441, 1455 wizards, Workflow Activity Library project, 1083 Workflow Console Application project, 1083 workflow designer, defining arguments using, 1084—1086 Workflow Foundation (WF), 1024 Workflow node, 1103 Workflow Service Application project template, WCF, 1083 Workflow1.xaml file, 1081, 1084 WorkflowApplication class, hosting workflows using, 1086—1088 workflow-enabled applications, 30 WorkflowInvoker class, hosting workflows using defining arguments using workflow designer, 1084—1086 overview, 1083 passing arguments to workflow, 1084 WorkflowInvoker.Invoke( ) method, 1084, 1113 WorkflowLibraryClient project, 1112, 1114 WorkflowRuntime class, 1086 workflows consuming libraries, 1112—1114 flowchart activities, connecting in, 1094 FlowDecision activity, 1096—1098 ForEachT activity, 1099—1100 InvokeMethod activity, 1094—1095 overview, 1093 TerminateWorkflow activity, 1097 variables, workflow wide, 1095—1096 hosting using WorkflowApplication class, 1086—1088 hosting using WorkflowInvoker class defining arguments using workflow designer, 1084—1086 overview, 1083 passing arguments to workflows, 1084 isolating into dedicated libraries arguments, defining, 1105—1106 assemblies, importing, 1105 1708 www.it-ebooks.info INDEX ■ Assign activity, 1107 Code activity, 1109—1111 defining project, 1103—1104 If activity, 1107—1108 namespaces, importing, 1105 Switch activity, 1107—1108 variables, defining, 1106—1107 simple, 1079—1083 WorkflowServiceHost class, 1088 WorkWithArrayList( ) method, 367 World Wide Web (WWW) environment, 1473 World Wide Web Consortium (W3C), 995, 1019 WPF See Windows Presentation Foundation WPF Fundamentals node, 1336 WPF triggers, 1366 WPF User Control Library project, 1300 WpfAppAllCode namespace, 1137 WpfAppAllCode project, 1135, 1144 WpfAppAllXaml application, 1167 WpfAppAllXaml project, 1154 WpfAppCodeFiles folder, 1165 WpfAppCodeFiles project, 1167 WpfControlsAndAPIs application, 1207 WpfControlsAndAPIs project, 1244 WPFRoutedEvents project, 1337, 1341 WpfStyles application, 1313 WpfStyles project, 1320 WrapPanel panel control, WPF, 1186 WrapPanel panels, 1188, 1190 Write( ) method, 82, 793, 795, 800, 1421, 1422 WriteAllBytes( )method, 791 WriteAllLines( )method, 791 WriteAllText( )method, 791 WriteByte( ) member, 793 WriteFile( ) method, 1421 WriteLine activity, 1080, 1081, 1084, 1085, 1093, 1094, 1097, 1098, 1099, 1100 WriteLine( ) member, 795 WriteLine( ) method, 75, 82, 83, 181, 704 WriteXml( ) method, 889, 901 WriteXmlSchema( ) method, 901 writing, to text files, 795—796 WS-* (web service specifications), 1020 WS-* specifications, 1019 WS-Addressing (Web Services Addressing), 1029 WS-Basic (Web Services Basic), 1029 WSDL (Web Service Definition Language), 1019, 1021, 1034, 1044, 1055, 1072, 1073 wsdl link, 1055 wsdl utility, Mono, 1571 wsdl.exe file, 1018 wsdl.exe utility, Microsoft NET, 1571 WSDualHttpBinding class, 1029, 1030, 1031 WSDualHttpBinding option, 1029 element, 1029 WSE (Web Services Enhancements), 1019 WS-Federation (Web Services Federation), 1029 WSFederationHttpBinding class, 1029, 1031 WSFederationHttpBinding option, 1029 WSFederationHttpBinding protocol, 1030 element, 1029 WSHttpBinding class, 1029, 1063, 1070 WSHttpBinding option, 1029 WSHttpBinding protocol, 1029, 1058 element, 1029 WS-I (Web Services Interoperability Organization), 1019, 1029 WS-Reliability (Web Services Reliability), 1028 WS-SecureConversation (Web Services SecureConversation), 1030 WS-Security (Web Services Security), 1028, 1030 WS-Transactions (Web Services Transactions), 1028 WS-Trust (Web Services Trust), 1030 WWW (World Wide Web) environment, 1473 WYSIWYG (fixeddocuments), 1120 1709 www.it-ebooks.info INDEX ■ ■X x: Array keyword, 1163 x: ClassModifier keyword, 1158 X icon, 1142 x: Key keyword, 1158 x: Name keyword, 1158 x; prefix, 1157 X property, 211, 378, 1535 X string format character, 84 x: tag prefix, 1146 X value, 212 X1 property, 1250 X2 property, 1250 XAML NET 4.0 visual states, 1369—1370 authoring animation in discrete key frames, 1311—1312 event triggers, 1310—1311 overview, 1309 storyboards, 1310 exporting design document to, 1275— 1276 for simple workflows, 1081—1083 transforming markup into NET assembly, 1153—1154 WPF applications, building using application object, defining, 1147 MainWindow class, defining, 1146— 1147 overview, 1144—1145 processing files with msbuild.exe, 1148—1150 WPF applications, building without application level data, interacting with, 1139—1140 closing window, 1141—1142 keyboard events, intercepting, 1143— 1144 mouse events, intercepting, 1142— 1143 overview, 1135—1136 strongly typed window, 1137—1138 user interface, 1138—1139 WPF, syntax of attached properties, 1162 class and member variable declarations, controlling, 1159 kaxaml tool, 1154—1156 markup extensions, 1163—1165 overview, 1154 property-element syntax, 1161 type converters, 1160—1161 XAML, 1156—1159 XAML attributes, 1160—1161 XAML elements, 1160—1161 XAML XML namespaces, 1156—1159 XAML (Extensible Application Markup Language), 993 XAML (x:Name Extensible Application Markup Language) token, 1146 XAML attribute, 1160 XAML browser application (XBAP), 1124 XAML browser applications (XBAP applications), 1124—1125 XAML dialect, 1079 XAML editor, 1239, 1309, 1321, 1357 xaml file, 1298 *.xaml files, 1082, 1103, 1145, 1146, 1147, 1149, 1150, 1151, 1152, 1153 XAML files, external, 1082 XAML markup, 1152 XAML pane, 1155 XAML scope, 1316 XAML scrubber option, 1154 XAML string, 1347 XAML tab, 1369 XamlAnimations folder, 1309 XamlAnimations subdirectory, 1312 *.xaml.cs, 1165 XamlReader class, 1235 XamlReader type, 1173 XamlReader.Load( ) method, 1175 XamlSpecificStuff, 1157, 1158 XamlWriter class, 1235 XamlWriter type, 1173 x:Array keyword, 1158 x:Array markup extension, 1164 XAttribute class, 995, 998 XBAP (XAML browser application), 1124 1710 www.it-ebooks.info INDEX ■ XBAP applications (XAML browser applications), 1124—1125 XButton1 property, 1143 XButton1 value, 1536 XButton2 property, 1143 XButton2 value, 1536 XCData class, 998 x:Class attribute, 1104, 1150, 1156, 1159, 1357 x:Class keyword, 1158 x:Class value, 1104 x:ClassModifier attribute, 1159 x:Code attribute, 1159 x:Code keyword, 1158 element, 1147 XComment class, 998 XContainer class, 1000, 1001 x-coordinate, 1535 Xcopy deployment, 553 XDeclaration class, 998, 1003 XDocument class, 998, 1000, 1002, 1003, 1006, 1008, 1011 XDocument objects generating documents from arrays and containers, 1004—1005 loading and parsing XML content, 1006 overview, 1002 XDocuments class, 1004 XElement class, 995, 996, 999, 1000, 1003, 1004, 1006, 1011 XElement objects generating documents from arrays and containers, 1004—1005 loading and parsing XML content, 1006 overview, 1002 XElements class, 1004, 1005 x:FieldModifier attribute, 1159 XHTML (Extensible Hypertext Markup Language), 1383, 1392 x:Key attribute, 1293, 1315 x:Key value, 1293, 1316 XML (Extensible Markup Language), 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004 XML (Extensible Markup Language) schema editor, 902 XML APIs vs DOM models, 995—996 overview, 993—994 Visual Basic (VB) literal syntax, 996—997 XML content, loading and parsing, 1006 XML data, 815—816 XML documents building UI of LINQ to XML App, 1007 defining LINQ to XML Helper class, 1008—1009 importing Inventory.xml files, 1007— 1008 overview, 1006 rigging up UI to Helper class, 1009— 1011 XML Editor option, 968 XML markup, 1119 XML namespace (xmlns) attribute, 1383 XML namespaces, XAML, 1156—1159 XML Paper Specification (XPS), 1120, 1183, 1227 XML, serializing DataTable/DataSet objects as, 901—902 XML web services, 1016—1019 [XmlAttribute] attribute, 815 XML-based grammar, 1088 XmlDocument class, 995 XmlElement class, 995 [XmlElement] attribute, 815 [XmlEnum] attribute, 815 xmlns (XML namespace) attribute, 1383 [XmlnsDefinition] attribute, 1157 XmlReader class, 993 [XmlRoot] attribute, 815 XmlSerializer type, serializing objects using, 814—816 [XmlText] attribute, 815 [XmlType] attribute, 815 XmlWriter class, 993 x:Name attribute, 1150, 1156, 1159, 1275, 1276, 1293, 1357 XName class, 1001—1002 1711 www.it-ebooks.info INDEX ■ x:Name Extensible Application Markup Language (XAML) token, 1146 x:Name keyword, 1158 XName object, 1001 x:Name property, 1181 XNamespace class, 999, 1001—1002 XNode class, 999, 1000 x:Null keyword, 1158, 1163 xor opcode, 678 XPath (Extensible Markup Language Path Language), 993 XProcessingInstruction class, 999 XPS (XML Paper Specification), 1120, 1183, 1227 XQuery (Extensible Markup Language Query), 993 XSD (Extensible Markup Language Schema Definition) editor, 902 *.xsd file, 901, 902 xsd utility, Mono, 1571 xsd.exe utility, Microsoft NET, 1571 XSLT (Extensible Stylesheet Language Family Transformations), 993 XSP server, 1566 xsp2 utility, Mono, 1571 x:Static keyword, 1158, 1163 x:Static markup extension, 1163 XStreamingElement class, 999 x:Type keyword, 1158, 1163 x:Type markup extension, 1164 x:TypeArguments keyword, 1158 ■Y Y property, 211, 378, 1535 Y value, 212 Y1 property, 1250 Y2 property, 1250 y-coordinate, 1535 YesOrNo variable, 1095, 1097 yield keyword, building iterator methods with, 346 yield return statement, 346 yield return syntax, 346, 349 YourCars.dll assembly, 532 YourXaml.xaml file, 1174, 1175, 1176 Yugo value, 515 yugosOnlyView variable, 912 ■Z zero second mark, 1360 zero-code, 1452 zooming, 49 1712 www.it-ebooks.info www.it-ebooks.info .. .Pro C# 2010 and the NET Platform Fifth Edition ■■■ Andrew Troelsen www.it-ebooks.info Pro C# 2010 and the NET Platform, Fifth Edition Copyright © 2010 by Andrew Troelsen All... 43 9 Understanding Operator Overloading 44 4 Understanding Custom Type Conversions .45 4 Understanding Extension Methods 46 0 Understanding Partial Methods .47 0... 144 1 The Role of the Validation Controls 145 7 Working with Themes 146 5 Summary . 147 1 ■ Chapter 34: ASP.NET State Management Techniques . 147 3 The Issue

Ngày đăng: 06/03/2019, 13:59

Từ khóa liên quan

Mục lục

  • Prelim

  • Contents at a Glance

  • Contents

  • About the Author

  • About the Technical Reviewer

  • Acknowledgments

  • Introduction

    • We’re a Team, You and I

    • An Overview of This Book

    • Obtaining This Book’s Source Code

    • Obtaining Updates for This Book

    • Contacting Me

    • Part 1: Introducing C# and the .NET Platform

      • The Philosophy of .NET

        • Understanding the Previous State of Affairs

          • Life As a C/Windows API Programmer

          • Life As a C++/MFC Programmer

          • Life As a Visual Basic 6.0 Programmer

          • Life As a Java Programmer

          • Life As a COM Programmer

          • The Complexity of COM Data Type Representation

          • The .NET Solution

          • Introducing the Building Blocks of the .NET Platform (the CLR, CTS, and CLS)

            • The Role of the Base Class Libraries

            • What C# Brings to the Table

Tài liệu cùng người dùng

Tài liệu liên quan