public void Init()
        {
            locator = new DataSourceLocator(string.Empty);
            binFolder = locator.GetBasePath();

            FoldersCreated.Add(@"TestFolder");
            FoldersCreated.Add(@"TestFolder\TestChildFolder");

            CreateFolders();
            CopyDLLsIntoFolders();
        }
        public static IEnumerable<DesignTimeDataSourceTreeItem> BuildDesignTimeDataSourceTreeItems(DataSourceLocator locator, MyReportBase report, out DynamicTree<DesignTimeDataSourceTreeItem> tree, out List<DesignTimeDataSourceTreeItem> flatList)
        {
            var treeItems = BuildDesignTimeDataSourceTreeItems(locator, report);

            Func<string, string, DesignTimeDataSourceTreeItem> structureBuilder = (string1, string2) =>
            {
                return new DesignTimeDataSourceTreeItem()
                {
                    Name = string1,
                    Path = string2,
                    IsStructure = true
                };
            };

            var treeView = new TreeviewStructureBuilder<DesignTimeDataSourceTreeItem>();
            treeView.Delimiter = @"\";
            treeView.CreateTree(treeItems, structureBuilder, out tree, out flatList, DuplicateTreeItemBehavior.ShowOnlyOneItem);

            return treeItems;
        }
 public void Init()
 {
     locator = new DataSourceLocator(string.Empty);
 }
        private static IEnumerable<DesignTimeDataSourceTreeItem> BuildDesignTimeDataSourceTreeItems(DataSourceLocator locator, MyReportBase report)
        {
            // Report Requested Datasource Definitions
            var requestedDatasources = report.DesignTimeDataSources;

            // Folders
            var requestedFolders = requestedDatasources.Select(definition => locator.FormatRelativePath(definition.DataSourceAssemblyLocationPath));
            var realFolders = locator.GetAllFoldersWithinBasePathContainingDLLs().Select(folder => locator.FormatRelativePath(folder));
            var allFolders = requestedFolders.Union(realFolders);

            Func<string, IEnumerable<IReportDatasourceMetadata>> GetExportsFromRelativeFolder = relativeFolder =>
            {
                var exports = locator.GetDatasources(relativeFolder);
                var metadatas = exports.Select((lazy) => lazy.Metadata);
                return metadatas;
            };

            Func<IReportDatasourceMetadata, DesignTimeDataSourceDefinition, bool> match = (metadata, requested) =>
            {
                if (metadata == null || requested == null)
                    return false;
                else
                    return metadata.Name == requested.DataSourceName;
            };

            Func<string, IReportDatasourceMetadata, DesignTimeDataSourceDefinition, DesignTimeDataSourceTreeItem> CreateDataSourceTreeItem = (relativeFolder, metadataNullable, definitionNullable) =>
            {
                var definition = definitionNullable ?? new DesignTimeDataSourceDefinition(metadataNullable.Name, relativeFolder, string.Empty);

                return new DesignTimeDataSourceTreeItem()
                {
                    Path = relativeFolder,
                    Name = definition.DataSourceName,

                    DesignTimeDataSourceDefinition = definition,
                    MEFMetadata = metadataNullable,
                    PreviouslyUsedWithThisReport = (definitionNullable != null).ToString(),
                    RelationPath = definition.DataSourceRelationPath
                };
            };

            var dataSourceTreeItems = (from relativeFolder in allFolders
                                       let exports = GetExportsFromRelativeFolder(relativeFolder)
                                       let definitions = requestedDatasources.Where(definition => definition.DataSourceAssemblyLocationPath == relativeFolder)
                                       // Join exports & definitions on folder + datasource name
                                       from tuple in exports.FullOuterJoin(definitions, match)
                                       let export = tuple.T1Object
                                       let definition = tuple.T2Object
                                       select CreateDataSourceTreeItem(relativeFolder, export, definition)).ToList();

            return dataSourceTreeItems;
        }