aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2020-06-02 01:56:18 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2020-06-02 01:56:18 +0200
commitbebb97c35d322ca1a32f836470c3511f07ee3464 (patch)
tree8068888e16808a803aa880dacaeee529b2330662
parentd137c0e74445b540bcdafc7a9e04463b4199c076 (diff)
replace styling constant in iml files while generating instantiator
-rw-r--r--Crow/src/IML/Instantiator.cs41
-rw-r--r--Crow/src/styling/StyleReader.cs7
2 files changed, 38 insertions, 10 deletions
diff --git a/Crow/src/IML/Instantiator.cs b/Crow/src/IML/Instantiator.cs
index 0aa49eb4..4254933b 100644
--- a/Crow/src/IML/Instantiator.cs
+++ b/Crow/src/IML/Instantiator.cs
@@ -31,7 +31,7 @@ namespace Crow.IML {
/// - Default values (appearing as attribute in C#) loading
/// - Styling
///
- /// Instantiators are shared amongs interfaces. Their are stored with their path as key, and inlined template
+ /// Their are stored in the Interface with their path as key, and inlined template
/// and itemtemplate are stored with a generated uuid
/// </summary>
public class Instantiator
@@ -470,17 +470,44 @@ namespace Crow.IML {
if (reader.Name == "Style" || reader.Name == "DataSourceType" || reader.Name == "Template")
continue;
- #if DESIGN_MODE
+#if DESIGN_MODE
emitSetDesignAttribute (ctx, reader.Name, reader.Value);
- #endif
+#endif
+
+ string imlValue = reader.Value;
+ StringBuilder styledValue = new StringBuilder();
+
+ int vPtr = 0;
+ while (vPtr < imlValue.Length) {
+ if (imlValue [vPtr] == '$') {
+ if (imlValue [vPtr+1] == '{') {
+ vPtr+=2;
+ string cstId = "";
+ while (vPtr < imlValue.Length) {
+ if (imlValue [vPtr] == '}') {
+ vPtr++;
+ break;
+ }
+ cstId += imlValue [vPtr++];
+ }
+ if (string.IsNullOrEmpty (cstId) || !iface.StylingConstants.ContainsKey (cstId))
+ throw new Exception ("undefined constant id: " + cstId);
+ styledValue.Append (iface.StylingConstants [cstId]);
+ continue;
+ }
+ }
+ styledValue.Append (imlValue [vPtr++]);
+ }
+ imlValue = styledValue.ToString ();
MemberInfo mi = ctx.CurrentNodeType.GetMember (reader.Name).FirstOrDefault ();
if (mi == null)
throw new Exception ("Member '" + reader.Name + "' not found in " + ctx.CurrentNodeType.Name);
if (mi.MemberType == MemberTypes.Event) {
- foreach (string exp in reader.Value.Split (';')) {
+ foreach (string exp in imlValue.ToString().Split (';')) {
string trimed = exp.Trim();
+
if (trimed.StartsWith ("{", StringComparison.Ordinal))
compileAndStoreDynHandler (ctx, mi as EventInfo, trimed.Substring (1, trimed.Length - 2));
else
@@ -496,10 +523,10 @@ namespace Crow.IML {
if (pi.Name == "Name")
ctx.StoreCurrentName (reader.Value);
- if (reader.Value.StartsWith ("{", StringComparison.Ordinal))
- readPropertyBinding (ctx, reader.Name, reader.Value.Substring (1, reader.Value.Length - 2));
+ if (imlValue.StartsWith ("{", StringComparison.Ordinal))
+ readPropertyBinding (ctx, reader.Name, imlValue.Substring (1, reader.Value.Length - 2));
else
- CompilerServices.EmitSetValue (ctx.il, pi, reader.Value);
+ CompilerServices.EmitSetValue (ctx.il, pi, styledValue);
}
reader.MoveToElement ();
diff --git a/Crow/src/styling/StyleReader.cs b/Crow/src/styling/StyleReader.cs
index cace196a..218032e7 100644
--- a/Crow/src/styling/StyleReader.cs
+++ b/Crow/src/styling/StyleReader.cs
@@ -20,7 +20,8 @@ namespace Crow
enum States { classNames, members, value, endOfStatement }
States curState = States.classNames;
-
+ int column = 1;
+ int line = 1;
#region Character ValidityCheck
static Regex rxValidChar = new Regex(@"\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\p{Cf}");
@@ -62,8 +63,8 @@ namespace Crow
/// <param name="iFace">the Interface to load the style for</param>
public void Parse (Interface iFace, string resId)
{
- int column = 1;
- int line = 1;
+ column = 1;
+ line = 1;
curState = States.classNames;
string styleKey = resId.Substring (0, resId.Length - 6);