Example #1
0
        internal static DreamApplication Create(DreamApplicationConfiguration configuration)
        {
            var environment = new DreamApplication(configuration);

            HttpContext.Current.Application[ENV_CONFIG_KEY] = environment;
            return(environment);
        }
Example #2
0
 //--- Constructors ---
 private DreamApplication(DreamApplicationConfiguration appConfig)
 {
     _appConfig = appConfig;
     _env = new DreamHostService();
     Initialize();
     RegisterDefaultRoute();
     _self = Plug.New(_env.Self.Uri.AtAbsolutePath("/"));
 }
Example #3
0
 //--- Constructors ---
 private DreamApplication(DreamApplicationConfiguration appConfig)
 {
     _appConfig = appConfig;
     _env       = new DreamHostService();
     Initialize();
     RegisterDefaultRoute();
     _self = Plug.New(_env.Self.Uri.AtAbsolutePath("/"));
 }
Example #4
0
        /// <summary>
        /// Create configuration from <see cref="ConfigurationManager.AppSettings"/>, execution base path and storage path.
        /// </summary>
        /// <param name="basePath">File system path to execution base.</param>
        /// <param name="storagePath">File sytem path to where the host should keep it's local storage.</param>
        /// <returns>Configuration instance.</returns>
        public static DreamApplicationConfigurationBuilder FromAppSettings(string basePath, string storagePath)
        {
            var config       = new DreamApplicationConfiguration();
            var settings     = ConfigurationManager.AppSettings;
            var debugSetting = settings["dream.env.debug"] ?? "debugger-only";

            if (string.IsNullOrEmpty(storagePath))
            {
                storagePath = settings["dream.storage.path"] ?? settings["storage-dir"] ?? Path.Combine(basePath, "App_Data");
            }
            if (string.IsNullOrEmpty(storagePath))
            {
                storagePath = Path.Combine(basePath, "storage");
            }
            else if (!Path.IsPathRooted(storagePath))
            {
                storagePath = Path.Combine(basePath, storagePath);
            }
            var guid     = settings["dream.guid"] ?? settings["guid"];
            var hostPath = settings["dream.host.path"] ?? settings["host-path"];

            config.Apikey = settings["dream.apikey"] ?? settings["apikey"] ?? StringUtil.CreateAlphaNumericKey(8);
            config.DreamInParamAuthToken = settings["dream.in.authtoken"];
            config.HostConfig            = new XDoc("config")
                                           .Elem("guid", guid)
                                           .Elem("storage-dir", storagePath)
                                           .Elem("host-path", hostPath)
                                           .Elem("connect-limit", settings["connect-limit"])
                                           .Elem("apikey", config.Apikey)
                                           .Elem("debug", debugSetting);
            var rootRedirect = settings["dream.root.redirect"];

            if (!string.IsNullOrEmpty(rootRedirect))
            {
                config.HostConfig.Elem("root-redirect", rootRedirect);
            }
            config.ServicesDirectory = settings["dream.service.path"] ?? settings["service-dir"] ?? Path.Combine("bin", "services");
            if (!Path.IsPathRooted(config.ServicesDirectory))
            {
                config.ServicesDirectory = Path.Combine(basePath, config.ServicesDirectory);
            }
            return(new DreamApplicationConfigurationBuilder(config));
        }
Example #5
0
 //--- Constructors ---
 private DreamApplicationConfigurationBuilder(DreamApplicationConfiguration configuration)
 {
     _configuration = configuration;
 }
Example #6
0
 internal static DreamApplication Create(DreamApplicationConfiguration configuration)
 {
     var environment = new DreamApplication(configuration);
     HttpContext.Current.Application[ENV_CONFIG_KEY] = environment;
     return environment;
 }
 //--- Constructors ---
 private DreamApplicationConfigurationBuilder(DreamApplicationConfiguration configuration)
 {
     _configuration = configuration;
 }
 /// <summary>
 /// Create configuration from <see cref="ConfigurationManager.AppSettings"/>, execution base path and storage path.
 /// </summary>
 /// <param name="basePath">File system path to execution base.</param>
 /// <param name="storagePath">File sytem path to where the host should keep it's local storage.</param>
 /// <returns>Configuration instance.</returns>
 public static DreamApplicationConfigurationBuilder FromAppSettings(string basePath, string storagePath)
 {
     var config = new DreamApplicationConfiguration();
     var settings = ConfigurationManager.AppSettings;
     var debugSetting = settings["dream.env.debug"] ?? "debugger-only";
     if(string.IsNullOrEmpty(storagePath)) {
         storagePath = settings["dream.storage.path"] ?? settings["storage-dir"] ?? Path.Combine(basePath, "App_Data");
     }
     if(string.IsNullOrEmpty(storagePath)) {
         storagePath = Path.Combine(basePath, "storage");
     } else if(!Path.IsPathRooted(storagePath)) {
         storagePath = Path.Combine(basePath, storagePath);
     }
     var guid = settings["dream.guid"] ?? settings["guid"];
     var hostPath = settings["dream.host.path"] ?? settings["host-path"];
     config.Apikey = settings["dream.apikey"] ?? settings["apikey"] ?? StringUtil.CreateAlphaNumericKey(8);
     config.DreamInParamAuthToken = settings["dream.in.authtoken"];
     config.HostConfig = new XDoc("config")
         .Elem("guid", guid)
         .Elem("storage-dir", storagePath)
         .Elem("host-path", hostPath)
         .Elem("connect-limit", settings["connect-limit"])
         .Elem("apikey", config.Apikey)
         .Elem("debug", debugSetting);
     var rootRedirect = settings["dream.root.redirect"];
     if(!string.IsNullOrEmpty(rootRedirect)) {
         config.HostConfig.Elem("root-redirect", rootRedirect);
     }
     config.ServicesDirectory = settings["dream.service.path"] ?? settings["service-dir"] ?? Path.Combine("bin", "services");
     if(!Path.IsPathRooted(config.ServicesDirectory)) {
         config.ServicesDirectory = Path.Combine(basePath, config.ServicesDirectory);
     }
     return new DreamApplicationConfigurationBuilder(config);
 }