Create a solution from scratch

In this document, you will learn how to setup a solution from scratch.

If you came here from tutorial pages use Gazel.Tutorial for your solution name.

Create a blank solution

Create a blank solution with your company and product name [Company].[Product] in Visual Studio. Under the solution, create folders as shown below;

Create a service application host

Right click Host solution folder and create a new empty web application project named [Company].[Product].Test.AppHost.Service.

Make sure that this new AppHost.Service project is an empty Web Application.

Your directory structure should look like this;

Now add Gazel.Configuration package to the AppHost.Service project from nuget.org: https://nuget.org/packages/Gazel.Configuration.

To configure AppHost.Service add a Global Application Class (Global.asax) to the project. To configure AppHost.Service as a service application Global class should extend ServiceApplication base class as follows.

public class Global : ServiceApplication { protected override DatabaseConfiguration Database(DatabaseConfigurer configure) { return configure.Sqlite("gazel.tutorial.db"); } protected override ServiceConfiguration Service(ServiceConfigurer configure) { return configure.Routine(ServiceUrl.Localhost(6161)); } protected override AuthenticationFeature Authentication(AuthenticationConfigurer configure) { return configure.NoAuthentication(); } protected override AuthorizationFeature Authorization(AuthorizationConfigurer configure) { return configure.NoAuthorization(); } }

As you can see there are 4 main configurations.

  1. The first one tells Gazel to use a local SQLite database with a file named gazel.tutorial.db. This file will be located in My Documents folder.
  2. This one tells Gazel the service url base to itself to be able to make internal calls. You just need to type your web application's http port.
  3. and 4. disables authentication and authorization features.

Gazel scans bin directory to configure your classes automatically. To understand which assembly is yours, Gazel uses assembly name of your host project. If your host project is named Foo.Bar.Host.Service then it will only scan assemblies with a name that starts with Foo.

Create a REST application host

Right click Host solution folder and create a new empty web application project named [Company].[Product].Test.AppHost.Rest.

Make sure that this new AppHost.Rest project is an empty Web Application.

Your directory structure should look like this;

Now add Gazel.Configuration package to the AppHost.Rest project from nuget.org: https://nuget.org/packages/Gazel.Configuration.

To configure AppHost.Rest add a Global Application Class (Global.asax) to the project. To configure AppHost.Rest as a web service - service client application Global class should extend WebServiceServiceClientApplication base class as follows.

public class Global : WebServiceServiceClientApplication { protected override ServiceClientConfiguration ServiceClient(ServiceClientConfigurer configure) { return configure.Routine(ServiceUrl.Localhost(6161)); } protected override WebServiceConfiguration WebService(WebServiceConfigurer configure) { return configure.Rest(); } }

As you can see there are 2 main configurations.

  1. The first one tells Gazel the service url base to previously created service application. You need to type the http port of AppHost.Service project.
  2. This one tells Gazel to use Rest template for service generation.

Create a unit test project

To test your business services you need to create a test project. Right click UnitTest solution folder and create a new class library project named [Company].[Product].Test.UnitTest.

Your directory structure should look like this;

Now add Gazel.Configuration NuGet package to the UnitTest project from nuget.org: https://nuget.org/packages/Gazel.Configuration.

Create a configuration project

Finally you will create a configuration project. To do this right click Configuration folder and create a new class library project named [Company].[Product].Configuration.Service.

Your directory structure should look like this;

Now add Gazel.Configuration NuGet package to the Configuration.Service project from nuget.org: https://nuget.org/packages/Gazel.Configuration.

During application start, Gazel scans your assemblies to look for configuration classes.

This configuration project will include following type of items;

  • Web Service Packages
  • Configuration overrides for Castle.Windsor, NHibernate, Routine
  • Other 3rd party library configurations

Now go to the AppHost.Service project you previously created and add a reference to this Configuration.Service project. By doing this, your AppHost.Service will scan and use your configuration classes.

Summary

Now you've set up your environment to start developing a new product.

To add a new business module to your project checkout this document: Add a new business module.