예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateContainer"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 public TemplateContainer(TemplateContainer parent)
 {
     this.Parent = parent;
     this.Attributes = new Dictionary<string, object>();
     this.ArrayValues = new List<TemplateContainer>();
     this.ArrayValuesMap = new Dictionary<string, TemplateContainer>();
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateContainer"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 public TemplateContainer(TemplateContainer parent)
 {
     this.Parent         = parent;
     this.Attributes     = new Dictionary <string, object>();
     this.ArrayValues    = new List <TemplateContainer>();
     this.ArrayValuesMap = new Dictionary <string, TemplateContainer>();
 }
예제 #3
0
 private void BuildDomains(TemplateContainer node)
 {
     foreach (MetaDomain domain in model.Domains)
     {
         TemplateContainer arrnode = node.AddArrayValue(domain.Id.ToString());
         arrnode.AddFromObject(domain);
     }
 }
예제 #4
0
 public TemplateContainer Convert(MetaModel metamodel)
 {
     this.model = metamodel;
     TemplateContainer root = new TemplateContainer();
     root.AddAttribute("Test", "OK");
     this.BuildDomains(root.AddChild("Domains"));
     this.BuildColumns(root.AddChild("Columns"));
     this.BuildTables(root.AddChild("Tables"));
     return root;
 }
예제 #5
0
 /// <summary>
 /// Gets the key from array value.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 private string GetKeyFromArrayValue(TemplateContainer item)
 {
     foreach (KeyValuePair <string, TemplateContainer> kvp in this.ArrayValuesMap)
     {
         if (kvp.Value == item)
         {
             return(kvp.Key);
         }
     }
     return(null);
 }
예제 #6
0
파일: Form1.cs 프로젝트: jseijas/supido
 private void button2_Click(object sender, EventArgs e)
 {
     TemplateContainer container = new TemplateContainer();
     container.AddAttribute("varprueba", "prueba");
     container.AddAttribute("vartrans", "transformación");
     container.AddAttribute("i", 7);
     string s = "El resultado es [%if(i > 7)%]cierto[%else%]falso";
     s = TemplateTransformer.Transform(s);
     s = JavascriptEvaluator.ReplaceString(s, container);
     this.richTextBox2.Text = s;
 }
예제 #7
0
        /// <summary>
        /// Removes the array value.
        /// </summary>
        /// <param name="index">The index.</param>
        public void RemoveArrayValue(int index)
        {
            TemplateContainer item = this.ArrayValues[index];

            this.ArrayValues.RemoveAt(index);
            string key = this.GetKeyFromArrayValue(item);

            if (!string.IsNullOrEmpty(key))
            {
                this.ArrayValuesMap.Remove(key);
            }
        }
예제 #8
0
파일: Form1.cs 프로젝트: jseijas/supido
 public static string Test(string s, string expected, TemplateContainer container)
 {
     string result = JavascriptEvaluator.RunScript(s, container).ToString();
     if (result.Equals(expected))
     {
         return string.Format("OK '{0}' = {1}\n", s, result);
     }
     else
     {
         return string.Format("Error executing '{0}'. Expected {1} but obtained {2}\n", s, expected, result);
     }
 }
예제 #9
0
 private void BuildTables(TemplateContainer node)
 {
     foreach (MetaTable table in model.Tables)
     {
         TemplateContainer arrnode = node.AddArrayValue(table.Id.ToString());
         arrnode.AddFromObject(table);
         TemplateLink listLink = arrnode.AddListLink("Columns", "/Columns");
         foreach (MetaColumn column in table.Columns)
         {
             listLink.AddListValue(table.Id.ToString() + "!" + column.Ix.ToString());
         }
     }
 }
예제 #10
0
 public void BuildColumns(TemplateContainer node)
 {
     foreach (MetaTable table in model.Tables)
     {
         foreach (MetaColumn column in table.Columns)
         {
             TemplateContainer arrnode = node.AddArrayValue(table.Id.ToString() + "!" + column.Ix.ToString());
             arrnode.AddFromObject(column);
             arrnode.AddLink("Table", "Tables[" + column.TableId.ToString() + "]");
             MetaColumn currentcolumn = column;
             while (currentcolumn.TargetColumn != null)
             {
                 currentcolumn = currentcolumn.TargetColumn;
             }
             node.AddLink("Domain", "/Domains[" + currentcolumn.Domain.Id.ToString() + "]");
         }
     }
 }
예제 #11
0
 /// <summary>
 /// Adds the array value.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public TemplateContainer AddArrayValue(string key, TemplateContainer item)
 {
     this.ArrayValuesMap.Add(key, item);
     this.ArrayValues.Add(item);
     return item;
 }
예제 #12
0
 /// <summary>
 /// Adds the array value.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public TemplateContainer AddArrayValue(TemplateContainer item)
 {
     return this.AddArrayValue(this.ArrayValues.Count.ToString(), item);
 }
예제 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateLink"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="link">The link.</param>
 public TemplateLink(TemplateContainer parent, string link)
 {
     this.Parent = parent;
     this.Link = link;
     this.ListValues = null;
 }
예제 #14
0
 public TemplateContainer AddChild(string name, TemplateContainer container)
 {
     this.AddAttribute(name, container);
     return container;
 }
예제 #15
0
 /// <summary>
 /// Adds the array value.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public TemplateContainer AddArrayValue(string key, TemplateContainer item)
 {
     this.ArrayValuesMap.Add(key, item);
     this.ArrayValues.Add(item);
     return(item);
 }
예제 #16
0
 /// <summary>
 /// Adds the array value.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public TemplateContainer AddArrayValue(TemplateContainer item)
 {
     return(this.AddArrayValue(this.ArrayValues.Count.ToString(), item));
 }
예제 #17
0
 public TemplateContainer AddChild(string name, TemplateContainer container)
 {
     this.AddAttribute(name, container);
     return(container);
 }
예제 #18
0
 /// <summary>
 /// Gets the key from array value.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 private string GetKeyFromArrayValue(TemplateContainer item)
 {
     foreach (KeyValuePair<string, TemplateContainer> kvp in this.ArrayValuesMap)
     {
         if (kvp.Value == item)
         {
             return kvp.Key;
         }
     }
     return null;
 }
예제 #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateLink"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="link">The link.</param>
 public TemplateLink(TemplateContainer parent, string link)
 {
     this.Parent     = parent;
     this.Link       = link;
     this.ListValues = null;
 }