Building Enterprise Applications with WPF and the MVVM Pattern
[Microsoft Press] Building Enterprise Applications with Windows Presentation Foundation and the Model View ViewModel Pattern.pdfPublished with the authorization of microsoft corporation byO Reilly media. Inc1005 Gravenstein Highway NorthSebastopol, California 95472Copyright o 2011 Raffaele GarofaloComplying with all applicable copyright laws is the responsibility of the user. All rights reserved. Without limiting therights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, ortransmitted in any form or by any means(electronic, mechanical, photocopying, recording, or otherwise), or for anypurpose, without express written permission of o'Reilly Media, IncPrinted and bound in the United States of america123456789LSI654321Microsoft press titles may be purchased for educational, business or sales promotional use Online editions are alsoavailableformosttitles(http://my.safaribooksonline.com).foRmoreinformationcontactourcorporate/institutionalsalesdepartment:(800)998-9938orcorporate(@oreilly.com.Visitourwebsiteatmicrosoftpressoreillycom.Sendcommentstomspinput(amicrosoft.comMicrosoft, Microsoft Press, ActiveX, Excel, FrontPage, Internet Explorer, Power Point, SharePoint, Webdings, Windowsand windows 7 are either registered trademarks or trademarks of microsoft Corporation in the United States and/orother countries. Other product and company names mentioned herein may be the trademarks of their respective ownersUnless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos,people, places, and events depicted herein are fictitious, and no association with any real company, organization, product,domain name, e-mail address, logo, person, place, or event is intended or should be inferredThis book expresses the author's views and opinions. The information contained in this book is provided without anyexpress, statutory, or implied warranties. Neither the author, o'Reilly media, Inc, Microsoft Corporation, nor theirrespective resellers or distributors will be held liable for any damages caused or alleged to be caused either directlyor indirectly by such informationAcquisitions and Development Editor: Russell JonesProduction Editor: Kristen borgProduction Services: Octal Publishing, IncTechnical reviewer: David hillIndexing: Fred brownCover: Karen montgomeryIllustrator: robert romano978-0-735-65092-3To my wife Deborah. Thank you for everything!Contents at a glance1 Introduction to model view view Model and line of businessApplications2 Design Patterns.253 The domain model.614 The data Access layer915 The Business Layer。,。1236 The Ui layer with MVVM..。1497 MVVM Frameworks and toolkits.........,.179Table of contentsIntroductionConventions and features in this bookXVAcknowledgmentsXVIErrata and Book Support1 Introduction to model viewview Model and line of businessApplications...The model view view Model patternLine of Business Applications1123Choosing the right TechnologySilverlight or WPF?Microsoft's Ul-Building ToolsComposition of a lob User InterfaceThe menubarThe toolbarThe Tooltip(and Its abuse)Notifications and alertsThe ribbon barGeneral Style and control considerations16Separation of Concern17Layers, Tiers, and ServicesSummary232 Design Patterns25An Overview of design Patterns25Classifying Design PatternsUI Design Patterns..29The Mvc patternThe mvp PatternThe pm pattern and mvvm39Advanced Design Patterns and Techniques43The Inversion of control patternDSLS: Writing fluent Code53Introduction to tDD57Summary.......60Table of contents3 The domain model61Introduction to Domain-Driven design.61DDD Terminology·…62Analyzing the CRM Domain63Domain entity and data transfer object.64The poco object and the o/ rm66Development Approaches of a Domain67Transaction Script.68Database-Driven Approach69Domain-Driven Approach70How To Create an object In DDd71ory Patter72Domain entities validation75Classic Validation75Validation Using Attributes and Data Annotations77Available validation Frameworks79Unit Test the domain model80Sample Code: The CRM Domain Model81The person context81The Order Domain87Summary894 The data access layer,,,,,,,,,,,,,,,,,91Introduction91The database and stored procedures92Choosing an O/RM93Microsoft Entity Framework95NHibernate98Other O/RMs for. nEt.100The Unit of workLifef a uow102Identify a Business Transaction.102The repository Pattern.104est-Driven Development: The Data Layer.106Building a Distributed Data Layer with RIA and WCF108Table of contentsSample Code: The CRM Data Access Layer112A Flexible /Unitof work Interfa112Mapping the domain Model Using Entity FrameworkMapping the Domain Using Nhibernate117Getting the Tools118The Unitofwork and the /SessionSummar1215 The business layer123production123A Business rule is not a validation rule124Business Rules by Service127The Facade Pattern...128Business Rules by Workflow with WF 4.0129Different Ways of running a WorkflowThird-Party Toolkits133Technologies for the data validation134Rule engine and business rule engine136Business Layer Considerations.....137When do I Need to create a business layer?137Bad bll Habits138Sample Code: The Business Service Layer139Data Validation with the Enterprise Library 5.0139A Generic Workflow Engine141Service for business transactions143Summary1476 The Ul layer with mvvm,,,,,,,,,,,,,,,149Introduction to the mvvm pattern150The view151Blendability: A Dummy View Model152The model155The Command in WPF and Silverlight157A Workaround: An mvvm command158Re-evaluate /Command Execution160The View Model161The /Notify Property Changed Interface162The Data ErrorInfo Interface
用户评论