Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 850 Bytes

DotCommon.md

File metadata and controls

44 lines (31 loc) · 850 Bytes

DotCommon

DotCommon ABP Adapter, see DotCommon

Modules

  • SharpAbp.Abp.DotCommon

Sample

[DependsOn(typeof(AbpDotCommonModule))]
public class MyModule : AbpModule {


}
  • SnowflakeId Generator
public override void ConfigureServices(ServiceConfigurationContext context){
    Configure<SnowflakeIdOptions>(options=>{
        options.WorkerId = 2;
        options.DatacenterId = 2;
    });
}

public class MyApplicationAppService : ApplicationService 
{
    private readonly ISnowflakeIdGenerator _snowflakeIdGenerator;
    public MyApplicationAppService(ISnowflakeIdGenerator snowflakeIdGenerator)
    {
        _snowflakeIdGenerator = snowflakeIdGenerator;
    }

    public long GenerateId(){
        var id = _snowflakeIdGenerator.Create();
        return id;
    }
}