protected override void Initialize() { base.Initialize(); // this sucks - the options page grid needs access to the OptionsService when the options are loaded // however, I can't use GetService in the constructor for the OptionPageGrid because the Site is not // yet initialised - by the time it IS initialised, we also load our options - I think this is the // safest way (if not cleanest) to ensure we have an options service ready to push our data into var componentModel = GetService(typeof(SComponentModel)) as IComponentModel; OptionPageGrid.OptionsService = componentModel.GetService <IEditorOptionsFactoryService>(); // this also sucks - here we force the options to be loaded as they are otherwise NOT loaded even when // the package and MEF component ARE loaded - the only time it auto loads is if we go into the options page OptionPageGrid page = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid)); }
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); base.Initialize(); // this sucks - the options page grid needs access to the OptionsService when the options are loaded // however, I can't use GetService in the constructor for the OptionPageGrid because the Site is not // yet initialised - by the time it IS initialised, we also load our options - I think this is the // safest way (if not cleanest) to ensure we have an options service ready to push our data into var componentModel = await GetServiceAsync(typeof(SComponentModel)) as IComponentModel; if (componentModel != null) { OptionPageGrid.OptionsService = componentModel.GetService <IEditorOptionsFactoryService>(); // this also sucks - here we force the options to be loaded as they are otherwise NOT loaded even when // the package and MEF component ARE loaded - the only time it auto loads is if we go into the options page OptionPageGrid page = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid)); } }