public void SetData(TranslateMessageData newData) { m_Data = newData; var strings = Data.Text.Split(new char[] { '[', ']' }); m_MessageParts = new MessagePart[strings.Count()]; for (int i = 0; i < strings.Count(); i++) { m_MessageParts[i] = new MessagePart(strings[i]); } for (int i = 0; i < m_MessageParts.Count(); i++) { for (int j = 0; j < Data.OptionSet.Count(); j++) { if (m_MessageParts[i].Text == Data.OptionSet[j].Name) { if (Data.OptionSet[j].Options.Count() < 2) { break; } m_MessageParts[i] = new MessagePart(Data.OptionSet[j].Name, j); break; } } } }