Beispiel #1
0
        /// <summary>
        /// Deserialize string to <see cref="WitsSentence"/> collection
        /// </summary>
        /// <param name="witsData">WITS data string</param>
        /// <returns>Deserialized wits data of <see cref="WitsSentence"/> collection</returns>
        public IEnumerable <WitsSentence> StringToSentenceCollection(string witsData)
        {
            List <WitsSentence> wSent = new List <WitsSentence>();

            int startInd = 0;
            int stopInd  = 0;

            while (true)
            {
                startInd = witsData.IndexOf("&&", stopInd);
                if (startInd < 0)
                {
                    break;
                }
                stopInd = witsData.IndexOf("!!", startInd);
                if (stopInd < 0)
                {
                    break;
                }
                wSent.Add(WitsSentence.Parse(witsData.Substring(startInd, stopInd + 2 - startInd)));
            }

            return(wSent);
        }
Beispiel #2
0
 /// <summary>
 /// Convert byte array to <see cref="WitsSentence"/>
 /// </summary>
 /// <param name="sentenceInBytes">Wits sentence as byte array</param>
 /// <returns>Returns deserialized WITS sentence</returns>
 public WitsSentence BytesToSentence(byte[] sentenceInBytes)
 {
     return(WitsSentence.Parse(_encoding.GetString(sentenceInBytes)));
 }