#18040: Adding a list of available themes per tenant

Work Item: 18040

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-12-14 16:49:01 -08:00
parent 1b4a46f053
commit b6fbe4bd63
16 changed files with 279 additions and 176 deletions
@@ -31,7 +31,7 @@ namespace Orchard.Azure.Environment.Configuration {
}
void IShellSettingsManager.SaveSettings(ShellSettings settings) {
var content = ComposeSettings(settings);
var content = ShellSettingsSerializer.ComposeSettings(settings);
var filePath = _fileSystem.Combine(settings.Name, SettingsFilename);
var file = _fileSystem.FileExists(filePath)
@@ -55,83 +55,8 @@ namespace Orchard.Azure.Environment.Configuration {
using (var stream = file.OpenRead())
using (var reader = new StreamReader(stream))
yield return ParseSettings(reader.ReadToEnd());
yield return ShellSettingsSerializer.ParseSettings(reader.ReadToEnd());
}
}
static ShellSettings ParseSettings(string text) {
var shellSettings = new ShellSettings();
if (String.IsNullOrEmpty(text))
return shellSettings;
var settings = text.Split(new[] {"\r\n"}, StringSplitOptions.RemoveEmptyEntries);
foreach (var setting in settings) {
var separatorIndex = setting.IndexOf(Separator);
if(separatorIndex == -1) {
continue;
}
string key = setting.Substring(0, separatorIndex).Trim();
string value = setting.Substring(separatorIndex + 1).Trim();
if (value != EmptyValue) {
switch (key) {
case "Name":
shellSettings.Name = value;
break;
case "DataProvider":
shellSettings.DataProvider = value;
break;
case "State":
shellSettings.State = new TenantState(value);
break;
case "DataConnectionString":
shellSettings.DataConnectionString = value;
break;
case "DataPrefix":
shellSettings.DataTablePrefix = value;
break;
case "RequestUrlHost":
shellSettings.RequestUrlHost = value;
break;
case "RequestUrlPrefix":
shellSettings.RequestUrlPrefix = value;
break;
case "EncryptionAlgorithm":
shellSettings.EncryptionAlgorithm = value;
break;
case "EncryptionKey":
shellSettings.EncryptionKey = value;
break;
case "HashAlgorithm":
shellSettings.HashAlgorithm = value;
break;
case "HashKey":
shellSettings.HashKey = value;
break;
}
}
}
return shellSettings;
}
static string ComposeSettings(ShellSettings settings) {
if (settings == null)
return "";
return string.Format("Name: {0}\r\nDataProvider: {1}\r\nDataConnectionString: {2}\r\nDataPrefix: {3}\r\nRequestUrlHost: {4}\r\nRequestUrlPrefix: {5}\r\nState: {6}\r\nEncryptionAlgorithm: {7}\r\nEncryptionKey: {8}\r\nHashAlgorithm: {9}\r\nHashKey: {10}\r\n",
settings.Name,
settings.DataProvider,
settings.DataConnectionString ?? EmptyValue,
settings.DataTablePrefix ?? EmptyValue,
settings.RequestUrlHost ?? EmptyValue,
settings.RequestUrlPrefix ?? EmptyValue,
settings.State != null ? settings.State.ToString() : String.Empty,
settings.EncryptionAlgorithm ?? EmptyValue,
settings.EncryptionKey ?? EmptyValue,
settings.HashAlgorithm ?? EmptyValue,
settings.HashKey ?? EmptyValue
);
}
}
}