示例#1
0
 public ApiFeature(
     IFullNodeBuilder fullNodeBuilder,
     FullNode fullNode,
     ApiFeatureOptions apiFeatureOptions,
     IAsyncLoopFactory asyncLoopFactory,
     ApiSettings apiSettings,
     ILoggerFactory loggerFactory)
 {
     this.fullNodeBuilder   = fullNodeBuilder;
     this.fullNode          = fullNode;
     this.apiFeatureOptions = apiFeatureOptions;
     this.asyncLoopFactory  = asyncLoopFactory;
     apiSettings.Load(fullNode.Settings);
     this.apiSettings = apiSettings;
     this.logger      = loggerFactory.CreateLogger(this.GetType().FullName);
 }
示例#2
0
        public static IFullNodeBuilder UseApi(this IFullNodeBuilder fullNodeBuilder, Action <ApiSettings> setup = null, Action <ApiFeatureOptions> optionsAction = null)
        {
            // TODO: move the options in to the feature builder
            var options = new ApiFeatureOptions();

            optionsAction?.Invoke(options);

            fullNodeBuilder.ConfigureFeature(features =>
            {
                features
                .AddFeature <ApiFeature>()
                .FeatureServices(services =>
                {
                    services.AddSingleton(fullNodeBuilder);
                    services.AddSingleton(options);
                    services.AddSingleton <ApiSettings>(new ApiSettings(setup));
                });
            });

            return(fullNodeBuilder);
        }