Skip to content

Runtime instance to creation code transformer.

License

Notifications You must be signed in to change notification settings

BrokenEvent/Object2Code

Repository files navigation

GitHub license

Object2Code

Runtime instance to creation code transformer.

Usecase

Object2Code is used to generate the object creation C# code of the runtime objects with pre-existing data. The source object may be configured by user, deserialized or whatever. By using the code from this repository you can create the code to create such object and full it with current runtime data.

Usage Example

Use entry point BrokenEvent.Object2Code.CodeBuilder and pass the source object to one of its methods.

CodeBuilder.BuildStaticReadOnly(obj, "Simple");

The string result of such operation will be something like:

    public static readonly SimpleType Simple = new SimpleType
    {
      IntValue = 25,
      StringValue = ""Hello World"",
      CharValue = '!',
      EnumValue = SimpleEnum.SomeValue
    };

(the code from unit tests).

Formatting

We use two spaces as indent which is set as the default. This may be changed using BuildSettings.Indent as well as the other properties.

About

Runtime instance to creation code transformer.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages