示例#1
0
        /// <summary>
        /// Get count of structure components (fragments) from the formula part of the inchi
        /// </summary>
        /// <param name="inchi"></param>
        /// <returns></returns>

        public static int GetComponentCount(string inchi)
        {
            string mf = GetMf(inchi);

            if (Lex.IsUndefined(mf))
            {
                return(0);
            }
            int componentCount = Lex.CountCharacter(mf, '.') + 1;

            return(componentCount);
        }
示例#2
0
        /// <summary>
        /// Deserialize a string format DataRow value object array
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>

        public static object[] DeserializeText(
            string content)
        {
            string[] sa;
            string   vos;
            int      voi = 0, sai = 0;

            int cnt = Lex.CountCharacter(content, '>');

            object[] oa = new object[cnt];
            int      ltbrk = 0, rtbrk = 0;

            try
            {
                for (voi = 0; voi < cnt; voi++)
                {
                    for (rtbrk = ltbrk + 1; rtbrk < content.Length; rtbrk++)
                    {
                        if (content[rtbrk] == '>')
                        {
                            break;
                        }
                    }

                    vos   = content.Substring(ltbrk + 1, rtbrk - ltbrk - 1);
                    ltbrk = rtbrk + 1;                     // move to next
                    if (vos.Length == 0)
                    {
                        continue;                                      // null
                    }
                    sa = vos.Split(',');

                    for (sai = 0; sai < sa.Length; sai++)                     // convert back to original form
                    {
                        sa[sai] = MobiusDataType.DenormalizeForDeserialize(sa[sai]);
                    }

                    char type = sa[0][0];
                    switch (type)
                    {
                    case 's':                             // string
                        oa[voi] = sa[1];
                        break;

                    case 'i':                             // integer
                        oa[voi] = int.Parse(sa[1]);
                        break;

                    case 'f':                             // double
                        oa[voi] = double.Parse(sa[1]);
                        break;

                    case 'd':                             // date time - stored as tick count
                        long ticks = long.Parse(sa[1]);
                        oa[voi] = new DateTime(ticks);
                        break;

                    default:
                        oa[voi] = MobiusDataType.Deserialize(sa);
                        break;
                    }
                }

                //if (oa[0] == "02507049") oa = oa; // debug
            }

            catch (Exception ex)
            {
                string msg = "Deserialization error at position: " + voi + ", " + sai + " for string:\n\n" +
                             content + "\n\n" + DebugLog.FormatExceptionMessage(ex);

                //ServicesLog.Message(msg);
                throw new Exception(msg, ex);
            }

            return(oa);
        }