Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed obsolete stuff from IronControl&co

  • Loading branch information...
commit d36104bd18d4c4c7c0c8397970d76a0cf1944f6d 1 parent 9ed9091
@kmees kmees authored
View
3  src/IronSharePoint.Framework/IIronControl.cs
@@ -10,8 +10,7 @@ namespace IronSharePoint
public interface IIronControl
{
WebPart WebPart { get; set; }
- IIronDataStore Data { get; set; }
- string Config { get; set; }
+ IIronDataStore DataStore { get; set; }
List<EditorPart> CreateEditorParts();
}
}
View
3  src/IronSharePoint.Framework/IronCompositeControl.cs
@@ -12,8 +12,7 @@ public class IronCompositeControl : CompositeControl, IIronControl
{
public IronEngine Engine { get; set; }
public WebPart WebPart { get; set; }
- public IIronDataStore Data { get; set; }
- public string Config { get; set; }
+ public IIronDataStore DataStore { get; set; }
public virtual List<EditorPart> CreateEditorParts()
{
View
8 src/IronSharePoint.Framework/IronControl.cs
@@ -15,13 +15,7 @@ public class IronControl : Control, IIronControl
{
public IronEngine Engine { get; set; }
public WebPart WebPart { get; set; }
- public IIronDataStore Data { get; set; }
- public string Config { get; set; }
-
- public Exception RenderException { get; set; }
- public bool IsAsync { get; set; }
-
- protected delegate void AsyncTaskDelegate();
+ public IIronDataStore DataStore { get; set; }
public virtual List<EditorPart> CreateEditorParts()
{
View
6 src/IronSharePoint.Framework/IronEngine.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Web.UI;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.SharePoint;
@@ -93,5 +94,10 @@ public object ExcecuteScriptFile(SPFile scriptFile)
return output;
}
+
+ public Control CreateDynamicInstance(string controlName)
+ {
+ throw new NotImplementedException();
+ }
}
}
View
99 src/IronSharePoint.Framework/IronWrapperControl.cs
@@ -18,61 +18,26 @@ namespace IronSharePoint
{
public class IronWrapperControl : CompositeControl
{
- public string ScriptName { get; set; }
-
- public string ScriptClass { get; set; }
-
- public string ScriptHiveId { get; set; }
-
- public string Config { get; set; }
-
- public IIronDataStore DataStore { get; set; }
-
- protected IronEngine engine;
-
- protected Control ctrl;
-
- protected System.Web.UI.WebControls.WebParts.WebPart WebPart { get; set; }
-
- protected Exception Exception { get; set; }
+ public string ControlName { get; set; }
+ private IronEngine _engine;
+ private Control _control;
+ private Exception Exception { get; set; }
protected override void OnInit(EventArgs e)
{
- try
+ if (String.IsNullOrWhiteSpace(ControlName))
{
- if (String.IsNullOrEmpty(ScriptName))
- {
- Exception = new InvalidEnumArgumentException("Property ScriptName is empty!");
- }
- else if (String.IsNullOrEmpty(ScriptClass))
- {
- Exception = new InvalidEnumArgumentException("Property ScriptClass is empty!");
- }
-
- if (Exception != null)
- return;
-
- //Guid hiveId = String.IsNullOrEmpty(ScriptHiveId) ? Guid.Empty : new Guid(ScriptHiveId);
- //IronRuntime ironRuntime = IronRuntime.GetIronRuntime(SPContext.Current.Site, hiveId);
+ Exception = new InvalidOperationException("ControlName not set");
+ return;
+ }
+ try
+ {
IronRuntime ironRuntime = IronRuntime.GetDefaultIronRuntime(SPContext.Current.Site);
- engine = ironRuntime.GetEngineByExtension(Path.GetExtension(ScriptName));
-
- if (engine != null)
- {
- ctrl = engine.CreateDynamicInstance(ScriptClass, ScriptName) as Control;
-
- var dynamicControl = ctrl as IIronControl;
- if (dynamicControl != null)
- {
- dynamicControl.WebPart = null;
- dynamicControl.Data = null;
- dynamicControl.Config = Config;
- }
-
- this.Controls.Add(ctrl);
- }
+ _engine = ironRuntime.GetEngineByExtension(".rb");
+ _control = _engine.CreateDynamicInstance(ControlName) as Control;
+ this.Controls.Add(_control);
}
catch (Exception ex)
{
@@ -87,37 +52,29 @@ protected override void Render(HtmlTextWriter writer)
// Todo better error handling
if (Exception != null)
{
+ string errorMessage = null;
if (SPContext.Current.Web.UserIsSiteAdmin)
{
- var eo = engine.ScriptEngine.GetService<ExceptionOperations>();
- string error = eo.FormatException(Exception);
-
- IronRuntime.LogError(String.Format("Error executing script {0}: {1}", ScriptName, error), Exception);
-
- //if(engine!=null)
- //{
- // new IronLogger(engine.IronRuntime).Log(String.Format("Ruby Error: {0} at {1}", Exception.Message, error));
- //}
-
- writer.Write(error);
+ var eo = _engine.ScriptEngine.GetService<ExceptionOperations>();
+ errorMessage = eo.FormatException(Exception);
+ IronRuntime.LogError(String.Format("Error creating control: {0}", ControlName), Exception);
}
else
{
- writer.Write("Error occured.");
+ errorMessage = "An Error occured.";
}
-
+ writer.Write(errorMessage);
+ return;
}
- else
+
+ try
{
- try
- {
- ctrl.RenderControl(writer);
- }
- catch (Exception ex)
- {
- writer.Write(ex.Message);
- IronRuntime.LogError("Error", ex);
- }
+ _control.RenderControl(writer);
+ }
+ catch (Exception ex)
+ {
+ writer.Write(ex.Message);
+ IronRuntime.LogError("Error while rendering " + GetType().AssemblyQualifiedName, ex);
}
}
}
View
3  src/IronSharePoint.Framework/IronWrapperUserControl.cs
@@ -65,8 +65,7 @@ protected override void OnInit(EventArgs e)
if (dynamicControl != null)
{
dynamicControl.WebPart = null;
- dynamicControl.Data = null;
- dynamicControl.Config = Config;
+ dynamicControl.DataStore = null;
}
if (Template != null)
View
3  src/IronSharePoint/IronPart/IronPart.cs
@@ -70,9 +70,10 @@ protected override void OnInit(EventArgs e)
if (DynamicControl != null)
{
DynamicControl.WebPart = this;
- DynamicControl.Data = this;
+ DynamicControl.DataStore = this;
}
+
this.Controls.Add(ctrl);
base.OnInit(e);
Please sign in to comment.
Something went wrong with that request. Please try again.