diff --git a/README.md b/README.md index d1be2e432b..9198e75a29 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -# abp EDGE +# ABP + +ABP is a modern application development framework based on cross platform .Net Core framework. + +See documentation. diff --git a/docs/Getting-Started-Console-Application.md b/docs/Getting-Started-Console-Application.md new file mode 100644 index 0000000000..00d0e8961e --- /dev/null +++ b/docs/Getting-Started-Console-Application.md @@ -0,0 +1,120 @@ +## Getting Started ABP With Console Application + +### Create A New Project + +Create a new Regular .Net Core Console Application from Visual Studio: + +![](images/create-new-net-core-console-application.png) + +### Install Volo.Abp Package + +Volo.Abp is the core nuget package to create ABP based applications. So, install it to your project: + +```` +Install-Package Volo.Abp +```` + +### Create First ABP Module + +ABP is a modular framework and it requires a **root module** class derived from ``AbpModule``: + +````C# +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; + +namespace AbpConsoleDemo +{ + public class AppModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddAssemblyOf(); + } + } +} +```` + +``AppModule`` is a good name for the root module for a console application. A module class can register services to Dependency Injection by overriding ``ConfigureServices`` method as shown here. ``AddAssemblyOf<...>`` is a special extension method of ABP that registers all services in an assembly by convention (TODO: link to DI document). While this is optional, a module generally registers some of it's services. + +### Initialize The Application + +The next step is to bootstrap the application using the module created above: + +````C# +using System; +using Volo.Abp; + +namespace AbpConsoleDemo +{ + class Program + { + static void Main(string[] args) + { + using (var application = AbpApplicationFactory.Create()) + { + application.Initialize(); + + Console.WriteLine("Press ENTER to stop application..."); + Console.ReadLine(); + } + } + } +} + +```` + +``AbpApplicationFactory`` is used to create the application and load all modules taking ``AppModule`` as the root (starting) module. ``Initialize()`` method starts the application. + +### Hellow World! + +The application above does nothing. Let's create a service that writes "Hello World!" to the console: + +````C# +using System; +using Volo.Abp.DependencyInjection; + +namespace AbpConsoleDemo +{ + public class HelloWorldService : ITransientDependency + { + public void SayHello() + { + Console.WriteLine("Hello World!"); + } + } +} + +```` + +``ITransientDependency`` is a special interface of ABP that automatically registers the service as transient (TODO: link to MS DI documentation and ABP DI documentation). + +Now, we can resolve the ``HelloWorldService`` and say hello. Change the Program.cs as shown below: + +````C# +using System; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; + +namespace AbpConsoleDemo +{ + class Program + { + static void Main(string[] args) + { + using (var application = AbpApplicationFactory.Create()) + { + application.Initialize(); + + //Resolve a service and use it + var helloWorldService = application.ServiceProvider.GetService(); + helloWorldService.SayHello(); + + Console.WriteLine("Press ENTER to stop application..."); + Console.ReadLine(); + } + } + } +} +```` + +While it's enough for this simple code example, it's always suggested to create scopes in case of directly resolving dependencies from ``IServiceProvider`` (TODO: see DI documentation). \ No newline at end of file diff --git a/docs/Index.md b/docs/Index.md new file mode 100644 index 0000000000..ae05d01d9c --- /dev/null +++ b/docs/Index.md @@ -0,0 +1,9 @@ +# ABP Documentation + +## Table of Contents + +### Overall + +* Getting Started + * With Console Application + * With ASP.NET Core Web Application \ No newline at end of file diff --git a/docs/images/create-new-net-core-console-application.png b/docs/images/create-new-net-core-console-application.png new file mode 100644 index 0000000000..c5f39bfb37 Binary files /dev/null and b/docs/images/create-new-net-core-console-application.png differ