Finds contentitems for an IEntityProperty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<IContentItem> FindContentItems(this IScreenObject screen, IEntityProperty viewModel) | |
{ | |
IPresentationScreenView screenView = VsExportProviderService | |
.GetServiceFromCache<IServiceProxy>().ScreenViewService.GetScreenView(screen) as IPresentationScreenView; | |
if (screenView == null) | |
{ | |
throw new InvalidOperationException(); | |
} | |
IContentItem currentView = screenView.ContentItemTree; | |
var alreadyFoundViews = new List<IContentItem>(); | |
FindContentItems(currentView, viewModel, alreadyFoundViews); | |
return alreadyFoundViews; | |
} | |
private static void FindContentItems(IContentItem currentView, IEntityProperty viewModel, List<IContentItem> alreadyFoundViews) | |
{ | |
if (currentView != null) | |
{ | |
if (currentView.Details != null && currentView.Details.Equals(viewModel)) | |
{ | |
alreadyFoundViews.Add(currentView); | |
} | |
foreach (var child in currentView.ChildItems) | |
{ | |
FindContentItems(child, viewModel, alreadyFoundViews); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment