diff --git a/MBS.Framework/MBS.Framework.csproj b/MBS.Framework/MBS.Framework.csproj index 73ad8c1..61da8ad 100644 --- a/MBS.Framework/MBS.Framework.csproj +++ b/MBS.Framework/MBS.Framework.csproj @@ -86,6 +86,11 @@ + + + + + @@ -93,6 +98,8 @@ + + diff --git a/MBS.Framework/Scripting/ScriptEnvironment.cs b/MBS.Framework/Scripting/ScriptEnvironment.cs new file mode 100644 index 0000000..c5216be --- /dev/null +++ b/MBS.Framework/Scripting/ScriptEnvironment.cs @@ -0,0 +1,8 @@ +using System; +namespace MBS.Framework.Scripting +{ + public class ScriptEnvironment + { + + } +} diff --git a/MBS.Framework/Scripting/Strings/ScriptableString.cs b/MBS.Framework/Scripting/Strings/ScriptableString.cs new file mode 100644 index 0000000..0876f61 --- /dev/null +++ b/MBS.Framework/Scripting/Strings/ScriptableString.cs @@ -0,0 +1,54 @@ +using System; +using System.Text; + +namespace MBS.Framework.Scripting.Strings +{ + public class ScriptableString : ICloneable + { + public ScriptableString(StringComponent[] components = null) + { + if (components != null) + { + for (int i = 0; i < components.Length; i++) + { + Components.Add(components[i]); + } + } + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < Components.Count; i++) + { + sb.Append(Components[i].ToString()); + if (i < Components.Count - 1) + sb.Append(' '); + } + return sb.ToString(); + } + public string ToString(ScriptEnvironment environment) + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < Components.Count; i++) + { + sb.Append(Components[i].ToString(environment)); + if (i < Components.Count - 1) + sb.Append(' '); + } + return sb.ToString(); + } + + public StringComponent.StringComponentCollection Components { get; } = new StringComponent.StringComponentCollection(); + + public object Clone() + { + ScriptableString clone = new ScriptableString(); + for (int i = 0; i < Components.Count; i++) + { + clone.Components.Add(Components[i].Clone() as StringComponent); + } + return clone; + } + } +} diff --git a/MBS.Framework/Scripting/Strings/StringComponent.cs b/MBS.Framework/Scripting/Strings/StringComponent.cs new file mode 100644 index 0000000..bdf3268 --- /dev/null +++ b/MBS.Framework/Scripting/Strings/StringComponent.cs @@ -0,0 +1,16 @@ +using System; + +namespace MBS.Framework.Scripting.Strings +{ + public abstract class StringComponent : ICloneable + { + public class StringComponentCollection + : System.Collections.ObjectModel.Collection + { + } + + public abstract string ToString(ScriptEnvironment environment); + + public abstract object Clone(); + } +} diff --git a/MBS.Framework/Scripting/Strings/StringComponents/ConditionalStringComponent.cs b/MBS.Framework/Scripting/Strings/StringComponents/ConditionalStringComponent.cs new file mode 100644 index 0000000..e93d2e1 --- /dev/null +++ b/MBS.Framework/Scripting/Strings/StringComponents/ConditionalStringComponent.cs @@ -0,0 +1,10 @@ +using System; +using MBS.Framework.Logic.Conditional; + +namespace MBS.Framework.Scripting.Strings.StringComponents +{ + public class ConditionalStringComponent + { + public IConditionalStatement Condition { get; } + } +} diff --git a/MBS.Framework/Scripting/Strings/StringComponents/LiteralStringComponent.cs b/MBS.Framework/Scripting/Strings/StringComponents/LiteralStringComponent.cs new file mode 100644 index 0000000..9a2b3fd --- /dev/null +++ b/MBS.Framework/Scripting/Strings/StringComponents/LiteralStringComponent.cs @@ -0,0 +1,27 @@ +using System; +namespace MBS.Framework.Scripting.Strings.StringComponents +{ + public class LiteralStringComponent : StringComponent + { + public string Value { get; set; } = null; + + public override string ToString(ScriptEnvironment environment) + { + return Value; + } + public override string ToString() + { + return String.Format("\"{0}\"", Value); + } + + public LiteralStringComponent(string value) + { + Value = value; + } + + public override object Clone() + { + return new LiteralStringComponent(Value?.Clone() as string); + } + } +}