mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Moving scripting outside of framework.
--HG-- branch : dev
This commit is contained in:
11
src/Orchard.Web/Modules/Orchard.Scripting/Module.txt
Normal file
11
src/Orchard.Web/Modules/Orchard.Scripting/Module.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
Name: Scripting
|
||||
AntiForgery: enabled
|
||||
Author: The Orchard Team
|
||||
Website: http://orchardproject.net
|
||||
Version: 0.8.0
|
||||
OrchardVersion: 0.8.0
|
||||
Description: The scripting module enables the possibility to execute scripts.
|
||||
Features:
|
||||
Orchard.Scripting:
|
||||
Description: Scripting support.
|
||||
Category: Scripting
|
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{2AD6973D-C7BB-416E-89FE-EEE34664E05F}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Orchard.Search</RootNamespace>
|
||||
<AssemblyName>Orchard.Search</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<MvcBuildViews>false</MvcBuildViews>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="IronRuby, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\dlr\IronRuby.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronRuby.Libraries, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\dlr\IronRuby.Libraries.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Dynamic, Version=1.1.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\dlr\Microsoft.Dynamic.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Scripting, Version=1.1.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\dlr\Microsoft.Scripting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc">
|
||||
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Abstractions" />
|
||||
<Reference Include="System.Web.Routing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.EnterpriseServices" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Scripting\IScriptingManager.cs" />
|
||||
<Compile Include="Scripting\IScriptingRuntime.cs" />
|
||||
<Compile Include="Scripting\ScriptingManager.cs" />
|
||||
<Compile Include="Scripting\ScriptingRuntime.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard.Framework</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Module.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target> -->
|
||||
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
|
||||
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
|
||||
</Target>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>False</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>47866</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>
|
||||
</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>True</UseCustomServer>
|
||||
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Orchard.Scripting")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyProduct("Orchard.Scripting")]
|
||||
[assembly: AssemblyCopyright("Copyright © Outercurve Foundation 2009")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("fa37585c-b84e-4b5b-a7da-13692ff45a94")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("0.8.0")]
|
||||
[assembly: AssemblyFileVersion("0.8.0")]
|
||||
[assembly: SecurityTransparent]
|
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using Microsoft.Scripting.Hosting;
|
||||
|
||||
namespace Orchard.Scripting {
|
||||
public interface IScriptingManager /* : IDependency */ {
|
||||
dynamic GetVariable(string name);
|
||||
void SetVariable(string name, object value);
|
||||
dynamic ExecuteExpression(string expression);
|
||||
void ExecuteFile(string fileName);
|
||||
dynamic ExecuteOperation(Func<ObjectOperations, object> invoke);
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
using Microsoft.Scripting.Hosting;
|
||||
|
||||
namespace Orchard.Scripting {
|
||||
public interface IScriptingRuntime /*: ISingletonDependency */ {
|
||||
ScriptScope CreateScope();
|
||||
dynamic ExecuteExpression(string expression, ScriptScope scope);
|
||||
void ExecuteFile(string fileName, ScriptScope scope);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Microsoft.Scripting.Hosting;
|
||||
|
||||
namespace Orchard.Scripting {
|
||||
public class ScriptingManager : IScriptingManager {
|
||||
private readonly IScriptingRuntime _scriptingRuntime;
|
||||
private Lazy<ScriptScope> _scope;
|
||||
private Lazy<ObjectOperations> _operations;
|
||||
|
||||
public ScriptingManager(IScriptingRuntime scriptingRuntime) {
|
||||
_scriptingRuntime = scriptingRuntime;
|
||||
_scope = new Lazy<ScriptScope>(()=>_scriptingRuntime.CreateScope());
|
||||
_operations = new Lazy<ObjectOperations>(()=>_scope.Value.Engine.CreateOperations());
|
||||
}
|
||||
|
||||
public dynamic GetVariable(string name) {
|
||||
return _scope.Value.GetVariable(name);
|
||||
}
|
||||
|
||||
public void SetVariable(string name, object value) {
|
||||
_scope.Value.SetVariable(name, value);
|
||||
}
|
||||
|
||||
public dynamic ExecuteExpression(string expression) {
|
||||
return _scriptingRuntime.ExecuteExpression(expression, _scope.Value);
|
||||
}
|
||||
|
||||
public dynamic ExecuteOperation(Func<ObjectOperations, object> invoke) {
|
||||
return invoke(_operations.Value);
|
||||
}
|
||||
|
||||
public void ExecuteFile(string fileName) {
|
||||
_scriptingRuntime.ExecuteFile(fileName, _scope.Value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
using IronRuby;
|
||||
using Microsoft.Scripting.Hosting;
|
||||
|
||||
namespace Orchard.Scripting {
|
||||
public class ScriptingRuntime : IScriptingRuntime {
|
||||
private readonly LanguageSetup _defaultLanguageSetup;
|
||||
private readonly ScriptRuntime _scriptingRuntime;
|
||||
|
||||
public ScriptingRuntime() {
|
||||
_defaultLanguageSetup = Ruby.CreateRubySetup();
|
||||
|
||||
var setup = new ScriptRuntimeSetup();
|
||||
setup.LanguageSetups.Add(_defaultLanguageSetup);
|
||||
_scriptingRuntime = new ScriptRuntime(setup);
|
||||
}
|
||||
|
||||
ScriptEngine GetDefaultEngine() {
|
||||
return _scriptingRuntime.GetEngineByTypeName(_defaultLanguageSetup.TypeName);
|
||||
}
|
||||
|
||||
public ScriptScope CreateScope() {
|
||||
return _scriptingRuntime.CreateScope();
|
||||
}
|
||||
|
||||
public dynamic ExecuteExpression(string expression, ScriptScope scope) {
|
||||
var engine = GetDefaultEngine();
|
||||
var source = engine.CreateScriptSourceFromString(expression);
|
||||
return source.Execute(scope);
|
||||
}
|
||||
|
||||
public void ExecuteFile(string fileName, ScriptScope scope) {
|
||||
var engine = GetDefaultEngine();
|
||||
engine.ExecuteFile(fileName, scope);
|
||||
}
|
||||
}
|
||||
}
|
@@ -114,6 +114,11 @@
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard.Framework</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Scripting\Orchard.Scripting.csproj">
|
||||
<Project>{2AD6973D-C7BB-416E-89FE-EEE34664E05F}</Project>
|
||||
<Name>Orchard.Scripting</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@@ -51,22 +51,6 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\autofac\Autofac.Integration.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronRuby, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\dlr\IronRuby.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronRuby.Libraries, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\dlr\IronRuby.Libraries.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Dynamic, Version=1.1.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\dlr\Microsoft.Dynamic.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Scripting, Version=1.1.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\dlr\Microsoft.Scripting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate.ByteCode.Castle, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\fluentnhibernate\NHibernate.ByteCode.Castle.dll</HintPath>
|
||||
|
Reference in New Issue
Block a user