Fixing Widget / Scripting / Framework dependency loading.

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-11-20 15:38:56 -08:00
parent e208860ea2
commit 53bddd53d9
25 changed files with 38 additions and 44 deletions

View File

@@ -87,8 +87,8 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\IScriptingManager.cs" />
<Compile Include="Services\IScriptingRuntime.cs" />
<Compile Include="Services\RubyScriptingRuntime.cs" />
<Compile Include="Services\ScriptingManager.cs" />
<Compile Include="Services\ScriptingRuntime.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">

View File

@@ -9,4 +9,4 @@ namespace Orchard.Scripting.Services {
void ExecuteFile(string fileName);
dynamic ExecuteOperation(Func<ObjectOperations, object> invoke);
}
}
}

View File

@@ -6,4 +6,4 @@ namespace Orchard.Scripting.Services {
dynamic ExecuteExpression(string expression, ScriptScope scope);
void ExecuteFile(string fileName, ScriptScope scope);
}
}
}

View File

@@ -2,11 +2,11 @@
using Microsoft.Scripting.Hosting;
namespace Orchard.Scripting.Services {
public class ScriptingRuntime : IScriptingRuntime {
public class RubyScriptingRuntime : IScriptingRuntime {
private readonly LanguageSetup _defaultLanguageSetup;
private readonly ScriptRuntime _scriptingRuntime;
public ScriptingRuntime() {
public RubyScriptingRuntime() {
_defaultLanguageSetup = Ruby.CreateRubySetup();
var setup = new ScriptRuntimeSetup();
@@ -14,7 +14,7 @@ namespace Orchard.Scripting.Services {
_scriptingRuntime = new ScriptRuntime(setup);
}
ScriptEngine GetDefaultEngine() {
public ScriptEngine GetDefaultEngine() {
return _scriptingRuntime.GetEngineByTypeName(_defaultLanguageSetup.TypeName);
}
@@ -33,4 +33,4 @@ namespace Orchard.Scripting.Services {
engine.ExecuteFile(fileName, scope);
}
}
}
}

View File

@@ -4,8 +4,8 @@ using Microsoft.Scripting.Hosting;
namespace Orchard.Scripting.Services {
public class ScriptingManager : IScriptingManager {
private readonly IScriptingRuntime _scriptingRuntime;
private Lazy<ScriptScope> _scope;
private Lazy<ObjectOperations> _operations;
private readonly Lazy<ScriptScope> _scope;
private readonly Lazy<ObjectOperations> _operations;
public ScriptingManager(IScriptingRuntime scriptingRuntime) {
_scriptingRuntime = scriptingRuntime;
@@ -32,6 +32,5 @@ namespace Orchard.Scripting.Services {
public void ExecuteFile(string fileName) {
_scriptingRuntime.ExecuteFile(fileName, _scope.Value);
}
}
}
}

View File

@@ -69,7 +69,7 @@ namespace Orchard.Setup.Services {
string[] hardcoded = {
// Framework
"Orchard.Framework",
// Core
"Common",
"Containers",
@@ -98,6 +98,7 @@ namespace Orchard.Setup.Services {
"Orchard.Tags",
"Orchard.Themes",
"Orchard.Users",
"Orchard.Scripting",
"Orchard.Widgets",
"TinyMce",
@@ -108,7 +109,6 @@ namespace Orchard.Setup.Services {
context.EnabledFeatures = hardcoded;
}
var shellSettings = new ShellSettings(_shellSettings);
if (string.IsNullOrEmpty(shellSettings.DataProvider)) {

View File

@@ -4,7 +4,6 @@ using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Localization;
using Orchard.UI.Widgets;
using Orchard.Widgets.Models;
using Orchard.Widgets.Services;

View File

@@ -7,8 +7,8 @@ using Orchard.Localization;
using Orchard.Logging;
using Orchard.Mvc.Filters;
using Orchard.UI.Admin;
using Orchard.UI.Widgets;
using Orchard.Widgets.Models;
using Orchard.Widgets.Services;
namespace Orchard.Widgets.Filters {
public class WidgetFilter : FilterProvider, IResultFilter {

View File

@@ -9,4 +9,4 @@ Features:
Orchard.Widgets:
Description: An implementation of widgets.
Category: Widget
Dependencies: Orchard.Scripting
Dependencies: Orchard.Scripting

View File

@@ -88,7 +88,10 @@
<Compile Include="RuleEngine\BuiltinRuleProvider.cs" />
<Compile Include="RuleEngine\RuleManager.cs" />
<Compile Include="RuleEngine\UrlRuleProvider.cs" />
<Compile Include="Services\IRuleManager.cs" />
<Compile Include="Services\IRuleProvider.cs" />
<Compile Include="Services\IWidgetsService.cs" />
<Compile Include="Services\RuleContext.cs" />
<Compile Include="Services\WidgetsService.cs" />
<Compile Include="Shapes.cs" />
<Compile Include="ViewModels\WidgetsIndexViewModel.cs" />

View File

@@ -1,6 +1,6 @@
using System;
using Orchard.Security;
using Orchard.UI.Widgets;
using Orchard.Widgets.Services;
namespace Orchard.Widgets.RuleEngine {
public class AuthenticatedRuleProvider : IRuleProvider {

View File

@@ -1,5 +1,5 @@
using System;
using Orchard.UI.Widgets;
using Orchard.Widgets.Services;
namespace Orchard.Widgets.RuleEngine {
public class BuiltinRuleProvider : IRuleProvider {

View File

@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Orchard.Scripting;
using Orchard.Scripting.Services;
using Orchard.UI.Widgets;
using Orchard.Widgets.Services;
namespace Orchard.Widgets.RuleEngine {
public class RuleManager : IRuleManager {
@@ -17,15 +16,15 @@ namespace Orchard.Widgets.RuleEngine {
public bool Matches(string expression) {
object execContextType = _scriptingManager.ExecuteExpression(@"
class ExecContext
def execute(callbacks, text)
@callbacks = callbacks;
temp = instance_eval(text.to_s);
@callbacks = 0;
def execute(callbacks, text)
@callbacks = callbacks;
temp = instance_eval(text.to_s);
@callbacks = 0;
return temp;
end
end
def method_missing(name, *args, &block)
@callbacks.send(name, args, &block);
def method_missing(name, *args, &block)
@callbacks.send(name, args, &block);
end
end
ExecContext

View File

@@ -1,6 +1,6 @@
using System;
using Orchard.Mvc;
using Orchard.UI.Widgets;
using Orchard.Widgets.Services;
namespace Orchard.Widgets.RuleEngine {
public class UrlRuleProvider : IRuleProvider {

View File

@@ -0,0 +1,5 @@
namespace Orchard.Widgets.Services {
public interface IRuleManager : IDependency {
bool Matches(string expression);
}
}

View File

@@ -0,0 +1,6 @@
namespace Orchard.Widgets.Services {
public interface IRuleProvider : IDependency {
void Process(RuleContext ruleContext);
}
}

View File

@@ -0,0 +1,7 @@
namespace Orchard.Widgets.Services {
public class RuleContext {
public string FunctionName { get; set; }
public object[] Arguments { get; set; }
public object Result { get; set; }
}
}