Beispiel #1
0
        /// <summary>
        /// Adds the parts to folder.
        /// </summary>
        /// <param name="currentFolder">The current folder.</param>
        /// <param name="parts">The parts.</param>
        /// <param name="partIndex">Index of the part.</param>
        protected void AddPartsToFolder(ItemFolder currentFolder, string[] parts, int partIndex)
        {
            //-- empty folder
            if (partIndex >= parts.Length)
            {
                return;
            }

            string part = parts[partIndex];

            if (!IsFolder(part))
            {
                currentFolder.Items.Add(part);
                return;
            }

            var folder = currentFolder.Folders.FirstOrDefault(e => e.FolderName == part);

            if (folder == null)
            {
                folder = new ItemFolder()
                {
                    FolderName = part
                };
                currentFolder.Folders.Add(folder);
            }
            AddPartsToFolder(folder, parts, ++partIndex);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the item folder.
        /// </summary>
        /// <param name="projectItems">The project items.</param>
        protected void GetItemFolder(List <string> projectItems)
        {
            topFolder = new ItemFolder();
            string[] stringSeparator = new string[] { @"\" };

            foreach (var item in projectItems)
            {
                var parts = item.Split(stringSeparator, StringSplitOptions.RemoveEmptyEntries);
                AddPartsToTopFolder(parts);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Serializes the folder.
        /// </summary>
        /// <param name="topFolder">The top folder.</param>
        /// <returns></returns>
        protected string SerializeFolder(ItemFolder topFolder)
        {
            string folderString           = string.Empty;
            string projItemNodeTemplate   = @"<ProjectItem ReplaceParameters = ""true"" TargetFileName=""$filename"">$filename</ProjectItem>";
            string folderItemNodeTemplate = @"<Folder Name=""$folderName"" TargetFolderName=""$folderName"" >";

            if (topFolder.FolderName != null)
            {
                folderString = folderItemNodeTemplate.Replace("$folderName", topFolder.FolderName);
            }

            foreach (var item in topFolder.Items)
            {
                if (IsKeyProjectItemNode(item))
                {
                    folderString = folderString
                                   + @"<ProjectItem ReplaceParameters=""false"" TargetFileName=""$projectname$_TemporaryKey.pfx"" BlendDoNotCreate=""true"">Application_TemporaryKey.pfx</ProjectItem>"
                                   + Environment.NewLine;
                }
                else
                {
                    //-- now writing item.
                    if (!string.IsNullOrEmpty(item) && !item.Contains("csproj") && !item.Contains(".."))
                    {
                        folderString = folderString + projItemNodeTemplate.Replace("$filename", item)
                                       + Environment.NewLine;
                    }
                }
            }

            foreach (var folderItem in topFolder.Folders)
            {
                folderString = folderString + SerializeFolder(folderItem);
            }

            if (topFolder.FolderName != null)
            {
                folderString = folderString + "</Folder>\n";
            }

            return(folderString);
        }