Ejemplo n.º 1
0
        /// <summary>
        /// Replaces the exposed property when we get the text
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private string ReplaceWithExposedPropety(string text)
        {
            string finalText = "";

            //We make sure that at least once, both of the chars are contained and they are in the right order
            if (text.Contains("{") && text.Contains("}") && text.IndexOf('{') < text.IndexOf('}'))
            {
                //If so, we start by extracting the first part of the string (before the {)
                int startIndex = text.IndexOf('{');
                int endIndex   = text.IndexOf('}');
                while (text.Contains("{") && text.Contains("}") && startIndex < endIndex)
                {
                    finalText += text.Substring(0, startIndex);
                    finalText += currentDialogue.GetExposedProperty(text.Substring(startIndex + 1, endIndex - startIndex - 1));
                    //We crop the text
                    text = text.Substring(endIndex + 1);
                    //And get the new indexes
                    startIndex = text.IndexOf('{');
                    endIndex   = text.IndexOf('}');
                }
                //When we finish, we have a final value in 'text' that does not contain any value to replace, so we add it
                finalText += text;
            }
            else
            {
                finalText = text;
            }

            return(finalText);
        }