Removed Bind method from OSCADObject, added IBindable, Binding.cs, and BindingMapper stubs.

This commit is contained in:
Michael Smith 2016-02-25 23:52:16 -08:00
parent 963a58783a
commit d5ec961cb1
5 changed files with 58 additions and 11 deletions

View File

@ -227,17 +227,6 @@ namespace OSCADSharp
#endregion
#region Utility Methods
private Dictionary<string, Variable> bindings = new Dictionary<string, Variable>();
/// <summary>
/// Binds a variable to property of this object
/// </summary>
/// <param name="property"></param>
/// <param name="variable"></param>
public void Bind(string property, Variable variable)
{
bindings[property] = variable;
}
/// <summary>
/// Returns the computed position of this object.
///

View File

@ -48,6 +48,9 @@
<Compile Include="Files\IFileInvoker.cs" />
<Compile Include="Files\IFileWriter.cs" />
<Compile Include="Ids.cs" />
<Compile Include="Scripting\BindingMapper.cs" />
<Compile Include="Scripting\Bindings.cs" />
<Compile Include="Scripting\IBindable.cs" />
<Compile Include="Scripting\SingleStatementObject.cs" />
<Compile Include="Scripting\StatementBuilder.cs" />
<Compile Include="Scripting\Variable.cs" />

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSCADSharp.Scripting
{
internal class BindingMapper
{
public string OpenSCADFieldName { get; set; }
public List<string> BindingOptions { get; set; }
public Dictionary<string, Func<object, string>> BindingTransformers { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSCADSharp.Scripting
{
internal class Bindings
{
internal List<BindingMapper> Mappers { get; set; } = new List<BindingMapper>();
private Dictionary<string, Variable> bindings = new Dictionary<string, Variable>();
internal void Add(string property, Variable variable)
{
bindings[property] = variable;
}
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSCADSharp.Scripting
{
/// <summary>
/// An object whose properties can be bound to variables
/// </summary>
public interface IBindable
{
/// <summary>
/// Binds a variable to property of this object
/// </summary>
/// <param name="property"></param>
/// <param name="variable"></param>
void Bind(string property, Variable variable);
}
}