PROJECT FILE. For the Contract Wizard I introduced the notion of project. To contract a new .NET assembly the user has to create a new project. Given the right input parameters, provided through the GUI or command line, the class CW_PROJECT_HANDLER takes care of creating a new project file. The file stores the project name, working directory, assembly location, and assembly name. The project handler stores the file in the working directory. It has the same name as the project and the extension .cpr; an abbreviation for contract project. Table 8 shows the content of a sample project file. Project name: Account Working directory: D:\eth\DA\test\ Assembly location: D:\eth\DA\example\Accouting_Example\Account.dll Assembly name: Account.dll Besides creating a project file the project handler is also responsible for opening an existing project. It receives the path on the project file as argument in its creation procedure and then the feature read_project_file reads the content from the file and assigns it to public attributes of CW_PROJECT_HANDLER. An important job of the project handler is to load the assembly from the assembly path. The method load_from takes as argument the path where the assembly is located and returns the loaded assembly (2). The attribute assembly is of type ASSEMBLY, a class from the .NET Framework. While loading the assembly it is possible that the system throws an exception, for example FileNotFoundException (assembly file is not found) or BadImageFormatException (assembly file is not a valid assembly). Therefore it is important that the feature calling load_from catches the exception in a rescue clause and sets a flag if the assembly is not loaded (3). Table 9 shows the creation procedure of CW_PROJECT_HANDLER that creates a new project file and loads the assembly. make (an_assembly_name, an_assembly_path, a_working_directory, a_project_name: STRING) is -- Initialize Current with values for a new project. -- …Strings not empty… is_erroneous : BOOLEAN if not is_erroneous then assembly_name := an_assembly_name (1) assembly_path := an_assembly_path working_directory := a_working_directory project_name := a_project_name -- Load assembly assembly := assembly.load_from (assembly_path) is_assembly_loaded := True
Appears in 3 contracts
Sources: Master Thesis, Master Thesis, Master Thesis