Giter Site home page Giter Site logo

am1goo / storm.net Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 226 KB

STORM (Strong Typed Object Referenced Model) - another way to make a deal with configuration files

Home Page: https://github.com/am1goo/Storm.Net

License: MIT License

C# 99.95% Batchfile 0.05%
csharp deserialization dotnet include inline serialization strong system text typed

storm.net's Introduction

GitHub Issues or Pull Requests GitHub Issues or Pull Requests GitHub License

NuGet Version NuGet Downloads

Storm.Net

STORM (Strong Typed Object Referenced Model) - another way to make a deal with configuration files.
It's easy to use and give to you unlimited power to control every field or property in your file.

Why I made it?

I've worked in the video game industry at least 10 year and I've see how many errors was produced by a development team who works with JSON config files. Each error has chance to produce bugs and our most large time-eaters - tasks in trackers!
As you know, a lot of games used JSON format to declare game data and all of those files can be huge!
For example: GTA 5 game config has 63k items and 10mb size!
And I've decided that it could be easy to modify if it will have some tips like type definitions.

Syntax

Parameter key and his type shoud be separate by : colon symbol.
Value should be next after = equals sign.

  • Primitive and custom types, also enums: {param name}:{type} = {value}
  • Arrays: {array name} = [ .. any values between brackets .. ]
  • Objects: {object name} = { .. any properties between braces .. }

Built-in primitive types:

  • b - boolean
  • bt - byte
  • sbt - signed byte
  • s - short (int16)
  • us - unsigned short (uint16)
  • i - integer (int32)
  • ui - unsigned integer (uint32)
  • l - long (int64)
  • ul - unsigned long (uint64)
  • f - single aka float
  • d - double
  • dec - decimal
  • t - string
  • e - enum
  • url - path to external file

File association and format

.storm - is preferred extension for STORM files

#this is a comment

#b - means "boolean" and can be one of case-insensitives values 'yes' or '1' or 'tRuE' or 'no' or '0' or 'fAlSe'
param_1:b = yes

#i - means "integer"
param_2:i = -123

#f - means "float"
param_3:f = 32.32

#t - means "text" or "string"
param_4:t = this is a single line

param_5:t = "and this is a multi line
also called \"The King of Strings\".
It's not a joke!"

#objects should be mapped w/o any type
obj_1 = {
  field_1:t = "I'm a first field"
  field_2:s = 123
  field_3 = {
    arg_1:i = 123
    arg_2:sbt = 4
  }
}

#arrays should be mapped w/o any type as well
#also all array values can no have names
array_1 = [
  :t = "first element"
  :t =second element
  :t = "3rd element
in two lines"
]

#any inline objects should be mapped via type 'url'
obj = {
  internal:url = file:///home/user/internal.storm
  external:url = http://youhostname.domain/files/external.storm
}

Features

  • All types of primitive types
  • Enum deserialization from strings or numbers
  • Single-line and multi-line strings
  • Ability to inline any amount of inherit files (from local files or web servers)
  • Customization of deserialization process (you can add support to any your custom types!)

Installation

You can install NuGet package am1goo.Storm.Net into a .NET project.

  1. Open a command prompt and go to your's project folder
  2. Use the following command to install the Storm.Net package:
dotnet add package am1goo.Storm.Net
  1. After the command completes, open the .csproj file in Visual Studio to see the added NuGet package reference:
<ItemGroup>
  <PackageReference Include="am1goo.Storm.Net" Version="1.0.5" />
</ItemGroup>

Roadmap

  • Derialization from text or file
  • Serialization to text or file
  • Simplified serialization/deserialization of built-in C# collection types:
    • List<T>
    • LinkedList<T>
    • HashSet<T>
    • Queue<T>
    • ConcurrentQueue<T>
  • Simplified serialization/deserialization of built-in C# dictionary types:
    • Dictionary<KEY,VALUE>
    • Hashtable

Attributes

  • StormIgnoreAttribute - use to ignore property or field from serialization/deserialization process (along side with DataMemberIgnoreAttribute)
  • StormIncludeAttribute - use to add property or field into serialization/deserialization process
  • StormEnumAttribute - use to set specific type of Enum serialization

Example

using Storm;
using Storm.Serializers;

public class Example
{
  var settings = new StormSettings
  {
    options = StormSettings.Options.IgnoreCase,
    defaultBooleanStyle = StormBooleanStyle.Boolean,
    defaultEnumFormat = StormEnumFormat.String,
    encoding = System.Text.Encoding.UTF8,
    intentSize = 2,
    numberDecimalSeparator = ".",
    converters = new List<IStormConverter>
    {
      new UrlStormConverter(), //added ability to load parts of data from other files
    },
  };

  var serializer = new StormSerializer();
  var obj = await serializer.DeserializeFileAsync("Examples/test-file.storm", settings);
  /* do something with obj */
}

Requirements

  • Visual Studio 2019 or higher
  • .NET App 2.0 or higher
  • .NET Standard 2.1 or higher
  • .NET Core 5.0 and higher

Contribute

Contribution in any form is very welcome. Bugs, feature requests or feedback can be reported in form of Issues.

storm.net's People

Contributors

am1goo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.