// TODO: Move to CodeRush.State public ContextProviderBase[] GetStateContextProviders() { StateProviderBase[] lProviders = CodeRush.States.Providers; if (lProviders == null) { return(new ContextProviderBase[0]); } ContextProviderBase[] lContextProviders = new ContextProviderBase[lProviders.Length]; for (int i = 0; i < lProviders.Length; i++) { lContextProviders[i] = lProviders[i].StateContext; } return(lContextProviders); }
public IContextProvider Create(Thread th) { ContextProviderBase provider = null; switch (KPolicy.PeriodicDisposalStrategy) { case Strategy.DisposeLeastRecentlyUsed: provider = new SimpleContextProvider(KConnection); break; default: provider = new ContextProviderWithAge(KConnection); break; } return(provider); }
private ContextProviderBase[] FilterSatisfiedProviders(ContextProviderBase[] providers) { if (providers == null || providers.Length == 0) { return(new ContextProviderBase[0]); } ArrayList lSatisfied = new ArrayList(); for (int i = 0; i < providers.Length; i++) { ContextProviderBase lProvider = providers[i]; if (CodeRush.Context.Satisfied(lProvider.ProviderName) == ContextResult.Satisfied) { lSatisfied.Add(lProvider); } } ContextProviderBase[] lResult = new ContextProviderBase[lSatisfied.Count]; lSatisfied.CopyTo(lResult); return(lResult); }
private bool StateContextMatches() { ContextProviderBase[] lStateProviders = GetStateContextProviders(); ContextProviderBase[] lSatisfiedProviders = FilterSatisfiedProviders(lStateProviders); bool lIsAnyStateActive = lSatisfiedProviders.Length > 0; if (lIsAnyStateActive) { for (int i = 0; i < lSatisfiedProviders.Length; i++) { ContextProviderBase lProvider = lSatisfiedProviders[i]; if (_Context.Selected.Contains(lProvider.ProviderName)) { DevExpress.CodeRush.Core.KeyboardServices.LogShortcutMessage("StateContextMatches inside loop"); return(true); } } DevExpress.CodeRush.Core.KeyboardServices.LogShortcutMessage("!StateContextMatches"); return(false); } DevExpress.CodeRush.Core.KeyboardServices.LogShortcutMessage("StateContextMatches"); return(true); }