public override void Write(string message) { if (traceSwitch.Level == TraceLevel.Off) { return; } outputWindowService.Display(message); }
internal Dictionary <string, IAssetReference> GetAvailableRecipes(GuidancePackage guidancePackage) { #if DEBUG DateTime startTime = DateTime.Now; Debug.WriteLine(String.Format("GetAvailableRecipes - Start time {0}.", startTime.ToLongTimeString())); #endif Dictionary <string, IAssetReference> availableRecipes = new Dictionary <string, IAssetReference>(); IAssetReferenceService referenceService = (IAssetReferenceService)guidancePackage.GetService(typeof(IAssetReferenceService), true); IOutputWindowService outputWindow = guidancePackage.GetService <IOutputWindowService>(); IPersistenceService persistenceService = guidancePackage.GetService <IPersistenceService>(); IAssetReference[] allReferences = null; allReferences = persistenceService.LoadReferences(guidancePackage.Configuration.Name); #if DEBUG Debug.WriteLine(String.Format("GetAvailableRecipes - Probing using {0} references.", allReferences.Length)); #endif List <IUnboundAssetReference> unboundAssetReferenceList; List <IAssetReference> otherAssetList; GetAssetLists(allReferences, out unboundAssetReferenceList, out otherAssetList); #if DEBUG Debug.WriteLine(String.Format("GetAvailableRecipes - Probing using {0} unbound references.", unboundAssetReferenceList.Count)); Debug.WriteLine(String.Format("GetAvailableRecipes - Probing using {0} other references.", otherAssetList.Count)); #endif List <object> allPossibleTargets = GetAllSolutionExplorerItems(); #if DEBUG Debug.WriteLine(String.Format("GetAvailableRecipes - Probing against {0} targets.", allPossibleTargets.Count)); #endif List <IUnboundAssetReference> unboundAssetReferenceWithNoTargetList = new List <IUnboundAssetReference>(); foreach (IUnboundAssetReference unboundAssetReference in unboundAssetReferenceList) { bool referenceHasValidTarget = false; foreach (object item in allPossibleTargets) { try { if (unboundAssetReference.IsEnabledFor(item)) { referenceHasValidTarget = true; break; } } catch (Exception resolveReferenceException) { // The reference is not valid for this item. outputWindow.Display(string.Format(Resources.Navigator_ReferenceThrowException, unboundAssetReference.AssetName, resolveReferenceException.Message)); } } if (!referenceHasValidTarget) { unboundAssetReferenceWithNoTargetList.Add(unboundAssetReference); } } #if DEBUG Debug.WriteLine(String.Format("GetAvailableRecipes - Removing {0} unbound referenes with no valid targets", unboundAssetReferenceWithNoTargetList.Count)); #endif // remove those unbound asset references that don't have a valid target in the whole solution foreach (IUnboundAssetReference reference in unboundAssetReferenceWithNoTargetList) { unboundAssetReferenceList.Remove(reference); } // add the unbound asset references that have a valid target foreach (IAssetReference reference in unboundAssetReferenceList) { otherAssetList.Add(reference); } foreach (IAssetReference reference in otherAssetList) { if (!availableRecipes.ContainsKey(reference.AssetName)) { availableRecipes.Add(reference.AssetName, reference); } } #if DEBUG DateTime endTime = DateTime.Now; Debug.WriteLine(String.Format("GetAvailableRecipes - End time {0}.", endTime.ToLongTimeString())); TimeSpan ts = endTime.Subtract(startTime); Debug.WriteLine(String.Format("GetAvailableRecipes - Executed in {0} ms.", ts.Milliseconds)); #endif return(availableRecipes); }
public override void Write(string message) { outputWindowService.Display(message); }