Esempio n. 1
0
        private DB.AutoBox Database(string folderName)
        {
            var dbPath = Path.Combine(RootPathProvider.GetRootPath(), "App_Data", folderName);

            if (!Directory.Exists(dbPath))
            {
                Directory.CreateDirectory(dbPath);
            }

            var server = new DB(dbPath);

            var config = server.GetConfig();

            config.EnsureTable <Author>(DBTableNames.Authors, "Id");
            //config.EnsureIndex<Author>(DBTableNames.Authors, "Email");
            config.EnsureTable <BlogPost>(DBTableNames.BlogPosts, "Id");
            //config.EnsureIndex<BlogPost>(DBTableNames.BlogPosts, "TitleSlug", "Status", "PubDate", "DateUTC");
            config.EnsureTable <BlogComment>(DBTableNames.BlogComments, "Id");
            //config.EnsureIndex<BlogComment>(DBTableNames.BlogComments, "PostId");
            config.EnsureTable <SpamHash>(DBTableNames.SpamHashes, "Id");
            config.EnsureTable <Tag>(DBTableNames.Tags, "Slug");

            var db = server.Open();

            return(db);
        }
Esempio n. 2
0
        public D1SoccerBootstrapper()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(RootPathProvider.GetRootPath())
                          .AddJsonFile("appsettings.json")
                          .AddEnvironmentVariables();

            Configuration = builder.Build();
        }
Esempio n. 3
0
        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            var provider = new FileContentProvider(Path.Combine(RootPathProvider.GetRootPath(), "Content\\Posts"));

            container.Register <IContentProvider, FileContentProvider>(provider);
            container.Register <IMarkdownService, MarkdownService>().AsSingleton();
            container.Register <IPostParser, KiwiMarkdownPostParser>().AsSingleton();
            container.Register <PostProvider>().AsSingleton();
        }
Esempio n. 4
0
        protected override void ConfigureConventions(NancyConventions conventions)
        {
            base.ConfigureConventions(conventions);
            var rootPath = RootPathProvider.GetRootPath();

            conventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("", rootPath + @"\public")
                );
        }
        public CustomBootstrapper()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(RootPathProvider.GetRootPath())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile("appsettings.dev.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();
        }
        public CustomBootstrapper()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(RootPathProvider.GetRootPath())
                          .AddJsonFile("appsettings.json")
                          .AddEnvironmentVariables();
            var tracingConfig = new TraceConfiguration(true, true);

            Configuration = builder.Build();
        }
        public AppBootstrapper(IHostingEnvironment env)
        {
            _hostingEnvironment = env;

            var builder = new ConfigurationBuilder()
                          .SetBasePath(RootPathProvider.GetRootPath())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            _configuration = builder.Build();
        }
Esempio n. 8
0
        public StorylineBackendBootstrapper()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(RootPathProvider.GetRootPath())
                          .AddJsonFile("appsettings.json")
                          .AddEnvironmentVariables();

            Configuration = builder.Build();
            // auto denpendency injection not working, mannually new this
            _fileUploadHandler = new UploadHandler(Configuration, RootPathProvider);
            _layoutHandler     = new LayoutHandler(Configuration, RootPathProvider);
        }
Esempio n. 9
0
        private StaticContentProvider BuildStaticContentProvider()
        {
            var rootPathProvider         = new RootPathProvider();
            var staticContnetConventions = new StaticContentsConventions(new List <Func <Context, string, Response> >
            {
                StaticContentConventionBuilder.AddDirectory("Content")
            });
            var staticContentProvider = new StaticContentProvider(rootPathProvider, staticContnetConventions);

            FileResponse.SafePaths.Add(rootPathProvider.GetRootPath());

            return(staticContentProvider);
        }
Esempio n. 10
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            if (string.IsNullOrWhiteSpace(SettingsHelper.RootPath))
            {
                SettingsHelper.RootPath = RootPathProvider.GetRootPath();
            }

            // 默认情况下,nancy在序列化时将对json key进行大小写装换,效果如下
            // Serialize: NotificationId->notificationId
            // Deserialize: notificationId->NotificationId
            // 如需保存大小写,设置RetainCasing为true(默认为false)
            JsonSettings.RetainCasing = true;

            //初始化日志
            ApiBaseService.Initialize();
        }
Esempio n. 11
0
    protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
    {
        base.ApplicationStartup(container, pipelines);

        var dbpath = Path.Combine(RootPathProvider.GetRootPath(), "App_Data");

        if (!Directory.Exists(dbpath))
        {
            Directory.CreateDirectory(dbpath);
        }

        DB.Root(dbpath);
        var server = new DB(1);
        var config = server.GetConfig();

        config.EnsureTable("Test", new Dictionary <string, object> {
            { "ID", 0L }
        });
        MyDB.DB = server.Open();
    }
Esempio n. 12
0
 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     container.Register(new FigaroDataContext(RootPathProvider.GetRootPath()));
 }