neo-sharp

neo-sharp

  • Docs
  • English
    • Português (Brasil)

›NEO-Sharp

Home

  • Introduction
  • Basic Guide
  • Intermediate Guide
  • Advanced Guide

Blockchain

  • Block
  • Blockchain
  • Cryptography
  • Hash
  • Header
  • Unspent Transaction Output

NEO

  • Compiler
  • Consensus
  • Contract
  • Fees
  • GAS
  • NEO VM
  • NEP
  • Network Protocol
  • Nodes
  • RCP
  • Transaction Types
  • Verification
  • Wallets
  • Witness

NEO-Sharp

  • Modules
  • Application Module
  • Configuration Module
  • Core Module
  • Logging Module
  • Persistence Module
  • Serialization Module
  • Wallet Module

Development

  • Best Practices
  • Code Style
  • Dependency Injection
  • Unit Test

Tools

  • .NET Core
  • Documentation
  • Git / GitHub
  • NEO Tools
  • Platform

Modules

VM

Create a new module

Create a new folder in the NeoSharp.Core project following the naming structure 'ModuleName';

Example:
NeoSharp.Core/Persistence

Create an Interfaces containing your module specifications.

Example:
NeoSharp.Core/Persistence/IRepository.cs

Create an implementations for your Interface. In neo-sharp we have two implementations for the same interface, which means that we can easily change the desired implementation.

Example:
NeoSharp.Persistence.RedisDB/RedisDbRepository.cs
NeoSharp.Persistence.RocksDB/RocksDbRepository.cs

Create a class to register your dependency injection in the NeoSharp.Application/DI project.

Example:
NeoSharp.Application/DI/PersistenceModule.cs

Check your configuration file and choose which one implementation will be use, to register use 'containerBuilder.RegisterSingleton' or 'containerBuilder.Register'.

Example:

var cfg = PersistenceConfig.Instance();

switch (cfg.Provider)
{
    case RedisDbConfig.Provider:
        {
            containerBuilder.RegisterSingleton<RedisDbConfig>();
            containerBuilder.RegisterSingleton<IRepository, RedisDbRepository>();
            containerBuilder.RegisterSingleton<IRedisDbContext, RedisDbContext>();
            break;
        }

    case RocksDbConfig.Provider:
        {
            containerBuilder.RegisterSingleton<RocksDbConfig>();
            containerBuilder.RegisterSingleton<IRepository, RocksDbRepository>();
            containerBuilder.RegisterSingleton<IRocksDbContext, RocksDbContext>();
            break;
        }

    default:
        throw new Exception($"The persistence configuration contains unknown provider \"{cfg.Provider}\"");
}

To register your module onto application, add method 'containerBuilder.RegisterModule' in 'NeoSharp.Application/Program.cs'

Example:
containerBuilder.RegisterModule<PersistenceModule>();

In neo-sharp, unit test its mandatory, for more information UNIT TEST

← WitnessApplication Module →
  • VM
  • Create a new module
neo-sharp
Docs
Getting StartedGuides
Community
DiscordRedditFacebookTwitterMedium
More
NEOCoZStar