mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-24 21:43:37 +08:00
First rough cut at an Orchard.Core assembly. This is intended to act as a carrier of certain built-in packages. The enlistment, activation, content files, etc. within ~/Core/X are intended to have exactly the same overall effect as if they were in a ~/Packages/X standalone project.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4041143
This commit is contained in:
133
src/Orchard.Web/Core/Orchard.Core.csproj
Normal file
133
src/Orchard.Web/Core/Orchard.Core.csproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</ProjectGuid>
|
||||
<ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Orchard.Core</RootNamespace>
|
||||
<AssemblyName>Orchard.Core</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</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>
|
||||
</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="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<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, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\Program Files\Microsoft ASP.NET\ASP.NET MVC 2\\Assemblies\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
<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" />
|
||||
<Reference Include="System.Web.Mobile" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="XmlRpc\Controllers\HomeController.cs" />
|
||||
<Compile Include="XmlRpc\Controllers\LiveWriterController.cs" />
|
||||
<Compile Include="XmlRpc\IXmlRpcHandler.cs" />
|
||||
<Compile Include="XmlRpc\Models\ModelBinderProvider.cs" />
|
||||
<Compile Include="XmlRpc\Models\XRpcArray.cs" />
|
||||
<Compile Include="XmlRpc\Models\XRpcData.cs" />
|
||||
<Compile Include="XmlRpc\Models\XRpcMethodCall.cs" />
|
||||
<Compile Include="XmlRpc\Models\XRpcMethodResponse.cs" />
|
||||
<Compile Include="XmlRpc\Models\XRpcStruct.cs" />
|
||||
<Compile Include="XmlRpc\Services\XmlRpcReader.cs" />
|
||||
<Compile Include="XmlRpc\Services\XmlRpcWriter.cs" />
|
||||
<Compile Include="XmlRpc\XmlRpcContext.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="XmlRpc\Package.txt" />
|
||||
<Content Include="XmlRpc\Views\Home\Index.aspx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Orchard\Orchard.csproj">
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.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> -->
|
||||
<!-- To enable MVC area subproject support, uncomment the following two lines:
|
||||
<UsingTask TaskName="Microsoft.Web.Mvc.Build.CreateAreaManifest" AssemblyName="Microsoft.Web.Mvc.Build, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<UsingTask TaskName="Microsoft.Web.Mvc.Build.CopyAreaManifests" AssemblyName="Microsoft.Web.Mvc.Build, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
-->
|
||||
<Target Name="AfterBuild" DependsOnTargets="AfterBuildCompiler">
|
||||
<PropertyGroup>
|
||||
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
|
||||
</PropertyGroup>
|
||||
<!-- If this is an area child project, uncomment the following line:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
-->
|
||||
<!-- If this is an area parent project, uncomment the following lines:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
|
||||
-->
|
||||
</Target>
|
||||
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
|
||||
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
|
||||
</Target>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>False</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>52289</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>
|
||||
</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
35
src/Orchard.Web/Core/Properties/AssemblyInfo.cs
Normal file
35
src/Orchard.Web/Core/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 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.Core")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft IT")]
|
||||
[assembly: AssemblyProduct("Orchard.Core")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft IT 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("ed6d019b-39e6-4978-87ae-78655a99a5c8")]
|
||||
|
||||
// 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("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
153
src/Orchard.Web/Core/Web.config
Normal file
153
src/Orchard.Web/Core/Web.config
Normal file
@@ -0,0 +1,153 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Note: As an alternative to hand editing this file you can use the
|
||||
web admin tool to configure settings for your application. Use
|
||||
the Website->Asp.Net Configuration option in Visual Studio.
|
||||
A full list of settings and comments can be found in
|
||||
machine.config.comments usually located in
|
||||
\Windows\Microsoft.Net\Framework\v2.x\Config
|
||||
-->
|
||||
<configuration>
|
||||
|
||||
<configSections>
|
||||
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
|
||||
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
|
||||
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
|
||||
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
|
||||
</sectionGroup>
|
||||
</sectionGroup>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
|
||||
<system.web>
|
||||
|
||||
<!--
|
||||
Set compilation debug="true" to insert debugging
|
||||
symbols into the compiled page. Because this
|
||||
affects performance, set this value to true only
|
||||
during development.
|
||||
-->
|
||||
<compilation debug="true">
|
||||
<assemblies>
|
||||
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
|
||||
</assemblies>
|
||||
</compilation>
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
The <customErrors> section enables configuration
|
||||
of what to do if/when an unhandled error occurs
|
||||
during the execution of a request. Specifically,
|
||||
it enables developers to configure html error pages
|
||||
to be displayed in place of a error stack trace.
|
||||
|
||||
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
|
||||
<error statusCode="403" redirect="NoAccess.htm" />
|
||||
<error statusCode="404" redirect="FileNotFound.htm" />
|
||||
</customErrors>
|
||||
-->
|
||||
|
||||
<pages>
|
||||
<controls>
|
||||
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
</controls>
|
||||
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc"/>
|
||||
<add namespace="System.Web.Mvc.Ajax"/>
|
||||
<add namespace="System.Web.Mvc.Html"/>
|
||||
<add namespace="System.Web.Routing"/>
|
||||
<add namespace="System.Linq"/>
|
||||
<add namespace="System.Collections.Generic"/>
|
||||
</namespaces>
|
||||
</pages>
|
||||
|
||||
<httpHandlers>
|
||||
<remove verb="*" path="*.asmx"/>
|
||||
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
|
||||
<add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
</httpHandlers>
|
||||
|
||||
<httpModules>
|
||||
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
</httpModules>
|
||||
|
||||
</system.web>
|
||||
|
||||
<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
|
||||
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<providerOption name="CompilerVersion" value="v3.5"/>
|
||||
<providerOption name="WarnAsError" value="false"/>
|
||||
</compiler>
|
||||
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4"
|
||||
type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<providerOption name="CompilerVersion" value="v3.5"/>
|
||||
<providerOption name="OptionInfer" value="true"/>
|
||||
<providerOption name="WarnAsError" value="false"/>
|
||||
</compiler>
|
||||
</compilers>
|
||||
</system.codedom>
|
||||
|
||||
<system.web.extensions/>
|
||||
|
||||
<!--
|
||||
The system.webServer section is required for running ASP.NET AJAX under Internet
|
||||
Information Services 7.0. It is not necessary for previous version of IIS.
|
||||
-->
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
|
||||
<modules runAllManagedModulesForAllRequests="true">
|
||||
<remove name="ScriptModule" />
|
||||
<remove name="UrlRoutingModule" />
|
||||
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
</modules>
|
||||
|
||||
<handlers>
|
||||
<remove name="WebServiceHandlerFactory-Integrated"/>
|
||||
<remove name="ScriptHandlerFactory" />
|
||||
<remove name="ScriptHandlerFactoryAppServices" />
|
||||
<remove name="ScriptResource" />
|
||||
<remove name="MvcHttpHandler" />
|
||||
<remove name="UrlRoutingHandler" />
|
||||
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
|
||||
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
|
||||
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
<add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
|
||||
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
</configuration>
|
49
src/Orchard.Web/Core/XmlRpc/Controllers/HomeController.cs
Normal file
49
src/Orchard.Web/Core/XmlRpc/Controllers/HomeController.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Core.XmlRpc.Models;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.Core.XmlRpc.Controllers {
|
||||
public class HomeController : Controller {
|
||||
private readonly IMapper<XRpcMethodResponse, XElement> _writer;
|
||||
private readonly IEnumerable<IXmlRpcHandler> _xmlRpcHandlers;
|
||||
|
||||
public HomeController(
|
||||
IMapper<XRpcMethodResponse, XElement> writer,
|
||||
IEnumerable<IXmlRpcHandler> xmlRpcHandlers) {
|
||||
_writer = writer;
|
||||
_xmlRpcHandlers = xmlRpcHandlers;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public ActionResult Index() {
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Index")]
|
||||
public ActionResult ServiceEndpoint(XRpcMethodCall methodCall) {
|
||||
Logger.Debug("XmlRpc methodName {0}", methodCall.MethodName);
|
||||
var methodResponse = Dispatch(methodCall);
|
||||
|
||||
if (methodResponse == null)
|
||||
throw new HttpException(500, "TODO: xmlrpc fault");
|
||||
|
||||
var content = _writer.Map(methodResponse).ToString();
|
||||
return Content(content, "text/xml");
|
||||
}
|
||||
|
||||
private XRpcMethodResponse Dispatch(XRpcMethodCall request) {
|
||||
var context = new XmlRpcContext { HttpContext = HttpContext, Request = request };
|
||||
foreach (var handler in _xmlRpcHandlers)
|
||||
handler.Process(context);
|
||||
return context.Response;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.Core.XmlRpc.Controllers {
|
||||
public class LiveWriterController : Controller {
|
||||
private const string ManifestUri = "http://schemas.microsoft.com/wlw/manifest/weblog";
|
||||
|
||||
public LiveWriterController() {
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
protected ILogger Logger { get; set; }
|
||||
|
||||
|
||||
public ActionResult Manifest() {
|
||||
Logger.Debug("Manifest requested");
|
||||
|
||||
var options = new XElement(
|
||||
XName.Get("options", ManifestUri),
|
||||
new XElement(XName.Get("clientType", ManifestUri), "Metaweblog"),
|
||||
new XElement(XName.Get("supportsSlug", ManifestUri), "Yes"));
|
||||
|
||||
var doc = new XDocument(new XElement(
|
||||
XName.Get("manifest", ManifestUri),
|
||||
options));
|
||||
|
||||
Response.Cache.SetCacheability(HttpCacheability.NoCache);
|
||||
return Content(doc.ToString(), "text/xml");
|
||||
}
|
||||
}
|
||||
}
|
5
src/Orchard.Web/Core/XmlRpc/IXmlRpcHandler.cs
Normal file
5
src/Orchard.Web/Core/XmlRpc/IXmlRpcHandler.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Orchard.Core.XmlRpc {
|
||||
public interface IXmlRpcHandler : IDependency {
|
||||
void Process(XmlRpcContext context);
|
||||
}
|
||||
}
|
36
src/Orchard.Web/Core/XmlRpc/Models/ModelBinderProvider.cs
Normal file
36
src/Orchard.Web/Core/XmlRpc/Models/ModelBinderProvider.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Mvc.ModelBinders;
|
||||
|
||||
namespace Orchard.Core.XmlRpc.Models {
|
||||
public class ModelBinderProvider : IModelBinderProvider, IModelBinder {
|
||||
private readonly IMapper<XElement, XRpcMethodCall> _mapper;
|
||||
|
||||
public ModelBinderProvider(IMapper<XElement, XRpcMethodCall> mapper) {
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public IEnumerable<ModelBinderDescriptor> GetModelBinders() {
|
||||
return new[] {
|
||||
new ModelBinderDescriptor {
|
||||
ModelBinder =this,
|
||||
Type=typeof(XRpcMethodCall)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
|
||||
//Ah! xmlrpc is a value provider!!!
|
||||
// TODO: refactor this?
|
||||
using (var xmlReader = XmlReader.Create(controllerContext.HttpContext.Request.InputStream)) {
|
||||
var element = XElement.Load(xmlReader);
|
||||
return _mapper.Map(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
19
src/Orchard.Web/Core/XmlRpc/Models/XRpcArray.cs
Normal file
19
src/Orchard.Web/Core/XmlRpc/Models/XRpcArray.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Core.XmlRpc.Models {
|
||||
public class XRpcArray {
|
||||
public XRpcArray() {
|
||||
Data = new List<XRpcData>();
|
||||
}
|
||||
public IList<XRpcData> Data { get; set; }
|
||||
|
||||
public object this[int index] {
|
||||
get { return Data[index].Value; }
|
||||
}
|
||||
|
||||
public XRpcArray Add<T>(T value) {
|
||||
Data.Add(XRpcData.For(value));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
42
src/Orchard.Web/Core/XmlRpc/Models/XRpcData.cs
Normal file
42
src/Orchard.Web/Core/XmlRpc/Models/XRpcData.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
|
||||
namespace Orchard.Core.XmlRpc.Models {
|
||||
public class XRpcData {
|
||||
private object _value;
|
||||
public object Value {
|
||||
get { return _value; }
|
||||
set { SetValue(value); }
|
||||
}
|
||||
|
||||
protected virtual void SetValue(object value) {
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public virtual Type Type { get { return typeof(object); } }
|
||||
|
||||
public static XRpcData<T> For<T>(T t) {
|
||||
return new XRpcData<T> { Value = t };
|
||||
}
|
||||
}
|
||||
|
||||
public class XRpcData<T> : XRpcData {
|
||||
|
||||
private T _value;
|
||||
public new T Value {
|
||||
get { return _value; }
|
||||
set { SetValue(value); }
|
||||
}
|
||||
|
||||
void SetValue(T value) {
|
||||
_value = value;
|
||||
base.SetValue(value);
|
||||
}
|
||||
|
||||
protected override void SetValue(object value) {
|
||||
_value = (T)Convert.ChangeType(value, typeof(T));
|
||||
base.SetValue(value);
|
||||
}
|
||||
|
||||
public override Type Type { get { return typeof(T); } }
|
||||
}
|
||||
}
|
10
src/Orchard.Web/Core/XmlRpc/Models/XRpcMethodCall.cs
Normal file
10
src/Orchard.Web/Core/XmlRpc/Models/XRpcMethodCall.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Core.XmlRpc.Models {
|
||||
public class XRpcMethodCall {
|
||||
public XRpcMethodCall() { Params = new List<XRpcData>(); }
|
||||
|
||||
public string MethodName { get; set; }
|
||||
public IList<XRpcData> Params { get; set; }
|
||||
}
|
||||
}
|
14
src/Orchard.Web/Core/XmlRpc/Models/XRpcMethodResponse.cs
Normal file
14
src/Orchard.Web/Core/XmlRpc/Models/XRpcMethodResponse.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Core.XmlRpc.Models {
|
||||
public class XRpcMethodResponse {
|
||||
public XRpcMethodResponse() { Params = new List<XRpcData>(); }
|
||||
|
||||
public IList<XRpcData> Params { get; set; }
|
||||
|
||||
public XRpcMethodResponse Add<T>(T value) {
|
||||
Params.Add(XRpcData.For(value));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
26
src/Orchard.Web/Core/XmlRpc/Models/XRpcStruct.cs
Normal file
26
src/Orchard.Web/Core/XmlRpc/Models/XRpcStruct.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Core.XmlRpc.Models {
|
||||
public class XRpcStruct {
|
||||
public XRpcStruct() {
|
||||
Members = new Dictionary<string, XRpcData>();
|
||||
}
|
||||
public IDictionary<string, XRpcData> Members { get; set; }
|
||||
|
||||
public object this[string index] {
|
||||
get { return Members[index].Value; }
|
||||
}
|
||||
|
||||
public XRpcStruct Set<T>(string name, T value) {
|
||||
Members[name] = XRpcData.For(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public T Optional<T>(string name) {
|
||||
XRpcData data;
|
||||
if (Members.TryGetValue(name, out data))
|
||||
return (T)data.Value;
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
1
src/Orchard.Web/Core/XmlRpc/Package.txt
Normal file
1
src/Orchard.Web/Core/XmlRpc/Package.txt
Normal file
@@ -0,0 +1 @@
|
||||
Name: XmlRpc
|
88
src/Orchard.Web/Core/XmlRpc/Services/XmlRpcReader.cs
Normal file
88
src/Orchard.Web/Core/XmlRpc/Services/XmlRpcReader.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Core.XmlRpc.Models;
|
||||
|
||||
namespace Orchard.Core.XmlRpc.Services {
|
||||
public class XmlRpcReader :
|
||||
IMapper<XElement, XRpcMethodCall>,
|
||||
IMapper<XElement, XRpcData>,
|
||||
IMapper<XElement, XRpcStruct>,
|
||||
IMapper<XElement, XRpcArray> {
|
||||
|
||||
private readonly IDictionary<string, Func<XElement, XRpcData>> _dispatch;
|
||||
|
||||
public XmlRpcReader() {
|
||||
_dispatch = new Dictionary<string, Func<XElement, XRpcData>>
|
||||
{
|
||||
{"i4",x=>new XRpcData<int> { Value = (int)x }},
|
||||
{"int", x=>new XRpcData<int> { Value = (int)x }},
|
||||
{"boolean", x=>new XRpcData<bool> { Value = ((string)x=="1") }},
|
||||
{"string", x=>new XRpcData<string> { Value = (string)x }},
|
||||
{"double", x=>new XRpcData<double> { Value = (double)x }},
|
||||
{"dateTime.iso8601", x=>new XRpcData<DateTime> { Value = DateTime.Parse((string)x, null, DateTimeStyles.RoundtripKind) }},
|
||||
{"base64", x=>new XRpcData<byte[]> { Value = Convert.FromBase64String((string)x) }},
|
||||
{"struct", x=>XRpcData.For(Map<XRpcStruct>(x))} ,
|
||||
{"array", x=>XRpcData.For(Map<XRpcArray>(x))} ,
|
||||
};
|
||||
}
|
||||
|
||||
T2 Map<T2>(XElement t1) {
|
||||
return ((IMapper<XElement, T2>)this).Map(t1);
|
||||
}
|
||||
|
||||
XRpcData MapValue(XContainer t1) {
|
||||
var element = t1.Elements().SingleOrDefault();
|
||||
|
||||
Func<XElement, XRpcData> dispatch;
|
||||
if (_dispatch.TryGetValue(element.Name.LocalName, out dispatch) == false)
|
||||
throw new ApplicationException("Unknown XmlRpc value type " + element.Name.LocalName);
|
||||
|
||||
return dispatch(element);
|
||||
}
|
||||
|
||||
XRpcMethodCall IMapper<XElement, XRpcMethodCall>.Map(XElement source) {
|
||||
return new XRpcMethodCall {
|
||||
MethodName = (string)source.Element("methodName"),
|
||||
Params = source.Elements("params").Elements("param").Select(x => Map<XRpcData>(x)).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
XRpcData IMapper<XElement, XRpcData>.Map(XElement source) {
|
||||
var value = source.Element("value");
|
||||
if (value == null)
|
||||
return new XRpcData();
|
||||
|
||||
var element = value.Elements().SingleOrDefault();
|
||||
|
||||
Func<XElement, XRpcData> dispatch;
|
||||
if (_dispatch.TryGetValue(element.Name.LocalName, out dispatch) == false)
|
||||
throw new ApplicationException("Unknown XmlRpc value type " + element.Name.LocalName);
|
||||
|
||||
return dispatch(element);
|
||||
}
|
||||
|
||||
XRpcStruct IMapper<XElement, XRpcStruct>.Map(XElement source) {
|
||||
var result = new XRpcStruct();
|
||||
foreach (var member in source.Elements("member")) {
|
||||
result.Members.Add(
|
||||
(string)member.Element("name"),
|
||||
MapValue(member.Element("value")));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
XRpcArray IMapper<XElement, XRpcArray>.Map(XElement source) {
|
||||
var result = new XRpcArray();
|
||||
foreach (var value in source.Elements("data").Elements("value")) {
|
||||
result.Data.Add(MapValue(value));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
70
src/Orchard.Web/Core/XmlRpc/Services/XmlRpcWriter.cs
Normal file
70
src/Orchard.Web/Core/XmlRpc/Services/XmlRpcWriter.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Core.XmlRpc.Models;
|
||||
|
||||
namespace Orchard.Core.XmlRpc.Services {
|
||||
public class XmlRpcWriter :
|
||||
IMapper<XRpcMethodResponse, XElement>,
|
||||
IMapper<XRpcStruct, XElement>,
|
||||
IMapper<XRpcArray, XElement>,
|
||||
IMapper<XRpcData, XElement> {
|
||||
|
||||
public XmlRpcWriter() {
|
||||
_dispatch = new Dictionary<Type, Func<XRpcData, XElement>>
|
||||
{
|
||||
{typeof(int), p=>new XElement("int", (int)p.Value)},
|
||||
{typeof(bool), p=>new XElement("boolean", (bool)p.Value?"1":"0")},
|
||||
{typeof(string), p=>new XElement("string", (string)p.Value)},
|
||||
{typeof(double), p=>new XElement("double", (double)p.Value)},
|
||||
{typeof(DateTime), p=>new XElement("dateTime.iso8601", ((DateTime)p.Value).ToString("o"))},
|
||||
{typeof(byte[]), p=>new XElement("base64", Convert.ToBase64String((byte[])p.Value))},
|
||||
{typeof(XRpcStruct), p=>Map((XRpcStruct)p.Value)},
|
||||
{typeof(XRpcArray), p=>Map((XRpcArray)p.Value)},
|
||||
};
|
||||
}
|
||||
|
||||
private IDictionary<Type, Func<XRpcData, XElement>> _dispatch;
|
||||
|
||||
XElement IMapper<XRpcMethodResponse, XElement>.Map(XRpcMethodResponse source) {
|
||||
return new XElement(
|
||||
"methodResponse",
|
||||
new XElement(
|
||||
"params",
|
||||
source.Params.Select(
|
||||
p => new XElement("param", MapValue(p)))));
|
||||
}
|
||||
|
||||
XElement IMapper<XRpcData, XElement>.Map(XRpcData source) {
|
||||
return new XElement("param", MapValue(source));
|
||||
}
|
||||
|
||||
XElement IMapper<XRpcStruct, XElement>.Map(XRpcStruct source) {
|
||||
return new XElement(
|
||||
"struct",
|
||||
source.Members.Select(
|
||||
kv => new XElement(
|
||||
"member",
|
||||
new XElement("name", kv.Key),
|
||||
MapValue(kv.Value))));
|
||||
}
|
||||
|
||||
XElement IMapper<XRpcArray, XElement>.Map(XRpcArray source) {
|
||||
return new XElement(
|
||||
"array",
|
||||
new XElement(
|
||||
"data",
|
||||
source.Data.Select(d => MapValue(d))));
|
||||
}
|
||||
|
||||
XElement Map<T>(T t) {
|
||||
return ((IMapper<T, XElement>)this).Map(t);
|
||||
}
|
||||
|
||||
private XElement MapValue(XRpcData data) {
|
||||
return new XElement("value", _dispatch[data.Type](data));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
9
src/Orchard.Web/Core/XmlRpc/Views/Home/Index.aspx
Normal file
9
src/Orchard.Web/Core/XmlRpc/Views/Home/Index.aspx
Normal file
@@ -0,0 +1,9 @@
|
||||
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
|
||||
|
||||
<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
|
||||
Home Page
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
<p>Use this url for LiveWriter</p>
|
||||
</asp:Content>
|
10
src/Orchard.Web/Core/XmlRpc/XmlRpcContext.cs
Normal file
10
src/Orchard.Web/Core/XmlRpc/XmlRpcContext.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Web;
|
||||
using Orchard.Core.XmlRpc.Models;
|
||||
|
||||
namespace Orchard.Core.XmlRpc {
|
||||
public class XmlRpcContext {
|
||||
public HttpContextBase HttpContext { get; set; }
|
||||
public XRpcMethodCall Request { get; set; }
|
||||
public XRpcMethodResponse Response { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user