mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
47
lib/yaml/ChangeLog.txt
Normal file
47
lib/yaml/ChangeLog.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
--- 2009-10-04 Osamu TAKEUCHI <osamu@big.jp>
|
||||
Alpha release of YamlSerializer as 0.9.0.2
|
||||
|
||||
* All "_"s in integer and floating point values are neglected
|
||||
to accommodate the !!int and !!float encoding.
|
||||
* YamlConfig.DontUseVerbatimTag is added but the default value is set false.
|
||||
Note that !<!System.Int32[,]> is much human friendly than !System.Int32%5B%2C%5D.
|
||||
* Equality of YamlNode with an unknown tag is evaluated by identity,
|
||||
while that of !!map and !!seq node is still evaluated by YAML's standard.
|
||||
Note that equality of !!map and !!seq are different from that of object[]
|
||||
and Dictionary<object, object>.
|
||||
* YamlConfig.OmitTagForRootNode was added. Fixed issue #2850.
|
||||
* Serialize Dictionary<object,object> to !!map. Fixed #2891.
|
||||
* Modified [126-130] ns-plain-???, [147] c-ns-flow-map-separate-value(n,c)
|
||||
to accommodate revision 2009-10-01
|
||||
* Omit !< > if Tag contains only ns-tag-char, Fixed issue #2813
|
||||
|
||||
--- 2009-09-23 Osamu TAKEUCHI <osamu@big.jp>
|
||||
Alpha release of YamlSerializer as 0.9.0.1
|
||||
|
||||
* Removed TODO's for reporting bugs in YAML spec that are done.
|
||||
* Fixed assembly copyright.
|
||||
* !!merge is supported. Fixed issue#2605.
|
||||
* Read-only class-type member with no child members are omitted when
|
||||
serializing. Fixed issue#2599.
|
||||
* Culture for TypeConverter is set to be CultureInfo.InvariantCulture.
|
||||
Fixed issue #2629.
|
||||
* To fix Issue#2631
|
||||
* Field names and property names are always presented as simple texts.
|
||||
* When deserializing, we can not avoid the parser parses some spacial
|
||||
names to !!bool and !!null. Such non-text nodes are converted to
|
||||
texts at construction stage.
|
||||
* To fix issue#2663
|
||||
* Hash code stored in a mapping node is now updated when the a key node's
|
||||
content is changed.
|
||||
* Hash code and equality became independent on the order of keys in a
|
||||
mapping node.
|
||||
* A mapping node checks for duplicated keys every time the node content
|
||||
is changed.
|
||||
* Test results are changed because some of them are dependent on the hash
|
||||
key order.
|
||||
* The current equality evaluation is too strict, probably needs some adjustment.
|
||||
* NativeObject property was added to YamlScalar.
|
||||
* YamlScalar's equality is evaluated by comparing NativeObject.
|
||||
|
||||
--- 2009-09-11 Osamu TAKEUCHI <osamu@big.jp>
|
||||
First release of YamlSerializer as 0.9.0.0
|
39
lib/yaml/Readme.txt
Normal file
39
lib/yaml/Readme.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
YamlSerializer 0.9.0.2 (2009-10-04) Osamu TAKEUCHI <osamu@big.jp>
|
||||
|
||||
Description:
|
||||
A library that serialize / deserialize C# native objects into YAML1.2 text.
|
||||
|
||||
Development environment:
|
||||
Visual C# 2008 Express Edition
|
||||
Sandcastle (2008-05-29)
|
||||
SandcastleBuilder 1.8.0.2
|
||||
HTML Help workshop 4.74.8702
|
||||
NUnit 2.5.0.9122
|
||||
TestDriven.NET 2.0
|
||||
|
||||
Support web page:
|
||||
http://yamlserializer.codeplex.com/
|
||||
|
||||
License:
|
||||
YamlSerializer is distributed under the MIT license as following:
|
||||
|
||||
---
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2009 Osamu TAKEUCHI <osamu@big.jp>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without limitation the rights to use, copy,
|
||||
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
BIN
lib/yaml/YAML Serializer.chm
Normal file
BIN
lib/yaml/YAML Serializer.chm
Normal file
Binary file not shown.
3770
lib/yaml/YamlSerializer.XML
Normal file
3770
lib/yaml/YamlSerializer.XML
Normal file
File diff suppressed because it is too large
Load Diff
BIN
lib/yaml/YamlSerializer.dll
Normal file
BIN
lib/yaml/YamlSerializer.dll
Normal file
Binary file not shown.
@@ -43,7 +43,7 @@ namespace Orchard.Tests.Modules.Setup {
|
||||
//builder.Register<Notifier>().As<INotifier>();
|
||||
//builder.Register<DefaultOrchardHost>().As<IOrchardHost>();
|
||||
//builder.Register<DatabaseMigrationManager>().As<IDatabaseMigrationManager>();
|
||||
//builder.Register<ShellSettingsLoader>().As<IShellSettingsLoader>();
|
||||
//builder.Register<DefaultTenantManager>().As<ITenantManager>();
|
||||
//builder.Register<TestAppDataFolder>().As<IAppDataFolder>();
|
||||
//_container = builder.Build();
|
||||
}
|
||||
|
@@ -77,5 +77,19 @@ namespace Orchard.Tests.Environment.Configuration {
|
||||
_appDataFolder.CreateFile("alpha\\omega\\foo\\bar.txt", "quux");
|
||||
Assert.That(Directory.Exists(Path.Combine(_tempFolder, "alpha\\omega\\foo")), Is.True);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void FilesCanBeReadBack() {
|
||||
_appDataFolder.CreateFile("alpha\\gamma\\foo\\bar.txt", @"
|
||||
this is
|
||||
a
|
||||
test");
|
||||
var text = _appDataFolder.ReadFile("alpha\\gamma\\foo\\bar.txt");
|
||||
Assert.That(text, Is.EqualTo(@"
|
||||
this is
|
||||
a
|
||||
test"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,76 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Environment.Configuration;
|
||||
|
||||
namespace Orchard.Tests.Environment.Configuration {
|
||||
[TestFixture]
|
||||
public class DefaultTenantManagerTests {
|
||||
private string _tempFolder;
|
||||
private AppDataFolder _appData;
|
||||
|
||||
[SetUp]
|
||||
public void Init() {
|
||||
_appData = new AppDataFolder();
|
||||
_tempFolder = Path.GetTempFileName();
|
||||
File.Delete(_tempFolder);
|
||||
_appData.SetBasePath(_tempFolder);
|
||||
}
|
||||
[TearDown]
|
||||
public void Term() {
|
||||
Directory.Delete(_tempFolder, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SingleSettingsFileShouldComeBackAsExpected() {
|
||||
|
||||
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
|
||||
|
||||
ITenantManager loader = new DefaultTenantManager(_appData);
|
||||
var settings = loader.LoadSettings().Single();
|
||||
Assert.That(settings, Is.Not.Null);
|
||||
Assert.That(settings.Name, Is.EqualTo("Default"));
|
||||
Assert.That(settings.DataProvider, Is.EqualTo("SQLite"));
|
||||
Assert.That(settings.DataConnectionString, Is.EqualTo("something else"));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void MultipleFilesCanBeDetected() {
|
||||
|
||||
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
|
||||
_appData.CreateFile("Sites\\Another\\Settings.txt", "Name: Another\r\nDataProvider: SQLite2\r\nDataConnectionString: something else2");
|
||||
|
||||
ITenantManager loader = new DefaultTenantManager(_appData);
|
||||
var settings = loader.LoadSettings();
|
||||
Assert.That(settings.Count(), Is.EqualTo(2));
|
||||
|
||||
var def = settings.Single(x => x.Name == "Default");
|
||||
Assert.That(def.Name, Is.EqualTo("Default"));
|
||||
Assert.That(def.DataProvider, Is.EqualTo("SQLite"));
|
||||
Assert.That(def.DataConnectionString, Is.EqualTo("something else"));
|
||||
|
||||
var alt = settings.Single(x => x.Name == "Another");
|
||||
Assert.That(alt.Name, Is.EqualTo("Another"));
|
||||
Assert.That(alt.DataProvider, Is.EqualTo("SQLite2"));
|
||||
Assert.That(alt.DataConnectionString, Is.EqualTo("something else2"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NewSettingsCanBeStored() {
|
||||
_appData.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SQLite\r\nDataConnectionString: something else");
|
||||
|
||||
ITenantManager loader = new DefaultTenantManager(_appData);
|
||||
var foo = new ShellSettings {Name = "Foo", DataProvider = "Bar", DataConnectionString = "Quux"};
|
||||
|
||||
Assert.That(loader.LoadSettings().Count(), Is.EqualTo(1));
|
||||
loader.SaveSettings(foo);
|
||||
Assert.That(loader.LoadSettings().Count(), Is.EqualTo(2));
|
||||
|
||||
var text = File.ReadAllText(_appData.MapPath("Sites\\Foo\\Settings.txt"));
|
||||
Assert.That(text, Is.StringContaining("Foo"));
|
||||
Assert.That(text, Is.StringContaining("Bar"));
|
||||
Assert.That(text, Is.StringContaining("Quux"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -47,7 +47,7 @@ namespace Orchard.Tests.Environment {
|
||||
builder.RegisterInstance(new ViewEngineCollection { new WebFormViewEngine() });
|
||||
builder.RegisterInstance(new StuExtensionManager()).As<IExtensionManager>();
|
||||
builder.RegisterInstance(new Mock<IHackInstallationGenerator>().Object);
|
||||
builder.RegisterInstance(new StubShellSettingsLoader()).As<IShellSettingsLoader>();
|
||||
builder.RegisterInstance(new StubShellSettingsLoader()).As<ITenantManager>();
|
||||
});
|
||||
_lifetime = _container.BeginLifetimeScope();
|
||||
var updater = new ContainerUpdater();
|
||||
@@ -55,7 +55,7 @@ namespace Orchard.Tests.Environment {
|
||||
updater.Update(_lifetime);
|
||||
}
|
||||
|
||||
public class StubShellSettingsLoader : IShellSettingsLoader {
|
||||
public class StubShellSettingsLoader : ITenantManager {
|
||||
private readonly List<IShellSettings> _shellSettings = new List<IShellSettings>
|
||||
{new ShellSettings {Name = "testing"}};
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Orchard.Tests.Environment {
|
||||
return Enumerable.Empty<ExtensionEntry>();
|
||||
}
|
||||
|
||||
public IEnumerable<Type> GetExtensionsTopology() {
|
||||
public ShellTopology GetExtensionsTopology() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
@@ -178,14 +178,14 @@ features:
|
||||
public void ExtensionManagerShouldReturnTopology() {
|
||||
var topology = _manager.GetExtensionsTopology();
|
||||
|
||||
Assert.That(topology.Count(), Is.Not.EqualTo(0));
|
||||
Assert.That(topology.Types.Count(), Is.Not.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtensionManagerTopologyShouldContainNonAbstractClasses() {
|
||||
var topology = _manager.GetExtensionsTopology();
|
||||
|
||||
foreach (var type in topology) {
|
||||
foreach (var type in topology.Types) {
|
||||
Assert.That(type.IsClass);
|
||||
Assert.That(!type.IsAbstract);
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ namespace Orchard.Tests.Mvc.Routes {
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerable<Type> GetExtensionsTopology() {
|
||||
public ShellTopology GetExtensionsTopology() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
@@ -153,6 +153,7 @@
|
||||
<Compile Include="Data\StubLocator.cs" />
|
||||
<Compile Include="Environment\AutofacUtil\DynamicProxy2\DynamicProxyTests.cs" />
|
||||
<Compile Include="Environment\Configuration\AppDataFolderTests.cs" />
|
||||
<Compile Include="Environment\Configuration\DefaultTenantManagerTests.cs" />
|
||||
<Compile Include="Environment\DefaultCompositionStrategyTests.cs" />
|
||||
<Compile Include="Environment\DefaultOrchardHostTests.cs" />
|
||||
<Compile Include="Environment\DefaultOrchardShellTests.cs" />
|
||||
|
25
src/Orchard.Web/Config/Sample.Host.config
Normal file
25
src/Orchard.Web/Config/Sample.Host.config
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
|
||||
<configSections>
|
||||
<section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration"/>
|
||||
</configSections>
|
||||
|
||||
<autofac defaultAssembly="Orchard.Framework">
|
||||
<components>
|
||||
|
||||
<component instance-scope="single-instance"
|
||||
type="Orchard.Environment.Configuration.AzureBlobTenantManager"
|
||||
service="Orchard.Environment.Configuration.ITenantManager">
|
||||
<parameters>
|
||||
<parameter name="account" value="devstoreaccount1"/>
|
||||
<parameter name="key" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="/>
|
||||
<parameter name="container" value="mycontainer"/>
|
||||
</parameters>
|
||||
</component>
|
||||
|
||||
</components>
|
||||
</autofac>
|
||||
|
||||
</configuration>
|
||||
|
@@ -21,17 +21,17 @@ namespace Orchard.Setup.Controllers {
|
||||
public class SetupController : Controller {
|
||||
private readonly INotifier _notifier;
|
||||
private readonly IOrchardHost _orchardHost;
|
||||
private readonly IShellSettingsLoader _shellSettingsLoader;
|
||||
private readonly ITenantManager _tenantManager;
|
||||
private readonly IAppDataFolder _appDataFolder;
|
||||
|
||||
public SetupController(
|
||||
INotifier notifier,
|
||||
IOrchardHost orchardHost,
|
||||
IShellSettingsLoader shellSettingsLoader,
|
||||
ITenantManager tenantManager,
|
||||
IAppDataFolder appDataFolder) {
|
||||
_notifier = notifier;
|
||||
_orchardHost = orchardHost;
|
||||
_shellSettingsLoader = shellSettingsLoader;
|
||||
_tenantManager = tenantManager;
|
||||
_appDataFolder = appDataFolder;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ namespace Orchard.Setup.Controllers {
|
||||
}
|
||||
}
|
||||
|
||||
_shellSettingsLoader.SaveSettings(shellSettings);
|
||||
_tenantManager.SaveSettings(shellSettings);
|
||||
|
||||
_orchardHost.Reinitialize();
|
||||
|
||||
|
@@ -164,6 +164,7 @@
|
||||
<Content Include="Themes\TheAdmin\Views\Layout.ascx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Config\Sample.Host.config" />
|
||||
<None Include="Themes\TheAdmin\Styles\images\icons.psd" />
|
||||
<Content Include="Themes\ClassicDark\Content\Images\bodyBackgroundgrey.gif" />
|
||||
<Content Include="Themes\ClassicDark\Content\Images\sidebarBackground.gif" />
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
<appSettings/>
|
||||
|
||||
<system.diagnostics configSource="Config\Diagnostics.config"/>
|
||||
<system.diagnostics configSource="Config\Diagnostics.config" />
|
||||
|
||||
<!--
|
||||
Set default transaction timeout to 30 minutes so that interactive debugging
|
||||
@@ -83,7 +83,7 @@
|
||||
passwordStrengthRegularExpression=""
|
||||
applicationName="/"
|
||||
/>-->
|
||||
<add name="OrchardMembershipProvider" type="Orchard.Security.Providers.OrchardMembershipProvider, Orchard"
|
||||
<add name="OrchardMembershipProvider" type="Orchard.Security.Providers.OrchardMembershipProvider, Orchard.Framework"
|
||||
applicationName="/" />
|
||||
</providers>
|
||||
</membership>
|
||||
@@ -102,7 +102,7 @@
|
||||
<roleManager enabled="false">
|
||||
<providers>
|
||||
<clear />
|
||||
<add name="OrchardRoleProvider" type="Orchard.Security.Providers.OrchardRoleProvider, Orchard"/>
|
||||
<add name="OrchardRoleProvider" type="Orchard.Security.Providers.OrchardRoleProvider, Orchard.Framework"/>
|
||||
<add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
</providers>
|
||||
|
@@ -15,6 +15,7 @@ namespace Orchard.Environment.Configuration {
|
||||
IEnumerable<string> ListDirectories(string path);
|
||||
|
||||
void CreateFile(string path, string content);
|
||||
string ReadFile(string path);
|
||||
void DeleteFile(string path);
|
||||
|
||||
string CreateDirectory(string path);
|
||||
@@ -26,7 +27,6 @@ namespace Orchard.Environment.Configuration {
|
||||
/// </summary>
|
||||
void SetBasePath(string basePath);
|
||||
string MapPath(string path);
|
||||
|
||||
}
|
||||
|
||||
public class AppDataFolder : IAppDataFolder {
|
||||
@@ -44,6 +44,10 @@ namespace Orchard.Environment.Configuration {
|
||||
File.WriteAllText(filePath, content);
|
||||
}
|
||||
|
||||
public string ReadFile(string path) {
|
||||
return File.ReadAllText(Path.Combine(_basePath, path));
|
||||
}
|
||||
|
||||
public void DeleteFile(string path) {
|
||||
File.Delete(Path.Combine(_basePath, path));
|
||||
}
|
||||
|
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Environment.Configuration {
|
||||
public class AzureBlobTenantManager : ITenantManager{
|
||||
public AzureBlobTenantManager(string foo) {
|
||||
int x = 5;
|
||||
}
|
||||
|
||||
public string Foo { get; set; }
|
||||
|
||||
public IEnumerable<IShellSettings> LoadSettings() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveSettings(IShellSettings settings) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Yaml.Serialization;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Environment.Configuration {
|
||||
public class DefaultTenantManager : ITenantManager {
|
||||
private readonly IAppDataFolder _appDataFolder;
|
||||
Localizer T { get; set; }
|
||||
|
||||
public DefaultTenantManager(IAppDataFolder appDataFolder) {
|
||||
_appDataFolder = appDataFolder;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
IEnumerable<IShellSettings> ITenantManager.LoadSettings() {
|
||||
return LoadSettings().ToArray();
|
||||
}
|
||||
|
||||
void ITenantManager.SaveSettings(IShellSettings settings) {
|
||||
if (settings == null)
|
||||
throw new ArgumentException(T("There are no settings to save.").ToString());
|
||||
if (string.IsNullOrEmpty(settings.Name))
|
||||
throw new ArgumentException(T("Settings \"Name\" is not set.").ToString());
|
||||
|
||||
var filePath = Path.Combine(Path.Combine("Sites", settings.Name), "Settings.txt");
|
||||
_appDataFolder.CreateFile(filePath, ComposeSettings(settings));
|
||||
}
|
||||
|
||||
IEnumerable<IShellSettings> LoadSettings() {
|
||||
var filePaths = _appDataFolder
|
||||
.ListDirectories("Sites")
|
||||
.SelectMany(path => _appDataFolder.ListFiles(path))
|
||||
.Where(path => string.Equals(Path.GetFileName(path), "Settings.txt", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
foreach (var filePath in filePaths) {
|
||||
yield return ParseSettings(_appDataFolder.ReadFile(filePath));
|
||||
}
|
||||
}
|
||||
|
||||
class Content {
|
||||
public string Name { get; set; }
|
||||
public string DataProvider { get; set; }
|
||||
public string DataConnectionString { get; set; }
|
||||
public string DataPrefix { get; set; }
|
||||
}
|
||||
|
||||
static IShellSettings ParseSettings(string text) {
|
||||
var ser = new YamlSerializer();
|
||||
var content = ser.Deserialize(text, typeof(Content)).Cast<Content>().Single();
|
||||
return new ShellSettings {
|
||||
Name = content.Name,
|
||||
DataProvider = content.DataProvider,
|
||||
DataConnectionString = content.DataConnectionString,
|
||||
DataPrefix = content.DataPrefix,
|
||||
};
|
||||
}
|
||||
|
||||
static string ComposeSettings(IShellSettings settings) {
|
||||
if (settings == null)
|
||||
return "";
|
||||
|
||||
var ser = new YamlSerializer();
|
||||
return ser.Serialize(new Content {
|
||||
Name = settings.Name,
|
||||
DataProvider = settings.DataProvider,
|
||||
DataConnectionString = settings.DataConnectionString,
|
||||
DataPrefix = settings.DataPrefix,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
8
src/Orchard/Environment/Configuration/ITenantManager.cs
Normal file
8
src/Orchard/Environment/Configuration/ITenantManager.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Environment.Configuration {
|
||||
public interface ITenantManager {
|
||||
IEnumerable<IShellSettings> LoadSettings();
|
||||
void SaveSettings(IShellSettings settings);
|
||||
}
|
||||
}
|
@@ -1,13 +1,15 @@
|
||||
namespace Orchard.Environment.Configuration {
|
||||
public interface IShellSettings {
|
||||
string Name { get; set; }
|
||||
string DataProvider { get; set; }
|
||||
string DataConnectionString { get; set; }
|
||||
string Name { get; }
|
||||
string DataProvider { get; }
|
||||
string DataConnectionString { get; }
|
||||
string DataPrefix { get; }
|
||||
}
|
||||
|
||||
public class ShellSettings : IShellSettings {
|
||||
public string Name { get; set; }
|
||||
public string DataProvider { get; set; }
|
||||
public string DataConnectionString { get; set; }
|
||||
public string DataPrefix { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,93 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Hosting;
|
||||
using Orchard.Localization;
|
||||
using Yaml.Grammar;
|
||||
|
||||
namespace Orchard.Environment.Configuration {
|
||||
public interface IShellSettingsLoader {
|
||||
IEnumerable<IShellSettings> LoadSettings();
|
||||
void SaveSettings(IShellSettings settings);
|
||||
}
|
||||
|
||||
public class ShellSettingsLoader : IShellSettingsLoader {
|
||||
private readonly IAppDataFolder _appDataFolder;
|
||||
Localizer T { get; set; }
|
||||
|
||||
public ShellSettingsLoader(IAppDataFolder appDataFolder) {
|
||||
_appDataFolder = appDataFolder;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
IEnumerable<IShellSettings> IShellSettingsLoader.LoadSettings() {
|
||||
return LoadSettings().ToArray();
|
||||
}
|
||||
|
||||
public void SaveSettings(IShellSettings settings) {
|
||||
if (settings == null)
|
||||
throw new ArgumentException(T("There are no settings to save.").ToString());
|
||||
if (string.IsNullOrEmpty(settings.Name))
|
||||
throw new ArgumentException(T("Settings \"Name\" is not set.").ToString());
|
||||
|
||||
var settingsFile = Path.Combine(Path.Combine("Sites", settings.Name), "Settings.txt");
|
||||
_appDataFolder.CreateFile(settingsFile, ComposeSettings(settings));
|
||||
}
|
||||
|
||||
IEnumerable<IShellSettings> LoadSettings() {
|
||||
foreach (var yamlDocument in LoadFiles()) {
|
||||
yield return ParseSettings(yamlDocument);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<YamlDocument> LoadFiles() {
|
||||
var sitePaths = _appDataFolder
|
||||
.ListDirectories("Sites")
|
||||
.SelectMany(path => _appDataFolder.ListFiles(path))
|
||||
.Where(path => string.Equals(Path.GetFileName(path), "Settings.txt", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
foreach (var sitePath in sitePaths) {
|
||||
var yamlStream = YamlParser.Load(_appDataFolder.MapPath(sitePath));
|
||||
yield return yamlStream.Documents.Single();
|
||||
}
|
||||
}
|
||||
|
||||
static IShellSettings ParseSettings(YamlDocument document) {
|
||||
var mapping = (Mapping)document.Root;
|
||||
var fields = mapping.Entities
|
||||
.Where(x => x.Key is Scalar)
|
||||
.ToDictionary(x => ((Scalar)x.Key).Text, x => x.Value);
|
||||
|
||||
return new ShellSettings {
|
||||
Name = GetValue(fields, "Name"),
|
||||
DataProvider = GetValue(fields, "DataProvider"),
|
||||
DataConnectionString = GetValue(fields, "DataConnectionString")
|
||||
};
|
||||
}
|
||||
|
||||
static string GetValue(
|
||||
IDictionary<string, DataItem> fields,
|
||||
string key) {
|
||||
|
||||
DataItem value;
|
||||
return fields.TryGetValue(key, out value) ? value.ToString() : null;
|
||||
}
|
||||
|
||||
static string ComposeSettings(IShellSettings shellSettings) {
|
||||
if (shellSettings == null)
|
||||
return "";
|
||||
|
||||
var settingsBuilder = new StringBuilder();
|
||||
|
||||
settingsBuilder.AppendLine(string.Format("Name: {0}", shellSettings.Name));
|
||||
settingsBuilder.AppendLine(string.Format("DataProvider: {0}", shellSettings.DataProvider));
|
||||
|
||||
if (!string.IsNullOrEmpty(shellSettings.DataConnectionString))
|
||||
settingsBuilder.AppendLine(string.Format("DataConnectionString: {0}", shellSettings.DataConnectionString));
|
||||
|
||||
return settingsBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,6 +7,7 @@ using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.Extensions.Records;
|
||||
|
||||
namespace Orchard.Environment {
|
||||
//TEMP: This will be replaced by packaging system
|
||||
@@ -30,11 +31,11 @@ namespace Orchard.Environment {
|
||||
}
|
||||
|
||||
public IEnumerable<Type> GetModuleTypes() {
|
||||
return _extensionManager.GetExtensionsTopology().Where(t => typeof(IModule).IsAssignableFrom(t));
|
||||
return _extensionManager.GetExtensionsTopology().Types.Where(t => typeof(IModule).IsAssignableFrom(t));
|
||||
}
|
||||
|
||||
public IEnumerable<Type> GetDependencyTypes() {
|
||||
return _extensionManager.GetExtensionsTopology().Where(t => typeof(IDependency).IsAssignableFrom(t));
|
||||
return _extensionManager.GetExtensionsTopology().Types.Where(t => typeof(IDependency).IsAssignableFrom(t));
|
||||
}
|
||||
|
||||
public IEnumerable<RecordDescriptor> GetRecordDescriptors() {
|
||||
@@ -42,6 +43,7 @@ namespace Orchard.Environment {
|
||||
new RecordDescriptor { Prefix = "Core", Type = typeof (ContentTypeRecord)},
|
||||
new RecordDescriptor { Prefix = "Core", Type = typeof (ContentItemRecord)},
|
||||
new RecordDescriptor { Prefix = "Core", Type = typeof (ContentItemVersionRecord)},
|
||||
new RecordDescriptor { Prefix = "Core", Type = typeof (ExtensionRecord)},
|
||||
};
|
||||
|
||||
foreach (var extension in _extensionManager.ActiveExtensions()) {
|
||||
|
@@ -15,17 +15,17 @@ namespace Orchard.Environment {
|
||||
private readonly ControllerBuilder _controllerBuilder;
|
||||
private readonly IEnumerable<IShellContainerFactory> _shellContainerFactories;
|
||||
|
||||
private readonly IShellSettingsLoader _shellSettingsLoader;
|
||||
private readonly ITenantManager _tenantManager;
|
||||
private IOrchardShell _current;
|
||||
|
||||
|
||||
public DefaultOrchardHost(
|
||||
IContainerProvider containerProvider,
|
||||
IShellSettingsLoader shellSettingsLoader,
|
||||
ITenantManager tenantManager,
|
||||
ControllerBuilder controllerBuilder,
|
||||
IEnumerable<IShellContainerFactory> shellContainerFactories) {
|
||||
_containerProvider = containerProvider;
|
||||
_shellSettingsLoader = shellSettingsLoader;
|
||||
_tenantManager = tenantManager;
|
||||
_controllerBuilder = controllerBuilder;
|
||||
_shellContainerFactories = shellContainerFactories;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace Orchard.Environment {
|
||||
}
|
||||
|
||||
public virtual ILifetimeScope CreateShellContainer() {
|
||||
var settings = _shellSettingsLoader.LoadSettings();
|
||||
var settings = _tenantManager.LoadSettings();
|
||||
if (settings.Any()) {
|
||||
//TEMP: multi-tenancy not implemented yet
|
||||
var shellContainer = CreateShellContainer(settings.Single());
|
||||
|
@@ -1,14 +1,15 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Web.Hosting;
|
||||
using Autofac;
|
||||
using Autofac.Builder;
|
||||
using Autofac.Core;
|
||||
using Autofac.Configuration;
|
||||
using Autofac.Integration.Web;
|
||||
using Orchard.Environment.AutofacUtil;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Extensions.Loaders;
|
||||
using Orchard.Mvc;
|
||||
|
||||
namespace Orchard.Environment {
|
||||
public static class OrchardStarter {
|
||||
@@ -20,7 +21,7 @@ namespace Orchard.Environment {
|
||||
builder.RegisterType<DefaultCompositionStrategy>().As<ICompositionStrategy>().SingleInstance();
|
||||
builder.RegisterType<DefaultShellContainerFactory>().As<IShellContainerFactory>().SingleInstance();
|
||||
builder.RegisterType<AppDataFolder>().As<IAppDataFolder>().SingleInstance();
|
||||
builder.RegisterType<ShellSettingsLoader>().As<IShellSettingsLoader>().SingleInstance();
|
||||
builder.RegisterType<DefaultTenantManager>().As<ITenantManager>().SingleInstance();
|
||||
builder.RegisterType<SafeModeShellContainerFactory>().As<IShellContainerFactory>().SingleInstance();
|
||||
|
||||
// The container provider gives you access to the lowest container at the time,
|
||||
@@ -47,6 +48,15 @@ namespace Orchard.Environment {
|
||||
|
||||
registrations(builder);
|
||||
|
||||
|
||||
var autofacSection = ConfigurationManager.GetSection(ConfigurationSettingsReader.DefaultSectionName);
|
||||
if (autofacSection != null)
|
||||
builder.RegisterModule(new ConfigurationSettingsReader());
|
||||
|
||||
var optionalHostConfig = HostingEnvironment.MapPath("~/Config/Host.config");
|
||||
if (File.Exists(optionalHostConfig))
|
||||
builder.RegisterModule(new ConfigurationSettingsReader(ConfigurationSettingsReader.DefaultSectionName, optionalHostConfig));
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
|
@@ -35,17 +35,18 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
|
||||
// add components by the IDependency interfaces they expose
|
||||
foreach (var serviceType in _compositionStrategy.GetDependencyTypes()) {
|
||||
var registrar = addingModulesAndServices.RegisterType(serviceType)
|
||||
.EnableDynamicProxy(dynamicProxyContext)
|
||||
.InstancePerLifetimeScope();
|
||||
|
||||
foreach (var interfaceType in serviceType.GetInterfaces()) {
|
||||
if (typeof(IDependency).IsAssignableFrom(interfaceType)) {
|
||||
var registrar = addingModulesAndServices.RegisterType(serviceType).As(interfaceType).EnableDynamicProxy(dynamicProxyContext);
|
||||
registrar = registrar.As(interfaceType);
|
||||
if (typeof(ISingletonDependency).IsAssignableFrom(interfaceType)) {
|
||||
registrar.SingleInstance();
|
||||
registrar = registrar.SingleInstance();
|
||||
}
|
||||
else if (typeof(ITransientDependency).IsAssignableFrom(interfaceType)) {
|
||||
registrar.InstancePerDependency();
|
||||
}
|
||||
else {
|
||||
registrar.InstancePerLifetimeScope();
|
||||
registrar = registrar.InstancePerDependency();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -70,17 +70,15 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
.GetExportedTypes()
|
||||
.Where(type => type.IsClass && !type.IsAbstract && typeof(IDependency).IsAssignableFrom(type));
|
||||
foreach (var serviceType in dependencies) {
|
||||
var registrar = builder.RegisterType(serviceType).EnableDynamicProxy(dynamicProxyContext).InstancePerLifetimeScope();
|
||||
foreach (var interfaceType in serviceType.GetInterfaces()) {
|
||||
if (typeof(IDependency).IsAssignableFrom(interfaceType)) {
|
||||
var registrar = builder.RegisterType(serviceType).As(interfaceType).EnableDynamicProxy(dynamicProxyContext);
|
||||
registrar = registrar.As(interfaceType);
|
||||
if (typeof(ISingletonDependency).IsAssignableFrom(interfaceType)) {
|
||||
registrar.SingleInstance();
|
||||
registrar = registrar.SingleInstance();
|
||||
}
|
||||
else if (typeof(ITransientDependency).IsAssignableFrom(interfaceType)) {
|
||||
registrar.InstancePerDependency();
|
||||
}
|
||||
else {
|
||||
registrar.InstancePerLifetimeScope();
|
||||
registrar = registrar.InstancePerDependency();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,15 +16,19 @@ namespace Orchard.Extensions {
|
||||
private readonly IEnumerable<IExtensionFolders> _folders;
|
||||
private readonly IEnumerable<IExtensionLoader> _loaders;
|
||||
private IEnumerable<ExtensionEntry> _activeExtensions;
|
||||
//private readonly IRepository<ExtensionRecord> _extensionRepository;
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public ExtensionManager(
|
||||
IEnumerable<IExtensionFolders> folders,
|
||||
IEnumerable<IExtensionLoader> loaders) {
|
||||
IEnumerable<IExtensionLoader> loaders
|
||||
//IRepository<ExtensionRecord> extensionRepository
|
||||
) {
|
||||
_folders = folders;
|
||||
_loaders = loaders.OrderBy(x => x.Order);
|
||||
//_extensionRepository = extensionRepository;
|
||||
T = NullLocalizer.Instance;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
@@ -97,10 +101,10 @@ namespace Orchard.Extensions {
|
||||
return _activeExtensions;
|
||||
}
|
||||
|
||||
public IEnumerable<Type> GetExtensionsTopology() {
|
||||
public ShellTopology GetExtensionsTopology() {
|
||||
var types = ActiveExtensions().SelectMany(x => x.ExportedTypes);
|
||||
types = types.Concat(typeof(IOrchardHost).Assembly.GetExportedTypes());
|
||||
return types.Where(t => t.IsClass && !t.IsAbstract);
|
||||
return new ShellTopology { Types = types.Where(t => t.IsClass && !t.IsAbstract) };
|
||||
}
|
||||
|
||||
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
||||
@@ -163,8 +167,8 @@ namespace Orchard.Extensions {
|
||||
}
|
||||
|
||||
private IEnumerable<ExtensionEntry> BuildActiveExtensions() {
|
||||
//TODO: this component needs access to some "current settings" to know which are active
|
||||
foreach (var descriptor in AvailableExtensions()) {
|
||||
//_extensionRepository.Create(new ExtensionRecord { Name = descriptor.Name });
|
||||
// Extensions that are Themes don't have buildable components.
|
||||
if (String.Equals(descriptor.ExtensionType, "Module", StringComparison.OrdinalIgnoreCase)) {
|
||||
yield return BuildEntry(descriptor);
|
||||
@@ -172,7 +176,15 @@ namespace Orchard.Extensions {
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsExtensionEnabled(string name) {
|
||||
//ExtensionRecord extensionRecord = _extensionRepository.Get(x => x.Name == name);
|
||||
//if (extensionRecord.Enabled) return true;
|
||||
//return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private ExtensionEntry BuildEntry(ExtensionDescriptor descriptor) {
|
||||
if (!IsExtensionEnabled(descriptor.Name)) return null;
|
||||
foreach (var loader in _loaders) {
|
||||
var entry = loader.Load(descriptor);
|
||||
if (entry != null)
|
||||
|
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
public interface IExtensionManager {
|
||||
IEnumerable<ExtensionDescriptor> AvailableExtensions();
|
||||
IEnumerable<ExtensionEntry> ActiveExtensions();
|
||||
IEnumerable<Type> GetExtensionsTopology();
|
||||
ShellTopology GetExtensionsTopology();
|
||||
void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle);
|
||||
void UninstallExtension(string extensionType, string extensionName);
|
||||
}
|
||||
|
13
src/Orchard/Extensions/Records/ExtensionRecord.cs
Normal file
13
src/Orchard/Extensions/Records/ExtensionRecord.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Orchard.Extensions.Records {
|
||||
public class ExtensionRecord {
|
||||
public ExtensionRecord() {
|
||||
// ReSharper disable DoNotCallOverridableMethodsInConstructor
|
||||
Enabled = true;
|
||||
// ReSharper restore DoNotCallOverridableMethodsInConstructor
|
||||
}
|
||||
|
||||
public virtual int Id { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual bool Enabled { get; set; }
|
||||
}
|
||||
}
|
8
src/Orchard/Extensions/ShellTopology.cs
Normal file
8
src/Orchard/Extensions/ShellTopology.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Extensions {
|
||||
public class ShellTopology {
|
||||
public IEnumerable<Type> Types { get; set; }
|
||||
}
|
||||
}
|
@@ -35,6 +35,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\autofac\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration, Version=2.1.13.813, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\autofac\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Integration.Web, Version=2.1.13.813, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\autofac\Autofac.Integration.Web.dll</HintPath>
|
||||
@@ -101,6 +105,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\yaml\Yaml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="YamlSerializer, Version=0.9.0.2, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\yaml\YamlSerializer.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Data\SessionLocator.cs" />
|
||||
@@ -155,7 +163,9 @@
|
||||
<Compile Include="Environment\AutofacUtil\DynamicProxy2\DynamicProxyExtensions.cs" />
|
||||
<Compile Include="Environment\AutofacUtil\DynamicProxy2\ConstructorFinderWrapper.cs" />
|
||||
<Compile Include="Environment\Configuration\AppDataFolder.cs" />
|
||||
<Compile Include="Environment\Configuration\ShellSettingsLoader.cs" />
|
||||
<Compile Include="Environment\Configuration\AzureBlobTenantManager.cs" />
|
||||
<Compile Include="Environment\Configuration\DefaultTenantManager.cs" />
|
||||
<Compile Include="Environment\Configuration\ITenantManager.cs" />
|
||||
<Compile Include="Environment\AutofacUtil\ContainerUpdater.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\DefaultShellContainerFactory.cs" />
|
||||
<Compile Include="Environment\ShellBuilders\IShellContainerFactory.cs" />
|
||||
@@ -166,6 +176,8 @@
|
||||
<Compile Include="Extensions\ExtensionFolders.cs" />
|
||||
<Compile Include="Extensions\FeatureDescriptor.cs" />
|
||||
<Compile Include="Extensions\Loaders\AreaExtensionLoader.cs" />
|
||||
<Compile Include="Extensions\Records\ExtensionRecord.cs" />
|
||||
<Compile Include="Extensions\ShellTopology.cs" />
|
||||
<Compile Include="Mvc\AntiForgery\ValidateAntiForgeryTokenOrchardAttribute.cs" />
|
||||
<Compile Include="Mvc\FollowReturnUrl\FollowReturnUrlFilter.cs" />
|
||||
<Compile Include="Mvc\Html\FileRegistrationContextExtensions.cs" />
|
||||
|
Reference in New Issue
Block a user