tailieunhanh - Expert VB 2005 Business Objects Second Edition phần 8

Điều này có thể được xử lý bởi điều kiện gọi MarkAsChild (), dựa trên đối tượng được tạo điều kiện kêu gọi MarkAsChild () thường không có thể được thực hiện trong các nhà xây dựng mặc định, bởi vì không có cách nào để xác định xem đối tượng đang được | 460 CHAPTER 8 BUSINESS OBJECT IMPLEMENTATION Dim principal As New PTPrincipal identity principal End If Return End Function Notice that PTIdentity has a factory method in fact it is derived from and so is a full-fledged business object. The username and password parameters are passed to the PTIdentity object s factory method. Of course the factory method calls the data portal which ultimately invokes the DataPortal_Fetch method in PTIdentity. As you ll see that method validates the credentials against the database. With a PTIdentity object created its IsAuthenticated property can be checked to see if the user s credentials were valid. If they were valid the identity object is used to create a new PTPrincipal object and that object is set to be the current principal by using the ApplicationContext object s User property as discussed in Chapter 4 Dim principal As New PTPrincipal identity principal If the credentials weren t valid then the current principal value is left unchanged. In any case the IsAuthenticated value is returned as a result so that the UI code can take appropriate steps based on whether the user was successfully logged in or not. Logout The Logout method is much simpler. All it needs to do is ensure that the current principal value is set to an unauthenticated principal object that means a principal object whose identity object has an IsAuthenticated property which returns False Public Shared Sub Logout Dim identity As PTIdentity Dim principal As New PTPrincipal identity principal End Sub To achieve this result an unauthenticated PTIdentity object is created by calling a special factory method for that purpose. That identity object is then used to create a new PTPrincipal object and it is set as the current principal by setting . The reason for creating an .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.