// This file is part of the Lobster.FolderBrowser library // Copyright: Andreas Raczek // This file is published under the The Code Project Open License (CPOL) // See the file "CPOL.html" for the full license governing this code. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel.Composition.Hosting; using System.ComponentModel.Composition; using Lobster.Components; namespace Lobster.FolderBrowser { internal class PathModelSelector { private EntityFrameworkComposer<IPathModelCreator> efc; public PathModelSelector() { efc = new EntityFrameworkComposer<IPathModelCreator>(this.GetType().Assembly); } public IPathModelCreator SelectCreatorForNav(string offsetPath, string path, ICollection<IPathModelConfiguration> confs) { foreach (var c in efc.Prototypes) { IPathModelCreator pmc = (IPathModelCreator) c.Clone(); if (pmc.CanNavigate(offsetPath, path)) { pmc.Configuration = FindConfiguration(confs, pmc.GetType()); return pmc; } } return null; } public IPathModelCreator SelectCreatorForNavUp(string offsetPath, ICollection<IPathModelConfiguration> confs) { foreach (var c in efc.Prototypes) { IPathModelCreator pmc = (IPathModelCreator)c.Clone(); if (pmc.CanNavigateUp(offsetPath)) { pmc.Configuration = FindConfiguration(confs, pmc.GetType()); return pmc; } } return null; } private IPathModelConfiguration FindConfiguration(ICollection<IPathModelConfiguration> confs, Type targetType) { if (null == confs) return null; foreach (var c in confs) { if (c.CreatorType == targetType) return c; } return null; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)