Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Required fixes b/c of refactorings

  • Loading branch information...
commit 40c38ebcf0a2c4a52c3477932c273e27765038d6 1 parent 05afbc1
@kmees kmees authored
View
80 src/IronSharePoint.Framework/IronExpressionBuilder.cs
@@ -1,80 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Web.Compilation;
-using System.CodeDom;
-using System.Web;
-using System.ComponentModel;
-using Microsoft.SharePoint;
-using System.IO;
-using System.Text.RegularExpressions;
-using Microsoft.Scripting.Hosting;
-
-namespace IronSharePoint
-{
- public class IronExpressionBuilder: ExpressionBuilder
- {
- private IronEngine engine;
-
- public override System.CodeDom.CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
- {
-
- throw new NotSupportedException();
- }
-
- public override bool SupportsEvaluate
- {
- get
- {
- return true;
- }
- }
-
- public override object EvaluateExpression(object target, System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
- {
- string value = String.Empty;
- string scriptName = entry.Expression;
-
- try
- {
- string functionName = null;
-
- if (scriptName.Contains("@"))
- {
- var tmp = scriptName.Split('@');
- functionName = tmp[0].Trim();
- scriptName = tmp[1].Trim();
- }
- else
- {
- throw new ArgumentException("Invalid expression! Use <%$Iron:My.sayHello@my/functions.rb");
- }
-
- engine = IronRuntime.GetDefaultIronRuntime(SPContext.Current.Site).GetEngineByExtension(Path.GetExtension(scriptName));
- value = engine.InvokeDynamicFunction(functionName, scriptName, target, entry).ToString();
- }
- catch (Exception ex)
- {
- IronRuntime.LogError("Error", ex);
-
- if (SPContext.Current.Web.UserIsSiteAdmin)
- {
- var eo = engine.ScriptEngine.GetService<ExceptionOperations>();
- string error = eo.FormatException(ex);
-
- IronRuntime.LogError(String.Format("Error executing script {0}: {1}", scriptName, error), ex);
-
- value = error;
- }
- else
- {
- value = "Error occured";
- }
- }
-
- return value;
- }
-
- }
-}
View
37 src/IronSharePoint.Framework/IronHttpModule.cs
@@ -12,23 +12,10 @@ public class IronHttpModule:IHttpModule
{
public void Init(HttpApplication application)
{
- //application.PreRequestHandlerExecute += new EventHandler(OnPreRequest);
application.EndRequest += new EventHandler(EndRequest);
application.Error += new EventHandler(Error);
}
- //private void OnPreRequest(object sender, EventArgs e)
- //{
- // var application = sender as HttpApplication;
- // var context = application.Context;
-
- // if (SPContext.Current != null)
- // {
- // var runtime = IronRuntime.GetDefaultIronRuntime(SPContext.Current.Site);
- // context.Items[IronHelper.GetPrefixedKey("Runtime")] = runtime;
- // }
- //}
-
void Error(object sender, EventArgs e)
{
var application = sender as HttpApplication;
@@ -36,20 +23,13 @@ void Error(object sender, EventArgs e)
if (SPContext.Current != null)
{
var runtime = IronRuntime.GetDefaultIronRuntime(SPContext.Current.Site);
- var engine = runtime.GetEngineByExtension(".rb");
- var exception = application.Server.GetLastError();
+ var engine = runtime.RubyEngine;
+ var exception = application.Server.GetLastError();
- if (engine != null)
- {
- var eo = engine.ScriptEngine.GetService<ExceptionOperations>();
- string error = eo.FormatException(exception);
+ var eo = engine.GetService<ExceptionOperations>();
+ string error = eo.FormatException(exception);
- IronRuntime.LogError(error, exception);
- }
- else
- {
- IronRuntime.LogError("Error in IronHttpModule", exception);
- }
+ IronRuntime.LogError(error, exception);
}
}
@@ -62,13 +42,6 @@ void EndRequest(object sender, EventArgs e)
private static void CleanUp(HttpApplication application)
{
- //var runtime = HttpContext.Current.Items[IronHelper.GetPrefixedKey("Runtime")] as IronRuntime;
-
- //if (runtime != null)
- //{
- // runtime.IronHive.Close();
- //}
-
var ironObjectsToDispose = new List<IDisposable>();
foreach (var key in application.Context.Items.Keys.OfType<String>())
View
10 src/IronSharePoint.Framework/IronWrapperControl.cs
@@ -19,7 +19,7 @@ namespace IronSharePoint
public class IronWrapperControl : CompositeControl
{
public string ControlName { get; set; }
- private IronEngine _engine;
+ private ScriptEngine _engine;
private Control _control;
private Exception Exception { get; set; }
@@ -34,8 +34,10 @@ protected override void OnInit(EventArgs e)
try
{
IronRuntime ironRuntime = IronRuntime.GetDefaultIronRuntime(SPContext.Current.Site);
- _engine = ironRuntime.GetEngineByExtension(".rb");
- _control = _engine.CreateDynamicInstance(ControlName) as Control;
+ _engine = ironRuntime.RubyEngine;
+ var scope = _engine.CreateScope();
+ var controlClass = scope.GetVariable("ControlName");
+ _control = controlClass.@new();
this.Controls.Add(_control);
}
@@ -55,7 +57,7 @@ protected override void Render(HtmlTextWriter writer)
string errorMessage = null;
if (SPContext.Current.Web.UserIsSiteAdmin)
{
- var eo = _engine.ScriptEngine.GetService<ExceptionOperations>();
+ var eo = _engine.GetService<ExceptionOperations>();
errorMessage = eo.FormatException(Exception);
IronRuntime.LogError(String.Format("Error creating control: {0}", ControlName), Exception);
}
View
26 src/IronSharePoint.Framework/IronWrapperUserControl.cs
@@ -21,18 +21,14 @@ public class IronWrapperUserControl : UserControl
public string TemplatePath { get; set; }
public string ScriptName { get; set; }
-
public string ScriptClass { get; set; }
-
public string ScriptHiveId { get; set; }
public string Config { get; set; }
private Exception _exception;
-
- private IronEngine engine;
-
- protected Control ctrl;
+ private ScriptEngine _scriptEngine;
+ protected Control _ctrl;
protected override void OnInit(EventArgs e)
{
@@ -55,13 +51,13 @@ protected override void OnInit(EventArgs e)
//IronRuntime ironRuntime = IronRuntime.GetIronRuntime(SPContext.Current.Site, hiveId);
IronRuntime ironRuntime = IronRuntime.GetDefaultIronRuntime(SPContext.Current.Site);
- engine = ironRuntime.GetEngineByExtension(Path.GetExtension(ScriptName));
+ _scriptEngine = ironRuntime.ScriptRuntime.GetEngineByFileExtension(Path.GetExtension(ScriptName));
- if (engine != null)
+ if (_scriptEngine != null)
{
- ctrl = engine.CreateDynamicInstance(ScriptClass, ScriptName) as Control;
+ _ctrl = null;// TODO _scriptEngine.CreateDynamicInstance(ScriptClass, ScriptName) as Control;
- var dynamicControl = ctrl as IIronControl;
+ var dynamicControl = _ctrl as IIronControl;
if (dynamicControl != null)
{
dynamicControl.WebPart = null;
@@ -70,7 +66,7 @@ protected override void OnInit(EventArgs e)
if (Template != null)
{
- Template.InstantiateIn(ctrl);
+ Template.InstantiateIn(_ctrl);
}
else
{
@@ -80,11 +76,11 @@ protected override void OnInit(EventArgs e)
.Replace("~web", SPContext.Current.Web.ServerRelativeUrl);
Template = this.LoadTemplate(path);
- Template.InstantiateIn(ctrl);
+ Template.InstantiateIn(_ctrl);
}
}
- this.Controls.Add(ctrl);
+ this.Controls.Add(_ctrl);
}
}
catch (Exception ex)
@@ -103,7 +99,7 @@ protected override void Render(HtmlTextWriter writer)
{
if (SPContext.Current.Web.UserIsSiteAdmin)
{
- var eo = engine.ScriptEngine.GetService<ExceptionOperations>();
+ var eo = _scriptEngine.GetService<ExceptionOperations>();
string error = eo.FormatException(_exception);
IronRuntime.LogError(String.Format("Error executing script {0}: {1}", ScriptName, error), _exception);
@@ -122,7 +118,7 @@ protected override void Render(HtmlTextWriter writer)
}
try
{
- ctrl.RenderControl(writer);
+ _ctrl.RenderControl(writer);
}
catch (Exception ex)
{
View
9 src/IronSharePoint/EventReceivers/IronScriptCompilerReceiver.cs
@@ -6,6 +6,7 @@
using Microsoft.SharePoint.Workflow;
using System.IO;
using Microsoft.Scripting.Hosting;
+using IronSharePoint.Util;
namespace IronSharePoint.EventReceivers
{
@@ -14,7 +15,7 @@ namespace IronSharePoint.EventReceivers
/// </summary>
public class IronScriptCompilerReceiver : SPItemEventReceiver
{
- private IronEngine engine;
+ private ScriptEngine engine;
public override void ItemAdded(SPItemEventProperties properties)
{
@@ -35,10 +36,10 @@ private void CompileScript(SPItemEventProperties properties)
try
{
runtime = IronRuntime.GetDefaultIronRuntime(properties.Web.Site);
- engine = runtime.GetEngineByExtension(Path.GetExtension(properties.ListItem.File.Name));
+ engine = runtime.ScriptRuntime.GetEngineByFileExtension(Path.GetExtension(properties.ListItem.File.Name));
EventFiringEnabled = false;
- properties.ListItem[FieldHelper.IronOutput] = engine.ExcecuteScriptFile(properties.ListItem.File);
+ properties.ListItem[FieldHelper.IronOutput] = engine.ExecuteSPFile(properties.ListItem.File);
properties.ListItem[FieldHelper.IronErrorFlag] = false;
properties.ListItem.SystemUpdate(false);
@@ -48,7 +49,7 @@ private void CompileScript(SPItemEventProperties properties)
}
catch (Exception ex)
{
- var eo = engine.ScriptEngine.GetService<ExceptionOperations>();
+ var eo = engine.GetService<ExceptionOperations>();
string error = eo.FormatException(ex);
properties.ListItem[FieldHelper.IronOutput] = error;
View
2  src/IronSharePoint/IronConsole/IronConsoleUserControl.ascx
@@ -1 +1 @@
-<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %><%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Control Language="C#" AutoEventWireup="true" CodeBehind="IronConsoleUserControl.ascx.cs" Inherits="IronSharePoint.IronConsole.IronConsoleUserControl" %><style type="text/css">#ironSP-console-input {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;border-width: 0px;box-sizing: border-box;float: left;overflow: auto;width: 90%;}#ironSP-console-container {max-height: 500px;overflow: auto;padding: 5px;}#ironSP-console { }.ironSP-console-edit { background-color: Yellow !important; }.ironSP-console-line td, .ironSP-console-prompt td, #ironSP-console-input {color: black !important;font-family: "Droid Sans Mono", Consolas, Courier !important;font-size: 12pt;}.ironSP-console-prefix { padding-right: 5px; }.ironSP-console-prefix {padding-top: 2px;vertical-align: top;}.ironSP-console-error td, .ironSP-console-stackTrace td {color: red !important;font-size: 10pt;}.ironSP-console-output { font-style: italic; }.ironSP-console-executing { background: url('_layouts/images/IronSP/ajax-loader.gif') no-repeat right top }</style><script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js" type="text/javascript"> </script><script src="/_layouts/15/IronSP/mustache.js" type="text/javascript"> </script><script src="/_layouts/15/IronSP/IronConsole.js" type="text/javascript"> </script><script type="text/javascript">$(document).ready(function() {var console = new IronConsole('<%= CurrentContext.Web.Url %>/_layouts/15/IronSP/IronConsoleService.ashx?ext=.rb');var consoleView = new IronConsoleView(console);});</script><script id="ironSP-console-line-template" type='text/html'><tr class='ironSP-console-line ironSP-console-{{type}}'><td class='ironSP-console-prefix'><span>{{prefix}}</span></td><td><span>{{text}}</span></td></tr></script><script id="ironSP-console-template" type='text/html'><table id="ironSP-console"><tr class='ironSP-console-prompt'><td class='ironSP-console-prefix'><span>{{prompt}}</span></td><td><textarea id="ironSP-console-input" cols="80" rows="5"/></td></tr></table></script><div id="ironSP-console-container"></div>
+<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %><%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Control Language="C#" AutoEventWireup="true" CodeBehind="IronConsoleUserControl.ascx.cs" Inherits="IronSharePoint.IronConsoleUserControl" %><style type="text/css">#ironSP-console-input {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;border-width: 0px;box-sizing: border-box;float: left;overflow: auto;width: 90%;}#ironSP-console-container {max-height: 500px;overflow: auto;padding: 5px;}#ironSP-console { }.ironSP-console-edit { background-color: Yellow !important; }.ironSP-console-line td, .ironSP-console-prompt td, #ironSP-console-input {color: black !important;font-family: "Droid Sans Mono", Consolas, Courier !important;font-size: 12pt;}.ironSP-console-prefix { padding-right: 5px; }.ironSP-console-prefix {padding-top: 2px;vertical-align: top;}.ironSP-console-error td, .ironSP-console-stackTrace td {color: red !important;font-size: 10pt;}.ironSP-console-output { font-style: italic; }.ironSP-console-executing { background: url('_layouts/images/IronSP/ajax-loader.gif') no-repeat right top }</style><script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js" type="text/javascript"> </script><script src="/_layouts/15/IronSP/mustache.js" type="text/javascript"> </script><script src="/_layouts/15/IronSP/IronConsole.js" type="text/javascript"> </script><script type="text/javascript">$(document).ready(function () { var console = new IronConsole('http://kev-sp/sites/playground/_layouts/15/IronSP/IronConsoleService.ashx?lang=ruby'); var consoleView = new IronConsoleView(console); });</script><script id="ironSP-console-line-template" type='text/html'><tr class='ironSP-console-line ironSP-console-{{type}}'><td class='ironSP-console-prefix'><span>{{prefix}}</span></td><td><span>{{text}}</span></td></tr></script><script id="ironSP-console-template" type='text/html'><table id="ironSP-console"><tr class='ironSP-console-prompt'><td class='ironSP-console-prefix'><span>{{prompt}}</span></td><td><textarea id="ironSP-console-input" cols="80" rows="5"/></td></tr></table></script><div id="ironSP-console-container"></div>
View
7 src/IronSharePoint/IronConsole/IronConsoleUserControl.ascx.cs
@@ -2,15 +2,10 @@
using System.Web.UI;
using Microsoft.SharePoint;
-namespace IronSharePoint.IronConsole
+namespace IronSharePoint
{
public partial class IronConsoleUserControl : UserControl
{
- public SPContext CurrentContext
- {
- get { return SPContext.Current; }
- }
-
protected void Page_Load(object sender, EventArgs e) { }
}
}
View
5 src/IronSharePoint/IronPart/IronPart.cs
@@ -9,6 +9,7 @@
using System.Collections.Generic;
using Microsoft.Scripting.Hosting;
using System.IO;
+using IronSharePoint.Util;
namespace IronSharePoint.IronPart
{
@@ -58,8 +59,8 @@ protected override void OnInit(EventArgs e)
Control ctrl = null;
if (!String.IsNullOrEmpty(ScriptName))
{
- var engine = ironRuntime.GetEngineByExtension(Path.GetExtension(ScriptName));
- ctrl = engine.CreateDynamicInstance(ScriptClass, ScriptName) as Control;
+ var engine = ironRuntime.ScriptRuntime.GetEngineByFileExtension(Path.GetExtension(ScriptName));
+ ctrl = engine.CreateInstance(ScriptClass) as Control;
}
else
{

0 comments on commit 40c38eb

Please sign in to comment.
Something went wrong with that request. Please try again.