/*-------------------------------------------------------------------------
 * 功能描述：RevitUtils
 * 作者：xulisong
 * 创建时间： 2019/7/29 9:08:18
 * 版本号：v1.0
 *  -------------------------------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SAGA.DotNetUtils.Revit;

namespace ExportStart
{
    public class RevitUtils
    {
        /// <summary>
        /// 获取Revit搜索dll路径
        /// </summary>
        /// <returns></returns>
        public static List<string> GetSearchPath()
        {
            //选择版本时，预先将版本信息写在RevitFileVision.txt文件中,读取版本号
            var vision = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, StarterConst.RevitFileVisionFile));
            var revitVision = $"{vision}";
            return SAGA.DotNetUtils.Revit.RevitProductUtility.GetAllInstalledRevitProducts().Where(t => t.Item1==(revitVision)).Select(t => t.Item2).ToList();
#if DEBUG
#else
         return new List<string>(){GetRevitDllPath()};
#endif
        }
        #region dll路径管理
        /// <summary>
        /// 获取RevitDll，所在目录
        /// </summary>
        /// <returns></returns>
        public static string GetRevitDllPath()
        {
            if (!string.IsNullOrWhiteSpace(m_RevitDllPath))
            {
                return m_RevitDllPath;
            }
            return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\\RevitDlls");
        }

        private static string m_RevitDllPath;
        public static void SetRevitkDllPath(string path)
        {
            m_RevitDllPath = path;
        } 
        #endregion
    }
}
