Exemplo n.º 1
0
        /// <summary>
        /// Use this block reference to derive a custom block based on the variable argument counts.
        /// </summary>
        /// <param name="?">original reference</param>
        /// <returns>derived description</returns>
        public AdvanceBlockDescription Derive(AdvanceBlockReference reference)
        {
            if (reference.Varargs.Count == 0)
            {
                return(this);
            }

            AdvanceBlockDescription result = new AdvanceBlockDescription();

            result.Assign(this);
            result.Inputs = new Dictionary <string, AdvanceBlockParameterDescription>();
            foreach (KeyValuePair <string, AdvanceBlockParameterDescription> e in this.Inputs)
            {
                int count;
                if (reference.Varargs.TryGetValue(e.Key, out count))
                {
                    for (int i = 1; i <= count; i++)
                    {
                        AdvanceBlockParameterDescription value = e.Value.Copy();
                        value.Type    = e.Value.Type; // keep shared type
                        value.Id      = e.Key + i;
                        value.Varargs = false;
                        result.Inputs.Add(value.Id, value);
                    }
                }
                else
                {
                    result.Inputs.Add(e.Key, e.Value);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Assign (shared) values from the other block description.
 /// </summary>
 /// <param name="other"></param>
 public void Assign(AdvanceBlockDescription other)
 {
     this.Id          = other.Id;
     this.Category    = other.Category;
     this.DisplayName = other.DisplayName;
     this.Keywords.AddRange(other.Keywords);
     this.Documentation = other.Documentation;
     foreach (KeyValuePair <string, AdvanceBlockParameterDescription> kvp in other.Inputs)
     {
         this.Inputs[kvp.Key] = kvp.Value;
     }
     foreach (KeyValuePair <string, AdvanceBlockParameterDescription> kvp in other.Outputs)
     {
         this.Outputs[kvp.Key] = kvp.Value;
     }
     foreach (KeyValuePair <string, AdvanceTypeVariable> kvp in other.TypeVariables)
     {
         this.TypeVariables[kvp.Key] = kvp.Value;
     }
     this.Tooltip = other.Tooltip;
 }