... | ... | @@ -13,7 +13,7 @@ In this document, we will walk through the development of a simple SiLA server t |
|
|
cd sila_csharp
|
|
|
git checkout -b my_first_sila_server
|
|
|
```
|
|
|
![1_create_branch](uploads/7e31cd5199458799916ba0629a9b3314/1_create_branch.png)
|
|
|
![0_branch](uploads/fe43566f6d4619bbfbb22904b56c6635/0_branch.png)
|
|
|
|
|
|
## Project setup
|
|
|
|
... | ... | @@ -21,23 +21,21 @@ git checkout -b my_first_sila_server |
|
|
1. Open the solution file `sila_csharp/sila_csharp.sln`with VisualStudio 2017 (or higher)
|
|
|
|
|
|
2. Create a new subfolder e.g. 'MyFirstServer' within the 'examples' project folder
|
|
|
|
|
|
![2_create_folder](uploads/b6e33a3c175045422a31a19036ecc000/2_create_folder.png)
|
|
|
![3_folder_created](uploads/73c9cf9e349538fb03ce9ecd19ec1138/3_folder_created.png)
|
|
|
![1_create_folder](uploads/beeddfa10d6a50c7caa0b6bce4b3a588/1_create_folder.png)
|
|
|
![2_name_folder](uploads/50cb9f337b3dce205913d0453031c036/2_name_folder.png)
|
|
|
|
|
|
3. Create a new .NET core console application e.g. 'MyFirstServer.App' within the created subfolder (`MyFirstServer`)
|
|
|
|
|
|
![4_create_project](uploads/6394ebc331e9c515bae084f8ccf060bb/4_create_project.png)
|
|
|
![3_create_project](uploads/f73429b7abe7a7d8e215b42c63ba99fe/3_create_project.png)
|
|
|
|
|
|
***NOTE:*** Pay attention to add the `examples\MyFirstServer` folder to the `Location:` entry
|
|
|
![5_create_project_options](uploads/6c12ea2c9a68cc2463c8af91ce338832/5_create_project_options.png)
|
|
|
![4_name_project](uploads/23cef09130a2a839a46450899c76c701/4_name_project.png)
|
|
|
|
|
|
4. Add the SiLA project dependencies `Sila2`and `Sila2.Utils`
|
|
|
|
|
|
*Option 1: Adding package source references:*
|
|
|
|
|
|
![6_select_project_dependencies](uploads/2110c4313a291fd346c136d3f2b1c465/6_select_project_dependencies.png)
|
|
|
![7_project_dependencies](uploads/13c0ae3517f3701aa19f73e6dbbf5e63/7_project_dependencies.png)
|
|
|
![5_add_dependencies](uploads/676f474f672c1647adf2e8b253136a64/5_add_dependencies.png)
|
|
|
![6_select_dependencies](uploads/36a87f922e5614341785211782e34c15/6_select_dependencies.png)
|
|
|
|
|
|
*Option 2: Add the dependencies as NuGet packages*
|
|
|
|
... | ... | @@ -61,14 +59,12 @@ Instead of adding the project to the existing C# repo, you can start with a fres |
|
|
### It all starts with SiLA 2 Features (create the first Feature)
|
|
|
|
|
|
1. Create a `features` sub folder within the `MyFirstServer.App`project
|
|
|
|
|
|
![8_create_features_subfolder](uploads/f9448df3ebf2e1cf4dd226ed8154eb63/8_create_features_subfolder.png)
|
|
|
![8a_features_subfolder](uploads/bc95b02c8de5cbf06c2826c652577230/8a_features_subfolder.png)
|
|
|
![7_create_features_folder](uploads/071f240b267a49e9bd8fe7c0ec2d3ec0/7_create_features_folder.png)
|
|
|
![8_name_features_folder](uploads/834f7befe6a0c96fcb1ae36bcf83a662/8_name_features_folder.png)
|
|
|
|
|
|
2. Create a feature definiton XML file e.g. `MyFirstFeature.sila.xml`
|
|
|
|
|
|
![9_create_feature_file](uploads/579e777ee2caa1c3c331497a9ad53aee/9_create_feature_file.png)
|
|
|
![10_create_feature_file_options](uploads/757de2728e946e4c32bba87f43f7604b/10_create_feature_file_options.png)
|
|
|
![9_add_xml_file](uploads/bd94f4b8c1f59af6d64e597ff1172115/9_add_xml_file.png)
|
|
|
![10_name_feature_file](uploads/6c97aacd40132afa59b4e4841d35ef92/10_name_feature_file.png)
|
|
|
|
|
|
3. Open the created file and add the following XML tag
|
|
|
```xml
|
... | ... | @@ -79,10 +75,10 @@ Instead of adding the project to the existing C# repo, you can start with a fres |
|
|
</Feature>
|
|
|
```
|
|
|
This immediately enables intellisense according to the referenced SiLA 2 Feature Definition schema
|
|
|
![11_feature_definition_intellisense](uploads/6a76e9e5e0f1e3cf6b1078b7e2ea1e0b/11_feature_definition_intellisense.png)
|
|
|
![11_fd_intellisense](uploads/3a8f236070591e7fa75a8ebbc70ff3b5/11_fd_intellisense.png)
|
|
|
|
|
|
**Note**: You may have to enable downloading XML schema in the Visual Studio options.
|
|
|
![11a_incorrect_options](uploads/0507420ea655f234313b415d40676ee9/11a_incorrect_options.png)
|
|
|
![12_fd_intellisense_diabled](uploads/85d8ec09101d66ab966da5e1f1790124/12_fd_intellisense_diabled.png)
|
|
|
|
|
|
To do that, open the `Options` dialog under `Tools|Options` and go to `Text Editor | XML | Miscellanious` and activate the `Automatically download DTDs and schemas` option.
|
|
|
|
... | ... | @@ -132,7 +128,10 @@ To do that, open the `Options` dialog under `Tools|Options` and go to `Text Edit |
|
|
|
|
|
### Generate Protos and Stubs from Features
|
|
|
|
|
|
1. To Generate the protobuf file as well as the C# stubs, add the following code in MyFirstServer.csproj:
|
|
|
1. To Generate the protobuf file as well as the C# stubs, open the MyFirstServer.csproj file for editing
|
|
|
![13_edit_project_file](uploads/75ceee6c6cf15c63e14c000920eef4d9/13_edit_project_file.png)
|
|
|
|
|
|
2. Add the following code:
|
|
|
```
|
|
|
<ItemGroup>
|
|
|
<SilaFeature Include="features\MyFirstFeature.sila.xml" Link="features\%(Filename)%(Extension)"/>
|
... | ... | @@ -150,6 +149,9 @@ This generates the follwing files in the intermediate files folder `obj` after c |
|
|
|
|
|
![14_generated_files](uploads/c8d13302ccfeb6dc6cc46cba58372a1a/14_generated_files.png)
|
|
|
|
|
|
The generated proto file:
|
|
|
![15_proto_file](uploads/b614effc254d09e6d3b7412a54675492/15_proto_file.png)
|
|
|
|
|
|
### Implement gRPC Server Call Handler
|
|
|
|
|
|
1. Create a new implementation class `MyFirstFeatureImpl.cs` of the MyFirstFeature gRPC calls
|
... | ... | |