Exemplo n.º 1
0
        public void Replace_Comment_Text_Test()
        {
            IDataRepository <Journal> dataRepository = new JournalData();
            IPerson <Person>          userdb         = new PersonData();
            var user    = new Person();
            var journal = dataRepository.GetById(1);

            //if (journal.CommentString.Contains("@"))
            //{
            //    Console.WriteLine("True");
            //    string name = "HARRY";
            //    int index = journal.CommentString.IndexOf("@");
            //    journal.CommentString = journal.CommentString.Remove(index, name.Length);
            //    journal.CommentString = journal.CommentString.Insert(index, name);
            //    Console.WriteLine(journal.CommentString);
            //}

            string[] words = journal.Journey.ContentString.Split(' ');
            for (int i = 0; i < words.Count(); i++)
            {
                if (words[i].Contains("@"))
                {
                    words[i] = words[i].Trim('@');
                    string pattern = "\\b" + $"{words[i]}" + "\\b";
                    user = userdb.GetUnitByName(words[i]);
                    string replace = $"{user}";
                    journal.Journey.ContentString = Regex.Replace(journal.Journey.ContentString.Replace("@", ""), pattern, replace, RegexOptions.IgnoreCase);
                }
            }
            Object t = new object();

            t = "gfgf" + user + "xcv";
            Console.WriteLine(journal.Journey);
        }
Exemplo n.º 2
0
        public void CommentObject_Test()
        {
            IPerson <Person> userdb = new PersonData();
            Person           person = new Person();

            person = userdb.GetUnitByName("sally");
            StringBuilder str = new StringBuilder();

            str.Append("Hello Mrs ");
            str.Append(person);
            str.Append(" .We hope that you are well");
            Console.WriteLine(str);
        }