unit ApplicationContext; // Dit is een klasse bedoeld om data te delen over de applicatie heen. // Dit kan bijvoorbeeld usernaam, login token, computernaam, ... // Informatie die elk component/klasse kan gebruiken. // Voor schaalbaarheid en isolatie worden interfaces gebruikt die deze klasse implementeert. interface uses ObserverPattern; // SUB CONTEXTS: klassen die overeenkomen met bepaalde sub-context (bv. alles gerelateerd met authenticatie). // - UserServerService type TUserContext = class(TSubject) private FSessionKey: string; FGebruikersNaam: string; FIsOK: Boolean; FErrorMessage: string; FInternalErrorMessage: string; public procedure NotifyChanged(); property SessionKey: string read FSessionKey write FSessionKey; property GebruikersNaam: string read FGebruikersNaam write FGebruikersNaam; property IsOK: Boolean read FIsOK write FIsOK; property ErrorMessage: string read FErrorMessage write FErrorMessage; property InternalErrorMessage: string read FInternalErrorMessage write FInternalErrorMessage; end; TProductsContext = class(TSubject) private FSessionKey: string; FDataSet: TObject; FIsOK: Boolean; FErrorMessage: string; FInternalErrorMessage: string; public procedure NotifyChanged(); property DataSet: TObject read FDataSet write FDataSet; property IsOK: Boolean read FIsOK write FIsOK; property ErrorMessage: string read FErrorMessage write FErrorMessage; property InternalErrorMessage: string read FInternalErrorMessage write FInternalErrorMessage; end; // APPLICATION CONTEXT // Application context bevat alle sub-contexts TApplicationContext = class private FUserContext: TUserContext; FProductsContext: TProductsContext; public constructor Create(); property UserContext: TUserContext read FUserContext write FUserContext; property ProductsContext: TProductsContext read FProductsContext write FProductsContext; end; implementation procedure TUserContext.NotifyChanged(); begin self.Change(); end; procedure TProductsContext.NotifyChanged(); begin self.Change(); end; constructor TApplicationContext.Create(); begin FUserContext := TUserContext.Create(); FProductsContext := TProductsContext.Create(); end; end.