Ejemplo n.º 1
0
        private static string processBlock(VariablesResult variable, string block, string superVariable)
        {
            string result = "";

            try
            {
                if (variable.Values != null && variable.Values.Count > 0)
                {
                    variable.Values.ForEach(value =>
                    {
                        if (string.IsNullOrEmpty(superVariable))
                        {
                            result = result + block.Replace("<!" + variable.Name + "!>", value.Value);
                        }
                        else
                        {
                            result = result + block.Replace("<!" + superVariable + "." + variable.Name + "!>", value.Value);
                        }

                        if (value.Variables != null && value.Variables.Count > 0)
                        {
                            value.Variables.ForEach(variablesResult =>
                            {
                                if (string.IsNullOrEmpty(superVariable))
                                {
                                    result = processBlock(variablesResult, result, variable.Name);
                                }
                                else
                                {
                                    result = processBlock(variablesResult, result, superVariable + "." + variable.Name);
                                }
                            });
                        }
                    });
                }
                else
                {
                    if (string.IsNullOrEmpty(superVariable))
                    {
                        result = result + block.Replace("<!" + variable.Name + "!>", "");
                    }
                    else
                    {
                        result = result + block.Replace("<!" + superVariable + "." + variable.Name + "!>", "");
                    }
                }
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Ejemplo n.º 2
0
        private static string processVariable(VariablesResult variable, string value, string superVariable)
        {
            string result = value;

            try
            {
                if (variable.Values != null && variable.Values.Count > 0)
                {
                    if (string.IsNullOrEmpty(superVariable))
                    {
                        result = result.Replace("<%" + variable.Name + "%>", variable.Values.First().Value);
                    }
                    else
                    {
                        result = result.Replace("<%" + superVariable + "." + variable.Name + "%>", variable.Values.First().Value);
                    }

                    if (variable.Values.First().Variables != null && variable.Values.First().Variables.Count > 0)
                    {
                        variable.Values.First().Variables.ForEach(variablesResult =>
                        {
                            if (string.IsNullOrEmpty(superVariable))
                            {
                                result = processVariable(variablesResult, result, variable.Name);
                            }
                            else
                            {
                                result = processVariable(variablesResult, result, superVariable + "." + variable.Name);
                            }
                        });
                    }
                }
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }