/// <summary> /// Initializes a new instance of the <see cref="CommandsFixture" /> class. /// </summary> public CommandsFixture() { string programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); string autodeskFolder = Path.Combine(programFiles, "Autodesk"); string rvtVersionString = RvtVersionUtil.GetRvtVersionString(); var revitFolder = $"Revit {rvtVersionString}"; var fullRevitFolder = Path.Combine(autodeskFolder, revitFolder); _assemblyResolver = new AssemblyResolver(fullRevitFolder); AppDomain.CurrentDomain.AssemblyResolve += _assemblyResolver.OnAssemblyResolve; RvtMapper.Initialize(cfg => cfg.AddProfile <ElementProfile>()); }
////[CanBeNull] ////private readonly IDialogService _dialogService; /// <summary> /// Initializes a new instance of the <see cref="App" /> class. /// Initialize as much logic in the constructor as possible /// </summary> public App() { Instance = this; try { AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; string location = Assembly.GetExecutingAssembly().Location; _assemblyDir = Path.GetDirectoryName(location).ThrowIfNull(); _assemblyResolver = new AssemblyResolver(_assemblyDir); AppDomain.CurrentDomain.AssemblyResolve += _assemblyResolver.OnAssemblyResolve; var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterModule <CommandModule>(); var container = containerBuilder.Build(); _autofacScope = container.BeginLifetimeScope("SampleRevitApp"); // The service locator is required in classes that are not initiated by this program // It is used for the GenericCommand class because we do not control its initialization ////var autofacServiceLocator = new AutofacServiceLocator(_autofacScope); ////ServiceLocator.SetLocatorProvider(() => autofacServiceLocator); ////_dialogService = _autofacScope.Resolve<IDialogService>(); ////_autofacScope.Resolve<ILogService>(); // The instance API of AutoMapper is used to avoid conflicts with other addins var mapperConf = new MapperConfiguration(cfg => cfg.AddProfile <ElementProfile>()); RvtMapper.Initialize(mapperConf); #if DEBUG RvtMapper.Instance.ConfigurationProvider.AssertConfigurationIsValid(); #endif } catch (Exception e) { Console.WriteLine(e); throw; } }