public Task InitializeAsync() { try { _logger.InfoFormat("Initializing Async"); Container.RegisterInstance <Bootstrapper>(this); var sc = new SchedulerContext( new SharedScheduler(TaskScheduler.FromCurrentSynchronizationContext(), DispatcherSchedulerEx.Current), new SharedScheduler(TaskScheduler.Default, Scheduler.Default)); Container.RegisterInstance <ISchedulerContext>(sc); ObservableObjectBase.DispatcherSynchronizationContext = SynchronizationContext.Current; } catch (Exception e) { _logger.Error("An error occurred in the initialization block: ", e); throw; } return(Task.Factory.StartNew(() => { try { _logger.InfoFormat("... 1of4 base.Initialize()"); base.Initialize(); // Do init async // Bootstrap example definitions _logger.InfoFormat("... 2of4 IModule.Initializer()"); Container.Resolve <IModule>().Initialize(); _logger.InfoFormat("... 3of4 Resolve IMainWindowViewModel"); var vm = ServiceLocator.Container.Resolve <IMainWindowViewModel>(); // Bootstrap D3D to save time on startup _logger.InfoFormat("... 4of4 D3D11.Initialize()"); SciChart.Drawing.DirectX.Context.D3D11.Direct3D11RenderSurface.InitEngineAsync().Then(r => { vm.InitReady = true; }); } catch (Exception e) { _logger.Error("One or more errors occurred during initialization of the MainViewModel or DirectX11 engine", e); throw; } })); }
public IEnumerable <Type> DiscoverAttributedTypes <T>() where T : Attribute { var attributeType = typeof(T); if (CachedTypesByAttributeType.ContainsKey(attributeType)) { return(CachedTypesByAttributeType[attributeType]); } Log.InfoFormat("Discovering Types with Attribute {0}", attributeType); var allTypes = new List <Type>(); foreach (var assembly in _assemblyDiscovery.GetAssemblies()) { allTypes.AddRange(ReflectionUtil.DiscoverTypesWithAttribute(attributeType, assembly)); } var attributedTypes = allTypes.ToArray(); CachedTypesByAttributeType.Add(attributeType, attributedTypes); return(attributedTypes); }
public IEnumerable <Assembly> GetAssemblies() { if (_assemblies == null) { _assemblies = new List <Assembly>(); var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // Search the directory for assemblies. Exclude those in the exclude list var assemblyDlls = Directory.GetFiles(assemblyPath, "*.dll") .Where(asm => !_excludeList.Any(exl => asm.Contains(exl))); var exes = Directory.GetFiles(assemblyPath, "*.exe") .Where(asm => !_excludeList.Any(exl => asm.Contains(exl))); var assemblyFiles = assemblyDlls.Concat(exes).ToArray(); foreach (var assemblyFile in assemblyFiles) { try { Log.InfoFormat(" ... Loading assembly {0}", assemblyFile); var assembly = Assembly.Load(Path.GetFileNameWithoutExtension(assemblyFile)); if (!_assemblies.Contains(assembly)) { _assemblies.Add(assembly); } } catch (Exception caught) { Log.Error(caught); } } } return(_assemblies); }