Пример #1
0
        /// <summary>
        /// Validate given <paramref name="mat"/> match with given compiler <paramref name="mode"/>
        /// </summary>
        /// <param name="mode">Compiler mode</param>
        /// <param name="mat">Matrix to check</param>
        /// <param name="disposeIfInvalid">True if given matrix needs to be disposed after an unsuccessful validation</param>
        public static void CheckModeAndMatrixReference(CompilerDictionaryMode mode,
                                                       dynamic mat,
                                                       bool disposeIfInvalid = false)
        {
            if (mode == CompilerDictionaryMode.Dataframe && !(mat is Dataframe))
            {
                if (disposeIfInvalid)
                {
                    ((Dataframe)mat).Dispose();
                }

                throw new Exception(CompilerMessage.COMPILER_MODE_MISMATCH(mode));
            }
            else if (mode == CompilerDictionaryMode.Matrix && mat is Dataframe dataframe)
            {
                if (disposeIfInvalid)
                {
                    dataframe.Dispose();
                }

                throw new Exception(CompilerMessage.COMPILER_MODE_MISMATCH(mode));
            }
        }