Esempio n. 1
0
        public Task <IList <ObjectCountInfo> > GetInfos()
        {
            var simpleJson       = SimpleJson.Resolve();
            var simpleJsonFile   = SimpleJson.ResolveSimpleJsonFile();
            var simpleLogFactory = SimpleLogFactory.Resolve();

            var objectCountInfos = ObjectCountInfo.Create(ObjectCounter.Instance);

            return(Task.FromResult(objectCountInfos));
        }
Esempio n. 2
0
        public static void AddCommon(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddSingleton(SimpleJson.Resolve() as SimpleJson);
            services.AddSingleton(SimpleJson.Resolve());
            services.AddSingleton(SimpleJson.ResolveSimpleJsonFile());

            services.AddSingleton(SimpleLogFactory.Resolve() as SimpleLogFactory);
            services.AddSingleton(SimpleLogFactory.Resolve());

            services.AddSingleton(WebApiHelper.Resolve() as WebApiHelper);
            services.AddSingleton(WebApiHelper.Resolve());

            services.AddSingleton(AsyncFile.Instance);

            //also can use like this:
            //services.AddSingleton<WebApiHelper>();
            //services.AddSingleton<IWebApiHelper>(sp => sp.GetService<WebApiHelper>());
            //WebApiHelper.Resolve = () => app.ApplicationServices.GetService<IWebApiHelper>(); //in Config process
        }