Exemple #1
0
        public static string GetInChI(ref InChIStrucInput inp, out int retCode)
        {
            InChIStringOutput output = new InChIStringOutput();
            string            ret;

            // Console.WriteLine("try getinchi starting");
            try
            {
                retCode = GetInChI(ref inp, out output);
                ret     = output.InChI;
            }
            finally
            {
                output.Dispose();
            }

            return(ret);
        }
Exemple #2
0
        public static string GetInChIKey(ref InChIStrucInput inp)
        {
            var retCode = GetInChI(ref inp, out InChIStringOutput output);

            if (retCode != 0)
            {
                throw new ApplicationException($"GetInChI returned code {retCode}. Internal error: {output.ErrorMessage}");
            }
            try
            {
                sbyte *inchiKeyPtr = stackalloc sbyte[28];
                retCode = GetInChIKey(output.inchi, inchiKeyPtr);
                if (retCode != 0)
                {
                    throw new ApplicationException($"GetInChIKey returned code {retCode}");
                }
                return(new string(inchiKeyPtr, 0, 27));
            }
            finally
            {
                output.Dispose();
            }
        }
Exemple #3
0
 public static string GetInChI(ref InChIStrucInput inp) => GetInChI(ref inp, out int ret);
Exemple #4
0
 public static extern int GetInChI(ref InChIStrucInput structData, out InChIStringOutput output);