Beispiel #1
0
        /// <summary>
        /// Returns the collection of subfolders containing source code that need to be
        /// included in the project file. This is comprised the standard platform folders
        /// under Generated, plus any custom folders we find that are not otherwise handled
        /// (eg Properties).
        /// </summary>
        /// <param name="projectFileConfiguration">
        /// The .Net project type we are generating. This governs the platform-specific
        /// subfolders that get included in the project.
        /// </param>
        /// <param name="serviceRootFolder">The root output folder for the service code</param>
        /// <returns></returns>
        private IList <string> GetProjectSourceFolders(ProjectFileConfiguration projectFileConfiguration, string serviceRootFolder)
        {
            // Start with the standard generated code folders for the platform
            var sourceCodeFolders = new List <string>
            {
                "Generated",
                @"Generated\Model",
                @"Generated\Model\Internal",
                @"Generated\Model\Internal\MarshallTransformations"
            };

            var platformSubFolders = projectFileConfiguration.PlatformCodeFolders;

            sourceCodeFolders.AddRange(platformSubFolders.Select(folder => Path.Combine(@"Generated", folder)));

            // Augment the returned folders with any custom subfolders already in existence. If the custom folder
            // ends with a recognised platform, only add it to the set if it matches the platform being generated
            if (Directory.Exists(serviceRootFolder))
            {
                var subFolders = Directory.GetDirectories(serviceRootFolder, "*", SearchOption.AllDirectories);
                if (subFolders.Any())
                {
                    foreach (var folder in subFolders)
                    {
                        var serviceRelativeFolder = folder.Substring(serviceRootFolder.Length);

                        if (!serviceRelativeFolder.StartsWith(@"\Custom", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }

                        if (projectFileConfiguration.IsPlatformCodeFolder(serviceRelativeFolder))
                        {
                            if (projectFileConfiguration.IsValidPlatformCodeFolderForProject(serviceRelativeFolder))
                            {
                                sourceCodeFolders.Add(serviceRelativeFolder.TrimStart('\\'));
                            }
                        }
                        else
                        {
                            sourceCodeFolders.Add(serviceRelativeFolder.TrimStart('\\'));
                        }
                    }
                }
            }

            var foldersThatExist = new List <string>();

            foreach (var folder in sourceCodeFolders)
            {
                if (Directory.Exists(Path.Combine(serviceRootFolder, folder)))
                {
                    foldersThatExist.Add(folder);
                }
            }

            // sort so we get a predictable layout
            foldersThatExist.Sort(StringComparer.OrdinalIgnoreCase);
            return(foldersThatExist);
        }
        /// <summary>
        /// Returns the collection of subfolders containing source code that need to be 
        /// included in the project file. This is comprised the standard platform folders
        /// under Generated, plus any custom folders we find that are not otherwise handled
        /// (eg Properties).
        /// </summary>
        /// <param name="projectFileConfiguration">
        /// The .Net project type we are generating. This governs the platform-specific
        /// subfolders that get included in the project.
        /// </param>
        /// <param name="serviceRootFolder">The root output folder for the service code</param>
        /// <returns></returns>
        private IList<string> GetProjectSourceFolders(ProjectFileConfiguration projectFileConfiguration, string serviceRootFolder)
        {
            // Start with the standard generated code folders for the platform
            var sourceCodeFolders = new List<string>
            {
                "Generated", 
                @"Generated\Model", 
                @"Generated\Model\Internal", 
                @"Generated\Model\Internal\MarshallTransformations"
            };

            var platformSubFolders = projectFileConfiguration.PlatformCodeFolders;
            sourceCodeFolders.AddRange(platformSubFolders.Select(folder => Path.Combine(@"Generated", folder)));

            // Augment the returned folders with any custom subfolders already in existence. If the custom folder 
            // ends with a recognised platform, only add it to the set if it matches the platform being generated
            if (Directory.Exists(serviceRootFolder))
            {
                var subFolders = Directory.GetDirectories(serviceRootFolder, "*", SearchOption.AllDirectories);
                if (subFolders.Any())
                {
                    foreach (var folder in subFolders)
                    {
                        var serviceRelativeFolder = folder.Substring(serviceRootFolder.Length);

                        if (!serviceRelativeFolder.StartsWith(@"\Custom", StringComparison.OrdinalIgnoreCase))
                            continue;

                        if (projectFileConfiguration.IsPlatformCodeFolder(serviceRelativeFolder))
                        {
                            if (projectFileConfiguration.IsValidPlatformCodeFolderForProject(serviceRelativeFolder))
                                sourceCodeFolders.Add(serviceRelativeFolder.TrimStart('\\'));
                        }
                        else
                            sourceCodeFolders.Add(serviceRelativeFolder.TrimStart('\\'));
                    }
                }
            }

            var foldersThatExist = new List<string>();
            foreach (var folder in sourceCodeFolders)
            {
                if (Directory.Exists(Path.Combine(serviceRootFolder, folder)))
                    foldersThatExist.Add(folder);
            }

            // sort so we get a predictable layout
            foldersThatExist.Sort(StringComparer.OrdinalIgnoreCase);
            return foldersThatExist;
        }
Beispiel #3
0
        /// <summary>
        /// Returns the collection of subfolders containing source code that need to be
        /// included in the project file. This is comprised the standard platform folders
        /// under Generated, plus any custom folders we find that are not otherwise handled
        /// (eg Properties).
        /// </summary>
        /// <param name="projectFileConfiguration">
        /// The .Net project type we are generating. This governs the platform-specific
        /// subfolders that get included in the project.
        /// </param>
        /// <param name="serviceRootFolder">The root output folder for the service code</param>
        /// <returns></returns>
        private IList <string> GetCoreProjectSourceFolders(ProjectFileConfiguration projectFileConfiguration, string coreRootFolder)
        {
            var exclusionList = new List <string>
            {
                "Properties",
                "bin",
                "obj"
            };

            // Start with the standard folders for core
            var sourceCodeFolders = new List <string>
            {
                "."
            };

            var childDirectories = Directory.GetDirectories(coreRootFolder, "*", SearchOption.AllDirectories);

            foreach (var childDirectory in childDirectories)
            {
                var folder = childDirectory.Substring(coreRootFolder.Length).TrimStart('\\');

                if (exclusionList.Any(e => folder.Equals(e, StringComparison.InvariantCulture) ||
                                      folder.StartsWith(e + "\\", StringComparison.InvariantCulture)))
                {
                    continue;
                }

                if (projectFileConfiguration.IsPlatformCodeFolder(folder))
                {
                    if (projectFileConfiguration.IsValidPlatformCodeFolderForProject(folder))
                    {
                        sourceCodeFolders.Add(folder);
                    }
                }
                else
                {
                    sourceCodeFolders.Add(folder);
                }
            }



            //var platformSubFolders = projectFileConfiguration.PlatformCodeFolders;
            //sourceCodeFolders.AddRange(platformSubFolders.Select(folder => Path.Combine(@"Generated", folder)));

            //// Augment the returned folders with any custom subfolders already in existence. If the custom folder
            //// ends with a recognised platform, only add it to the set if it matches the platform being generated
            ////if (Directory.Exists(serviceRootFolder))
            //{
            //    var subFolders = Directory.GetDirectories(coreRootFolder, "*", SearchOption.AllDirectories);
            //    subFolders = subFolders.Except(exclusionList).ToArray();
            //    if (subFolders.Any())
            //    {
            //        foreach (var folder in subFolders)
            //        {
            //            var serviceRelativeFolder = folder.Substring(coreRootFolder.Length);

            //            if (!serviceRelativeFolder.StartsWith(@"\Custom", StringComparison.OrdinalIgnoreCase))
            //                continue;

            //            if (projectFileConfiguration.IsPlatformCodeFolder(serviceRelativeFolder))
            //            {
            //                if (projectFileConfiguration.IsValidPlatformCodeFolderForProject(serviceRelativeFolder))
            //                    sourceCodeFolders.Add(serviceRelativeFolder.TrimStart('\\'));
            //            }
            //            else
            //                sourceCodeFolders.Add(serviceRelativeFolder.TrimStart('\\'));
            //        }
            //    }
            //}

            var foldersThatExist = new List <string>();

            foreach (var folder in sourceCodeFolders)
            {
                if (Directory.Exists(Path.Combine(coreRootFolder, folder)))
                {
                    foldersThatExist.Add(folder);
                }
            }

            // sort so we get a predictable layout
            foldersThatExist.Sort(StringComparer.OrdinalIgnoreCase);
            return(foldersThatExist);
        }
        /// <summary>
        /// Returns the collection of subfolders containing source code that need to be 
        /// included in the project file. This is comprised the standard platform folders
        /// under Generated, plus any custom folders we find that are not otherwise handled
        /// (eg Properties).
        /// </summary>
        /// <param name="projectFileConfiguration">
        /// The .Net project type we are generating. This governs the platform-specific
        /// subfolders that get included in the project.
        /// </param>
        /// <param name="serviceRootFolder">The root output folder for the service code</param>
        /// <returns></returns>
        private IList<string> GetCoreProjectSourceFolders(ProjectFileConfiguration projectFileConfiguration, string coreRootFolder)
        {
            var exclusionList = new List<string>
            {
                "Properties",
                "bin",
                "obj"
            };

            // Start with the standard folders for core
            var sourceCodeFolders = new List<string>
            {
                "."
            };

            var childDirectories = Directory.GetDirectories(coreRootFolder, "*", SearchOption.AllDirectories);
            foreach (var childDirectory in childDirectories)
            {
                var folder = childDirectory.Substring(coreRootFolder.Length).TrimStart('\\');

                if (exclusionList.Any(e => folder.Equals(e, StringComparison.InvariantCulture) ||
                    folder.StartsWith(e + "\\", StringComparison.InvariantCulture)))
                    continue;

                if (projectFileConfiguration.IsPlatformCodeFolder(folder))
                {
                    if (projectFileConfiguration.IsValidPlatformCodeFolderForProject(folder))
                        sourceCodeFolders.Add(folder);
                }
                else
                {
                    sourceCodeFolders.Add(folder);
                }


            }

            

            //var platformSubFolders = projectFileConfiguration.PlatformCodeFolders;
            //sourceCodeFolders.AddRange(platformSubFolders.Select(folder => Path.Combine(@"Generated", folder)));

            //// Augment the returned folders with any custom subfolders already in existence. If the custom folder 
            //// ends with a recognised platform, only add it to the set if it matches the platform being generated
            ////if (Directory.Exists(serviceRootFolder))
            //{
            //    var subFolders = Directory.GetDirectories(coreRootFolder, "*", SearchOption.AllDirectories);
            //    subFolders = subFolders.Except(exclusionList).ToArray();
            //    if (subFolders.Any())
            //    {
            //        foreach (var folder in subFolders)
            //        {
            //            var serviceRelativeFolder = folder.Substring(coreRootFolder.Length);

            //            if (!serviceRelativeFolder.StartsWith(@"\Custom", StringComparison.OrdinalIgnoreCase))
            //                continue;

            //            if (projectFileConfiguration.IsPlatformCodeFolder(serviceRelativeFolder))
            //            {
            //                if (projectFileConfiguration.IsValidPlatformCodeFolderForProject(serviceRelativeFolder))
            //                    sourceCodeFolders.Add(serviceRelativeFolder.TrimStart('\\'));
            //            }
            //            else
            //                sourceCodeFolders.Add(serviceRelativeFolder.TrimStart('\\'));
            //        }
            //    }
            //}

            var foldersThatExist = new List<string>();
            foreach (var folder in sourceCodeFolders)
            {
                if (Directory.Exists(Path.Combine(coreRootFolder, folder)))
                    foldersThatExist.Add(folder);
            }

            // sort so we get a predictable layout
            foldersThatExist.Sort(StringComparer.OrdinalIgnoreCase);
            return foldersThatExist;
        }