1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- /*-------------------------------------------------------------------------
- * 功能描述:VersionManager
- * 作者:xulisong
- * 创建时间: 2019/1/16 15:47:21
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Autodesk.RevitAddIns;
- namespace RevitVersion
- {
- /// <summary>
- /// 版本管理
- /// </summary>
- public class VersionManager
- {
- static VersionManager()
- {
- Current = new VersionManager();
- }
- public static VersionManager Current
- {
- get;private set;
- }
- /// <summary>
- /// 当前版本信息
- /// </summary>
- public Version Version
- {
- get
- {
- #if R14
- return Version.Revit2017;
- #elif R15
- return Version.Revit2015;
- #elif R16
- return Version.Revit2016;
- #elif R17
- return Version.Revit2017;
- #elif R18
- return Version.Revit2018;
- #endif
- }
- }
- public static List<RevitProduct> GetRevitProducts()
- {
- return RevitProductUtility.GetAllInstalledRevitProducts();
- }
- private RevitProduct m_Product;
- public RevitProduct Product
- {
- get
- {
- if (m_Product == null)
- {
- var products = GetRevitProducts();
- m_Product = products.FirstOrDefault(p => p.Version.ToString() == Version.ToString());
- }
- return m_Product;
- }
- }
- }
- }
|