maintaining list of broken rules, 69Remove method, 135ToString method, 135BrokenRulesList class checking validation rules, 132, 133Browsable attribute IsDirty property, BusinessBase clas
Trang 1AuthorizationRules class, 137–139
associating roles with properties, 138BusinessBase class and, 125
CanReadProperty method, 125checking roles, 138
description, 92retrieving roles, 137RolesForProperty class and, 136AutoComplete attribute
ServicedDataPortal class, 215autonomy
web services as services, 569
see also classes
business (CSLA NET) framework, 91business framework, 59
BusinessBase class, 59–61, 109–127, 139–142BusinessListBase class, 61, 142–155
BusinessPrincipalBase class, 246CommandBase class, 236–239enhancing for data access, 169–176factory methods and criteria, 171–172inheriting from non-generic base classes, 60NameValueListBase class, 239–243
ReadOnlyBase class, 62, 155–156ReadOnlyListBase class, 62–63, 156–157base index, 250
BaseIndex property
ListItem class, 256Basic theme, 528
Basic.css file, 528
Basic.skin file, 528
BeginEdit method
BusinessBase class, 102, 116–117BusinessListBase class, 102deleting and undeleting child objects, 147,
149, 154edit level, 145IEditableObject interface, 118, 119ProjectEdit loading user controls, 506ProjectEdit saving data, 509, 510UndoableBase class, 65BeginLoadData method
DataTable class, 292behaviors
behavioral object-oriented design, 50data portals, 76–82
dealing with common behaviors, 334normalizing common behavior, 333, 334relational and object modeling, 50bidirectional data updates, 79
BinaryFormatter classcloning serializable object, 97serializing and stacking Hashtable, 107serializing object state, 98
BindableBase class, 66, 98–101class diagram for, 67description, 91OnPropertyChanged method, 100OnUnknownPropertyChanged method, 100binding
see data binding
Binding objectFormat event, 299Parse event, 299BindingComplete eventBindingSource control, 303bindingEdit field, 119BindingList class, 66class diagram for, 67data binding, 41SortedBindingList class, 87BindingNavigator control, 488BindingSource controladding roleListBindingSource control, 500BindingComplete event, 303
CanExtend method, 302data binding, 288, 302RolesEdit saving data, 491, 492saving data with remote data portal, 493setting DataSource property on, 500smart client calling web method, 596using business class as data source, 487BindingSourceRefresh control, 301–303,504–505
extender controls, 301ReadValuesOnChange property, 302, 505using GetReadValuesOnChange method, 302using SetReadValuesOnChange method, 302Windows data binding, 303
Windows Forms data binding, 301Boolean data type
empty values, 280broken rulesIDataErrorInfo interface, 124maintaining list of broken rules, 133–134ValidationRules object managing, 122BrokenRule class, 134
description, 92function, 68maintaining list of broken rules, 69brokenRules field
maintaining list of broken rules, 133BrokenRulesCollection class, 134–135Add method, 135
description, 92function, 68GetFirstBrokenRule method, 135
Trang 2maintaining list of broken rules, 69Remove method, 135
ToString method, 135BrokenRulesList class
checking validation rules, 132, 133Browsable attribute
IsDirty property, BusinessBase class, 112IsValid property, BusinessBase class, 114business class structure, 374–402
common regions, 374–377Criteria class, 377–379private default constructor, 377Serializable attribute, 374business classes, implementing PTracker,
407–462Assignment class, 439–441Exists method, 455–456ExistsCommand class, 456–457main areas of each class, 405Project class, 408–429ProjectList class, 446ProjectResource class, 434–439ProjectResources class, 429–434ProjectTracker application classes, 406ProjectTracker objects, 405–407PTIdentity class, 459–462PTPrincipal class, 457–459Resource class, 444–446ResourceInfo class, 447–448ResourceList class, 446–449Role class, 453–455RoleList class, 442–444Roles class, 449–453using business class as data source, 486–489business concepts and process flow design
creating use case descriptions, 323–325project maintenance, 323–324resource maintenance, 324–325gathering application requirements, 322, 323maintaining list of roles, 325
programmatic access, 325business framework
see CSLA NET framework
business framework base classes, 59
business functionality, Web Forms, 537–562
ProjectEdit form, 552–562ProjectList form, 548–552RolesEdit form, 538–548business functionality, Windows Forms,
482–512creating forms as user controls, 467MainForm form, 482–486
ProjectEdit control, 497–512ProjectList object, 494–497RolesEdit control, 486–494business logic
authorization, 57business object centralizing, 26business objects, 21–24
encapsulation, 53locating in multiple layers, 17, 18locations for validation and manipulationbusiness and data access tier, 20common locations illustrated, 18data management layer, 18user interface, 19
locations for validation and manipulation,18–21
managing, 17–32mobile objects, 24–32object-oriented programming, 160shared between UI and data access layers, 27sharing across tiers, 20
tracking broken business rules, 40–41business logic layer
5-layer logical architecture, 10–11description of role, 13
high security web client, 16high-scalability smart client, 14managing business logic, 17–32mobile objects and logical architecture, 26tied to UI and data access layers, 27Business Methods region, 376editable child business objects, 386editable root business objects, 383implementing Assignment class, 440implementing business classes, 409–416implementing Project class, 409–416child collection properties, 414instance field declarations, 409interdependent properties, 413–414overriding GetIdValue method, 415overriding IsDirty method, 415–416overriding IsValid method, 415–416read-only properties, 409–410read-write properties, 411–412SmartDate properties, 413implementing ProjectResource class, 435implementing ProjectResources class, 429,430–431
Assign method, 430Contains method, 431ContainsDeleted method, 431GetItem method, 431Remove method, 431implementing PTIdentity class, 459–460implementing ResourceInfo class, 447–448implementing RoleList class, 442
implementing Roles class, 450–451business objects, 21–24
see also mobile objects
business class structure, 374–402centralizing business logic, 26command objects, 399–401common regions, 374–377component parts of, 23composed of
Trang 3CSLA NET design benefits, 340CSLA NET framework, 58–63CSLA NET in design process, 341data portal returning updated businessobject to UI, 81
data transfer, 26description, 22designing Web Service interfacereturning and accepting data, 574determining type of, in data portal request,182
editable child business objects, 384–387editable child collections, 394–395editable root business objects, 380–384editable root collections, 390–394encapsulation, 21
framework classes used by businessdevelopers, 59
IEditableObject interface, 47implementing business objects, 405–463invoking methods on, 181
loading from database, 169locating specific method, 177managing persistence to data store, 54models for UI developer, 42–46name/value list objects, 401–402object design, 21, 326
potential objects and associated classnames, 327
read-only business objects, 395–397read-only collections, 397–399referencing business object, 131sending to data portal to beinserted/updated, 80Serializable attribute, 374serialization, 98
smart data and, 22snapshot of, 102structure with common regions, 375switchable business objects, 387–390UML sequence diagram for immediatedeletion of, 82
UML sequence diagram for updating of, 81UML sequence diagram illustrating creation
of, 78UML sequence diagram illustrating retrieval
of, 79user interface interacting with, 77using business object as data sourceRolesEdit web form, 539–540web service data transfers, 573wrapping in transaction, 215business objects, life cycle of, 361–373
adding/editing root objects, 368adding/editing/deleting child objects,369–370
creating child objects, 363–365creating root objects, 362deleting root objects, 370–372
object creation, 362–365object disposal, 372–373object retrieval, 365–367retrieving child objects, 367retrieving root objects, 365–366updating editable objects, 368–372business rules
see also rules
common business rules, 273–276CSLA NET design benefits, 340method signature for, 69tracking broken business rules, 40–41, 67BusinessBase class, 59–61, 109–127, 139–142authorization rules, 125–126
AuthorizationRules object and, 125CSLA NET in design process, 341description, 92
functional areas implemented in, 110ICloneable interface, 126–127implementing Project class, 408inheriting from non-generic base classes, 60methods
AddAuthorizationRules, 123, 125AddBusinessRules, 123, 274, 276ApplyEdit, 102
BeginEdit, 102CancelEdit, 102CanReadProperty, 125CanWriteProperty, 125Clone method, 142data access methods, 60exception handling methods, 61MarkAsChild, 60, 120
object-editing methods, 116–117pre- and post-processing methods, 61PropertyHasChanged, 274
Save, 79–81, 170, 173SetParent, 121n-level undo functionality, 64, 116–120overriding System.Object, 140–141properties
IsChild, 121IsDeleted, 115–116IsDirty, 112–114IsNew, 111–112IsSavable, 114IsValid, 114object status properties, 111Parent, 121
purpose, 59root/parent/child behaviors, 120–122tracking business rules, 67
tracking object status, 110–116UndoableBase class and, 64Update method processing, 222–223validation rules, 123–125
ValidationRules object and, 123–125
Trang 4BusinessListBase class, 61, 142–155
BindingList class, 66business objects subclassing, 341deleted object collection, 146deleting and undeleting child objects,147–154
description, 92edit level tracking, 144functional areas implemented in, 142ICloneable interface, 154–155IEditableCollection interface, 65, 96methods
AcceptChanges, 153–154Add, 61
ApplyEdit, 102, 154BeginEdit, 102, 154CancelEdit, 102, 154ContainsDeleted, 146CopyState, 150–151DeleteChild, 150InsertItem, 146Remove, 61RemoveChild, 145Save, 170, 173UnDeleteChild, 150UndoChanges, 151–152n-level undo functionality, 144–147properties
EditLevelAdded, 146IsChild, 144purpose, 59reacting to Insert/Remove/Clear operations,145
root/child behaviors, 144sorting collections, 66tracking object status, 143BusinessPrincipalBase class, 246
Identity property, 246interface implemented, 244IsInRole method, 246principal and identity objects, 83buttons
Login button, 479–481byte streams
converting Hashtable to, 107
■ C
caching
InvalidateCache method, 402, 443, 452, 453ProjectEdit web form, 555
RolesEdit web form, 540–541CallByName helper method, 274
CallMethod method
MethodCaller class, 181–182SimpleDataPortal implementing datamethods, 220
CallMethodException class
channel adapter behaviors, 183–184types required for channel adapter, 162
CallMethodIfImplemented methodMethodCaller class, 182
SimpleDataPortal implementing datamethods, 220
CanAddObject methodeditable root business objects, 383implementing Project class, 418, 420Cancel button
ProjectEdit saving data, 510CancelEdit method
BusinessBase class, 102, 116–117BusinessListBase class, 102deleting and undeleting child objects, 147,149
description, 118edit level, 145IEditableObject interface, 118, 119ProjectEdit saving data, 510UndoableBase class, 65CanDelete propertydata source controls, 313CanDeleteObject methodeditable root business objects, 383implementing Project class, 418, 419, 421CanEditObject method
editable root business objects, 383implementing Project class, 418ProjectEdit authorization rules, 507CanExtend method
BindingSource control, 302IExtenderProvider interface, 296CanGetObject method
editable root business objects, 383implementing Project class, 418read-only business objects, 397CanInsert property
data source controls, 312, 313CanReadProperty methodBusinessBase class, 125implementing Project class, 410, 411, 418implementing ProjectResource class, 435,436
integrated authorization, 84IReadOnlyObject interface, 96ReadOnlyBase class, 156CanRetrieveTotalRowCount propertydata source controls, 314
CanUpdate propertydata source controls, 313CanWriteProperty methodBusinessBase class, 125, 126implementing Project class, 411, 418implementing ProjectResource class, 435,436
integrated authorization, 84catch block
try catch block, 585ChangeType methodDataMapper class setting values, 283
Trang 5channel adapter behaviors
CallMethodException class, 183–184DataPortal class, 185–193
DataPortalEventArgs class, 184EnterpriseServicesPortal class, 201–205EnterpriseServicesProxy class, 200–201IDataPortalProxy interface, 194IDataPortalServer interface, 193–194LocalProxy class, 194
MethodCaller class, 177–183RemotingPortal class, 198–199RemotingProxy class, 195–198RunLocalAttribute class, 184WebServicePortal class, 208–210WebServicesProxy class, 206–208channel adapter design pattern, 161–163
data portal combining patterns, 161types required for channel adapter, 162channels
.NET Remoting channel, 605–609data portal comparison of, 602–605ease of deployment, 604ease of implementation, 604factors for comparison, 602firewall friendliness, 604host technology, 604performance, 602security, 603Enterprise Services channel, 612–619Web Services channel, 609–612channels element
implementing NET Remoting, 608CheckRules method
BrokenRulesCollection class, 134checking validation rules, 132, 133implementing Project class, 414, 416, 424maintaining list of broken rules, 133child collection properties
implementing Project class, 414child objects
adding/editing/deleting, 369–370base class for creating editable, 139BusinessBase indicating object is child, 60BusinessListBase class, 144
cascading call to, 106collections, 65creating, 363–365definition, 120deleting and undeleting, 147–154description, 120
edit level tracking for child objects, 122editable child business objects, 384–387editable child collections, 394–395IEditableObject interface, 117isChild field, 121
LineItem as example, 60MarkAsChild method, 120n-level undo functionality, 38, 144object creation without defaults, 387
read-only collections, 398RemoveChild method, 145retrieving, 367
root/parent/child behaviors, 120–122strongly typed collections of child objects,41–42
switchable business objects, 387–390UndoableBase class, 65
class-in-charge (Factory pattern) model, 45–46business objects, 377
classes
see also base classes
business class structure, 374–402business framework base classes, 59complete code for, 92
Criteria class, 377–379CslaDataSource class, 305–307CslaDataSourceDesigner class, 310CslaDataSourceView class, 307–309CslaDesignerDataSourceView class, 310–314DataMapper class, 280–285
final class list for PTracker, 338implementing PTracker business classes
see business classes, implementing
PTrackerListItem class, 250–251namespace organization, 88–89NameValuePair class, 240ObjectAdapter class, 286–294ObjectFieldInfo class, 316–318ObjectViewSchema class, 315–316primary base classes, 89
required to support editable/read-onlybusiness objects, 91
SafeDataReader class, 277–280SortedBindingList class, 247–262SortedEnumerator class, 254classes, PTracker
merging similar objects, 332clean objects
IsNew property, BusinessBase class, 111ClearContext method
DataPortal class, 228ClearItems methodReadOnlyBindingList class, 128client configuration
implementing NET Remoting, 608implementing Enterprise Services, 618, 619implementing Web Services, 611
Client folder, DataPortal, 93client models
high scalability smart client, 14high security web client, 16optimal performance smart client, 13optimal performance web client, 15Client-side Code region
command objects, 400client side context datamessage objects, 73
Trang 6client side DataPortal, 71–72
data portal functionality, 71methods, 71
RunLocal attribute, 71client side proxy classes, 72
data portal functionality, 71client-side cache
invalidating client-side cache, 452ClientContext collection
DataPortalContext class, 167ClientContext property
ApplicationContext class, 230ClientCulture
DataPortalContext class, 167ClientUICulture
DataPortalContext class, 167Clone method
BusinessBase class, 142ICloneable interface, 126, 127implementing ICloneable interface, 242cloning
BusinessBase class, 110, 126, 142BusinessBase class functionality, 110BusinessListBase class, 154
BusinessListBase class functionality, 142GetClone method, 127
ICloneable interface, 126, 154ObjectCloner class, 126ReadOnlyBase class, 156ReadOnlyListBase class, 157serialization, 97
Panel control, 475, 476code download
Diagrams folder, 93Resources.resx file, 93code reuse
architectures and frameworks, 32focusing on most productive areas, 35reflection, 273
validation rules, 40collaboration
behavioral object-oriented design, 51collections
ArrayList and List<T> types compared, 41BusinessListBase class, 61
BusinessListBase class and sorting, 66cascading call to, 106
child objects, 65deleted object collection, 146editable child collections, 394–395editable root collections, 390–394getting items from, 254
IBindingList interface, 47properties controlling editable collections,451
read-only collections, 397–399ReadOnlyListBase class, 62sorting collections, 246–262state and, 151
strongly typed collections of child objects,41–42
System.Collections.Generic namespace, 41column names
ObjectAdapter class getting, 288–291COM (Component Object Model)security and internal applications, 6COM-based technologies
optimal performance web client, 16COM+ applications
implementing Enterprise Services, 619COM+ transactional context
distributed transaction support, 215command object
lifetime of, 238command objects, 399–401common regions, 375CommandBase class, 62, 236–239purpose, 59
CommandBase objectUpdate method processing, 224common business rules, 273–276common regions, 374–377CommonRules class, 273function, 68
implementing common rules, 69implementing Project class, 416purpose, 273
rule methods, 276RuleHandler delegate, 273CompareTo methodListItem class, 251SmartDate type, 269, 271Complete method
TransactionalDataPortal class, 217complex relationships, revising, 329–335adding Assignment class, 330adding ProjectResources class, 331adding ResourceAssignments class, 332dealing with common behaviors, 334merging similar objects, 332normalizing common behavior, 333, 334component-based architecture
service-oriented design compared, 571–572web methods, PTracker, 572
component-based web methodsAddProject web method, 584–587PTWebService project, 584web service implementation, 584–587Component Object Model (COM)security and internal applications, 6
Trang 7component-based, scalable, logical architecture
see CSLA.NET framework
components
description, 572services vs components, 567web services as components, 568–569ComVisible attribute
EnterpriseServicesPortal class, 202implementing Enterprise Services, 615ServicedDataPortal class, 216
configuration files, 186
ApplicationContext class managing, 232implementing Enterprise Services, 615Configuration namespace, 232
configurations
high scalability smart client, 14high security web client, 16implementing NET Remoting, 608implementing Enterprise Services, 619implementing Web Services, 611optimal performance smart client, 13optimal performance web client, 15configuring site
forms-based authentication, 531–533connection pooling
high-scalability smart client, 15optimal performance web client, 16Resource class sharing database connection,445–446
scalability of physical model, 5connections
opening database connections, 445constructors
implementing ResourceInfo class, 448non public constructor, 421
private default constructor, 377ProjectResource class, 437ProjectResources class, 432using factory methods, 377consumer applications
grouping web methods into web services,572
IntelliSense, 574message-based communication, 565SOAP and web services, 565
Web Service authentication, 576web service consumer implementation,591–599
consumer-side proxy objects
soapsuds.exe utility, 567Visual Studio and, 566web services, 566Contains method
implementing ProjectResources class, 430,431
ContainsDeleted method
BusinessListBase class, 146implementing ProjectResources class, 430,431
ContainsKey methodNameValueListBase class, 241ContainsValue method
NameValueListBase class, 241Content control
RolesEdit web form, 538content pages
master page and, 526ContentPlaceHolder controlmaster page, 527ContentPlaceHolderID propertyRolesEdit web form, 539context data/information, 166–169ApplicationContext class, 229–233ClearContext method, DataPortal class, 228client and global context collections, 229–231context and exception data flow to/fromserver, 167
data access, 224–233DataPortalContext class, 167, 225–228DataPortalException class, 168, 228DataPortalResult class, 168, 228message objects, 73
SetContext method, DataPortal class, 226types required to implement, 169control skin, 528
controls
see also user controls
adding subclasses of custom control, 489BindingSourceRefresh control, 301–303,504–505
Close method, WinPart, 473control bound to a property, 295creating forms as user controls, 467not Form objects, 465
creating ProjectEdit controls, 498–505defining control prefix, 523
displaying user controls, 483ErrorProvider control, 502loading/adding user controls, 475MainForm hosting user controls, 474–477ProjectEdit control, 467, 497–512ReadWriteAuthorization control, 295–301,504
removing user controls, 476resizing user controls, 476ResourceEdit control, 467, 510roleListBindingSource control, 500RolesEdit control, 467, 486–494user control framework, Windows Forms,472–482
interface design, 467–469WinPart base control, 472–474cookies
reloading principal objects, 534CopyData method
ObjectAdapter class, 291–294
Trang 8CopyState method, UndoableBase class,
102–108avoiding double-processing of fields, 105cascading call to child objects or collections,106
deleting and undeleting child objects,150–151
getting list of fields, 105serializing and stacking Hashtable, 107skipping NotUndoable fields, 106stacking data, 102
taking snapshot of data, 103–105taking snapshot of regular fields, 106CopyStateComplete method
UndoableBase class, 105Core folder, CSLA NET project, 93
Core namespace, Csla
see Csla.Core namespace
corner.png file, Basic theme, 528
Count property, SortedBindingList class, 248
CRC cards
aspects of initial design, 327object design, 326
Create method, DataPortal class, 76–78
creating child objects, 364creating root objects, 362data passed to/from server for data portaloperations, 73
distributed transaction support, 212–214IDataPortalServer, 193–194
implementing data access methods, 191–192purpose, 163, 174, 185
RunLocalAttribute class, 184server side data portal, 74Create method, SimpleDataPortal class
message router functionality, 219–221CreateInstance method, Activator class
SimpleDataPortal implementing datamethods, 219, 222
creating objects
child objects, 363–365object creation without defaults, 390root objects, 362
credentials
Login button, 480security in physical model, 5smart client providing, 598–599validating, web service implementation,583–584
Credentials field, SoapHeader attribute
web service implementation, 582criteria, 171–172
protected criteria class, 242Criteria class, 377–379
dual criteria classes, 388factory methods and criteria, 172implementing RoleList class, 443inheriting from CriteriaBase, 172instantiating correct business class, 243
naming, 377nested criteria class, 172read-only business objects, 397criteria information
creating criteria object, 73data passed to/from server for data portaloperations, 73
determining type of class in which criterianested, 74
server side data portal, 74Criteria object
DataPortal_Create method using, 76, 77DataPortal_DeleteSelf method using, 82DataPortal_Fetch method using, 78, 242implementing data access methods, 191implementing Project class, 422purpose, 172
SimpleDataPortal implementing datamethods, 222
criteria parameterimplementing Project class, 425CriteriaBase class
code-generation tools, 378Criteria class and, 377, 378implementing Project class, 422message router functionality, 218types required for message router, 164Crystal Reports, 286
reporting against objects, 86CSLA NET framework
see also Csla namespace
attributesNotUndoableAttribute, 65business framework base classes, 59business object design benefits, 340business objects, 58–63
classes/controlsBindableBase, 66, 98–101BindingList, 66
BindingSourceRefresh, 301–303, 504–505BrokenRule, 68, 134
BrokenRulesCollection, 68, 134–135BusinessBase, 59–61, 109–127, 139–142BusinessListBase, 61, 142–155
BusinessPrincipalBase, 83, 246CommandBase, 62, 236–239CommonRules, 68, 273CslaDataSource, 305–307CslaDataSourceDesigner, 310CslaDataSourceView, 307–309CslaDesignerDataSourceView, 310–314CustomIdentity, 83, 245
DataMapper, 85, 86, 280–285DataPortal, 70–82, 162, 184–193DataPortalContext class, 169, 225–228DataPortalEventArgs class, 162, 184–185DataPortalException class, 169, 228ListItem, 250–251
Trang 9NameValueListBase, 63, 239–243NameValuePair, 240
ObjectAdapter, 85, 86, 286–294ObjectFieldInfo, 316–318ObjectSchema, 314ObjectViewSchema, 315–316ReadOnlyBase, 62, 155–156ReadOnlyBindingList class, 127–128ReadOnlyCollectionBase class, 446ReadOnlyListBase, 62–63, 156–157ReadWriteAuthorization, 295–301RuleArgs, 68, 129–130
RuleHandler, 68RunLocalAttribute class, 162, 184SafeDataReader, 85–86, 277–280SmartDate, 85, 86, 263–272SortedBindingList, 85, 87, 247–262SortedEnumerator, 254
TransactionalAttribute class, 166, 210–211TransactionalTypes class, 166
UndoableBase, 64–65, 101–109ValidationException, 68, 135ValidationRules, 68, 130–134classes for creating, 91classes used by business developers, 59command objects, 399–401
common business rules, 273–276custom authentication, 82–84, 243–246data access, 276–285
data binding, 66data handling, 262–272data portals, 70–82distributed transactions, 210–217editable child business objects, 384–387editable child collections, 394–395editable root business objects, 380–384editable root collections, 390–394framework design, 58–87generic types, 95helper types and classes, 85–87implementing PTracker business classes
see business classes, implementing
PTrackerintegrated authorization, 84list of object types, 379localization, 93message router, 163methods
CanReadProperty method, 84CanWriteProperty method, 84n-level undo functionality, 63–66name/value list objects, 401–402namespaces, 88–89
Csla, 88, 139–157Csla.Core, 88, 94–128Csla.Data, 88Csla.DataPortalClient, 89Csla.Properties, 89Csla.Security, 89, 136–139Csla.Server, 89
Csla.Server.Hosts, 89Csla.Validation, 89, 128–135Csla.Web, 89
Csla.Web.Design, 89Csla.WebServiceHost, 89Csla.Windows, 89naming convention, 88polymorphism, 95read-only business objects, 395–397read-only collections, 397–399referencing Csla.dll assembly, 407report generation, 285–294sorting collections, 246–262switchable objects, 387–390using in design process, 339–343validation rules, 67–70
Web Service authentication, 575CSLA NET project
creating directory structure, 93folders in, table of, 93
saving blank Csla solution, 93setting up, 92–94
Csla namespace, 139–157
see also CSLA NET framework
ApplicationContext class, 169BusinessBase class, 139–142BusinessListBase class, 142–155BusinessPrincipalBase class, 246CommandBase class, 236–239CriteriaBase class, 164DataPortal class, 162, 185–193DataPortalContext class, 169DataPortalEventArgs class, 162, 184–185DataPortalException class, 169
DataPortalResult class, 169description, 88
MethodCaller class, 162, 164, 177–183NameValueListBase class, 239–243ReadOnlyBase class, 155–156ReadOnlyListBase class, 156–157RunLocalAttribute class, 162, 184SmartDate type, 263–272TransactionalAttribute class, 166TransactionalTypes class, 166Csla.Core namespace, 94–128BindableBase class, 98–101BusinessBase class, 109–127description, 88
IBusinessObject interface, 94–95ICommandObject interface, 97IEditableCollection interface, 96IEditableObject interface, 95–96IReadOnlyCollection interface, 97IReadOnlyObject interface, 96NotUndoableAttribute class, 101ObjectCloner class, 97–98purpose, 94
ReadOnlyBindingList class, 127–128UndoableBase class, 101–109
Trang 10Csla.Data namespace
description, 88ObjectAdapter class, 286–294Csla.DataPortalClient namespace
description, 89EnterpriseServicesProxy class, 162, 200–201IDataPortalProxy interface, 162, 193–194LocalProxy class, 162, 194–195
RemotingProxy class, 162, 195–198WebServicesProxy class, 162, 206–208Csla.dll assembly
defining control prefix, 523PTWebService site setup, 579PTWin project setup, 472referencing Csla.dll assembly, 407Csla.Properties namespace, 89
Csla.Security namespace, 136–139
AccessType enumeration, 136AuthorizationRules class, 137–139description, 89
RolesForProperty class, 136Csla.Server namespace
CallMethodException class, 162, 183–184DataPortal class, 162
description, 89IDataPortalServer interface, 162, 193–194ServicedDataPortal class, 166
SimpleDataPortal class, 164TransactionalDataPortal class, 166Csla.Server.Hosts namespace
description, 89EnterpriseServicesPortal class, 162, 201–205RemotingPortal class, 162, 198–199WebServicePortal class, 162, 208–210Csla.Validation namespace, 128–135
BrokenRule class, 134BrokenRulesCollection class, 134–135description, 89
RuleArgs class, 129–130RuleHandler delegate, 128–129RuleMethod class, 130ValidationException class, 135ValidationRules class, 130–134Csla.Web namespace, 89
CslaCredentials class
smart client providing credentials, 598web service implementation, 581, 581–582CslaCredentials field, PTService class
web service implementation, 582, 583CslaDataPortalProxy element
implementing NET Remoting, 608implementing Enterprise Services, 619implementing Web Services, 612
CslaDataPortalProxy key, 186–187EnterpriseServicesProxy class, 200–201CslaDataPortalUrl element
implementing NET Remoting, 608implementing Web Services, 612CslaDataPortalUrl key, 187CslaDataSource class, 305–307CslaDataSource control, 304Designer attribute, 305event declaration, 306GetType method, 315handling events in a page, 306Web Forms data binding, 305–307CslaDataSource control, 303classes required to implement, 304CslaDataSource class, 304, 305–307CslaDataSourceDesigner class, 304, 310CslaDataSourceView class, 304, 307–309CslaDesignerDataSourceView class, 304,310–314
DeleteObject event, 305EventArgs objects, 305events raised by, 305InsertObject event, 305ObjectFieldInfo class, 304, 316–318ObjectSchema class, 304, 314ObjectViewSchema class, 304, 315–316refresh schema link enabled for, 310relationship between classes in, 304SelectObject event, 305
UpdateObject event, 305Web Forms interface design, 523CslaDataSource controls
ProjectEdit web form, 554CslaDataSourceDesigner class, 310CslaDataSource control, 304Web Forms data binding, 310CslaDataSourceView class, 307–309CslaDataSource control, 304ExecuteInsert method, 307ExecuteSelect method, 308–309Web Forms data binding, 307–309CslaDesignerDataSourceView class, 310–314CslaDataSource control, 304
GetDesignTimeData method, 311–312information provided by, 310
ObjectSchema class, 311Web Forms data binding, 310–314CSS style sheet
master page theme, 528cultures
see also localization
setting server context, 226Current property
IEnumerator interface, 254, 256CurrentPrincipal property, Thread classLogin button, 480
Trang 11CurrentPrincipalChanged event
ProjectEdit authorization rules, 507RolesEdit authorization, 489WinPart base control, 474CurrentUICulture setting
setting server context, 227custom authentication, 56–57, 243–246
CSLA NET design benefits, 340CSLA NET framework, 82–84objects supporting, 342CslaAuthentication key, 470, 577custom principal object inheritance, 243implementing business objects, 457–462message objects, 73
object design, 339PTIdentity class, 459–462PTPrincipal class, 457–459setting server context, 227web service implementation, 581custom controls
adding subclasses of custom control, 489custom membership provider
forms-based authentication, 533–534custom rule methods
implementing Project class, 417customer payment terms, 239
CustomIdentity class, 245
GetIdentity method, 83UnauthenticatedIdentity method, 84CustomPrincipal class, 243
identity object and, 244
■ D
d date format, 268
data
see also application data
business logic as smart data, 22data access, 276–285
adding to CSLA NET framework, 159basic data access models, 514channel adapter behaviors, 177–210common regions, 375
context and location transparency, 224–233CSLA NET design benefits, 340
data portals, 71DataMapper class, 280–285distributed transaction support, 210–217enhancing base classes, 169–176message router functionality, 217–224NameValueListBase class, 242–243SafeDataReader class, 277–280SmartDate type, 272
data access layer
5-layer logical architecture, 11–12description of role, 13
encapsulation of business objects, 32high security web client, 16
high-scalability smart client, 14mobile objects and logical architecture, 25, 27security, 14
data access methodsBusinessBase class, 60DataPortal class implementing, 188–193dual data access methods, 389
Data Access regioneditable child business objects, 387editable root business objects, 383editable root collections, 393implementing Assignment class, 441implementing business classes, 422–429implementing Project class, 422–429Criteria object, 422
DataPortal_Create method, 423–424DataPortal_Delete method, 429DataPortal_DeleteSelf method, 428DataPortal_Fetch method, 424–426DataPortal_Insert method, 426–427DataPortal_Update method, 427–428handling transactions, 423
implementing ProjectResource class,437–439
deleting data, 439inserting data, 438loading existing object, 437updating data, 439implementing ProjectResources class, 429,433–434
loading data, 433updating data, 433implementing PTIdentity class, 461–462implementing ResourceList class, 448–449implementing RoleList class, 443–444implementing Roles class, 451–453invalidating client-side cache, 452invalidating server-side cache, 452name/value list objects, 402
read-only business objects, 397regions, 377
using identity column, 444data access tier
locating business logic in, 20data binding
.NET Framework interfaces, 66application design supporting, 46–49ASP.NET, 307
benefits of using in NET, 46BindableBase class, 66, 98binding ProjectEdit control to Project class,498–500
BindingSource control, 302BindingSource object, 288BindingSourceRefresh control, 301BusinessBase class, 110
collection interfaces required to support, 47creating child objects, 363
creating forms as user controls, 467CSLA NET framework, 66
data binding ListBox, 495–496DetailsView control, 543enabling objects for, 47–48
Trang 12events and serialization, 48grid-based binding, 48GridView control, 541IBindingList interface, 47, 66IDataErrorInfo interface, 49, 124IEditableObject interface, 47, 117INotifyPropertyChanged interface, 47, 66, 98IsDirty property, BusinessBase class, 112loading RolesEdit control, 490
null values, 263ProjectEdit control binding to Resourcescollection, 501–502
ProjectEdit loading user controls, 506PropertyChanged event, 301
public properties, 101ReadOnlyBindingList class, 127report engines, 286
ResourcesDataSource control, 557RolesEdit saving data, 491saving data with remote data portal, 493SortedBindingList class, 247
Web Forms, 46, 303–318Windows Forms, 46, 295–303data centric object model, 52
data contention
performance of physical model, 5data creation
DataPortal_Create method, 76–78data focused design
gathering application requirements, 322Data folder, CSLA NET project, 93
data management tier
see data storage and management layer
Data namespace, Csla, 88
data portals
application server hosts, 601areas of functionality, 71behaviors/methods, 76–82benefits of, 71
channel adapter design pattern, 161–163channels, factors for comparison, 602–605ease of deployment, 604
ease of implementation, 604firewall friendliness, 604host technology, 604performance, 602security, 603client side DataPortal, 71–72client side proxy classes, 71, 72consistent entry point to application server,70
context information, 166–169CSLA NET framework, 70–82data access, 55
data passed to/from server for data portaloperations, 73
description, 56, 159design patterns, 161designing for data access, 160–169
distributed transactions, 164–166flow of client call through, 161implementing remote data portal hosts,601–620
.NET Remoting channel, 605–609Enterprise Services channel, 612–619Web Services channel, 609–612location transparency, 169message objects, 71, 72–74message router design pattern, 163–164methods exposed by data portal server, 163remote data portals, 374
implementing remote data portal hosts,605–619
when to use, 601saving data with remote data portal, 493server side data portal, 71, 74–76server side host classes, 71, 74support for distributed transactions, 210–217transaction models, 75
types supporting transactional technologies
in, 165using ASP.NET membership service with, 536Web Forms interface design
local data portals, 524remote data portal (with EnterpriseServices), 525
remote data portal (with remoting), 524remote data portal (with Web Services),525
web service implementationlocal data portal, 577remote data portal (with EnterpriseServices), 578
remote data portal (with remoting), 578remote data portal (with Web Services),578
Windows Forms interface designlocal data portals, 470remote data portal (with EnterpriseServices), 471
remote data portal (with remoting), 471remote data portal (with Web Services),471
Data properties, Role columnbinding to Resources collection, 502data reader objects
basic data access models, 514IDataReader interface, 277data removal
DataPortal_DeleteSelf method, 82data retrieval
DataPortal_Fetch method, 78–79data source controls
ASP.NET, 303control capabilities, 314CslaDataSource controls, 554object capabilities, 312ProjectDataSource control, 556–557
Trang 13ProjectListDataSource control, 550ResourceListDataSource control, 560ResourcesDataSource control, 557–559RoleListDataSource control, 559RolesDataSource control, 539using business class as data source, 486–489using business object as data sourceRolesEdit web form, 539–540Data Sources window, 495
data stacking
CopyState method, UndoableBase class, 102serializing and stacking Hashtable, 107data storage and management layer
5-layer logical architecture, 12,–3description of role, 13
locating business logic in, 18data structures
designing Web Service interfacereturning formal data structures, 574data transfer objects (DTOs), 586
DataMapper class, 276data updates
bidirectional, 79DataPortal_Update method, 79–81database connections
using identity column, 445database design, 343–359
creating databases, 344–345PTracker database, 345database diagrams
PTracker database, 348, 349Security database, 358database format
SmartDate type, 272DataBind method
GridView control, 545DataGrid control
IEditableObject interface, 117, 118DataKeyNames property
DetailsView controlRolesEdit web form, 543GridView control
ProjectEdit web form, 553ProjectList web form, 549RolesEdit web form, 541, 546DataMapper class, 86, 280–285
description, 85GetSourceProperties method, 284Map method, 283
mapping from an object, 284mapping from IDictionary, 283SetValue method, 281, 283DataObjectField attribute
implementing Project class, 410, 411ObjectFieldInfo class, 316–318parameters for, 317
DataPortal class
channel adapter behaviors, 177, 185–193, 209creating proxy object, 186–188
description, 159determining network protocol, 186distributed transaction support, 210–215events
DataPortalInvoke, 186DataPortalInvokeComplete, 186implementing data access methods, 188–193methods, 174
ClearContext, 227–228Create, 76–78, 174, 185, 190–191, 212–214Delete, 174, 185, 193, 214
DeleteSelf, 82, 174Execute, 174, 185, 193Fetch, 78–79, 174, 185, 189–191, 214Insert, 174
OnDataPortalException, 174OnDataPortalInvoke, 174OnDataPortalInvokeComplete, 174RunLocal, 186
SetContext, 226Update, 79–81, 174, 185, 192, 214–215methods exposed by data portal server, 163remote server-side DataPortal, 368RunLocal attribute, 186
transactional contexts, 165TransactionalAttribute, 165types required for channel adapter, 162using MethodCaller class methods, 177DataPortal folders, CSLA NET project, 93DataPortalClient namespace, Csla, 89DataPortalContext class, 225–228clearing server context, 228context and exception data flow to/fromserver, 167
context data within, 167context passing and location transparency,169
creating DataPortalContext object, 225–226implementing data access methods, 189–190providing public access to contexts, 230setting server context, 226–227
DataPortalContext property, 185DataPortalEventArgs classchannel adapter behaviors, 185types required for channel adapter, 162DataPortalException class, 228
context data within, 168context passing and location transparency,169
SimpleDataPortal implementing datamethods, 221
DataPortalException typeWebServicesProxy class, 208DataPortalInvoke eventDataPortal class, 186implementing data access methods, 190DataPortalInvokeComplete event
DataPortal class, 186implementing data access methods, 190
Trang 14DataPortalProxy property
ApplicationContext class, 232DataPortalResult class, 228
context data within, 168context passing and location transparency,169
DataPortalException class, 168SimpleDataPortal implementing datamethods, 221
DataPortalUrl property
WebServicesProxy class, 206DataPortal_Create method, 76, 78
child object creation without defaults, 387creating child objects, 364
creating root objects, 362dual data access methods, 389editable root business objects, 383implementing Project class, 423–424purpose, 174
SimpleDataPortal implementing datamethods, 220
DataPortal_Delete method
deleting root objects, 371implementing Project class, 429purpose, 174
DataPortal_DeleteSelf method, 80, 82
deleting root objects, 372implementing Project class, 428processing BusinessBase object, 223purpose, 174
DataPortal_Execute method
description, 239implementing ExistsCommand class, 456,457
processing CommandBase object, 224purpose, 174
shipping an order, 238DataPortal_Fetch method, 78–79
criteria object, 242custom authentication, 245dual data access methods, 390editable root collections, 393implementing Project class, 420, 424–426implementing PTIdentity class, 461implementing ResourceList class, 448implementing RoleList class, 443purpose, 174
read-only collections, 399retrieving child objects, 367retrieving root objects, 365, 366SimpleDataPortal implementing datamethods, 222
DataPortal_Insert method
adding/editing root objects, 368implementing Project class, 426–427processing BusinessBase object, 223purpose, 174
using identity column, 444
DataPortal_OnDataPortalException methodCSLA NET base classes, 242
purpose, 174SimpleDataPortal implementing datamethods, 218, 221
DataPortal_OnDataPortalInvoke methodCSLA NET base classes, 242
implementing Roles class, 452purpose, 174
SimpleDataPortal implementing datamethods, 218, 220
DataPortal_OnDataPortalInvokeCompletemethod
CSLA NET base classes, 242purpose, 174
SimpleDataPortal implementing datamethods, 218
DataPortal_Update method, 79–81adding/editing root objects, 368editable root collections, 393implementing Project class, 427–428implementing Roles class, 452processing BusinessBase object, 223processing other objects, 224purpose, 174
DataPortal_Xyz methodsCommandBase class implementing, 239editable root business objects, 383NameValueListBase class, 242overriding methods, 176protected virtual methods, 176read-only objects, 176saving child object data, 368scope, 176
setting up ProjectTracker, 407SimpleDataPortal implementing datamethods, 218, 220
table of, stating purpose, 174Transactional attribute, 210, 211TransactionalTypes enumeration, 210using criteria, 175
DataRowView class/object, 293DataSet object
basic data access models, 514, 515business logic and, 22
IList interface, 287ObjectAdapter class filling, 85, 86passing between business logic and dataaccess layers, 25
report generation, 286DataSource property, BindingSource controldata binding ListBox, 496
loading RolesEdit control, 490ProjectEdit loading user controls, 506RolesEdit saving data, 491, 492setting, 500
smart client calling web method, 596DataSourceID property
Trang 15DataTable class/object
BeginLoadData method, 292CslaDesignerDataSourceView class, 312EndLoadData method, 292
ObjectAdapter class filling, 85, 86DataType property
ObjectFieldInfo class, 318DataView class/object, 293
date field
SmartDate type, 263, 264, 265date functions
SmartDate type, 269date handling, 262–272
empty/blank dates, 263SmartDate type, 263–272date manipulation
SmartDate type, 270Date property
DateTime type, 269dates
see also SmartDate class/type
database access for writing, 272date conversion functions, 266–268working with empty date values, 86, 265DateTime data type
Date property, 269empty date values, 279empty fields, 277GetDateTime method, 279implementing Project class, 413inheritance from, 263
SmartDate class/type, 85, 86, 263DateToString method
SmartDate type, 268, 267–268DCOM (Distributed Component Object Model)
implementing Enterprise Services, 612security and internal applications, 6debugging
message objects, 73DeclaringType property
SimpleDataPortal implementing datamethods, 222
decomposition
object design, 326Default form, 522
default value
Role class setting, 453–454Default.aspx, 521
content pages, 527DefaultRole method
implementing ProjectResource class, 436implementing RoleList class, 442deferred approach
IsDeleted property, 115deferred deletion
editable root business objects, 384root objects, 371–372
delegatesbehavioral object-oriented design, 51declaring events to avoid serialization issues,
98, 100description, 40events and, 48RuleHandler delegate, 128Delete method, DataPortal classdata passed to/from server for data portaloperations, 73
deleting root objects, 371distributed transaction support, 214IDataPortalServer, 193–194
implementing data access methods, 193IsDeleted property, 115, 116
purpose, 163, 174, 186server side data portal, 74SimpleDataPortal class, 224deleteAssignment procedure, PTracker, 354DeleteChild method
BusinessListBase class, 146deleting and undeleting child objects, 150editable child business objects, 386IsDeleted property, 115, 116deleted object collectionBusinessListBase class, 146DeletedList
deleted object collection, 146deleting and undeleting child objects, 147implementing ProjectResources class, 434DeleteObject event
CslaDataSource control, 305ProjectDataSource control, 557ProjectListDataSource control, 551ResourcesDataSource control, 558RolesDataSource control, 546RolesEdit web form, 547DeleteObject event handler, 306deleteProject procedure, PTracker, 352deleteResource procedure, PTracker, 356deleteRole procedure, PTracker, 358DeleteSelf method
deleting child objects, 369editable child business objects, 387editable root collections, 393implementing ProjectResource class, 439DeleteSelf method, DataPortal class, 82deleting root objects, 372
purpose, 174deleting objectschild objects, 369editable root business objects, 384IsDeleted property, 115–116root objects, 370–372deferred deletion, 371–372immediate deletion, 371demilitarized zone (DMZ), 16DenyRead method
associating roles with properties, 138
Trang 16see application design
Design namespace, Csla.Web, 89
design patterns
channel adapter design pattern, 161–163message router design pattern, 163–164Designer attribute
CslaDataSource class, 305DesignerCategory attribute
ReadWriteAuthorization control, 295DesignMode property
WinPart base control, 473DetailsView control, 312
ItemDeleted event, 557ItemInserted event, 544ModeChanged event, 545ProjectEdit web form, 552, 557, 561RolesDataSource control, 543Diagrams folder, code download, 93
DialogResult property
selecting project, 496dialogs
see forms
directory structure, CSLA NET project, 93
dirty objects
IsDirty property, 112–114DisplayList helper method, 495
IDisposable interface, 373distributed applications
mobile objects, 24–32passing by reference/value, 30procedural model, 25distributed architectures
architectures and frameworks, 32–33logical and physical architectures, 1–17managing business logic, 17–32Distributed Component Object Model
ServicedDataPortal class, 215–216support for, 210–217
TransactionalAttribute class, 210–211TransactionalDataPortal class, 216–217TransactionalTypes enumeration, 210TransactionScope object, 165wrapping business object in transaction, 215DMZ (demilitarized zone), 16
DNA (Windows DNA)Windows Distributed interNet Architecture, 4DoAddUpdate helper method, 441
Dock propertyPanel control, 475Documents menuDropDownOpening event, 477MainForm Windows form, 477Tag property, 477
using Windows menu or, 468DoFetch helper method, 390DoInsertUpdate helper method, 426DoLogin method
Login button, 479domains, 22domains of trusthackers, 6security and external applications, 7security and internal applications, 6surface area, 5
DoSort methodListItem class, 251–252SortedBindingList class, 250DropDownList controlsProjectEdit web form, 553DropDownOpening eventDocuments menu, 477DTC (Microsoft Distributed TransactionCoordinator), 164
dual criteria classesswitchable business objects, 388dual data access methods, 389dual factory methods, 388duplicate objectsrevising PTracker design, 329duplicate values
Role class preventing, 454–455
■ E
edit level, 145editable child business objects, 384–387object creation without defaults, 387editable child collections, 394–395editable collections
properties controlling, 451editable objects
classes required to support, 91creating, 59
Trang 17edit level trackingBusinessListBase class, 144for child objects, 122IEditableObject interface, 117–120object-editing methods in BusinessBase, 116updating, 368–372
editable root business objects, 380–384
editable root collections, 390–394
editing objects
child objects, 369root objects, 368EditLevel property
edit level tracking for child objects, 122UndoableBase class, 108
EditLevelAdded property
BusinessListBase class, 146EditorBrowsable attribute, 100
Employee class
potential class for PTracker, 327revising project tracker design, 328empty date values
SmartDate type, 265empty fields
DateTime data type, 277null values and, 277empty values
Boolean data type, 280DateTime data type, 279GetEmptyValue method, 299, 300ReturnEmpty method, 299SmartDate type, 279emptyIsMax field
SmartDate type, 264, 265emptyIsMax flag
SmartDate type, 266emptyIsMin parameter
SmartDate type, 265Enabled property
ReadWriteAuthorization control, 299, 301encapsulation
architecture and framework guidelines, 36business logic, 53
CSLA NET design benefits, 340data access layer, 32
description, 21, 53mobile/business objects, 31–32performance and, 54
preserving, 52–54state and, 106user interface layer, 31web services returning objects, 281EncryptChannel property
RemotingProxy class, 198encryption
data portal channel comparison, 603implementing NET Remoting, 609Ended property
implementing Project class, 413, 414EndEdit method, IEditableObject, 118
EndLoadData methodDataTable class, 292Enterprise Servicesclient side proxy classes, 72implementing remote data portal hosts,612–619
client setup, 618–619COM+ configuration files, 615comparison of factors between channels,602–605
configuring class library project, 613configuring client, 619
creating proxy/host assembly, 612–618creating setup program, 618
EnterpriseServicesPortal class, 615EnterpriseServicesProxy class, 614installing COM+ application, 619installing proxy/host into COM+, 616–618referencing assemblies, 614
remote data portal withWeb Forms interface design, 525web service implementation, 578Windows Forms interface design, 471server side host classes, 74
EnterpriseServices transaction type, 75DataPortal transactional contexts, 166routing call to data portal, 211EnterpriseServicesHostcs assemblyimplementing Enterprise Services, 615EnterpriseServicesHostcs projectimplementing Enterprise Services, 613, 616EnterpriseServicesPortal class
application.config file, 205application.manifest file, 204ApplicationAccessControl property, 202ApplicationActivation property, 202, 204ApplicationName property, 202AssemblyResolve event, 203channel adapter behaviors, 201–205ComVisible attribute, 201
Description property, 202EventTrackingEnabled attribute, 201implementing Enterprise Services, 615types required for channel adapter, 162EnterpriseServicesProxy class
channel adapter behaviors, 200–201GetServerObject method, 200, 201implementing Enterprise Services, 614types required for channel adapter, 162entities
PTracker initial design, 326enumerators
collection enumerator, 254custom enumerator class, 254GetEnumerator method, 256getting items from collections, 254IEnumerator interface, 254properties and methods of Enumeratorobject, 254
Trang 18Equals method
overriding System.Object, 140, 141SmartDate type, 270
WinPart base control, 473Error property
IDataErrorInfo interface, 124ErrorLabel control
RolesEdit web form, 539ErrorProvider control, 502
properties, 503EventArgs objects
CslaDataSource control, 305handling events in a page, 306EventHandler<T>, 307
events
AssemblyResolve event, 203CslaDataSource control, 305data binding, 48
DataPortalInvoke, 186DataPortalInvokeComplete, 186declaration in CslaDataSource control, 306declaring to avoid serialization issues, 98, 100delegates and, 48
inheritance and, 100PropertyChanged event, 98serializing objects that declare, 98EventTrackingEnabled attribute
EnterpriseServicesPortal class, 201implementing Enterprise Services, 615ServicedDataPortal class, 216
exception handling
BusinessBase class method, 61DataPortalException class, 228implementing data access methods, 191loading RolesEdit control, 490
message objects, 73ValidationException class, 135exceptions
CallMethodException, 183–184context and exception data flow to/fromserver, 167
Execute method, DataPortal class
data passed to/from server for data portaloperations, 73
implementing data access methods, 193purpose, 163, 174, 185–6
server side data portal, 74shipping an order, 238ExecuteInsert method
CslaDataSourceView class, 307ExecuteReader method
creating SafeDataReader object, 278ExecuteSelect method
CslaDataSourceView class, 308–309ExecutionLocation property
ApplicationContext class, 233setting server context, 226exists field
ExistsCommand class, 456
Exists methodpossible implementation of, 237Project class, 455–456
Resource class, 457Exists propertyExistsCommand class, 456Exists region
implementing business classes, 409implementing Project class, 409ExistsCommand class, PTracker, 456–457Exists method initializing object, 455existsProject procedure, PTracker, 350existsResource procedures, PTracker, 354extender controls
ApplyAuthorization property, 297applying authorization rules, 297–301BindingSourceRefresh control, 301GetApplyAuthorization method, 297IExtenderProvider interface, 296inheritance, 295
SetApplyAuthorization method, 297Windows Forms data binding, 295external applications
security in physical model, 6
■ F
facadedesigning Web Service interface, 575Factory design pattern
class in charge model, 45–46factory methods, 171–172common regions, 375creating child objects, 363, 364creating root objects, 362CustomIdentity class, 245dual factory methods, 388editable child collections, 395implementing Project class, 420–421implementing ProjectResources class, 432Factory Methods region, 376
command objects, 400editable child business objects, 386editable root business objects, 383editable root collections, 393implementing business classes, 419–421implementing Project class, 419–421factory methods, 420–421non public constructor, 421overriding Save method, 421implementing ProjectResource class,436–437
implementing ProjectResources class, 429constructor, 432
factory methods, 432implementing PTIdentity class, 460implementing ResourceList class, 448implementing RoleList class, 442–443implementing Roles class, 451name/value list objects, 402
Trang 19read-only business objects, 397read-only collections, 399fault tolerance
data access tier and, 11optimal performance web client, 16physical model, 7–8
redundant servers, 8Fetch method, DataPortal class, 78–79
data passed to/from server for data portaloperations, 73
distributed transaction support, 214editable child business objects, 387IDataPortalServer, 193–194implementing data access methods, 189–191implementing ProjectResource class, 438implementing ProjectResources class, 433purpose, 163, 174, 185
retrieving child objects, 367retrieving root objects, 365server side data portal, 74using criteria, 175WebServicePortal class, 207, 208Fetch method, SimpleDataPortal class
message router functionality, 221–222FetchRequest class/object, 207, 208
WebServicePortal class, 209fields
avoiding double-processing of fields, 105getting list of fields, 105
skipping NotUndoable fields, 106taking snapshot of regular fields, 106Fill method
ObjectAdapter class, 86, 286, 287–288filtered list
retrieving, 243finalizing objects, 372–373
SmartDate type, 264forms
creating forms as user controls, 467Login form, 467, 481–482
MainForm form, 467, 474–481, 482–486ProjectSelect form, 467, 496
ResourceSelect form, 467forms-based authentication
configuring site, 531–533custom membership provider, 533–534login page, 531–535
reloading principal object, 534–535
forms, PTWebDefault form, 522Login form, 522ProjectEdit web form, 522ProjectList web form, 522ResourceEdit web form, 522ResourceList web form, 522RolesEdit form, 522frameworks
see also CSLA NET framework
architectures and, 32–33high-level guidelines, 36namespace organization, 88–89overview, 58
■ G
garbage collectiondisposing and finalizing objects, 372generic types
BusinessListBase class, 143CSLA NET framework, 95overriding System.Object, 141polymorphism, 60, 95generics
BusinessBase class, 140introduction, 41ReadOnlyBase class, 155System.Collections.Generic namespace, 41get blocks
implementing Project class, 411, 413implementing ProjectResource class, 435GetApplyAuthorization method
extender controls, 297GetChildItemType methodObjectAdapter class using, 290Utilities class, 290, 315GetClone methodICloneable interface, 127, 142, 154GetColumns method
ObjectAdapter class, 289GetDataObjectAttributes method, 317GetDataPortalProxy method, 187implementing data access methods, 189–190GetDateTime method
DateTime data type, 279GetDesignTimeData methodCslaDesignerDataSourceView class, 311–312GetEditableChild method
editable child business objects, 386GetEmptyValue method, 299, 300GetEnumerator method
SortedBindingList class, 256GetField method
ObjectAdapter class, 292–294GetFields method
ObjectViewSchema class, 315GetFirstBrokenRule methodBrokenRulesCollection class, 135
Trang 20GetHashCode method
overriding System.Object, 140, 141WinPart base control, 473GetIdentity method
CustomIdentity class, 83implementing PTIdentity class, 460GetIdValue method
editable root business objects, 383implementing Project class, 415implementing PTIdentity class, 460implementing ResourceInfo class, 447read-only business objects, 397WinPart base control, 472–473GetIList method
ObjectAdapter class, 288GetItem method
implementing ProjectResources class, 430, 431GetList factory method
implementing RoleList class, 442GetMethod method
MethodCaller class, 177–181GetNameDataSlot method, Thread object
client and global context collections, 229GetObjectType method
MethodCaller class, 183–184GetOrdinal method
SafeDataReader class, 278GetProject method, PTWebService
copying properties from Project intoProjectData, 590
implementing Project class, 420ProjectEdit web form, 555ProjectRequest class, 589ProjectResourceData class, 590ProjectResources property, 591service-oriented web methods, 588–591smart client providing credentials, 599getProject procedure, PTracker, 350
implementing Project class, 426GetProjectList method, PTWebService
ProjectList web form, 550service-oriented web methods, 587–588GetProjectResource method
implementing ProjectResource class, 437GetProjectResources method
implementing ProjectResources class, 432getProjects procedure, PTracker, 349
getResources procedure, PTracker, 354
GetRoleById methodimplementing Roles class, 450GetRoles method
implementing Roles class, 451RolesEdit web form, 540getRoles procedure, PTracker, 357GetRolesForProperty methodAccessType enumeration, 136GetRulesForProperty methodassociating rules with properties, 132GetServerObject method
EnterpriseServicesProxy class, 200, 201implementing Enterprise Services, 614GetSmartDate method
implementing Project class, 426SafeDataReader class, 279GetSourceProperties methodDataMapper class, 284GetString methodSafeDataReader class, 278GetSwitchable methodsdual factory methods, 389GetType method
CslaDataSource class, 315data source controls, 313GetValue method
returning objects, 106, 285GetViews method
ObjectSchema class, 314Global Assembly Cache (GAC)alternative to IIS, 531global context dataDataPortalResult class, 228GlobalContext collectionDataPortalContext class, 167DataPortalResult class, 168implementing data access methods, 190–191GlobalContext property, ApplicationContextclass
providing public access to contexts, 230providing public access to contexts, 231granularity
object-oriented performance, 25graphical user interface (GUI)presentation layer and UI, 9grid-based binding, 48GridView controlcolumns, 548DataBind method, 545DataKeyNames property, 546, 549enabling paging for, 549
Fields dialog for, 542PageSize property, 549ProjectEdit web form, 553, 554assigning resources to projects, 559RolesEdit web form, 541
GUI (graphical user interface)presentation layer and UI, 9Guid class
class in charge model, 45
Trang 21■ H
hackers
domains of trust, 6Hashtable object
re-creating, 108restoring object’s state data, 109serializing and stacking, 107taking snapshot of regular fields, 106HasReadAllowedRoles method
checking roles, 139header region
appearance in MasterPage.master, 528master page, 529
helper types and classes
CSLA NET framework, 85–87high scalability smart client
5-layer logical architecture, 14summary of architecture, 25high security web client
5-layer logical architecture, 16summary of architecture, 25host technology
data portal channel comparison, 604hosts
hosting PTWeb site in IIS, 526hosting PTWebService implementation inIIS, 579
implementing remote data portal hosts,601–620
server side host classes, 71Hosts folder, DataPortal, 93
Hosts namespace, Csla.Server, 89
description, 91ICancelAddNew interface, 66
ICloneable interface, 242
BusinessBase class, 126–127BusinessListBase class, 154–155Clone method, 126, 127, 142GetClone method, 142ReadOnlyBase class, 156ReadOnlyListBase class, 157ICollection interface, 248
ICommandObject interface, 97
CommandBase class, 239description, 91
IComparable interface
Key property, 251SmartDate type, 269
id fieldExistsCommand class, 456
Id propertyimplementing Project class, 410implementing Role class, 453, 454IDataErrorInfo interface, 66data binding, 49, 66maintaining list of broken rules, 69tracking broken business rules, 40validation rules, 124
IDataPortalProxy interfacechannel adapter behaviors, 193–194types required for channel adapter, 162IDataPortalServer interface
channel adapter behaviors, 193–194method definition, 194
types required for channel adapter, 162IDataReader interface
data reader objects, 277Read method, 280IDataSourceFieldSchema interfaceNullable property, 317
Precision property, 318PrimaryKey property, 317Scale property, 318identity columnResource class using, 444–445identity element
Web Service authentication, 575identity objects, 83
CustomIdentity class, 245CustomPrincipal class and, 244PTIdentity class, 459–462Identity property
BusinessPrincipalBase class, 246implementing PTPrincipal class, 457IDictionary interface
DataMapper mapping from, 283IDisposable interface
Dispose method, 373disposing and finalizing objects, 373remote data portals, 374
IEditableCollection interface, 96BusinessListBase class, 65description, 91
RemoveChild method, 96SuppressMessage attribute, 96IEditableObject interface, 66, 95–96, 117–120data binding, 47, 66
description, 91methods, 118object-editing methods, 116UndoableBase class, 102IEnumerable interfaceExecuteSelect method, 309IEnumerable<T> interfaceSortedBindingList class, 247IEnumerator interface, 254Current property, 254, 256
Trang 22MoveNext method, 254, 255Reset method, 254, 255IEnumerator<T> interface
SortedEnumerator class, 256IExtenderProvider interface
CanExtend method, 296ReadWriteAuthorization control, 296IHoldRoles interface
implementing Assignment class, 440implementing ProjectResource class, 435IIdentity interface, 83
IIS (Internet Information Services)
ASP.NET Development Server compared, 531ASP.NET security and, 532
hosting PTWeb site in, 526hosting PTWebService implementation in,579
server side host classes, 74using remote data portal with, 482IList interface
data sources implementing, 287indexer, 253
SortedBindingList class sorting, 85, 87IList<T> interface
SortedBindingList class, 247IListSource interface
data sources implementing, 287immediate approach
IsDeleted property, 115immediate deletion
editable root business objects, 384root objects, 371
impersonation, 56
description, 166Web Service authentication, 575implementation
data portal channel comparison, 604remote data portal hosts
.NET Remoting, 605–609Enterprise Services, 612–619web services, 609–612web services, 576–591implementation code
business objects, 23indexers
IList interface, 253Indigo, 43, 601
inheritance
avoiding double-processing of fields, 105BindableBase class, 98
BrokenRulesCollection class, 134BusinessBase class, 110
BusinessListBase class, 142events and, 100
extender controls, 295ICommandObject interface, 97IEditableObject interface, 96polymorphism, 95
ReadOnlyBindingList class, 127
initialized fieldSmartDate type, 264, 269InnerException
DataPortalException class, 168SimpleDataPortal implementing datamethods, 221
INotifyPropertyChanged interface, 66data binding, 47, 66, 98
PropertyChanged event, 98UndoableBase class, 102Insert method
DataPortal class, 174editable child business objects, 387implementing ProjectResource class, 438inserting child objects, 369, 370
sharing database connection, 446SortedBindingList class, 257, 260inserting data
ExecuteInsert method, 307InsertItem method
BusinessListBase class, 146deleting and undeleting child objects, 150RemoveChild method overriding, 145InsertObject event
CslaDataSource control, 305ProjectDataSource control, 556ResourcesDataSource control, 557RolesDataSource control, 542–545InsertObject event handler, 306InsertView control
RolesEdit web form, 539instance field changesPropertyHasChanged method, 412instance field declarations
implementing Project class, 409Instance property
MainForm class, 478integrated authorization, 57CSLA NET framework, 84IntelliSense
consumer applications, 574methods appearing in, 100inter object collaborationrevising PTracker design, 337interdependent propertiesimplementing Project class, 413–414interface design, Web Forms, 521–537application configuration, 523–525login page, 531–537
master page, 526–530PTWeb site setup, 525–526interface design, Windows Forms, 465–472application configuration, 469–472PTWin project setup, 472
user control design, 469user control framework, 467–469interfaces
BindableBase class, 98business objects, 23
Trang 23BusinessBase class, 110BusinessListBase class, 143definition, 568
security and external applications, 7UndoableBase class, 102
internal applications
security in physical model, 6internal scope
ObjectCloner class, 98taking snapshot of data, 105Internet Information Services
see IIS
InvalidateCache method
implementing RoleList class, 443implementing Roles class, 452, 453name/value list objects, 402Invoice objects
n-level undo functionality, 38IPrincipal interface, 83
DataPortalContext class, 167IPrincipal value
setting server context, 227IRaiseItemChangedEvents interface, 66
BusinessBase class, 121BusinessListBase class, 144IsDeleted property, BusinessBase class, 115–116
description, 111implementing ProjectResource class, 438IsDirty method
implementing Project class, 415–416IsDirty property, BusinessBase class, 112–114,
143Browsable attribute, 112description, 111implementing Project class, 412IsEmpty property
SmartDate type, 265, 272ISerializable interface
creating mobile objects in NET, 29isIdentity parameter
DataObjectField attribute, 317IsInRole method
BusinessPrincipalBase class, 246implementing PTIdentity class, 460implementing PTPrincipal class, 457IsNew property
editable root collections, 393IsNew property, BusinessBase class, 111–112
isNullable parameter
DataObjectField attribute, 317IsPropertyImplemented method
ReadWriteAuthorization control using, 296
IsReadAllowed methodchecking roles, 139RolesForProperty class, 136IsReadDenied methodRolesForProperty class, 136IsReadOnly property
implementing ResourceList class, 449name/value list objects, 402
read-only collections, 399ReadOnlyBindingList class, 127, 128IsRemotePortal flag
DataPortalContext class, 167IsSavable property, BusinessBase class, 114description, 111
IsValid methodimplementing Project class, 415–416IsValid property
BusinessBase class, 114BusinessListBase class, 143description, 111
maintaining list of broken rules, 69IsWriteAllowed method
RolesForProperty class, 136IsWriteDenied methodRolesForProperty class, 136ItemDeleted event
DetailsView control, 557ItemInserted eventDetailsView control, 544IUndoableObject interfaceIEditableCollection interface, 65UndoableBase class, 65
■ J
JavaScriptobject-orientation, 7security and external applications, 7user interface and presentation layer, 9Just-in-Time (JIT) compiler
avoiding double-processing of fields, 105
■ K
K parameter
see also Key property
NameValueListBase class, 240NameValuePair class, 241key collection
SortedBindingList class, 247Key property
IComparable interface, 251ListItem class, 251
NameValueListBase class, 241key/value pairs
Key property, 241ListItem class, 250NameValuePair class, 240ReadOnlyListBase class, 239Value property, 241