Beispiel #1
0
        public BafFileReader(string bafFilePath)
        {
            if (string.IsNullOrWhiteSpace(bafFilePath))
            {
                throw new ArgumentNullException("bafFilePath");
            }
            if (!File.Exists(bafFilePath))
            {
                throw new FileNotFoundException("Baf file not exists.");
            }

            this.bafFilePath = bafFilePath;

            try
            {
                sqlFilePath = Baf2SqlWrapper.GetSQLiteCacheFilename(bafFilePath);

                // First argument = 1, ignore contents of Calibrator.ami (if it exists)
                baf2SqlHandle = Baf2SqlWrapper.baf2sql_array_open_storage(1, bafFilePath);

                if (baf2SqlHandle == 0)
                {
                    Baf2SqlWrapper.ThrowLastBaf2SqlError();
                }

                linq2BafSql = new Linq2BafSql(sqlFilePath);

                model = MzLiteJson.HandleExternalModelFile(this, GetModelFilePath());
                supportedVariables = SupportedVariablesCollection.ReadSupportedVariables(linq2BafSql);
            }
            catch (Exception ex)
            {
                throw new MzLiteIOException(ex.Message, ex);
            }
        }
Beispiel #2
0
            public static SupportedVariablesCollection ReadSupportedVariables(Linq2BafSql linq2BafSql)
            {
                var variables = linq2BafSql
                                .SupportedVariables
                                .ToArray()
                                .Where(x => x.Variable.HasValue && string.IsNullOrWhiteSpace(x.PermanentName) == false);

                var col = new SupportedVariablesCollection();

                foreach (var item in variables)
                {
                    col.Add(item);
                }

                return(col);
            }
Beispiel #3
0
            public bool TryGetValue(string variablePermanentName, SupportedVariablesCollection supportedVariables, out decimal value)
            {
                BafSqlSupportedVariable variable;

                if (supportedVariables.TryGetItem(variablePermanentName, out variable))
                {
                    if (Contains(variable.Variable.Value))
                    {
                        value = this[variable.Variable.Value].Value.Value;
                        return(true);
                    }
                    else
                    {
                        value = default(decimal);
                        return(false);
                    }
                }
                else
                {
                    value = default(decimal);
                    return(false);
                }
            }