internal string GetMeasuresText()
        {
            if (this._database == null)
            {
                if (_isConnecting)
                {
                    return("-- Reading metadata from the database.  Please retry operation later.");
                }

                return("-- Not connected to the database.");
            }

            var sb           = new StringBuilder();
            var restrictions = new AdomdRestrictionCollection();

            restrictions.Add("DatabaseID", _database.ID);
            var dataSet = _adomdConn.GetSchemaDataSet("DISCOVER_XML_METADATA", restrictions);

            Debug.Assert(dataSet.Tables.Count == 1);
            var table = dataSet.Tables[0];

            Debug.Assert(table.Columns.Count == 1);
            Debug.Assert(table.Rows.Count == 1);
            var script = table.Rows[0][0] as string;

            Debug.Assert(!string.IsNullOrEmpty(script));

            var mc = MeasuresContainer.ParseText(script);

            sb.Append(mc.GetDaxText());

            return(sb.ToString());
        }
 /// <summary>
 /// Gets Measures section of BIM file
 /// </summary>
 internal static string GetMeasuresFromBimFile(string bimFilePath)
 {
     try
     {
         if (!File.Exists(bimFilePath))
         {
             throw new FileNotFoundException(string.Format("Model file {0} doesn't exist.", bimFilePath));
         }
         string bimScript = File.ReadAllText(bimFilePath);
         var    mc        = MeasuresContainer.ParseText(bimScript);
         return(mc.GetDaxText());
     }
     catch (Exception e)
     {
         throw new DaxException(string.Format("Error while reading measures from file '{0}'", bimFilePath), e);
     }
 }