Home News DOC Class DL Others Rice
DOC  >  Development - Dynamic embedded classes  >  Overview and preparation
Overview and preparation

At the beginning

Cooker supports dynamic class embedding.

If your project requires special functionality, you can implement a new class as a dynamic link library.

You can freely extend the functionality of Cooker as you need. Dynamic class embedding is the key to that.


There are a few things to keep in mind when implementing a dynamic embedded class.

In this document, we will explain these points while actually implementing a dynamic embedded class.


Table of contents:


fake class

Sample code

Environment

How to create a project

Reference

Target platform

Assembly name

Addition of files

fake class

As mentioned above, we will proceed with the implementation and explanation of a dynamic embedded class at the same time, but we cannot implement unless the class specifications have been decided.


The class specifications are shown below.

Name is "fake". It is string manipulation class.

It holds a string as internal data.

It has a fitter by a initialization string.

It has setters and a getter to access the internal data.

It has methods for concatenating the internal data and an argument and a method for returning the instance to the uninitialized state.

Sample code

The template for the dynamic embedded class is prepared as an archive.

We will implement the "fake" class by adding and modifying the C # source files in the archive.


The Rtemplate.cs in the archive is shown below.



As shown in the image, we divide the Rtemplate.cs into five parts, each of which is explained on a separate page. In addition, the RtemplateEmbedder.cs, which controls the actual registration of the class, will be explained on a separate page.


Please download the archive from the link below.

The downloaded archive is a 7z format executable file. If you execute this file, the necessary files will be decompressed.

Environment

This document assumes that you use C# language on Microsoft Visual Studio Community 2019.

How to create a project

We need to create a project in order to build C# source files distributed as an archive file on Visual Studio.

It starts Visual Studio and select "Create a new project" to create a project. The type of project to create is as follows.


Class Library

.NET Framework

C#



Next, enter a name for the project, etc. Please enter the following.


Project nameRfake
LocationAny path
Solution nameRfake
Framework.NET Framework 4.6


A new project is created.

References

We need to set a reference to Rice to the project. Please install the latest Rice for x86 from NuGet.


Target platform

Target platform of the project needs to be x86.



Here, target platform is set by the above method, but there are other setting methods. Please set in the appropriate way.

Assembly name

A .dll file for dynamic embedded class must have a name according to the following rules.



The name of the .dll file can specify by setting the assembly name. Here, please specify "Rtype.fake". The name will be "Rtype.fake.dll".


Addition of files

Please load source files, Rtemplate.cs and RtemplateEmbedder.cs, into the project.



Here, source files are loaded by the above method, but there are other loading methods. Please load in the appropriate way.

If there is a Class1.cs file in the project, please delete it.

Next
Copyright © Cooker All rights reserved.