private void Initialize() { OSD.OSD.SettingsFilePath = Path.Combine(CraftSynth.BuildingBlocks.UI.Console.ApplicationPhysicalPath, "OSD.ini"); PopulateCommandsProviders(); PopulateCommands(); MergeCommands(); SuggestionsCache.DropAllCache(); SuggestionsCache.BuildAllCache(); }
private Dictionary <string, IWorkItem> GetAvailableSuggestions(Command bestCandidateForUsedCommand) { MessagesHandler.Display("Retrieving suggestions. Please wait..."); Dictionary <string, IWorkItem> suggestions = new Dictionary <string, IWorkItem>(); foreach (Type supportedParameterTypeProvider in bestCandidateForUsedCommand.supportedParameterTypeProviders) { try { Application.DoEvents(); IWorkItemsProvider ptp = Assembly.GetExecutingAssembly().CreateInstance(supportedParameterTypeProvider.FullName) as IWorkItemsProvider; foreach (KeyValuePair <string, IWorkItem> kv in SuggestionsCache.Get(ptp)) { IWorkItem existingWorkItemWithSameName = null; if (suggestions.TryGetValue(kv.Key, out existingWorkItemWithSameName)) { string message = string.Format("Can't add item '{0}' from provider '{1}' because item with same name allready loaded from provider {2}.", kv.Key, kv.Value.GetProvider().GetType().Name, existingWorkItemWithSameName.GetProvider().GetType().Name); Logging.AddErrorLog(message); //MessagesHandler.Display(message); } else { suggestions.Add(kv.Key, kv.Value); } } } catch (Exception exception) { MessagesHandler.Display("Error occured while retriving suggestions", exception.Message); Logging.AddErrorLog("Error occured while retriving suggestions: " + exception.Message + ((exception.InnerException != null) ? ":" + exception.InnerException.Message : "")); Common.Logging.AddExceptionLog(exception); } } MessagesHandler.HideAllMessages(); return(suggestions); }