/// <summary> /// Creates instance information based on configuration. /// </summary> /// <param name="config">Instance configuration</param> public InstanceInfo(InstanceConfig config) { if (config == null) { throw new ArgumentNullException("version"); } Config = config; dbService = new Lazy <DatabaseService>(() => new DatabaseService(Config)); version = new Lazy <Version>(GetKenticoVersion); // Ensure backslash to the Config.Url to support VirtualPath URLs. // Sometimes the website is running under virtual path and // the URL looks like this http://localhost/kentico8 // Some modules (RobotsTxtModule, CacheItemsModle, ...) try // to append the relative path to the base URL but // without trailing slash, the relative path is replaced. // E.g.: // var uri = new Uri("http://localhost/kentico8"); // new Uri(uri, "robots.txt"); -> http://localhost/robots.txt // // With trailing slash, the relative path is appended as expected. // var uri = new Uri("http://localhost/kentico8/"); // new Uri(uri, "robots.txt"); -> http://localhost/kentico8/robots.txt uri = new Lazy <Uri>(() => new Uri(Config.Url.EndsWith("/") ? Config.Url : Config.Url + "/")); directory = new Lazy <DirectoryInfo>(() => new DirectoryInfo(Config.Path)); }
/// <summary> /// Creates instance information based on configuration. /// </summary> /// <param name="config">Instance configuration</param> public InstanceInfo(InstanceConfig config) { if (config == null) { throw new ArgumentNullException("version"); } Config = config; dbService = new Lazy<DatabaseService>(() => new DatabaseService(Config)); version = new Lazy<Version>(() => GetKenticoVersion()); // Ensure backslash to the Config.Url to support VirtualPath URLs. // Sometimes the website is running under virtual path and // the URL looks like this http://localhost/kentico8 // Some modules (RobotsTxtModule, CacheItemsModle, ...) try // to append the relative path to the base URL but // without trailing slash, the relative path is replaced. // E.g.: // var uri = new Uri("http://localhost/kentico8"); // new Uri(uri, "robots.txt"); -> http://localhost/robots.txt // // With trailing slash, the relative path is appended as expected. // var uri = new Uri("http://localhost/kentico8/"); // new Uri(uri, "robots.txt"); -> http://localhost/kentico8/robots.txt uri = new Lazy<Uri>(() => new Uri(Config.Url.EndsWith("/") ? Config.Url : Config.Url + "/")); directory = new Lazy<DirectoryInfo>(() => new DirectoryInfo(Config.Path)); }
public void EnsureTrailingSlash(string url, string expected) { var instanceConfig = new InstanceConfig { Url = url }; var instanceInfo = new InstanceInfo(instanceConfig); Assert.AreEqual(expected, instanceInfo.Uri.AbsoluteUri); }
/// <summary> /// Creates instance information based on configuration. /// </summary> /// <param name="config">Instance configuration</param> public InstanceInfo(InstanceConfig config) { if (config == null) { throw new ArgumentNullException("version"); } Config = config; dbService = new Lazy<DatabaseService>(() => new DatabaseService(Config)); version = new Lazy<Version>(() => GetKenticoVersion()); uri = new Lazy<Uri>(() => new Uri(Config.Url)); directory = new Lazy<DirectoryInfo>(() => new DirectoryInfo(Config.Path)); }
/// <summary> /// Builds connection string based on instance configuration. /// </summary> private string BuildConnectionString(InstanceConfig config) { SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder(); if (config.IntegratedSecurity) { sb.IntegratedSecurity = true; } else { sb.UserID = config.User; sb.Password = config.Password; } sb["Server"] = config.Server; sb["Database"] = config.Database; return(sb.ConnectionString); }
public DatabaseService(InstanceConfig config) { mConnectionString = BuildConnectionString(config); }