示例#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;
 }