Expert C# 2008 Business Objects potx

802 1.1K 1
Expert C# 2008 Business Objects potx

Đ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

this print for content only—size & color not accurate spine = 1.5015" 800 page count Books for professionals By professionals ® Expert C# 2008 Business Objects Dear Reader, This book is about application architecture, design, and development using object-oriented concepts in .NET. Specifically, I’ll show how to build business- focused objects called business objects and how to use them to build applica- tions with Windows Presentation Foundation (WPF), Web Forms, Windows Communication Foundation (WCF), Windows Forms, Windows Workflow Foundation (WF), and other types of application. While this book is about the creation of the CSLA .NET development framework, that framework is the codi- fication of an underlying architecture, which helps provide order to the chaos and enables productive application of the architectural concepts. You may agree or disagree with my views, and that is fine. In the end, having an architecture that withstands the tests of time and technological change is the key. At a minimum, the concepts, ideas, and techniques in this book will help inform your understanding of architecture and will enable you to put all the new and changing technologies into perspective. The CSLA .NET framework itself is one of the most widely used development frameworks on the .NET platform. In reading this book, you will see the design decisions that enable the framework to support the many technologies listed previously—all based on the same set of business objects. You’ll also learn how the framework abstracts the concept of data access, enabling an application to use nearly any data access technology available on the .NET platform. Over the past eight years, CSLA .NET has evolved, and it continues to evolve to support new capabilities of the .NET platform. The underlying architecture of using object-oriented design in a distributed computing environment has remained consistent all this time, and it continues to be critical looking forward to Silverlight, Windows Azure, and beyond. I hope you enjoy this book and find it challenging and educational. Code well, have fun! Rockford Lhotka Author of Expert C# 2005 Business Objects US $59.99 Shelve in Programming Languages/C# User level: Advanced C# 2008 The eXperT’s Voice ® in .neT Expert C# 2008 Business Objects cyan MaGenTa yelloW Black panTone 123 c Rockford Lhotka Companion eBook Available THE APRESS ROADMAP Beginning C# 2008, 2e Pro ASP.NET 3.5 in C# 2008, 3e Expert C# 2008 Business Objects Pro C# 2008 and the .NET 3.5 Platform, 4e Pro WPF in C# 2008, 2e Beginning C# 2008 Objects Illustrated C# 2008 www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version Architect, design, and develop highly scalable and maintainable object-oriented business applications ISBN 978-1-4302-1019-1 9 781430 210191 5 5 9 9 9 Expert Business Objects Lhotka www.it-ebooks.info www.it-ebooks.info Expert C# 2008 Business Objects ■■■ Rockford Lhotka Lhotka_1019-1FRONT.fm Page i Thursday, November 20, 2008 5:04 PM www.it-ebooks.info Expert C# 2008 Business Objects Copyright © 2009 by Rockford Lhotka 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-1019-1 ISBN-13 (electronic): 978-1-4302-1020-7 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 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. Editor: Matthew Moodie Technical Reviewers: James Miller, Andrés Villanueva, Joe Fallon Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Richard Dal Porto Copy Editors: Nicole Abramowitz, Jennifer Whipple Associate Production Director: Kari Brooks-Copony Production Editor: Laura Esterman Compositor: Susan Glinert Proofreader: Nancy Bell Indexer: John Collin Artist: April Milne Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski 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 http://www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit http:// 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 http://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 http://www.apress.com. Lhotka_1019-1FRONT.fm Page ii Thursday, November 20, 2008 5:04 PM www.it-ebooks.info To my Mom and Dad. Thank you for all you’ve taught me through the years! Lhotka_1019-1FRONT.fm Page iii Thursday, November 20, 2008 5:04 PM www.it-ebooks.info Lhotka_1019-1FRONT.fm Page iv Thursday, November 20, 2008 5:04 PM www.it-ebooks.info v Contents at a Glance About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv ■CHAPTER 1 Distributed Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 ■CHAPTER 2 Framework Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 ■CHAPTER 3 Object-Oriented Application Design . . . . . . . . . . . . . . . . . . . . . . . . . . 101 ■CHAPTER 4 CSLA .NET Object Stereotypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 ■CHAPTER 5 CSLA .NET Object Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 ■CHAPTER 6 Business Framework Implementation . . . . . . . . . . . . . . . . . . . . . . . . 207 ■CHAPTER 7 Property Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 ■CHAPTER 8 Object Status Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 ■CHAPTER 9 Parent-Child Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 ■CHAPTER 10 Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 ■CHAPTER 11 Business and Validation Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 ■CHAPTER 12 Authentication and Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 ■CHAPTER 13 N-Level Undo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 ■CHAPTER 14 LINQ to CSLA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 ■CHAPTER 15 Persistence and the Data Portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 ■CHAPTER 16 Other Framework Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487 ■CHAPTER 17 Business Object Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517 ■CHAPTER 18 Example Data Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547 ■CHAPTER 19 Windows Presentation Foundation UI . . . . . . . . . . . . . . . . . . . . . . . . 583 ■CHAPTER 20 Web Forms UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619 ■CHAPTER 21 WCF Service Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675 ■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719 Lhotka_1019-1FRONT.fm Page v Thursday, November 20, 2008 5:04 PM www.it-ebooks.info Lhotka_1019-1FRONT.fm Page vi Thursday, November 20, 2008 5:04 PM www.it-ebooks.info vii Contents About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv ■CHAPTER 1 Distributed Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Logical and Physical Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 N-Tier and SOA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Complexity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Relationship Between Logical and Physical Models . . . . . . . . . . . . . . 4 A 5-Layer Logical Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Applying the Logical Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 The Way Ahead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Managing Business Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Potential Business Logic Locations . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Business Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Mobile Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Architectures and Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 ■CHAPTER 2 Framework Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Basic Design Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Validation and Business Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Tracking Whether the Object Has Changed . . . . . . . . . . . . . . . . . . . . 41 Integrated Authorization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Strongly Typed Collections of Child Objects . . . . . . . . . . . . . . . . . . . 42 N-Level Undo Capability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Simple and Abstract Model for the UI Developer . . . . . . . . . . . . . . . 45 Supporting Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Object Persistence and Object-Relational Mapping . . . . . . . . . . . . . 54 Custom Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Lhotka_1019-1FRONT.fm Page vii Thursday, November 20, 2008 5:04 PM www.it-ebooks.info viii ■CONTENTS Designing the Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Business Object Creation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 N-Level Undo Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Data Binding Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Business and Validation Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Data Portal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Custom Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Integrated Authorization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Helper Types and Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Namespace Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 ■CHAPTER 3 Object-Oriented Application Design . . . . . . . . . . . . . . . . . . . . . 101 Responsibility-Driven Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Use-Case or Story-Based Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Objects with Responsibilities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Objects Exist for Use Cases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Normalization of Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Application Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Object Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Initial Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Revising the Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Custom Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Using CSLA .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Database Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Creating the Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 PTracker Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Security Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Lhotka_1019-1FRONT.fm Page viii Thursday, November 20, 2008 5:04 PM www.it-ebooks.info [...]... 173 Business Class Structure 174 Editable Root Business Objects 174 Editable Child Business Objects 180 Switchable Objects 184 Editable Root Collection 187 Editable Child Collection 190 Read-Only Business. .. Chapter 19 demonstrates how to create a WPF interface to the business objects Chapter 20 covers the creation of an ASP.NET Web Forms interface with comparable functionality Chapter 21 shows how to build WCF services using business objects This approach enables service-oriented development by providing a programmatic interface to the business objects that any web service or WCF client can call By the... service-oriented applications Using object-oriented design and business objects in a distributed environment has its own challenges, and CSLA NET uses various techniques to overcome those challenges For n-tier client/server applications, the framework supports the idea of mobile objects objects that actually move between computers in an n-tier environment Mobile objects provide a powerful way to implement object-oriented... assemblies, application configuration files, and more Chapters 17 and 18 create the business objects for the application These chapters illustrate how you can use the framework to create a powerful set of business objects rapidly and easily for an application The end result is a set of objects that not only model business responsibilities, but also support data binding, validation, authorization, n-level... or reflection All of these are embedded in the framework, so that a developer using it can focus almost entirely on business logic and application design rather than on getting caught up in “plumbing” issues This book is a major update to the previous edition, Expert C# 2005 Business Objects This updated book takes advantage of new features of NET 3.5 and applies lessons learned by using NET 2.0 and... 199 Dynamic Editable Root Objects 201 Criteria Objects 202 Conclusion 205 www.it-ebooks.info ix Lhotka_1019-1FRONT.fm Page x Thursday, November 20, 2008 5:04 PM x ■C O N T E N T S ■CHAPTER 6 Business Framework Implementation 207 CSLA... 190 Read-Only Business Objects 191 Read-Only Child Objects 193 Read-Only Collection 194 Read-Only Child Collection 196 Command Objects 197 Name/Value List Objects 198 Dynamic... single-user programs to full-blown enterprise applications that power major parts of their businesses xxv www.it-ebooks.info Lhotka_1019-1FRONT.fm Page xxvi Thursday, November 20, 2008 5:04 PM xxvi ■I N T R O D U C T I O N This framework addresses two primary areas of object-oriented software development: • How to use business objects to efficiently build Windows, web, and service-oriented applications • How... 510 Conclusion 516 ■CHAPTER 17 Business Object Implementation 517 ProjectTracker Objects 517 Setting Up the Project 518 Business Class Implementation 519 Project ... nation’s premier Microsoft Gold Certified Partners that is focused on delivering business value through applied technology For more information, go to www.lhotka.net xix www.it-ebooks.info Lhotka_1019-1FRONT.fm Page xx Thursday, November 20, 2008 5:04 PM www.it-ebooks.info Lhotka_1019-1FRONT.fm Page xxi Thursday, November 20, 2008 5:04 PM About the Technical Reviewers ■ JAMES MILLER is a senior architect . C# 2008, 3e Expert C# 2008 Business Objects Pro C# 2008 and the .NET 3.5 Platform, 4e Pro WPF in C# 2008, 2e Beginning C# 2008 Objects Illustrated C# 2008 www.apress.com SOURCE CODE ONLINE Companion. of Expert C# 2005 Business Objects US $59.99 Shelve in Programming Languages /C# User level: Advanced C# 2008 The eXperT s Voice ® in .neT Expert C# 2008 Business

Ngày đăng: 16/03/2014, 20:20

Mục lục

  • Prelims

  • Contents at a Glance

  • Contents

  • About the Author

  • About the Technical Reviewers

  • Acknowledgments

  • Introduction

    • From CSLA .NET 2.0 to 3.6

    • Designing CSLA .NET

    • Framework License

    • What You Need to Use This Book

    • How This Book Is Structured

    • Downloading the Code

    • Contacting the Author

    • Distributed Architecture

      • Logical and Physical Architecture

        • N-Tier and SOA

        • Complexity

        • Relationship Between Logical and Physical Models

          • The Logical Model

          • Cross-Layer Communication

          • The Physical Model

          • A 5-Layer Logical Architecture

            • Interface

            • Interface Control

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

  • Đang cập nhật ...

Tài liệu liên quan